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


Java BanList类代码示例

本文整理汇总了Java中org.bukkit.BanList的典型用法代码示例。如果您正苦于以下问题:Java BanList类的具体用法?Java BanList怎么用?Java BanList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BanList类属于org.bukkit包,在下文中一共展示了BanList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.bukkit.BanList; //导入依赖的package包/类
/**
 * Get the data from config file.
 *
 * @param config the configuration file.
 */
public void read(FileConfiguration config) {

    // read type and time.
    banType = BanList.Type.valueOf(config.getString("ban-type"));
    banTime = config.getInt("ban-time", banTime);

    // convert the days into a date.
    String days = config.getString("ban-days");
    if (Objects.isNull(days) || Objects.equals(days, "0")) {
        banDate = null;
    } else {
        GregorianCalendar c = new GregorianCalendar();
        c.add(GregorianCalendar.DATE, Integer.parseInt(days));
        banDate = c.getTime();
    }

    tpsLimit = config.getInt("tps-limit", tpsLimit);

    broadcastBan = config.getBoolean("broadcast-ban");
    if (broadcastBan) {
        String message = config.getString("broadcast-message");
        broadcastMessage = ChatColor.translateAlternateColorCodes('&', message);
    }

}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:31,代码来源:ArcConfiguration.java

示例2: onGuildBan

import org.bukkit.BanList; //导入依赖的package包/类
@Override
public void onGuildBan(GuildBanEvent event) {
    UUID linkedUuid = DiscordSRV.getPlugin().getAccountLinkManager().getUuid(event.getUser().getId());
    if (linkedUuid == null) {
        DiscordSRV.debug("Not handling ban for user " + event.getUser() + " because they didn't have a linked account");
        return;
    }

    OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(linkedUuid);
    if (!offlinePlayer.hasPlayedBefore()) return;

    if (!DiscordSRV.config().getBoolean("BanSynchronizationDiscordToMinecraft")) {
        DiscordSRV.debug("Not handling ban for user " + event.getUser() + " because doing so is disabled in the config");
        return;
    }

    Bukkit.getBanList(BanList.Type.NAME).addBan(offlinePlayer.getName(), LangUtil.Message.BAN_DISCORD_TO_MINECRAFT.toString(), null, "Discord");
}
 
开发者ID:Scarsz,项目名称:DiscordSRV,代码行数:19,代码来源:DiscordBanListener.java

示例3: onGuildUnban

import org.bukkit.BanList; //导入依赖的package包/类
@Override
public void onGuildUnban(GuildUnbanEvent event) {
    UUID linkedUuid = DiscordSRV.getPlugin().getAccountLinkManager().getUuid(event.getUser().getId());
    if (linkedUuid == null) {
        DiscordSRV.debug("Not handling unban for user " + event.getUser() + " because they didn't have a linked account");
        return;
    }

    OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(linkedUuid);
    if (!offlinePlayer.hasPlayedBefore()) return;

    if (!DiscordSRV.config().getBoolean("BanSynchronizationDiscordToMinecraft")) {
        DiscordSRV.debug("Not handling unban for user " + event.getUser() + " because doing so is disabled in the config");
        return;
    }

    Bukkit.getBanList(BanList.Type.NAME).pardon(offlinePlayer.getName());
}
 
开发者ID:Scarsz,项目名称:DiscordSRV,代码行数:19,代码来源:DiscordBanListener.java

示例4: execute

import org.bukkit.BanList; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
    if (!testPermission(sender)) return true;
    if (args.length == 0)  {
        sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
        return false;
    }

    String reason = args.length > 0 ? StringUtils.join(args, ' ', 1, args.length) : null;
    Bukkit.getBanList(BanList.Type.NAME).addBan(args[0], reason, null, sender.getName());

    Player player = Bukkit.getPlayer(args[0]);
    if (player != null) {
        player.kickPlayer("Banned by admin.");
    }

    Command.broadcastCommandMessage(sender, "Banned player " + args[0]);
    return true;
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:20,代码来源:BanCommand.java

示例5: ban

import org.bukkit.BanList; //导入依赖的package包/类
@Command(aliases = {"ban", "pb"}, usage = "<player> <reason>", desc = "Ban a player.", min = 2)
@CommandPermissions("cardinal.punish.ban")
public static void ban(CommandContext cmd, CommandSender sender) throws CommandException {
    OfflinePlayer banned = Bukkit.getOfflinePlayer(cmd.getString(0));
    if (sender instanceof Player) {
        if (PermissionModule.isMod(((Player) sender).getUniqueId()) && banned.isOp()) {
            throw new CommandException(new LocalizedChatMessage(ChatConstant.ERROR_PLAYER_NOT_AFFECTED).getMessage(ChatUtils.getLocale(sender)));
        }
    }
    String reason = "";
    for (int i = 1; i < cmd.argsLength(); i++) {
        reason = reason + cmd.getString(i) + " ";
    }
    reason = reason.trim();
    if (banned.isOnline()) {
        Player onlineBanned = (Player) banned;
        onlineBanned.kickPlayer(ChatColor.RED + "Permanently Banned" + ChatColor.GOLD + "  \u00BB  " + ChatColor.AQUA + reason);
        Bukkit.broadcastMessage((sender instanceof Player ? TeamUtils.getTeamColorByPlayer((Player) sender) + ((Player) sender).getDisplayName() : ChatColor.YELLOW + "*Console") + ChatColor.GOLD + " \u00BB Permanent Ban \u00BB " + TeamUtils.getTeamColorByPlayer(banned) + onlineBanned.getDisplayName() + ChatColor.GOLD + " \u00BB " + ChatColor.DARK_AQUA + reason);
        Bukkit.getBanList(BanList.Type.NAME).addBan(cmd.getString(0), ChatColor.RED + "Permanently Banned" + ChatColor.GOLD + "  \u00BB  " + ChatColor.AQUA + reason, null, sender.getName());
    } else if (!Bukkit.getBanList(BanList.Type.NAME).isBanned(banned.getName())){
        Bukkit.broadcastMessage((sender instanceof Player ? TeamUtils.getTeamColorByPlayer((Player) sender) + ((Player) sender).getDisplayName() : ChatColor.YELLOW + "*Console") + ChatColor.GOLD + " \u00BB Permanent Ban \u00BB " + TeamUtils.getTeamColorByPlayer(banned) + banned.getName() + ChatColor.GOLD + " \u00BB " + ChatColor.DARK_AQUA + reason);
        Bukkit.getBanList(BanList.Type.NAME).addBan(cmd.getString(0), ChatColor.RED + "Permanently Banned" + ChatColor.GOLD + "  \u00BB  " + ChatColor.AQUA + reason, null, sender.getName());
    } else throw new CommandException(new LocalizedChatMessage(ChatConstant.ERROR_PLAYER_ALREADY_BANNED).getMessage(ChatUtils.getLocale(sender)));

}
 
开发者ID:dentmaged,项目名称:Cardinal-Plus,代码行数:26,代码来源:PunishmentCommands.java

示例6: resetWarnings

import org.bukkit.BanList; //导入依赖的package包/类
public boolean resetWarnings(String uName, CommandSender sender) {
	
	UUID uuid = plugin.getUUIDFromName(uName);
	
	if (plugin.wasWarned(uuid)) {
		BanList bl = Bukkit.getBanList(BanList.Type.NAME);
		bl.pardon(uName);
		plugin.removeBanned(uuid);
		sender.sendMessage(RED+"[BadWords] "+WHITE+ uName + " warnings reset and unbanned");
		return true;
	} else {
		sender.sendMessage(RED+"[BadWords] "+WHITE+uName + " has not been warned");
		return false;
	}
	
}
 
开发者ID:ChuckHunky,项目名称:BadWords,代码行数:17,代码来源:ServerCommandExecutor.java

示例7: checkBans

import org.bukkit.BanList; //导入依赖的package包/类
@Override
protected void checkBans(PlayerLoginEvent event, Object[] data) {
	String name = event.getPlayer().getName();
	String hostaddr = event.getAddress().getHostAddress();
	final BanList nameBans = server.getBanList(BanList.Type.NAME);
	final BanList ipBans = server.getBanList(BanList.Type.IP);
	if (nameBans.isBanned(name)) {
		event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "Banned: " + nameBans.getBanEntry(name).getReason());
	} else if (ipBans.isBanned(hostaddr)) {
		event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "Banned: " + ipBans.getBanEntry(hostaddr).getReason());
	} else if (server.hasWhitelist() && !event.getPlayer().isWhitelisted()) {
		event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not whitelisted on this server.");
	} else if (server.getOnlinePlayers().size() >= server.getMaxPlayers()) {
		event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full (" + server.getMaxPlayers() + " players).");
	}
}
 
开发者ID:ProtocolSupport,项目名称:ProtocolSupport,代码行数:17,代码来源:GlowStoneLoginListenerPlay.java

示例8: banPlayer

import org.bukkit.BanList; //导入依赖的package包/类
/**
 * Clean a player's history and ban him
 * 
 * @param player the player to ban
 */
@Override
public void banPlayer(final OfflinePlayer player) {
    if (playerChatHistory.contains(player.getName())) {
        playerChatHistory.get(player.getName()).clear();
    }
    final Player onlinePlayer = player.getPlayer();
    if (onlinePlayer != null && !Perms.BYPASS_BAN.has(onlinePlayer) && !Perms.BYPASS_KICK.has(onlinePlayer)) {
        class RunLater implements Runnable {
            @Override
            public void run() {
                onlinePlayer.kickPlayer(Language.BAN_MESSAGE.toString());
                Bukkit.getServer().getBanList(BanList.Type.NAME).addBan(player.getName(), null, null, null);
                plugin.getLogger().log(Level.INFO, "Player banned: {0}", player.getName());
            }
        }
        Bukkit.getScheduler().runTaskLater(plugin, new RunLater(), 1L);
    }
}
 
开发者ID:slipcor,项目名称:SpamHammer,代码行数:24,代码来源:DefaultSpamHandler.java

示例9: isBanned

import org.bukkit.BanList; //导入依赖的package包/类
public boolean isBanned() {
    if (getName() == null) {
        return false;
    }

    return server.getBanList(BanList.Type.NAME).isBanned(getName());
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:8,代码来源:CraftOfflinePlayer.java

示例10: setBanned

import org.bukkit.BanList; //导入依赖的package包/类
public void setBanned(boolean value) {
    if (getName() == null) {
        return;
    }

    if (value) {
        server.getBanList(BanList.Type.NAME).addBan(getName(), null, null, null);
    } else {
        server.getBanList(BanList.Type.NAME).pardon(getName());
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:12,代码来源:CraftOfflinePlayer.java

示例11: getBanList

import org.bukkit.BanList; //导入依赖的package包/类
@Override
public BanList getBanList(BanList.Type type){
    Validate.notNull(type, "Type cannot be null");

    switch(type){
    case IP:
        return new CraftIpBanList(playerList.getBannedIPs());
    case NAME:
    default:
        return new CraftProfileBanList(playerList.func_152608_h());
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:13,代码来源:CraftServer.java

示例12: processIPBan

import org.bukkit.BanList; //导入依赖的package包/类
private void processIPBan(String ip, CommandSender sender, String reason) {
    Bukkit.getBanList(BanList.Type.IP).addBan(ip, reason, null, sender.getName());

    // Find all matching players and kick
    for (Player player : Bukkit.getOnlinePlayers()) {
        if (player.getAddress().getAddress().getHostAddress().equals(ip)) {
            player.kickPlayer("You have been IP banned.");
        }
    }

    Command.broadcastCommandMessage(sender, "Banned IP Address " + ip);
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:13,代码来源:BanIpCommand.java

示例13: execute

import org.bukkit.BanList; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
    if (!testPermission(sender)) return true;
    if (args.length != 1)  {
        sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
        return false;
    }

    Bukkit.getBanList(BanList.Type.NAME).pardon(args[0]);
    Command.broadcastCommandMessage(sender, "Pardoned " + args[0]);
    return true;
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:13,代码来源:PardonCommand.java

示例14: execute

import org.bukkit.BanList; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
    if (!testPermission(sender)) return true;

    BanList.Type banType = BanList.Type.NAME;
    if (args.length > 0) {
        if (args[0].equalsIgnoreCase("ips")) {
            banType = BanList.Type.IP;
        } else if (!args[0].equalsIgnoreCase("players")) {
            sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
            return false;
        }
    }

    StringBuilder message = new StringBuilder();
    BanEntry[] banlist = Bukkit.getBanList(banType).getBanEntries().toArray(new BanEntry[0]);

    for (int x = 0; x < banlist.length; x++) {
        if (x != 0) {
            if (x == banlist.length - 1) {
                message.append(" and ");
            } else {
                message.append(", ");
            }
        }

        message.append(banlist[x].getTarget());
    }

    sender.sendMessage("There are " + banlist.length + " total banned players:");
    sender.sendMessage(message.toString());
    return true;
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:34,代码来源:BanListCommand.java

示例15: getBanList

import org.bukkit.BanList; //导入依赖的package包/类
@Override
public BanList getBanList(BanList.Type type) {
    Validate.notNull(type, "Type cannot be null");

    switch(type){
    case IP:
        return new CraftIpBanList(playerList.getIPBans());
    case NAME:
    default:
        return new CraftProfileBanList(playerList.getProfileBans());
    }
}
 
开发者ID:Techcable,项目名称:DiffUtils,代码行数:13,代码来源:CraftServer_188.java


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