本文整理汇总了Java中org.spongepowered.api.util.ban.Ban.Profile方法的典型用法代码示例。如果您正苦于以下问题:Java Ban.Profile方法的具体用法?Java Ban.Profile怎么用?Java Ban.Profile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.util.ban.Ban
的用法示例。
在下文中一共展示了Ban.Profile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pardonBan
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
@Override
public Optional<SanctionManualProfile.Ban> pardonBan(long date, Text reason, CommandSource source) {
Preconditions.checkNotNull(reason, "reason");
Preconditions.checkNotNull(source, "source");
Optional<EManualProfileBan> manual = this.findFirst(EManualProfileBan.class);
// Aucun manual
if(!manual.isPresent()) {
return Optional.empty();
}
final Optional<EUser> user = this.plugin.getEServer().getOrCreateEUser(this.getUniqueId());
if (!user.isPresent()) {
return Optional.empty();
}
manual.get().pardon(date, reason, source.getIdentifier());
final Ban.Profile ban = manual.get().getBan(user.get().getProfile());
this.plugin.getSanctionService().remove(ban);
this.ban = this.findFirst(SanctionBanProfile.class);
this.plugin.getThreadAsync().execute(() -> this.sqlPardonManual(manual.get()));
return Optional.of(manual.get());
}
示例2: remove
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
public void remove(Ban.Profile profile) {
BiPredicate<Ban.Profile, UUID> predicate = (ban, uuid) -> {
if (!ban.getProfile().getUniqueId().equals(profile.getProfile().getUniqueId())) {
return false;
}
if (ban.getCreationDate().toEpochMilli() != profile.getCreationDate().toEpochMilli()) {
return false;
}
if(ban.getExpirationDate().isPresent() || profile.getExpirationDate().isPresent()) {
if (!ban.getExpirationDate().isPresent() || !profile.getExpirationDate().isPresent() ||
ban.getExpirationDate().get().toEpochMilli() != profile.getExpirationDate().get().toEpochMilli()) {
return false;
}
}
if(!ban.getReason().orElse(Text.EMPTY).toPlain().equals(profile.getReason().orElse(Text.EMPTY).toPlain())) {
return false;
}
if(!ban.getBanSource().orElse(Text.EMPTY).toPlain().equals(profile.getBanSource().orElse(Text.EMPTY).toPlain())) {
return false;
}
return true;
};
UtilsMap.removeIf(this.bans_profile, predicate);
}
示例3: banlistPlayer
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
private void banlistPlayer(CommandSource context, String filter)
{
// TODO filter
Collection<Ban.Profile> userBans = this.banService.getProfileBans();
if (userBans.isEmpty())
{
i18n.send(context, POSITIVE, "There are no players banned on this server!");
return;
}
if (userBans.size() == 1)
{
Ban.Profile next = userBans.iterator().next();
i18n.send(context, POSITIVE, "Only {user}({name#uuid}) is banned on this server",
next.getProfile().getName().orElse("?"), next.getProfile().getUniqueId().toString());
return;
}
i18n.send(context, POSITIVE, "The following {amount} players are banned from this server",
userBans.size());
context.sendMessage(Text.of(StringUtils.implode(GREY + ", ", userBans)));
// TODO implode on Text
}
示例4: getBan
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
public default Ban.Profile getBan(GameProfile profile) {
Builder builder = Ban.builder()
.type(BanTypes.PROFILE)
.profile(profile)
.reason(this.getReason())
.startDate(Instant.ofEpochMilli(this.getCreationDate()))
.source(EChat.of(this.getSource()));
if(this.getExpirationDate().isPresent()) {
builder = builder.expirationDate(Instant.ofEpochMilli(this.getExpirationDate().get()));
}
return (Ban.Profile) builder.build();
}
示例5: getProfileBans
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
@Override
public Collection<Ban.Profile> getProfileBans() {
this.removeExpired();
Builder<Ban.Profile> builder = ImmutableSet.builder();
builder.addAll(this.bans_profile.keySet());
return builder.build();
}
示例6: getBanFor
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
@Override
public Optional<Ban.Profile> getBanFor(GameProfile profile) {
this.removeExpired();
Optional<Ban.Profile> ban = Optional.empty();
Iterator<Entry<Ban.Profile, UUID>> iterator = this.bans_profile.entrySet().iterator();
while(!ban.isPresent() && iterator.hasNext()) {
Entry<Ban.Profile, UUID> element = iterator.next();
if(element.getValue().equals(profile.getUniqueId())) {
ban = Optional.of(element.getKey());
}
}
return ban;
}
示例7: removeBan
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
@Override
public boolean removeBan(Ban ban) {
checkNotNull(ban, "ban");
if (this.entries0.remove(ban)) {
final CauseStack causeStack = CauseStack.currentOrEmpty();
// Post the pardon events
final Event event;
final Cause cause = causeStack.getCurrentCause();
if (ban instanceof Ban.Ip) {
event = SpongeEventFactory.createPardonIpEvent(cause, (Ban.Ip) ban);
} else {
final Ban.Profile profileBan = (Ban.Profile) ban;
// Check if the pardoned player is online (not yet been kicked)
final Optional<Player> optTarget = Sponge.getServer().getPlayer(profileBan.getProfile().getUniqueId());
if (optTarget.isPresent()) {
event = SpongeEventFactory.createPardonUserEventTargetPlayer(cause, profileBan, optTarget.get(), optTarget.get());
} else {
event = SpongeEventFactory.createPardonUserEvent(cause, profileBan, Lantern.getGame().getServiceManager()
.provideUnchecked(UserStorageService.class).getOrCreate(profileBan.getProfile()));
}
}
// Just ignore for now the fact that they may be cancellable,
// only the PardonIpEvent seems to be cancellable
// TODO: Should they all be cancellable or none of them?
Sponge.getEventManager().post(event);
return true;
}
return false;
}
示例8: addBan
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
@Override
public Optional<? extends Ban> addBan(Ban ban) {
checkNotNull(ban, "ban");
final Optional<Ban> oldBan;
if (ban instanceof Ban.Ip) {
oldBan = (Optional) getBanFor(((Ban.Ip) ban).getAddress());
} else {
oldBan = (Optional) getBanFor(((Ban.Profile) ban).getProfile());
}
oldBan.ifPresent(this.entries0::remove);
this.entries0.add((BanEntry) ban);
if (!oldBan.isPresent() || !oldBan.get().equals(ban)) {
final CauseStack causeStack = CauseStack.currentOrEmpty();
// Post the ban events
final Event event;
final Cause cause = causeStack.getCurrentCause();
if (ban instanceof Ban.Ip) {
event = SpongeEventFactory.createBanIpEvent(cause, (Ban.Ip) ban);
} else {
final Ban.Profile profileBan = (Ban.Profile) ban;
// Check if the pardoned player is online (not yet been kicked)
final Optional<Player> optTarget = Sponge.getServer().getPlayer(profileBan.getProfile().getUniqueId());
if (optTarget.isPresent()) {
event = SpongeEventFactory.createBanUserEventTargetPlayer(cause, profileBan, optTarget.get(), optTarget.get());
} else {
event = SpongeEventFactory.createBanUserEvent(cause, profileBan, Lantern.getGame().getServiceManager()
.provideUnchecked(UserStorageService.class).getOrCreate(profileBan.getProfile()));
}
}
// Just ignore for now the fact that they may be cancellable,
// only the PardonIpEvent seems to be cancellable
// TODO: Should they all be cancellable or none of them?
Sponge.getEventManager().post(event);
}
return oldBan;
}
示例9: unban
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
/**
* Unbans the player
*/
@Override
public void unban() {
BanService service = HammerSponge.getBanService().get();
Optional<Ban.Profile> obp = service.getBanFor(player.getProfile());
if (obp.isPresent()) {
service.removeBan(obp.get());
}
}
示例10: EBanService
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
public EBanService(final EverSanctions plugin) {
super(plugin);
this.bans_profile = new ConcurrentSkipListMap<Ban.Profile, UUID>(EBanService.COMPARATOR_BAN);
this.bans_ip = new ConcurrentSkipListMap<Ban.Ip, String>(EBanService.COMPARATOR_BAN);
}
示例11: add
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
public void add(Ban.Profile ban) {
this.bans_profile.put(ban, ban.getProfile().getUniqueId());
}
示例12: getProfileBans
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
@Override
public Collection<Ban.Profile> getProfileBans() {
return (Collection) this.entries0.stream().filter(e -> e instanceof Ban.Profile).collect(ImmutableList.toImmutableList());
}
示例13: getBanFor
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
@Override
public Optional<Ban.Profile> getBanFor(GameProfile profile) {
return (Optional) this.getEntryByProfile(profile);
}
示例14: pardon
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
@Override
public boolean pardon(GameProfile profile) {
final Optional<Ban.Profile> ban = getBanFor(checkNotNull(profile, "profile"));
return ban.isPresent() && removeBan(ban.get());
}
示例15: getBanFor
import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
@Override
protected Optional<Ban.Profile> getBanFor(String target) {
return getGameProfile(target).flatMap(getBanService()::getBanFor);
}