Esempio n. 1
0
  public static void main(String[] args) {
    // Generate code for toID() function
    System.out.println("/*");
    System.out.println(" * Returns a classic block type id related to the material");
    System.out.println(" */");
    System.out.println("@SuppressWarnings(\"deprecation\")");
    System.out.println("public static int toID(EntityType entityType)");
    System.out.println("{");
    boolean added = false;
    for (int i = 0; i < 1024; i++) {

      @SuppressWarnings("deprecation")
      EntityType entityType = EntityType.fromId(i);
      if (entityType != null) {
        String name = entityType.name();
        String suffix = "";
        if (added) {
          suffix = "else ";
        }
        System.out.println("\t" + suffix + "if(entityType.equals(EntityType." + name + "))");
        System.out.println("\t{");
        System.out.println("\t\treturn " + i + ";");
        System.out.println("\t}");
        added = true;
      }
    }
    System.out.println("\treturn entityType.getTypeId();");
    System.out.println("}");

    System.out.println();

    // Generate code for toMaterial() function
    System.out.println("/*");
    System.out.println(" * Returns a classic block type id related to the material");
    System.out.println(" */");
    System.out.println("@SuppressWarnings(\"deprecation\")");
    System.out.println("public static EntityType toEntityType(int id)");
    System.out.println("{");
    added = false;
    for (int i = 0; i < 1024; i++) {
      @SuppressWarnings("deprecation")
      EntityType entityType = EntityType.fromId(i);
      if (entityType != null) {
        String name = entityType.name();
        String suffix = "";
        if (added) {
          suffix = "else ";
        }
        System.out.println("\t" + suffix + "if(id==" + i + ")");
        System.out.println("\t{");
        System.out.println("\t\treturn EntityType." + name + ";");
        System.out.println("\t}");
        added = true;
      }
    }
    System.out.println("\treturn EntityType.fromId(id);");
    System.out.println("}");
  }
  public boolean projectileHitEntity(Entity projectile, LivingEntity target, ProjectileInfo info) {
    if (!info.done
        && (maxDistanceSquared == 0
            || projectile.getLocation().distanceSquared(info.start) <= maxDistanceSquared)) {
      if (aoeRadius == 0) {
        float power = info.power;

        // check player
        if (!targetPlayers && target instanceof Player) return false;

        // call target event
        SpellTargetEvent evt = new SpellTargetEvent(this, info.player, target, power);
        Bukkit.getPluginManager().callEvent(evt);
        if (evt.isCancelled()) {
          return false;
        } else if (allowTargetChange) {
          target = evt.getTarget(); // TODO make an alternative to overriding the parameter
          power = evt.getPower();
        }

        // run spells
        for (Subspell spell : spells) {
          if (spell.isTargetedEntitySpell()) {
            spell.castAtEntity(info.player, target, power);
            playSpellEffects(EffectPosition.TARGET, target);
          } else if (spell.isTargetedLocationSpell()) {
            spell.castAtLocation(info.player, target.getLocation(), power);
            playSpellEffects(EffectPosition.TARGET, target.getLocation());
          }
        }

        // send messages
        String entityName;
        if (target instanceof Player) {
          entityName = ((Player) target).getDisplayName();
        } else {
          EntityType entityType = target.getType();
          entityName = MagicSpells.getEntityNames().get(entityType);
          if (entityName == null) {
            entityName = entityType.name().toLowerCase();
          }
        }
        sendMessage(
            formatMessage(strHitCaster, "%t", entityName), info.player, MagicSpells.NULL_ARGS);
        if (target instanceof Player) {
          sendMessage(
              formatMessage(strHitTarget, "%a", info.player.getDisplayName()),
              (Player) target,
              MagicSpells.NULL_ARGS);
        }
      } else {
        aoe(projectile, info);
      }

      info.done = true;
    }
    return true;
  }
Esempio n. 3
0
  public void save(ConfigurationNode node) {
    // Set if the world can be directly accessed
    World w = this.getWorld();
    if (w != null) {
      this.difficulty = w.getDifficulty();
      this.keepSpawnInMemory = w.getKeepSpawnInMemory();
      this.autosave = w.isAutoSave();
    }
    if (this.worldname == null || this.worldname.equals(this.getConfigName())) {
      node.remove("name");
    } else {
      node.set("name", this.worldname);
    }
    node.set("loaded", w != null);
    node.set("keepSpawnLoaded", this.keepSpawnInMemory);
    node.set("environment", this.worldmode.getName());
    node.set("chunkGenerator", LogicUtil.fixNull(this.getChunkGeneratorName(), ""));
    node.set("clearInventory", this.clearInventory ? true : null);
    node.set("gamemode", this.gameMode == null ? "NONE" : this.gameMode.toString());

    if (this.timeControl.isLocked()) {
      node.set("lockedtime", this.timeControl.getTime());
    } else {
      node.remove("lockedtime");
    }

    ArrayList<String> creatures = new ArrayList<String>();
    for (EntityType type : this.spawnControl.deniedCreatures) {
      creatures.add(type.name());
    }
    node.set("forcedRespawn", this.forcedRespawn);
    node.set("rememberlastplayerpos", this.rememberLastPlayerPosition);
    node.set("pvp", this.pvp);
    node.set("defaultNetherPortal", this.defaultNetherPortal);
    node.set("defaultEndPortal", this.defaultEnderPortal);
    node.set("operators", this.OPlist);
    node.set("deniedCreatures", creatures);
    node.set("holdWeather", this.holdWeather);
    node.set("hunger", this.allowHunger);
    node.set("formIce", this.formIce);
    node.set("formSnow", this.formSnow);
    node.set("showRain", this.showRain);
    node.set("showSnow", this.showSnow);
    node.set("difficulty", this.difficulty == null ? "NONE" : this.difficulty.toString());
    node.set("reloadWhenEmpty", this.reloadWhenEmpty);
    if (this.spawnPoint == null) {
      node.remove("spawn");
    } else {
      node.set("spawn.world", this.spawnPoint.getWorldName());
      node.set("spawn.x", this.spawnPoint.getX());
      node.set("spawn.y", this.spawnPoint.getY());
      node.set("spawn.z", this.spawnPoint.getZ());
      node.set("spawn.yaw", (double) this.spawnPoint.getYaw());
      node.set("spawn.pitch", (double) this.spawnPoint.getPitch());
    }
  }
Esempio n. 4
0
  public static String getProperMobName(EntityType type) {

    String name = type.name().toLowerCase();

    name = Character.toUpperCase(name.charAt(0)) + name.substring(1);
    while (fixUnderscore(name) != null) {
      name = fixUnderscore(name);
    }

    return name;
  }
Esempio n. 5
0
 @Override
 public void getParameterOptions(Spell spell, String parameterKey, Collection<String> examples) {
   if (parameterKey.equals("type")) {
     for (EntityType type : EntityType.values()) {
       examples.add(type.name().toLowerCase());
     }
   } else if (parameterKey.equals("reason")) {
     for (CreatureSpawnEvent.SpawnReason type : CreatureSpawnEvent.SpawnReason.values()) {
       examples.add(type.name().toLowerCase());
     }
   } else if (parameterKey.equals("skeleton_type")) {
     for (Skeleton.SkeletonType type : Skeleton.SkeletonType.values()) {
       examples.add(type.name().toLowerCase());
     }
   } else if (parameterKey.equals("ocelot_type")) {
     for (Ocelot.Type type : Ocelot.Type.values()) {
       examples.add(type.name().toLowerCase());
     }
   } else if (parameterKey.equals("villager_profession")) {
     for (Villager.Profession profession : Villager.Profession.values()) {
       examples.add(profession.name().toLowerCase());
     }
   } else if (parameterKey.equals("rabbity_type")) {
     for (Rabbit.Type type : Rabbit.Type.values()) {
       examples.add(type.name().toLowerCase());
     }
   } else if (parameterKey.equals("horse_variant")) {
     for (Horse.Variant type : Horse.Variant.values()) {
       examples.add(type.name().toLowerCase());
     }
   } else if (parameterKey.equals("horse_style")) {
     for (Horse.Style type : Horse.Style.values()) {
       examples.add(type.name().toLowerCase());
     }
   } else if (parameterKey.equals("horse_color")) {
     for (Horse.Color type : Horse.Color.values()) {
       examples.add(type.name().toLowerCase());
     }
   } else if (parameterKey.equals("color")) {
     for (DyeColor type : DyeColor.values()) {
       examples.add(type.name().toLowerCase());
     }
   } else if (parameterKey.equals("track")
       || parameterKey.equals("loot")
       || parameterKey.equals("baby")) {
     examples.addAll(Arrays.asList((BaseSpell.EXAMPLE_BOOLEANS)));
   } else if (parameterKey.equals("name")) {
     examples.add("Philbert");
   } else if (parameterKey.equals("speed")) {
     examples.addAll(Arrays.asList((BaseSpell.EXAMPLE_SIZES)));
   } else {
     super.getParameterOptions(spell, parameterKey, examples);
   }
 }
Esempio n. 6
0
  public static EntityType getProperMobType(String properName) {

    properName = properName.replaceAll("_", "").toUpperCase();
    for (EntityType et : EntityType.values()) {

      if (et.isAlive() && et.name().replaceAll("_", "").equalsIgnoreCase(properName)) {
        return et;
      }
    }

    return null;
  }
Esempio n. 7
0
 static {
   entityTypes = new HashMap<>();
   for (final EntityType e : EntityType.values()) {
     entityTypes.put(e.name(), e);
   }
 }
 public MCEntityType getType() {
   EntityType type = e.getType();
   return MCEntityType.valueOf(type.name());
 }
  /*
   * (non-Javadoc)
   * @see de.oppermann.bastian.spleef.util.command.AbstractArgument#executeForPlayer(org.bukkit.entity.Player, org.bukkit.command.Command, java.lang.String[])
   */
  @Override
  public CommandResult executeForPlayer(Player player, Command cmd, String[] args) {
    if (args.length == 4) {

      if (!player.hasPermission(getPermission())) {
        return CommandResult.NO_PERMISSION;
      }

      SpleefArena arena = null;
      for (SpleefArena sArena : SpleefArena.getSpleefArenas()) {
        if (sArena.getName().equals(args[1])) {
          arena = sArena;
          break;
        }
      }

      if (arena == null) {
        player.sendMessage(Language.NO_ARENA_WITH_NAME.toString().replace("%arena%", args[1]));
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_ENABLED.toString())) {
        boolean enabled = args[3].equalsIgnoreCase(Language.VALUE_TRUE.toString());
        String strValue =
            enabled ? Language.VALUE_TRUE.toString() : Language.VALUE_FALSE.toString();
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_ENABLED.toString())
                .replace("%value%", strValue));

        arena.getConfiguration().setDisabled(!enabled);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("enabled", enabled);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_SNOWBALLS_ENABLED.toString())) {
        boolean enabled = args[3].equalsIgnoreCase(Language.VALUE_TRUE.toString());
        String strValue =
            enabled ? Language.VALUE_TRUE.toString() : Language.VALUE_FALSE.toString();
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_ENABLED.toString())
                .replace("%value%", strValue));

        arena.getConfiguration().setEnableSnowballs(enabled);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("snowballs.enabled", enabled);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_MAX_SNOWBALLS.toString())) {
        int maxSnowballs;
        try {
          maxSnowballs = Integer.valueOf(args[3]);
        } catch (NumberFormatException e) {
          player.sendMessage(Language.VALUE_MUST_BE_A_NUMBER.toString());
          return CommandResult.SUCCESS;
        }
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_ENABLED.toString())
                .replace("%value%", String.valueOf(maxSnowballs)));

        arena.getConfiguration().setMaxSnowballs(maxSnowballs);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("snowballs.maxSnowballs", maxSnowballs);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_MODE.toString())) {
        if (args[3].equalsIgnoreCase(Language.VALUE_MODE_NORMAL.toString())) {
          arena.getConfiguration().setMode(SpleefMode.NORMAL);
          player.sendMessage(
              Language.SUCCESSFULLY_SET_VALUE
                  .toString()
                  .replace("%flag%", Language.FLAG_MODE.toString())
                  .replace("%value%", Language.VALUE_MODE_NORMAL.toString()));
          SpleefMain.getInstance()
              .getArenaAccessor(arena.getName())
              .getConfig()
              .set("mode", arena.getConfiguration().getMode().name().toLowerCase());
          SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
          return CommandResult.SUCCESS;
        }
        if (args[3].equalsIgnoreCase(Language.VALUE_MODE_BOWSPLEEF.toString())) {
          arena.getConfiguration().setMode(SpleefMode.BOWSPLEEF);
          player.sendMessage(
              Language.SUCCESSFULLY_SET_VALUE
                  .toString()
                  .replace("%flag%", Language.FLAG_MODE.toString())
                  .replace("%value%", Language.VALUE_MODE_BOWSPLEEF.toString()));
          SpleefMain.getInstance()
              .getArenaAccessor(arena.getName())
              .getConfig()
              .set("mode", arena.getConfiguration().getMode().name().toLowerCase());
          SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
          return CommandResult.SUCCESS;
        }
        if (args[3].equalsIgnoreCase(Language.VALUE_MODE_SPLEGG.toString())) {
          arena.getConfiguration().setMode(SpleefMode.SPLEGG);
          player.sendMessage(
              Language.SUCCESSFULLY_SET_VALUE
                  .toString()
                  .replace("%flag%", Language.FLAG_MODE.toString())
                  .replace("%value%", Language.VALUE_MODE_SPLEGG.toString()));
          SpleefMain.getInstance()
              .getArenaAccessor(arena.getName())
              .getConfig()
              .set("mode", arena.getConfiguration().getMode().name().toLowerCase());
          SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
          return CommandResult.SUCCESS;
        }
        if (args[3].equalsIgnoreCase(Language.VALUE_MODE_SPLEEF_RUN.toString())) {
          arena.getConfiguration().setMode(SpleefMode.SPLEEF_RUN);
          player.sendMessage(
              Language.SUCCESSFULLY_SET_VALUE
                  .toString()
                  .replace("%flag%", Language.FLAG_MODE.toString())
                  .replace("%value%", Language.VALUE_MODE_SPLEEF_RUN.toString()));
          SpleefMain.getInstance()
              .getArenaAccessor(arena.getName())
              .getConfig()
              .set("mode", arena.getConfiguration().getMode().name().toLowerCase());
          SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
          return CommandResult.SUCCESS;
        }
        if (args[3].equalsIgnoreCase(Language.VALUE_MODE_SUPER_SPLEEF.toString())) {
          arena.getConfiguration().setMode(SpleefMode.SUPER_SPLEEF);
          player.sendMessage(
              Language.SUCCESSFULLY_SET_VALUE
                  .toString()
                  .replace("%flag%", Language.FLAG_MODE.toString())
                  .replace("%value%", Language.VALUE_MODE_SUPER_SPLEEF.toString()));
          SpleefMain.getInstance()
              .getArenaAccessor(arena.getName())
              .getConfig()
              .set("mode", arena.getConfiguration().getMode().name().toLowerCase());
          SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
          return CommandResult.SUCCESS;
        }
        if (args[3].equalsIgnoreCase(Language.VALUE_MODE_SUPER_SPLEGG.toString())) {
          arena.getConfiguration().setMode(SpleefMode.SUPER_SPLEGG);
          player.sendMessage(
              Language.SUCCESSFULLY_SET_VALUE
                  .toString()
                  .replace("%flag%", Language.FLAG_MODE.toString())
                  .replace("%value%", Language.VALUE_MODE_SUPER_SPLEGG.toString()));
          SpleefMain.getInstance()
              .getArenaAccessor(arena.getName())
              .getConfig()
              .set("mode", arena.getConfiguration().getMode().name().toLowerCase());
          SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
          return CommandResult.SUCCESS;
        }
        player.sendMessage(Language.UNKNOWN_MODE.toString());
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_CUSTOMINVENTORY_ENABLED.toString())) {
        boolean enabled = args[3].equalsIgnoreCase(Language.VALUE_TRUE.toString());
        String strValue =
            enabled ? Language.VALUE_TRUE.toString() : Language.VALUE_FALSE.toString();
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_CUSTOMINVENTORY_ENABLED.toString())
                .replace("%value%", strValue));

        arena.getConfiguration().setCustomInventory(enabled);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("customInventory.enabled", enabled);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_VEHICLE.toString())) {
        if (args[3].equalsIgnoreCase("none")) {
          arena.getConfiguration().setVehicle(null);
          SpleefMain.getInstance()
              .getArenaAccessor(arena.getName())
              .getConfig()
              .set("vehicle", "none");
          SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
          player.sendMessage(
              Language.SUCCESSFULLY_SET_VALUE
                  .toString()
                  .replace("%flag%", Language.FLAG_VEHICLE.toString())
                  .replace("%value%", "none"));
          return CommandResult.SUCCESS;
        }
        EntityType type;
        try {
          type = EntityType.valueOf(args[3].toUpperCase());
        } catch (IllegalArgumentException e) {
          player.sendMessage(Language.UNKNOWN_ENTITY.toString());
          return CommandResult.SUCCESS;
        }
        if (!type.isSpawnable()) {
          player.sendMessage(Language.UNKNOWN_ENTITY.toString());
          return CommandResult.SUCCESS;
        }
        /* TODO
        if (!type.getEntityClass().isAssignableFrom(LivingEntity.class)) {
        	player.sendMessage(Language.UNKNOWN_ENTITY.toString());
        	return CommandResult.SUCCESS;
        }
        */
        arena.getConfiguration().setVehicle(type);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("vehicle", type.name().toLowerCase());
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_VEHICLE.toString())
                .replace("%value%", type.name().toLowerCase()));
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_INSTANT_BLOCK_DESTORY.toString())) {
        boolean enabled = args[3].equalsIgnoreCase(Language.VALUE_TRUE.toString());
        String strValue =
            enabled ? Language.VALUE_TRUE.toString() : Language.VALUE_FALSE.toString();
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_INSTANT_BLOCK_DESTORY.toString())
                .replace("%value%", strValue));

        arena.getConfiguration().setInstanstBlockDestroy(enabled);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("instantBlockDestroy", enabled);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_REWARD_MONEY_PARTICIPATION.toString())) {
        int reward;
        try {
          reward = Integer.valueOf(args[3]);
        } catch (NumberFormatException e) {
          player.sendMessage(Language.VALUE_MUST_BE_A_NUMBER.toString());
          return CommandResult.SUCCESS;
        }
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_REWARD_MONEY_PARTICIPATION.toString())
                .replace("%value%", String.valueOf(reward)));

        arena.getConfiguration().setMoneyParticipationReward(reward);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("reward.money.participation", reward);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_REWARD_MONEY_WINNING.toString())) {
        int reward;
        try {
          reward = Integer.valueOf(args[3]);
        } catch (NumberFormatException e) {
          player.sendMessage(Language.VALUE_MUST_BE_A_NUMBER.toString());
          return CommandResult.SUCCESS;
        }
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_REWARD_MONEY_WINNING.toString())
                .replace("%value%", String.valueOf(reward)));

        arena.getConfiguration().setMoneyWinningReward(reward);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("reward.money.winning", reward);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_REWARD_POINTS_PARTICIPATION.toString())) {
        int reward;
        try {
          reward = Integer.valueOf(args[3]);
        } catch (NumberFormatException e) {
          player.sendMessage(Language.VALUE_MUST_BE_A_NUMBER.toString());
          return CommandResult.SUCCESS;
        }
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_REWARD_POINTS_PARTICIPATION.toString())
                .replace("%value%", String.valueOf(reward)));

        arena.getConfiguration().setPointsParticipationReward(reward);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("reward.points.participation", reward);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_REWARD_POINTS_WINNING.toString())) {
        int reward;
        try {
          reward = Integer.valueOf(args[3]);
        } catch (NumberFormatException e) {
          player.sendMessage(Language.VALUE_MUST_BE_A_NUMBER.toString());
          return CommandResult.SUCCESS;
        }
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_REWARD_POINTS_WINNING.toString())
                .replace("%value%", String.valueOf(reward)));

        arena.getConfiguration().setPointsWinningReward(reward);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("reward.points.winning", reward);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_FREEZE_PLAYERS.toString())) {
        boolean enabled = args[3].equalsIgnoreCase(Language.VALUE_TRUE.toString());
        String strValue =
            enabled ? Language.VALUE_TRUE.toString() : Language.VALUE_FALSE.toString();
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_FREEZE_PLAYERS.toString())
                .replace("%value%", strValue));

        arena.getConfiguration().setFreezePlayers(enabled);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("freezePlayers", enabled);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_MODIFY_GRAVITY.toString())) {
        boolean enabled = args[3].equalsIgnoreCase(Language.VALUE_TRUE.toString());
        String strValue =
            enabled ? Language.VALUE_TRUE.toString() : Language.VALUE_FALSE.toString();
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_MODIFY_GRAVITY.toString())
                .replace("%value%", strValue));

        arena.getConfiguration().setModifyGravity(enabled);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("modifygravity.enable", enabled);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_GRAVITY.toString())) {
        double gravity;
        try {
          gravity = Double.valueOf(args[3]);
        } catch (NumberFormatException e) {
          player.sendMessage(Language.VALUE_MUST_BE_A_NUMBER_BETWEEN_0_AND_1.toString());
          return CommandResult.SUCCESS;
        }
        if (gravity <= 0 || gravity >= 1) {
          player.sendMessage(Language.VALUE_MUST_BE_A_NUMBER_BETWEEN_0_AND_1.toString());
          return CommandResult.SUCCESS;
        }
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_GRAVITY.toString())
                .replace("%value%", String.valueOf(gravity)));

        arena.getConfiguration().setGravity(gravity);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("modifygravity.gravity", gravity);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_MIN_PLAYERS.toString())) {
        int minPlayers;
        try {
          minPlayers = Integer.valueOf(args[3]);
        } catch (NumberFormatException e) {
          player.sendMessage(Language.VALUE_MUST_BE_A_NUMBER.toString());
          return CommandResult.SUCCESS;
        }

        minPlayers = minPlayers < 2 ? 2 : minPlayers; // must be at least 2
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_MIN_PLAYERS.toString())
                .replace("%value%", String.valueOf(minPlayers)));

        arena.getConfiguration().setMinPlayers(minPlayers);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("minPlayers", minPlayers);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_REQUIRED_PLAYERS_TO_START_COUNTDOWN.toString())) {
        int requiredPlayersToStartCountdown;
        try {
          requiredPlayersToStartCountdown = Integer.valueOf(args[3]);
        } catch (NumberFormatException e) {
          player.sendMessage(Language.VALUE_MUST_BE_A_NUMBER.toString());
          return CommandResult.SUCCESS;
        }

        requiredPlayersToStartCountdown =
            requiredPlayersToStartCountdown < 2
                ? 2
                : requiredPlayersToStartCountdown; // must be at least 2
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_REQUIRED_PLAYERS_TO_START_COUNTDOWN.toString())
                .replace("%value%", String.valueOf(requiredPlayersToStartCountdown)));

        arena.getConfiguration().setMinPlayers(requiredPlayersToStartCountdown);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("requiredPlayersToStartCountdown", requiredPlayersToStartCountdown);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_SPECTATE_TYPE.toString())) {

        SpectateType spectateType = SpectateType.NONE;
        String spectateTypeName = Language.SPECTATE_TYPE_NONE.toString();
        if (args[3].equalsIgnoreCase(Language.SPECTATE_TYPE_NORMAL.toString())) {
          spectateType = SpectateType.NORMAL;
          spectateTypeName = Language.SPECTATE_TYPE_NORMAL.toString();
        }
        if (args[3].equalsIgnoreCase(Language.SPECTATE_TYPE_NORMAL_FLYING.toString())) {
          spectateType = SpectateType.NORMAL_FLYING;
          spectateTypeName = Language.SPECTATE_TYPE_NORMAL_FLYING.toString();
        }
        if (args[3].equalsIgnoreCase(Language.SPECTATE_TYPE_GAMEMODE_3.toString())) {
          spectateType = SpectateType.GAMEMODE_3;
          spectateTypeName = Language.SPECTATE_TYPE_GAMEMODE_3.toString();
        }
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_SPECTATE_TYPE.toString())
                .replace("%value%", spectateTypeName));

        arena.getConfiguration().setSpectateType(spectateType);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("spectateType", spectateType.name().toLowerCase());
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_ARENA_COUNTDOWN.toString())) {
        int arenaCountdown;
        try {
          arenaCountdown = Integer.valueOf(args[3]);
        } catch (NumberFormatException e) {
          player.sendMessage(Language.VALUE_MUST_BE_A_NUMBER.toString());
          return CommandResult.SUCCESS;
        }

        arenaCountdown = arenaCountdown < 0 ? 0 : arenaCountdown; // must be at least 0
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_ARENA_COUNTDOWN.toString())
                .replace("%value%", String.valueOf(arenaCountdown)));

        arena.getConfiguration().setArenaCountdown(arenaCountdown);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("arenaCountdown", arenaCountdown);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_LOBBY_COUNTDOWN.toString())) {
        int lobbyCountdown;
        try {
          lobbyCountdown = Integer.valueOf(args[3]);
        } catch (NumberFormatException e) {
          player.sendMessage(Language.VALUE_MUST_BE_A_NUMBER.toString());
          return CommandResult.SUCCESS;
        }

        lobbyCountdown = lobbyCountdown < 5 ? 5 : lobbyCountdown; // must be at least 5
        player.sendMessage(
            Language.SUCCESSFULLY_SET_VALUE
                .toString()
                .replace("%flag%", Language.FLAG_LOBBY_COUNTDOWN.toString())
                .replace("%value%", String.valueOf(lobbyCountdown)));

        arena.getConfiguration().setLobbyCountdown(lobbyCountdown);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("lobbyCountdown", lobbyCountdown);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        return CommandResult.SUCCESS;
      }

      player.sendMessage(Language.UNKNOWN_FLAG.toString().replace("%flag%", args[2]));
      return CommandResult.SUCCESS;
    }

    // flags without arguments
    if (args.length == 3) {
      if (!player.hasPermission(getPermission())) {
        return CommandResult.NO_PERMISSION;
      }

      SpleefArena arena = null;
      for (SpleefArena sArena : SpleefArena.getSpleefArenas()) {
        if (sArena.getName().equals(args[1])) {
          arena = sArena;
          break;
        }
      }

      if (arena == null) {
        player.sendMessage(Language.NO_ARENA_WITH_NAME.toString().replace("%arena%", args[1]));
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_CUSTOMINVENTORY.toString())) {
        ItemStack[] contents = player.getInventory().getContents();
        for (int i = 0; i < contents.length; i++) {
          SpleefMain.getInstance()
              .getArenaAccessor(arena.getName())
              .getConfig()
              .set("customInventory.items." + i, contents[i]);
        }

        arena.getConfiguration().setCustomInventoryContents(contents);
        arena.getConfiguration().setCustomInventory(true);
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("customInventory.enabled", true);
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        player.sendMessage(Language.SUCCESSFULLY_SET_CUSTOMINVENTORY.toString());
        return CommandResult.SUCCESS;
      }

      if (args[2].equalsIgnoreCase(Language.FLAG_SPECTATE_LOCATION.toString())) {
        arena.getConfiguration().setSpectateLocation(player.getLocation());

        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("spectateLocation.x", player.getLocation().getX());
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("spectateLocation.y", player.getLocation().getY());
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("spectateLocation.z", player.getLocation().getZ());
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("spectateLocation.yaw", player.getLocation().getYaw());
        SpleefMain.getInstance()
            .getArenaAccessor(arena.getName())
            .getConfig()
            .set("spectateLocation.pitch", player.getLocation().getPitch());
        SpleefMain.getInstance().getArenaAccessor(arena.getName()).saveConfig();
        player.sendMessage(Language.SUCCESSFULLY_SET_SPECTATE_LOCATION.toString());
        return CommandResult.SUCCESS;
      }
    }
    return CommandResult.ERROR;
  }
 public static at.pcgamingfreaks.TestClasses.NMS.Statistic getEntityStatistic(
     Statistic statistic, EntityType entityType) {
   return new at.pcgamingfreaks.TestClasses.NMS.Statistic(
       statistic.name() + "-" + entityType.name());
 }