コード例 #1
0
  public static void signClick(PlayerInteractEvent event, PlayerHolder am) {
    /// Get our sign
    final Sign sign = (Sign) event.getClickedBlock().getState();
    /// Check to see if sign has correct format (is more efficient than doing string manipulation )
    if (!sign.getLine(0).matches("^.[0-9a-fA-F]\\*.*$") && !sign.getLine(0).matches("^\\[.*$")) {
      return;
    }

    final Action action = event.getAction();
    if (action != Action.LEFT_CLICK_BLOCK && action != Action.RIGHT_CLICK_BLOCK) {
      return;
    }
    if (action == Action.LEFT_CLICK_BLOCK) { // / Dont let them break the sign
      event.setCancelled(true);
    }

    final ArenaClass ac =
        ArenaClassController.getClass(
            MessageUtil.decolorChat(sign.getLine(0))
                .replace('*', ' ')
                .replace('[', ' ')
                .replace(']', ' ')
                .trim());
    ArenaClassController.changeClass(event.getPlayer(), am, ac);
  }
コード例 #2
0
 public static void loadClasses(ConfigurationSection cs) {
   if (cs == null) {
     Log.info(BattleArena.getPName() + " has no classes");
     return;
   }
   StringBuilder sb = new StringBuilder();
   Set<String> keys = cs.getKeys(false);
   boolean first = true;
   for (String className : keys) {
     ArenaClass ac = parseArenaClass(cs.getConfigurationSection(className));
     if (ac == null) continue;
     if (first) first = false;
     else sb.append(", ");
     sb.append(ac.getName());
     ArenaClassController.addClass(ac);
   }
   if (first) {
     Log.info(
         BattleArena.getPName()
             + " no predefined classes found. inside of "
             + cs.getCurrentPath());
   } else {
     Log.info(BattleArena.getPName() + " registering classes: " + sb.toString());
   }
 }
コード例 #3
0
 public Object parseValue(String value) throws Exception {
   /// Handle values for this option
   switch (this) {
     case HEALTHP:
     case HEALTH:
     case POOLMONEY:
     case WITHINDISTANCE:
     case MONEY:
       return Double.valueOf(value);
     case LEVELRANGE:
       return MinMax.valueOf(value);
     case DISGUISEALLAS:
       return value;
     case MAGIC:
     case MAGICP:
     case HUNGER:
     case EXPERIENCE:
     case INVULNERABLE:
       return Integer.valueOf(value);
     case FLIGHTSPEED:
       return Float.valueOf(value);
     case ENCHANTS:
       return EffectUtil.parseArg(value, 0, 120);
     case DOCOMMANDS:
       return value;
     case GIVECLASS:
       return ArenaClassController.getClass(value);
     case GAMEMODE:
       GameMode gm;
       try {
         gm = GameMode.getByValue(Integer.valueOf(value));
       } catch (Throwable e) {
         gm = GameMode.valueOf(value.toUpperCase());
       }
       return gm; // multiply by number of ticks per second
     default:
       break;
   }
   return null;
 }