コード例 #1
0
  @Override
  public boolean conflicts(final FileConfiguration base) {
    final ConfigurationSection target = this.target(base);
    if (target == null) return false;

    return target.isSet(this.key);
  }
コード例 #2
0
ファイル: ConfigObject.java プロジェクト: Guiedo/jsonapi
 @SuppressWarnings({"rawtypes", "unchecked"})
 protected List getList(Field field, ConfigurationSection cs, String path, int depth)
     throws Exception {
   depth++;
   int listSize = cs.getKeys(false).size();
   String key = path;
   if (key.lastIndexOf(".") >= 0) {
     key = key.substring(key.lastIndexOf("."));
   }
   List list = new ArrayList();
   if (listSize > 0) {
     int loaded = 0;
     int i = 0;
     while (loaded < listSize) {
       if (cs.isSet(key + i)) {
         Object in = cs.get(key + i);
         in = loadObject(field, cs, key + i, depth);
         list.add(in);
         loaded++;
       }
       i++;
       // ugly overflow guard... should only be needed if config was manually edited very badly
       if (i > (listSize * 3)) loaded = listSize;
     }
   }
   return list;
 }
コード例 #3
0
ファイル: ConfigObject.java プロジェクト: Guiedo/jsonapi
 protected void onLoad(ConfigurationSection cs) throws Exception {
   for (Field field : getClass().getDeclaredFields()) {
     String path = field.getName().replaceAll("_", ".");
     if (doSkip(field)) {
       // Do nothing
     } else if (cs.isSet(path)) {
       field.set(this, loadObject(field, cs, path));
     } else {
       cs.set(path, saveObject(field.get(this), field, cs, path));
     }
   }
 }
コード例 #4
0
  public boolean removeVaultItem(Player p, UUID lotUuid) {

    String vaultPath = new StringBuilder(43).append("vaults.").append(p.getUniqueId()).toString();
    ConfigurationSection singlePlayerVaultSection = data.getConfigurationSection(vaultPath);
    String uuidString = lotUuid.toString();

    if (singlePlayerVaultSection.isSet(uuidString)) {
      singlePlayerVaultSection.set(uuidString, null);
      unoccupyVault(p.getUniqueId());
      return true;
    } else {
      return false;
    }
  }
コード例 #5
0
  private void load() {

    ConfigurationSection lotsSection = data.getConfigurationSection("lots");

    for (String uuidString : lotsSection.getKeys(false)) {

      ConfigurationSection singleLotSection = lotsSection.getConfigurationSection(uuidString);

      ItemStack item = singleLotSection.getItemStack("item");
      boolean started = singleLotSection.getBoolean("started");
      double price = singleLotSection.getDouble("price");
      String lastBidPlayerName = singleLotSection.getString("lastBidPlayerName");
      UUID lastBidPlayerUuid =
          singleLotSection.isSet("lastBidPlayerUuid")
              ? UUID.fromString(singleLotSection.getString("lastBidPlayerUuid"))
              : null;
      double lastBidPrice = singleLotSection.getDouble("lastBidPrice");
      double minimumIncrement = singleLotSection.getDouble("minimumIncrement");
      long preserveTimeExpire = singleLotSection.getLong("preserveTimeExpire");
      long auctionDurationExpire = singleLotSection.getLong("auctionDurationExpire");

      Lot lot =
          new Lot(
              UUID.fromString(uuidString),
              item,
              started,
              price,
              lastBidPlayerName,
              lastBidPlayerUuid,
              lastBidPrice,
              minimumIncrement,
              preserveTimeExpire,
              auctionDurationExpire);
      lots.add(lot);
    }
  }
コード例 #6
0
  public boolean loadOld() {
    final YamlConfiguration confighandle =
        YamlConfiguration.loadConfiguration(
            new File(SimpleRegionMarket.getPluginDir() + "agents.yml"));

    TemplateHotel tokenHotel = null;
    TemplateSell tokenAgent = null;
    for (final TemplateMain token : TokenManager.tokenList) {
      if (token.id.equalsIgnoreCase("SELL")) {
        tokenAgent = (TemplateSell) token;
      }
      if (token.id.equalsIgnoreCase("HOTEL")) {
        tokenHotel = (TemplateHotel) token;
      }
    }
    if (tokenHotel == null || tokenAgent == null) {
      return false;
    }

    ConfigurationSection path;
    for (final String world : confighandle.getKeys(false)) {
      final World worldWorld = Bukkit.getWorld(world);
      if (worldWorld == null) {
        continue;
      }
      path = confighandle.getConfigurationSection(world);
      for (final String region : path.getKeys(false)) {
        final ProtectedRegion protectedRegion =
            SimpleRegionMarket.wgManager.getProtectedRegion(worldWorld, region);
        if (protectedRegion == null) {
          continue;
        }
        path = confighandle.getConfigurationSection(world).getConfigurationSection(region);
        for (final String signnr : path.getKeys(false)) {
          path =
              confighandle
                  .getConfigurationSection(world)
                  .getConfigurationSection(region)
                  .getConfigurationSection(signnr);
          if (path == null) {
            continue;
          }

          if (path.getInt("Mode") == 1) { // HOTEL
            if (!tokenHotel.entries.containsKey(world)) {
              tokenHotel.entries.put(world, new HashMap<String, HashMap<String, Object>>());
            }
            if (!tokenHotel.entries.get(world).containsKey(region)) {
              tokenHotel.entries.get(world).put(region, new HashMap<String, Object>());
              Utils.setEntry(tokenHotel, world, region, "price", path.getInt("Price"));
              Utils.setEntry(tokenHotel, world, region, "account", path.getInt("Account"));
              Utils.setEntry(tokenHotel, world, region, "renttime", path.getLong("RentTime"));
              if (path.isSet("ExpireDate")) {
                Utils.setEntry(tokenHotel, world, region, "taken", true);
                Utils.setEntry(tokenHotel, world, region, "owner", path.getString("RentBy"));
                Utils.setEntry(tokenHotel, world, region, "expiredate", path.getLong("ExpireDate"));
              } else {
                Utils.setEntry(tokenHotel, world, region, "taken", false);
              }
            }

            final ArrayList<Location> signLocations =
                Utils.getSignLocations(tokenHotel, world, region);
            signLocations.add(
                new Location(
                    worldWorld, path.getDouble("X"), path.getDouble("Y"), path.getDouble("Z")));
            if (signLocations.size() == 1) {
              Utils.setEntry(tokenHotel, world, region, "signs", signLocations);
            }
          } else { // SELL
            if (!tokenAgent.entries.containsKey(world)) {
              tokenAgent.entries.put(world, new HashMap<String, HashMap<String, Object>>());
            }
            if (!tokenAgent.entries.get(world).containsKey(region)) {
              tokenAgent.entries.get(world).put(region, new HashMap<String, Object>());
              Utils.setEntry(tokenAgent, world, region, "price", path.getInt("Price"));
              Utils.setEntry(tokenAgent, world, region, "account", path.getInt("Account"));
              Utils.setEntry(tokenAgent, world, region, "renttime", path.getLong("RentTime"));
              Utils.setEntry(tokenAgent, world, region, "taken", false);
            }

            final ArrayList<Location> signLocations =
                Utils.getSignLocations(tokenAgent, world, region);
            signLocations.add(
                new Location(
                    worldWorld, path.getDouble("X"), path.getDouble("Y"), path.getDouble("Z")));
            if (signLocations.size() == 1) {
              Utils.setEntry(tokenAgent, world, region, "signs", signLocations);
            }
          }
        }
      }
    }
    return true;
  }
コード例 #7
0
 @Override
 public boolean keyExists(String key) {
   return root.isSet(getKeyFor(key));
 }
コード例 #8
0
  private void loadGrowthConfigs(ConfigurationSection config) {

    // load names that map to lists of biomes to be used as shorthand for those biomes
    ConfigurationSection biomeAliasSection = config.getConfigurationSection("biome_aliases");
    HashMap<String, List<Biome>> biomeAliases = new HashMap<String, List<Biome>>();
    for (String alias : biomeAliasSection.getKeys(false)) {
      // convert list of strings into list of biomes
      List<String> biomeStrs = biomeAliasSection.getStringList(alias);
      List<Biome> biomes = new ArrayList<Biome>();
      for (String biomeStr : biomeStrs) {
        try {
          Biome biome = Biome.valueOf(biomeStr);
          biomes.add(biome);
        } catch (IllegalArgumentException e) {
          LOG.warning(
              "loading configs: in biome_aliases: \"" + biomeStr + "\" is not a valid biome name.");
        }
      }

      // map those biomes to an alias
      biomeAliases.put(alias, biomes);
    }

    GrowthConfig defaultConfig = new GrowthConfig();

    materialGrowth = new HashMap<Object, GrowthConfig>();
    HashMap<String, GrowthConfig> growthConfigNodes = new HashMap<String, GrowthConfig>();

    ConfigurationSection growthConfigSection = config.getConfigurationSection("growth");
    for (String materialName : growthConfigSection.getKeys(false)) {
      ConfigurationSection configSection =
          growthConfigSection.getConfigurationSection(materialName);

      GrowthConfig inheritConfig = defaultConfig;

      if (configSection.isSet("inherit")) {
        String inheritStr = configSection.getString("inherit");

        if (growthConfigNodes.containsKey(inheritStr)) {
          inheritConfig = growthConfigNodes.get(inheritStr);
        } else {
          Object inheritKey = getMaterialKey(inheritStr);
          if (materialGrowth.containsKey(inheritKey)) {
            inheritConfig = materialGrowth.get(inheritKey);
          }
        }
      }

      GrowthConfig newGrowthConfig = new GrowthConfig(inheritConfig, configSection, biomeAliases);

      Object key = getMaterialKey(materialName);
      if (key == null) {
        // if the name is partially capitalized, then warning the player that
        // the name might be a misspelling
        if (materialName.length() > 0 && materialName.matches(".*[A-Z].*"))
          LOG.warning("config material name: is \"" + materialName + "\" misspelled?");
        growthConfigNodes.put(materialName, newGrowthConfig);
      } else {
        materialGrowth.put(key, newGrowthConfig);
      }
    }
  }