Пример #1
0
 @Override
 public CommandTree<String> getSubs(final Arena arena) {
   final CommandTree<String> result = new CommandTree<String>(null);
   if (arena == null) {
     return result;
   }
   for (final ArenaClass aClass : arena.getClasses()) {
     result.define(new String[] {aClass.getName()});
   }
   return result;
 }
Пример #2
0
  @Override
  public boolean hasSpawn(final String string) {
    for (final String teamName : arena.getTeamNames()) {
      if (string.toLowerCase().equals(teamName.toLowerCase() + "block")) {
        return true;
      }
      if (string.toLowerCase().startsWith(teamName.toLowerCase() + "spawn")) {
        return true;
      }

      if (arena.getArenaConfig().getBoolean(CFG.GENERAL_CLASSSPAWN)) {
        for (final ArenaClass aClass : arena.getClasses()) {
          if (string
              .toLowerCase()
              .startsWith(teamName.toLowerCase() + aClass.getName().toLowerCase() + "spawn")) {
            return true;
          }
        }
      }
    }
    return false;
  }
Пример #3
0
  @Override
  public void commit(final Arena arena, final CommandSender sender, final String[] args) {
    if (!hasPerms(sender, arena)
        || !arena.getArenaConfig().getBoolean(CFG.USES_INGAMECLASSSWITCH)) {
      return;
    }

    if (!argCountValid(sender, arena, args, new Integer[] {0, 1})) {
      return;
    }

    if (args.length < 1) {
      Set<String> classes = new TreeSet<String>();
      for (ArenaClass ac : arena.getClasses()) {
        if (ac.getName().equals("custom")) {
          continue;
        }
        classes.add(ChatColor.GREEN + ac.getName() + ChatColor.WHITE);
      }
      arena.msg(sender, Language.parse(arena, MSG.CLASS_LIST, StringParser.joinSet(classes, ", ")));
      return;
    }

    if (!(sender instanceof Player)) {
      Arena.pmsg(sender, Language.parse(arena, MSG.ERROR_ONLY_PLAYERS));
      return;
    }

    final ArenaPlayer aPlayer = ArenaPlayer.parsePlayer(sender.getName());

    final ArenaClass aClass = arena.getClass(args[0]);

    if (aClass == null) {
      sender.sendMessage(Language.parse(arena, MSG.ERROR_CLASS_NOT_FOUND, args[0]));
      return;
    }

    if (arena.getArenaConfig().getBoolean(CFG.PERMS_EXPLICITCLASS)
        && !sender.hasPermission("pvparena.class." + aClass.getName())) {
      arena.msg(sender, Language.parse(arena, MSG.ERROR_NOPERM_CLASS, aClass.getName()));
      return;
    }

    if (ArenaModuleManager.cannotSelectClass(arena, (Player) sender, args[0])) {
      return;
    }
    PAClassSign.remove(arena.getSigns(), (Player) sender);

    PAClassSign oldSign = null;
    boolean error = false;

    for (PAClassSign sign : arena.getSigns()) {
      try {
        Sign s = (Sign) sign.getLocation().toLocation().getBlock().getState();
        if (aPlayer.getArenaClass().getName().equals(s.getLine(0))) {
          oldSign = sign;
        }
        if (aClass.getName().equals(s.getLine(0))) {
          if (!sign.add((Player) sender)) {
            error = true;
          }
        }
      } catch (Exception e) {

      }
    }

    if (error) {
      if (oldSign != null) {
        oldSign.add((Player) sender);
      }
      arena.msg(sender, Language.parse(arena, MSG.ERROR_CLASS_FULL, aClass.getName()));
      return;
    }

    if (!arena.getArenaConfig().getBoolean(CFG.GENERAL_CLASSSWITCH_AFTER_RESPAWN)
        || !arena.isFightInProgress()) {
      InventoryManager.clearInventory(aPlayer.get());
      if (aPlayer.getArenaClass() != null) {
        ArenaPlayer.givePlayerFightItems(arena, aPlayer.get());

        arena.msg(sender, Language.parse(arena, MSG.CLASS_SELECTED, aClass.getName()));
      }
      aPlayer.setArenaClass(aClass);
    } else if (aPlayer.getArenaClass() != null) {
      arena.msg(sender, Language.parse(arena, MSG.CLASS_SELECTED_RESPAWN, aClass.getName()));
      aPlayer.setNextArenaClass(aClass);
    }
  }