当前位置: 首页>>代码示例>>Java>>正文


Java Ban.Profile方法代码示例

本文整理汇总了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());
}
 
开发者ID:EverCraft,项目名称:EverSanctions,代码行数:27,代码来源:EUserSubject.java

示例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);
}
 
开发者ID:EverCraft,项目名称:EverSanctions,代码行数:25,代码来源:EBanService.java

示例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
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:22,代码来源:KickBanCommands.java

示例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();
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:14,代码来源:SanctionAuto.java

示例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();
}
 
开发者ID:EverCraft,项目名称:EverSanctions,代码行数:9,代码来源:EBanService.java

示例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;
}
 
开发者ID:EverCraft,项目名称:EverSanctions,代码行数:16,代码来源:EBanService.java

示例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;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:30,代码来源:BanConfig.java

示例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;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:37,代码来源:BanConfig.java

示例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());
    }
}
 
开发者ID:dualspiral,项目名称:Hammer,代码行数:12,代码来源:SpongeWrappedPlayer.java

示例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);
}
 
开发者ID:EverCraft,项目名称:EverSanctions,代码行数:7,代码来源:EBanService.java

示例11: add

import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
public void add(Ban.Profile ban) {
	this.bans_profile.put(ban, ban.getProfile().getUniqueId());
}
 
开发者ID:EverCraft,项目名称:EverSanctions,代码行数:4,代码来源:EBanService.java

示例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());
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:BanConfig.java

示例13: getBanFor

import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
@Override
public Optional<Ban.Profile> getBanFor(GameProfile profile) {
    return (Optional) this.getEntryByProfile(profile);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:BanConfig.java

示例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());
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:6,代码来源:BanConfig.java

示例15: getBanFor

import org.spongepowered.api.util.ban.Ban; //导入方法依赖的package包/类
@Override
protected Optional<Ban.Profile> getBanFor(String target) {
    return getGameProfile(target).flatMap(getBanService()::getBanFor);
}
 
开发者ID:LapisBlue,项目名称:Pore,代码行数:5,代码来源:PoreUserBanList.java


注:本文中的org.spongepowered.api.util.ban.Ban.Profile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。