Exemple #1
0
 public void run() {
   nSpleefArena arena = Filter.getArenaByPlayerIn(player);
   if (arena == null) return;
   if (arena.getInGame() > 0) return;
   arena.getPlayerStatus().set(arena.getPlayers().indexOf(player), true);
   arena.checkReady();
 }
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   Player player = (Player) sender;
   if (args.length < 2) return false;
   if (Util.exists("arenas.txt") == false) {
     player.sendMessage(ChatColor.DARK_PURPLE + "No arenas!");
     return true;
   }
   ArrayList<String> data = new ArrayList<String>();
   Util.openfileread("arenas.txt");
   data = Util.filetoarray();
   Util.closefileread();
   nSpleefArena arena = Filter.getArenaByName(args[1]);
   if (arena == null) {
     player.sendMessage(ChatColor.DARK_PURPLE + "No arena with that name exists!");
     return true;
   }
   for (int i = 0; i < arena.getPlayersIn().size(); i++) {
     new LeaveJob(plugin, arena.getPlayersIn().get(i), 2).run();
   }
   if (!(arena.getGame() == null)) plugin.nSpleefGames.remove(arena.getGame());
   data.remove(Filter.getArenaIndex(arena).intValue());
   new File("plugins/nSpleef/arenas.txt").delete();
   if (!(data.size() == 0)) {
     Util.openfile("arenas.txt");
     for (int i = 0; i < data.size(); i++) {
       Util.writefile(data.get(i) + "\n");
     }
     Util.closefile();
   }
   Data.setupArenas();
   player.sendMessage(ChatColor.DARK_PURPLE + "Arena " + args[1] + " has been deleted.");
   return true;
 }
 @Override
 public void onPlayerMove(PlayerMoveEvent event) {
   final Player player = event.getPlayer();
   Location loc = player.getLocation();
   BlockVector theblock = new BlockVector();
   if (plugin.nSpleefArenas.size() == 0) return;
   final nSpleefArena arena = Filter.getArenaByPlayerIn(player);
   if (arena == null) return;
   if (arena.getFirstBlock().getY() > arena.getSecondBlock().getY())
     theblock = arena.getSecondBlock();
   if (arena.getFirstBlock().getY() < arena.getSecondBlock().getY())
     theblock = arena.getFirstBlock();
   if (loc.getBlockY() + 1 <= theblock.getBlockY() + 1) {
     arena.messagePlayersIn(
         ChatColor.DARK_PURPLE + "[nSpleef] " + player.getDisplayName() + " is out!");
     arena.getPlayers().remove(player);
     arena.checkLeave();
     player.setFireTicks(0);
     player.setFallDistance(0F);
     player.setHealth(20);
   }
 }