org.bukkit.Bukkit.getBanList()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(184)

本文整理了Java中org.bukkit.Bukkit.getBanList()方法的一些代码示例,展示了Bukkit.getBanList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bukkit.getBanList()方法的具体详情如下:
包路径:org.bukkit.Bukkit
类名称:Bukkit
方法名:getBanList

Bukkit.getBanList介绍

暂无

代码示例

代码示例来源:origin: Bukkit/Bukkit

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);
}

代码示例来源:origin: Bukkit/Bukkit

@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;
}

代码示例来源:origin: Bukkit/Bukkit

@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;
}

代码示例来源:origin: Bukkit/Bukkit

@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;
}

代码示例来源:origin: GlowstoneMC/Glowstone

Bukkit.getBanList(BanList.Type.IP).addBan(target, null, null, null);
} else {
  StringBuilder reason = new StringBuilder();
    reason.append(args[i]).append(" ");
  Bukkit.getBanList(BanList.Type.IP)
    .addBan(target, reason.toString(), null, null);

代码示例来源:origin: GlowstoneMC/Glowstone

final Set<BanEntry> banEntries = Bukkit.getBanList(banType).getBanEntries();

代码示例来源:origin: GlowstoneMC/Glowstone

Bukkit.getBanList(BanList.Type.NAME).addBan(player.getName(),
      null, null, null);
} else {
    reason.append(args[i]).append(" ");
  Bukkit.getBanList(BanList.Type.NAME).addBan(player.getName(),
      reason.toString(), null, null);

代码示例来源:origin: SpigotMC/Spigot-API

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);
}

代码示例来源:origin: SpigotMC/Spigot-API

@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;
}

代码示例来源:origin: EngineHub/WorldGuard

@Override
public void ban(String msg) {
  if (!silenced) {
    Bukkit.getBanList(Type.NAME).addBan(getName(), null, null, null);
    getPlayer().kickPlayer(msg);
  }
}

代码示例来源:origin: SpigotMC/Spigot-API

@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;
}

代码示例来源:origin: SpigotMC/Spigot-API

@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;
}

代码示例来源:origin: DevLeoko/AdvancedBan

@EventHandler
  public void onRevokePunishment(RevokePunishmentEvent e) {
    BanList banlist;
    if (e.getPunishment().getType().equals(PunishmentType.BAN) || e.getPunishment().getType().equals(PunishmentType.TEMP_BAN)) {
      banlist = Bukkit.getBanList(BanList.Type.NAME);
      banlist.pardon(e.getPunishment().getName());
    } else if (e.getPunishment().getType().equals(PunishmentType.IP_BAN) || e.getPunishment().getType().equals(PunishmentType.TEMP_IP_BAN)) {
      banlist = Bukkit.getBanList(BanList.Type.IP);
      banlist.pardon(e.getPunishment().getName());
    }
  }
}

代码示例来源:origin: DevLeoko/AdvancedBan

@EventHandler
public void onPunish(PunishmentEvent e) {
  BanList banlist;
  if (e.getPunishment().getType().equals(PunishmentType.BAN) || e.getPunishment().getType().equals(PunishmentType.TEMP_BAN)) {
    banlist = Bukkit.getBanList(BanList.Type.NAME);
    banlist.addBan(e.getPunishment().getName(), e.getPunishment().getReason(), new Date(e.getPunishment().getEnd()), e.getPunishment().getOperator());
  } else if (e.getPunishment().getType().equals(PunishmentType.IP_BAN) || e.getPunishment().getType().equals(PunishmentType.TEMP_IP_BAN)) {
    banlist = Bukkit.getBanList(BanList.Type.IP);
    banlist.addBan(e.getPunishment().getName(), e.getPunishment().getReason(), new Date(e.getPunishment().getEnd()), e.getPunishment().getOperator());
  }
}

相关文章