Exemplo n.º 1
0
  public static void updateMinecraftYMLCache() {
    if (!updated || !getConfigFile().exists()) {
      synchronized (key) {
        String current = null;
        if (getConfigFile().exists()) {
          try {
            current = getConfig().getString("current");
          } catch (Exception ex) {
            ex.printStackTrace();
          }
        }

        if (YmlUtils.downloadYmlFile(
            MINECRAFT_YML, "http://quebecgmz.ca/mods/minecraft.yml", getConfigFile())) {
          // GameUpdater.copy(getConfigFile(), output)
          config = null;
          Configuration config = getConfig();
          latest = config.getString("latest");
          recommended = config.getString("recommended");
          if (current != null) {
            config.setProperty("current", current);
            config.save();
          }
        }
        updated = true;
      }
    }
  }
Exemplo n.º 2
0
  /**
   * Gets the ticket currently opened by the given player.
   *
   * @param player The player whose ticket is being retrieved.
   * @return An array containing the ticket info for the given player.<br>
   *     The first element is the player's desired job, the second is the timestamp of the request.
   */
  public String[] getTicket(String player) {
    String[] ticket = {
      tickets.getString("tickets." + player + ".job"),
      tickets.getString("tickets." + player + ".time")
    };

    return ticket;
  }
Exemplo n.º 3
0
  /** Loads the configuration file data into appropriate places. */
  public void loadConfig() {
    config.load();

    int duplicatorTool = config.getInt("duplicatorTool", 275);
    int paintbrushTool = config.getInt("paintbrushTool", 341);
    int scrollerTool = config.getInt("scrollerTool", 352);
    int superPickaxe = config.getInt("superPickaxe", 274);

    Integer[] array = new Integer[] {duplicatorTool, paintbrushTool, scrollerTool, superPickaxe};
    HashSet<Integer> tools = new HashSet<Integer>(Arrays.asList(array));

    if (tools.size() != 4) {
      log.warning("[" + name + "] Some tools are conflicting, using defaults insted.");
    } else {
      ToolHandler.duplicatorTool = duplicatorTool;
      ToolHandler.paintbrushTool = paintbrushTool;
      ToolHandler.scrollerTool = scrollerTool;
      ToolHandler.superPickaxe = superPickaxe;
    }

    CommandHandler.mimicRadius = config.getInt("mimicRadius", 40);

    // load blocks that are unduplicatable
    String temp[] = config.getString("unduplicatable", "7,8,9,10,11,51,52,79").split(",");
    for (String block : temp) {
      if (!block.equals("")) {
        BlockHandler.unduplicatableBlocks.put(Integer.parseInt(block), false);
      }
    }
    // load blocks that are unmimicable
    temp = config.getString("unmimicable", "0,1,2,3,7,8,9,10,11,12,13,46,51,66,79").split(",");
    for (String block : temp) {
      if (!block.equals("")) {
        BlockHandler.unmimicableBlocks.put(Integer.parseInt(block), false);
      }
    }
    // load blocks that are scrollable
    temp =
        config
            .getString("scrollable", "17,18,23,25,26,35,43,44,53,61,63,65,66,67,68,69,77,86,81,91")
            .split(",");
    for (String block : temp) {
      if (!block.equals("")) {
        BlockHandler.scrollableBlocks.put(Integer.parseInt(block), true);
      }
    }
    // load tools that are invincible
    temp = config.getString("invincibleTools", "278,284,285,286").split(",");
    for (String block : temp) {
      if (!block.equals("")) {
        ToolHandler.invincibleTools.put(Integer.parseInt(block), true);
      }
    }

    saveConfig();
  }
Exemplo n.º 4
0
 public void loadPreferences(String name) {
   File pref = new File(root + File.separator + name + ".pref");
   Configuration c = new Configuration(pref);
   c.load();
   armourType.put(name.toString(), getArmour(c.getString("Preferences.ArmourType", "NONE")));
   blockHead.put(
       name.toString(),
       new ItemStack((Material.getMaterial(c.getString("Preferences.BlockOnHead", "AIR"))), 1));
   swordType.put(
       name.toString(),
       Material.getMaterial(c.getString("Preferences.Sword", Material.WOOD_SWORD.toString())));
 }
Exemplo n.º 5
0
  /**
   * Gets the Location of the given world's new player spawn.
   *
   * @param world The world to get the new player spawn for.
   * @return The Location of the new player spawn.
   */
  public Location getNewPlayerSpawn(String world) {
    Location spawn = this.getServer().getWorld(world).getSpawnLocation();

    if (deathSpawnExists(world)) {
      spawn.setX(spawns.getDouble("new-player-spawn." + world + ".x", spawn.getX()));
      spawn.setY(spawns.getDouble("new-player-spawn." + world + ".y", spawn.getY()));
      spawn.setZ(spawns.getDouble("new-player-spawn." + world + ".z", spawn.getZ()));
      spawn.setYaw(Float.parseFloat(spawns.getString("new-player-spawn." + world + ".yaw")));
      spawn.setPitch(Float.parseFloat(spawns.getString("new-player-spawn." + world + ".pitch")));
    }

    return spawn;
  }
Exemplo n.º 6
0
  public void loadConfiguration() {
    // make sure the config exists
    // and if it doesn't, make it!
    this.checkConfiguration();

    // ge the configuration..
    Configuration config = getConfiguration();
    this.autoRestart = config.getBoolean("auto-restart", true);
    this.restartInterval = config.getDouble("auto-restart-interval", 8);
    this.warnTimes = config.getDoubleList("warn-times", null);
    this.warningMessage =
        config.getString("warning-message", "&cServer will be restarting in %t minutes!");
    this.restartMessage =
        config.getString("restart-message", "&cServer is restarting, we'll be right back!");
  }
Exemplo n.º 7
0
  public void readLangFile(String language) {
    String filename = getLangFolder() + File.separator + language + ".yml";

    try {
      Configuration config = new Configuration(new File(filename));

      config.load();

      List<String> keys = config.getKeys();

      if (!langDb.containsKey(language)) {
        langDb.put(language, new HashMap<String, String>());
      }

      Map<String, String> langMap = langDb.get(language);

      for (Iterator<String> it = keys.iterator(); it.hasNext(); ) {
        String key = it.next();

        Log.v("Adding " + language + "." + key + ";");
        langMap.put(key, config.getString(key));
      }

      Log.d("Done parsing localization file '" + filename + "' for language '" + language + "'");
    } catch (Exception ex) {
      Log.e("Could not load localizaion file '" + filename + "'");
    }
  }
Exemplo n.º 8
0
  /**
   * Sets the option located at the given path for player to val.
   *
   * @param player The player whose option is being changed.
   * @param path The path of the option to change.
   * @param val The new value of the option.
   * @return A Boolean representation of the success of the operation.
   */
  public Boolean setPlayerConfig(String player, String path, String val) {
    players.setProperty("players." + player + "." + path, val);
    players.save();
    players.load();

    return (players.getString("players." + player + "." + path) == val);
  }
Exemplo n.º 9
0
  /**
   * Sets the option located at the given path to val.
   *
   * @param path The path of the option to be changed.
   * @param val The new value of the option.
   * @return A Boolean representation of the success of the operation.
   */
  public Boolean setConfig(String path, String val) {
    config.setProperty("config." + path, val);
    config.save();
    config.load();

    return (config.getString("config." + path) == val);
  }
Exemplo n.º 10
0
  /**
   * Attempts to create a new player in players.yml.
   *
   * @param player The new player to add to players.yml.
   * @return Whether or not the player exists after the operation has run.
   */
  public Boolean createPlayer(String player) {
    players.setProperty("players." + player + ".job", config.getString("config.default-job"));
    players.setProperty("players." + player + ".exempt", false);
    players.save();
    players.load();

    return (playerExists(player));
  }
Exemplo n.º 11
0
 public InstanceConfig(int id, String name, Configuration config) {
   config.load();
   this.instanceName = name;
   this.world = config.getString("instances." + this.instanceName + ".world", null);
   this.maxPlayers = config.getInt("instances." + this.instanceName + ".players", 0);
   this.timer = config.getInt("instances." + this.instanceName + ".timer", 0);
   this.exp = config.getInt("instances." + this.instanceName + ".exp", 0);
 }
Exemplo n.º 12
0
  private void loadConfigValues() {
    pluginConfig = plugin.getConfiguration();

    PRE_RELEASE_MODE = pluginConfig.getBoolean("general.pre_release_mode", true);
    if (PRE_RELEASE_MODE) System.out.println("Activating Pre-release mode.");

    DB_URL = pluginConfig.getString("database.url");
    DB_NAME = pluginConfig.getString("database.name");
    DB_DRIVER = pluginConfig.getString("database.driver");
    DB_USER = pluginConfig.getString("database.user");
    DB_PASSWORD = pluginConfig.getString("database.password");
    DB_TIMEOUT = pluginConfig.getInt("database.timeout", 20000000);

    this.Lot_X_OFFSET = pluginConfig.getInt("lots.x_offset", -384);
    this.Lot_Z_OFFSET = pluginConfig.getInt("lots.z_offset", 416);

    Capitol_Name = pluginConfig.getString("capitol.name", "Rage City");
    Capitol_X1a = pluginConfig.getInt("capitol.x1a", -386); // The NW corner of region A for capitol
    Capitol_Z1a = pluginConfig.getInt("capitol.z1a", 146);
    Capitol_X2a = pluginConfig.getInt("capitol.x2a", -82); // The SE corner of region A for capitol
    Capitol_Z2a = pluginConfig.getInt("capitol.z2a", -261);
    Capitol_X1b = pluginConfig.getInt("capitol.x1b", -83); // The NW corner of region B for capitol
    Capitol_Z1b = pluginConfig.getInt("capitol.z1b", 418);
    Capitol_X2b = pluginConfig.getInt("capitol.x2b", 513); // The SE corner of region B for capitol
    Capitol_Z2b = pluginConfig.getInt("capitol.z2b", -261);
    Capitol_SANDLOT = pluginConfig.getString("capitol.sandlot", "114,60,-19,141,68,-46");

    NPC_TOTAL_FLOATING = pluginConfig.getInt("npc.total_floating", 5);

    System.out.println("Connecting to " + DB_URL + "..."); // Debug
  }
Exemplo n.º 13
0
  private void load() {
    for (String key : keys) {
      if (config.getProperty(key) == null) config.setProperty(key, defaults.get(key));
      strings.put(key, config.getString(key).replace("&", "\u00a7"));
    }

    // clear defaults to free memory
    defaults.clear();
  }
Exemplo n.º 14
0
  /**
   * Gets the block place deny message from config.yml.
   *
   * @return The String to output when block placement is denied.
   */
  public String getPlaceDenyMsg(String player) {
    String msg = config.getString("config.place-deny-msg");

    if (msg == null) {
      msg = "You may not place this type of block.";
    }

    msg = parseSpecialChars(msg, player);
    return msg;
  }
Exemplo n.º 15
0
  /**
   * Gets the full inventory message (for wear denied) from config.yml.
   *
   * @return The String to output when an item is dropped as a result of denied armor.
   */
  public String getWearDenyInvFullMsg(String player) {
    String msg = config.getString("config.wear-deny-inv-full-msg");

    if (msg == null) {
      msg = "Your inventory is full. The item has been dropped.";
    }

    msg = parseSpecialChars(msg, player);

    return msg;
  }
Exemplo n.º 16
0
  /**
   * Gets the message to display to players when the respawn.
   *
   * @param player The player who is recieving the respawn message.
   * @return A String contianing the respawn message.
   */
  public String getRespawnMsg(String player) {
    String msg = config.getString("config.respawn-msg");

    if (msg == null) {
      msg = "Welcom back, %p";
    }

    msg = parseSpecialChars(msg, player);

    return msg;
  }
Exemplo n.º 17
0
  /**
   * Gets the message to display when a crafting event is denied.
   *
   * @return The message to display to the player whose craft event was cancelled.
   */
  public String getCraftDenyMsg(String player) {
    String msg = config.getString("config.craft-deny-msg");

    if (msg == null) {
      msg = "The purpose of the materials in front of you evades you...";
    }

    msg = parseSpecialChars(msg, player);

    return msg;
  }
Exemplo n.º 18
0
  /**
   * Gets the message to display when a user is denied access to a zone.
   *
   * @return The message to display to the player.
   */
  public String getZoneDenyMsg(String zone, String player) {
    String msg = zones.getString("zones." + zone + "deny-msg");

    if (msg == null) {
      msg = "A mysterious force pushes you away...";
    }

    msg = parseSpecialChars(msg, player);

    return msg;
  }
Exemplo n.º 19
0
  /**
   * Gets the message to display when a new player joins.
   *
   * @param player The name of the new player.
   * @return The message to display to the new player.
   */
  public String getNewPlayerMsg(String player) {
    String msg = config.getString("config.new-player-msg");

    if (msg == null) {
      msg = "Welcome, %p. You have joined as %j. Type /job help for more info.";
    }

    msg = parseSpecialChars(msg, player);

    return msg;
  }
Exemplo n.º 20
0
  /**
   * Gets the armor usage deny message from config.yml.
   *
   * @return The String to output when armor usage is denied.
   */
  public String getWearDenyMsg(String player) {
    String msg = config.getString("config.wear-deny-msg");

    if (msg == null) {
      msg = "You may not wear this type of armor.";
    }

    msg = parseSpecialChars(msg, player);

    return msg;
  }
Exemplo n.º 21
0
  /**
   * Gets the item usage deny message from config.yml.
   *
   * @return The String to output when item usage is denied.
   */
  public String getUseDenyMsg(String player) {
    String msg = config.getString("config.use-deny-msg");

    if (msg == null) {
      msg = "You may not use type of item.";
    }

    msg = parseSpecialChars(msg, player);

    return msg;
  }
Exemplo n.º 22
0
  public MVPortal(String name, Configuration config, MultiVerse instance) {
    this.plugin = instance;
    this.utils = new MVUtils(plugin);
    this.config = config;

    this.name = name;
    this.owner = config.getString("portals." + name + ".owner", "");
    this.price = config.getDouble("portals." + name + ".price", 0.0);
    setupLocation();
    setDestLocation(this.config.getString("portals." + name + ".destlocation", ""));
  }
Exemplo n.º 23
0
 private void updateKeys() {
   String fromKey, toKey, holder;
   for (String[] update : keyUpdates) {
     fromKey = update[0];
     if (config.getProperty(fromKey) != null) {
       toKey = update[1];
       holder = config.getString(fromKey);
       config.removeProperty(fromKey);
       if (!toKey.equals("")) config.setProperty(toKey, holder);
     }
   }
 }
Exemplo n.º 24
0
 public void modifyBlockOnHead(Player p, int material) {
   int level = Statistics.playerLevel.get(p.getName());
   File pref = new File(root + File.separator + p.getName() + ".pref");
   Configuration c = new Configuration(pref);
   c.load();
   Material m = Material.getMaterial(material);
   if (level >= 40) {
     if (m == null || m == Material.AIR) {
       p.sendMessage(ChatColor.RED + "[Warzone] " + Warzone.li.getObj("Invalid Material Type!"));
       return;
     }
     c.setProperty("Preferences.ArmourType", c.getString("Preferences.ArmourType", "NONE"));
     c.setProperty(
         "Preferences.BlockOnHead",
         c.getString("Preferences.BlockOnHead", m.toString().toUpperCase()));
     c.setProperty(
         "Preferences.Sword", c.getString("Preferences.Sword", Material.WOOD_SWORD.toString()));
     blockHead.put(p.getName(), new ItemStack(m, 1));
     p.sendMessage(
         ChatColor.RED
             + "[Warzone] "
             + ChatColor.GREEN
             + "Block preference changed to "
             + ChatColor.DARK_AQUA
             + m.toString().toUpperCase()
             + ChatColor.GREEN
             + " successfully!");
     c.save();
   } else {
     p.sendMessage(
         ChatColor.RED
             + "[Warzone] "
             + Warzone.li.getObj("You must be level")
             + "40"
             + Warzone.li.getObj("or above to do this")
             + "!");
     return;
   }
 }
Exemplo n.º 25
0
  private void updateTo6(Configuration config) {
    String lampList = config.getString("Config.lamplist", "") + "tube;";
    config.setProperty("Config.lamplist", lampList);
    config.setProperty("Lamps.tube.height.min", Integer.valueOf(1));
    config.setProperty("Lamps.tube.height.max", Integer.valueOf(6));
    config.setProperty("Lamps.tube.width.min", Integer.valueOf(2));
    config.setProperty("Lamps.tube.width.max", Integer.valueOf(6));

    setVersion(6);
    config.save();
    LightPoles.log("# updated config.yml to VERSION 6", new Object[0]);
    LightPoles.log("# added new lamp: tube", new Object[0]);
  }
Exemplo n.º 26
0
  private void updateTo5(Configuration config) {
    String lampList = config.getString("Config.lamplist", "") + "globe;";
    config.setProperty("Config.lamplist", lampList);
    config.setProperty("Lamps.globe.height.min", Integer.valueOf(1));
    config.setProperty("Lamps.globe.height.max", Integer.valueOf(6));
    config.setProperty("Config.disableOnError", Boolean.valueOf(false));

    setVersion(5);
    config.save();
    LightPoles.log("# updated config.yml to VERSION 5", new Object[0]);
    LightPoles.log("# added new lamp: globe", new Object[0]);
    LightPoles.log("# added: disable on error", new Object[0]);
  }
Exemplo n.º 27
0
 public static double geta(String player) {
   File db =
       new File(
           TrueEconomy.getStatic().getDataFolder().toString()
               + File.separator
               + "bounties"
               + File.separator
               + player.toLowerCase()
               + ".efd");
   Configuration config = new Configuration(db);
   config.load();
   String t = config.getString("a");
   return Double.parseDouble(t);
 }
Exemplo n.º 28
0
  private static void load() {
    conf.load();

    key = conf.getString("APIkey", null);
    if (key == null) conf.setProperty("APIkey", "");

    servername = conf.getString("servername", null);
    if (servername == null) conf.setProperty("servername", "please change");

    owner = conf.getString("owner", null);
    if (owner == null) conf.setProperty("owner", "please change");

    // options
    banborder = conf.getString("options.banborder", "1000");
    if (banborder == "1000") conf.setProperty("options.banborder", "-40");

    glizer.D = conf.getBoolean("options.debugmode", false);

    // features
    List<String> features = conf.getKeys("features");
    bChat.log(features.toString());
    if (!features.contains("usewhitelist")) conf.setProperty("features.usewhitelist", false);
    if (!features.contains("useglobalbans")) conf.setProperty("features.useglobalbans", true);
    if (!features.contains("usebansystem")) conf.setProperty("features.usebansystem", true);
    if (!features.contains("useprofiles")) conf.setProperty("features.useprofiles", true);
    if (!features.contains("usecomments")) conf.setProperty("features.usecomments", true);
    if (!features.contains("useratings")) conf.setProperty("features.useratings", true);

    usewhitelist = conf.getBoolean("features.usewhitelist", false);
    useglobalbans = conf.getBoolean("features.useglobalbans", false);
    usebansystem = conf.getBoolean("features.usebansystem", false);
    useprofiles = conf.getBoolean("features.useprofiles", false);
    usecomments = conf.getBoolean("features.usecomments", false);
    useratings = conf.getBoolean("features.useratings", false);

    conf.save();
  }
Exemplo n.º 29
0
 public static boolean locked() {
   write();
   File db =
       new File(
           TrueEconomy.getStatic().getDataFolder().toString()
               + File.separator
               + "ores"
               + File.separator
               + "diamond"
               + ".efd");
   Configuration config = new Configuration(db);
   config.load();
   String a = config.getString("l");
   return Boolean.parseBoolean(a);
 }
Exemplo n.º 30
0
 public static double ratio() {
   write();
   File db =
       new File(
           TrueEconomy.getStatic().getDataFolder().toString()
               + File.separator
               + "ores"
               + File.separator
               + "diamond"
               + ".efd");
   Configuration config = new Configuration(db);
   config.load();
   String a = config.getString("r");
   double amount = Double.parseDouble(a);
   return amount;
 }