예제 #1
0
  /**
   * Parse a ConfigurationSection representing a AlchemyPotion. Returns null if input cannot be
   * parsed.
   *
   * @param potion_section ConfigurationSection to be parsed.
   * @return Parsed AlchemyPotion.
   */
  private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
    try {
      short dataValue = Short.parseShort(potion_section.getName());

      String name = potion_section.getString("Name");
      if (name != null) {
        name = ChatColor.translateAlternateColorCodes('&', name);
      }

      List<String> lore = new ArrayList<String>();
      if (potion_section.contains("Lore")) {
        for (String line : potion_section.getStringList("Lore")) {
          lore.add(ChatColor.translateAlternateColorCodes('&', line));
        }
      }

      List<PotionEffect> effects = new ArrayList<PotionEffect>();
      if (potion_section.contains("Effects")) {
        for (String effect : potion_section.getStringList("Effects")) {
          String[] parts = effect.split(" ");

          PotionEffectType type = parts.length > 0 ? PotionEffectType.getByName(parts[0]) : null;
          int amplifier = parts.length > 1 ? Integer.parseInt(parts[1]) : 0;
          int duration = parts.length > 2 ? Integer.parseInt(parts[2]) : 0;

          if (type != null) {
            effects.add(new PotionEffect(type, duration, amplifier));
          } else {
            mcMMO
                .p
                .getLogger()
                .warning("Failed to parse effect for potion " + name + ": " + effect);
          }
        }
      }

      Map<ItemStack, Short> children = new HashMap<ItemStack, Short>();
      if (potion_section.contains("Children")) {
        for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) {
          ItemStack ingredient = loadIngredient(child);
          if (ingredient != null) {
            children.put(
                ingredient,
                Short.parseShort(
                    potion_section.getConfigurationSection("Children").getString(child)));
          } else {
            mcMMO.p.getLogger().warning("Failed to parse child for potion " + name + ": " + child);
          }
        }
      }

      return new AlchemyPotion(dataValue, name, lore, effects, children);
    } catch (Exception e) {
      mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getName());
      return null;
    }
  }
예제 #2
0
 private static ArenaClass parseArenaClass(ConfigurationSection cs) {
   List<ItemStack> items = null;
   List<PotionEffect> effects = null;
   if (cs.contains("items")) {
     items = BAConfigSerializer.getItemList(cs, "items");
   }
   if (cs.contains("enchants")) {
     effects = BAConfigSerializer.getEffectList(cs, "enchants");
   }
   String prettyName = cs.getString("displayName", null);
   return new ArenaClass(cs.getName(), prettyName, items, effects);
 }
예제 #3
0
  /**
   * Loads a RSPlayerInventory from a loaded ConfigurationSection.
   *
   * @param source ConfigurationSection where to read.
   * @return Correctly built RSPlayerInventory object.
   */
  public static RSPlayerInventory loadInventory(ConfigurationSection source) {
    String player = source.getName();
    String store = source.getString("store");

    ConfigurationSection bgt = source.getConfigurationSection("bought");
    Map<Price, Integer> bought = loadPriceMap(bgt);

    ConfigurationSection itms = source.getConfigurationSection("contents");
    Map<Price, Integer> items = loadPriceMap(itms);

    return new RSPlayerInventory(player, RealShopping.getShop(store), bought, items);
  }
예제 #4
0
 public KitInfo(ConfigurationSection config) {
   this(config.getName());
   icon = config.getItemStack("icon");
   helmet = config.getItemStack("helmet");
   chest = config.getItemStack("chest");
   legs = config.getItemStack("legs");
   boots = config.getItemStack("boots");
   try {
     items = (List<ItemStack>) config.get("items", new ArrayList<ItemStack>());
   } catch (ClassCastException e) {
     Bukkit.getLogger().log(Level.WARNING, "[SimpleTeamPvP] Could not load items for kit " + name);
   }
 }
예제 #5
0
  /**
   * Loads a ShippedPackage from a loaded configuration section.
   *
   * @param source Configuration section where to load the ShippedPackage.
   * @return A ShippedPackage object built from configuration file.
   */
  public static ShippedPackage loadShippedPackage(ConfigurationSection source) {
    long date = Long.parseLong(source.getName());
    int cost = source.getInt("cost");
    ConfigurationSection location = source.getConfigurationSection("location");
    Location loc =
        new Location(
            Bukkit.getWorld(location.getString("world")),
            location.getDouble("x"),
            location.getDouble("y"),
            location.getDouble("z"));

    ConfigurationSection contents = source.getConfigurationSection("contents");
    return new ShippedPackage(loadItemStack(contents).toArray(new ItemStack[0]), cost, loc, date);
  }
예제 #6
0
 @Override
 protected void loadKeys() {
   ConfigurationSection groups = config.getConfigurationSection("groups");
   for (String keys : groups.getKeys(false)) {
     ConfigurationSection vars = groups.getConfigurationSection(keys);
     super.plugin
         .getChatProfiles()
         .add(
             new ChatProfile(
                 vars.getName(),
                 vars.getName(),
                 vars.getString("Prefix"),
                 vars.getString("Suffix"),
                 vars.getString("Muffix"),
                 vars.getString("Format")));
   }
 }
예제 #7
0
 public final void init(Game owner, ConfigurationSection config) {
   this.owner = owner;
   this.config = config;
   this.id = config.getName();
 }
예제 #8
0
  /**
   * Create new permission group based on configuration section and default group values
   *
   * @param config
   * @param defaults
   * @param forceDefault
   */
  public PermissionGroup(
      ConfigurationSection config, PermissionGroup defaults, boolean forceDefault) {
    m_name = config.getName();
    m_isDefault = config.getBoolean("isDefault", forceDefault);
    m_maxJobs =
        validate(config.getInt("maxJobs", defaults.getMaxJobs()), defaults.getMaxJobs(), true);
    m_cleanOnLogout = config.getBoolean("cleanOnLogout", defaults.getCleanOnLogout());
    m_isOnByDefault = config.getBoolean("defaultMode", defaults.isOnByDefault());

    ConfigurationSection rendererSection = config.getConfigurationSection("renderer");
    ConfigurationSection queueSection = config.getConfigurationSection("queue");
    ConfigurationSection messagesSection = config.getConfigurationSection("messages");

    int rendererBlocks =
        validate(
            rendererSection == null
                ? defaults.getRendererBlocks()
                : rendererSection.getInt("blocks", defaults.getRendererBlocks()),
            defaults.getRendererBlocks(),
            true);
    int rendererTime =
        validate(
            rendererSection == null
                ? defaults.getRendererTime()
                : rendererSection.getInt("time", defaults.getRendererTime()),
            defaults.getRendererTime(),
            true);

    if (rendererBlocks == -1 && rendererTime == -1) {
      AsyncWorldEditMain.log("Warning: Time and blocks are set to unlimited! For group " + m_name);
      rendererBlocks = s_defaultValue.getRendererBlocks();
      rendererTime = s_defaultValue.getRendererTime();
    }

    m_rendererBlocks = rendererBlocks;
    m_rendererTime = rendererTime;

    m_queueHardLimit =
        validate(
            queueSection == null
                ? defaults.getQueueHardLimit()
                : queueSection.getInt("limit-hard", defaults.getQueueHardLimit()),
            defaults.getQueueHardLimit(),
            false);
    m_queueSoftLimit =
        validate(
            queueSection == null
                ? defaults.getQueueSoftLimit()
                : queueSection.getInt("limit-soft", defaults.getQueueSoftLimit()),
            defaults.getQueueSoftLimit(),
            false);

    m_useBarApi =
        messagesSection == null
            ? defaults.isBarApiProgressEnabled()
            : messagesSection.getBoolean("progress-bar", defaults.isBarApiProgressEnabled());
    m_useChat =
        messagesSection == null
            ? defaults.isChatProgressEnabled()
            : messagesSection.getBoolean("progress-chat", defaults.isChatProgressEnabled());
    m_isTalkative =
        messagesSection == null
            ? defaults.isTalkative()
            : messagesSection.getBoolean("talkative", defaults.isTalkative());
  }