예제 #1
0
  /**
   * Applies a list of transformation on a block, if the block is not protected.
   *
   * @param toTransform the Bukkit block object to transform
   * @param transformations the list if transformations to apply
   */
  public static void transform(Block toTransform, List<List<String>> transformations) {
    if (isBlockProtected(toTransform)) {
      return;
    }

    for (List<String> toCheck : transformations) {
      ArrayList<String[]> stateIndex = new ArrayList<String[]>();

      for (int i = 0; i != 2; ++i) {
        String got = toCheck.get(i);

        if (got.contains(":")) { // Check for data _ appended.
          stateIndex.add(got.split(":"));
        } else {
          stateIndex.add(new String[] {got, "0"});
        }
      }

      String[] curState = stateIndex.get(0), toState = stateIndex.get(1);

      if (Integer.valueOf(curState[0]) == toTransform.getTypeId()
          && Integer.valueOf(curState[1]) == toTransform.getData()) {
        toTransform.setTypeIdAndData(Integer.valueOf(toState[0]), Byte.parseByte(toState[1]), true);
        return;
      }
    }
  }
예제 #2
0
  private Inventory getFuelInventory(Player player) {

    if (isValidFuelJacket(player.getInventory().getChestplate())) {

      FileConfiguration fuelConfig = getFuelConfig(player);
      Material jacket = player.getInventory().getChestplate().getType();

      int jacketSize = getFuelJacketSize(jacket);
      String jacketType = getFuelJacketConfigString(jacket);

      if (fuelConfig.get(jacketType) != null) {

        Inventory fuelInventory;
        ArrayList<ItemStack> itemStack = new ArrayList<>();

        itemStack.addAll(
            fuelConfig
                .getList(jacketType)
                .stream()
                .map(fuelCurrentItem -> (ItemStack) fuelCurrentItem)
                .collect(Collectors.toList()));

        fuelInventory =
            Bukkit.createInventory(
                player,
                jacketSize,
                "" + ChatColor.DARK_RED + ChatColor.BOLD + "Rocket Boot Fuel Jacket");
        fuelInventory.setContents(itemStack.toArray(new ItemStack[itemStack.size()]));

        return fuelInventory;
      }
    }

    return null;
  }
예제 #3
0
 @Override
 public Collection<GlowPlayer> getOnlinePlayers() {
   // todo: provide a view instead of reassembling the list each time
   ArrayList<GlowPlayer> result = new ArrayList<>();
   for (GlowWorld world : worlds.getWorlds()) {
     for (GlowPlayer player : world.getRawPlayers()) {
       result.add(player);
     }
   }
   return result;
 }
예제 #4
0
  @Override
  public List<Player> matchPlayer(String name) {
    name = name.toLowerCase();

    ArrayList<Player> result = new ArrayList<>();
    for (Player player : getOnlinePlayers()) {
      String lower = player.getName().toLowerCase();
      if (lower.equals(name)) {
        result.clear();
        result.add(player);
        break;
      } else if (lower.contains(name)) {
        result.add(player);
      }
    }
    return result;
  }
예제 #5
0
 public static void load() {
   final FileConfiguration config = UDSPlugin.getPlugin().getConfig();
   BLOCK_CREEPERS = config.getBoolean("block.creeper");
   BLOCK_ENDERMEN = config.getBoolean("block.endermen");
   BLOCK_SILVERFISH = config.getBoolean("block.silverfish");
   BLOCK_TNT = config.getBoolean("block.tnt");
   BLOCK_WITHER = config.getBoolean("block.wither");
   MAP_DATA = (byte) config.getInt("map-data");
   BASE_COST = config.getInt("cost.base");
   BUILD_COST = config.getInt("cost.build");
   CITY_COST = config.getInt("cost.city");
   CLAN_COST = config.getInt("cost.clan");
   EXPAND_COST = config.getInt("cost.expand");
   HOME_COST = config.getInt("cost.home");
   MAP_COST = config.getInt("cost.map");
   SHOP_COST = config.getInt("cost.shop");
   VIP_COST = config.getInt("cost.vip");
   UNDO_COUNT = config.getInt("range.undo");
   DRAIN_RANGE = config.getInt("range.drain");
   MOVE_RANGE = config.getInt("range.move");
   EDIT_RANGE = config.getInt("range.edit");
   COMPASS_RANGE = config.getInt("range.compass");
   BUTCHER_RANGE = config.getInt("range.butcher");
   VIP_SPAWNS = config.getInt("vip.spawns");
   WORLD_BORDER = config.getInt("range.world");
   WORLD_BORDER_SQRD = WORLD_BORDER * WORLD_BORDER;
   SPAWNER_EXP = config.getInt("exp.spawner");
   REQUEST_TTL = config.getLong("request-timeout") * TimeUtils.SECOND;
   MINECART_TTL = config.getLong("minecart.life") * TimeUtils.SECOND;
   PVP_TIME = config.getLong("pvp-time") * TimeUtils.SECOND;
   SLOW_TIME = config.getLong("auto-save") * TimeUtils.MINUTE;
   DRAGON_RESPAWN = config.getLong("respawn-dragon") * TimeUtils.MINUTE;
   VIP_TIME = config.getLong("vip.time") * TimeUtils.DAY;
   CURRENCIES = config.getString("currency.plural");
   WELCOME_MSG = config.getString("welcome.message");
   WELCOME_ADMIN = config.getString("welcome.admin");
   SERVER_OWNER = config.getString("server-owner");
   CURRENCY = config.getString("currency.singular");
   MAIN_WORLD = config.getString("world-name");
   WELCOME_GIFT = Material.getMaterial(config.getString("welcome.gift"));
   if (WELCOME_GIFT == null) WELCOME_GIFT = Material.EMERALD;
   SERVER_RULES = config.getStringList("server-rules");
   PISTON_POWER = config.getDouble("piston-power");
   SHARES = config.getStringList("inventory-shares");
   GMAIL_ADDRESS = config.getString("gmail.email");
   SKULL = config.getDouble("head-drop-chance");
   GMAIL_PASSWORD = config.getString("gmail.password");
   VIP_WHITELIST.clear();
   for (int typeId : config.getIntegerList("item-whitelist")) {
     VIP_WHITELIST.add(Material.getMaterial(typeId));
   }
   KITS.clear();
   for (String kit : config.getStringList("kits")) {
     final String[] kitSplit = kit.split(",");
     final List<ItemStack> items =
         new ArrayList<ItemStack>(ArrayUtils.subarray(kitSplit, 3, kitSplit.length - 1).length);
     for (Object item : ArrayUtils.subarray(kitSplit, 3, kitSplit.length - 1)) {
       items.add(new ItemStack(Material.getMaterial(Integer.parseInt((String) item))));
     }
     KITS.add(
         new Kit(
             kitSplit[0],
             Integer.parseInt(kitSplit[1]),
             items,
             PlayerRank.getByName(kitSplit[2])));
   }
   MOB_REWARDS.clear();
   for (EntityType entityType : EntityType.values()) {
     String entityName = "mob-rewards." + entityType.getName();
     if (entityName != null) {
       entityName = entityName.toLowerCase();
       MOB_REWARDS.put(entityType, config.getInt(entityName));
     }
   }
   GLOBAL_FLAGS.clear();
   for (RegionFlag flag : RegionFlag.values()) {
     final String flagname = "global-flags." + flag.toString().toLowerCase();
     GLOBAL_FLAGS.put(flag, config.getBoolean(flagname));
   }
 }