Beispiel #1
0
  /**
   * Attempts to create a new ticket for the given player.
   *
   * @param player The player requesting the job change ticket.
   * @param job The job that player is requesting a change to.
   * @param time The timestamp of the change request.
   * @return A Boolean representation of the operation's success.
   */
  public Boolean createTicket(String player, String job, String time) {
    tickets.setProperty("tickets." + player + ".job", job);
    tickets.setProperty("tickets." + player + ".time", time);
    tickets.save();
    tickets.load();

    return ticketExists(player);
  }
Beispiel #2
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));
  }
  private void updateTo4(Configuration config) {
    config.setProperty("Config.modes.cluster.enabled", Boolean.valueOf(true));
    config.setProperty("Config.modes.cluster.size", Integer.valueOf(20));

    setVersion(4);
    config.save();
    LightPoles.log("# updated config.yml to VERSION 4", new Object[0]);
    LightPoles.log("# added new mode: CLUSTER", new Object[0]);
  }
Beispiel #4
0
 public void save() {
   conf.setProperty(pre + "x", x);
   conf.setProperty(pre + "z", z);
   conf.setProperty(pre + "y", y);
   conf.setProperty(pre + "sx", startBlock.getX());
   conf.setProperty(pre + "sy", startBlock.getY());
   conf.setProperty(pre + "sz", startBlock.getZ());
   conf.save();
 }
  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]);
  }
  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]);
  }
Beispiel #7
0
  private static void setupconf() {
    File f = new File(plugin.getDataFolder(), "config.yml");
    conf = null;

    if (f.exists()) {
      conf = new Configuration(f);
      conf.load();
    } else {
      File confFile;
      confFile = new File(plugin.getDataFolder(), "config.yml");
      conf = new Configuration(confFile);
      conf.setProperty("APIkey", "Add your API-Key here");
      conf.setProperty("servername", "Add your servername here");
      conf.setProperty("owner", "Add your name here");

      // options
      conf.setProperty("options.banborder", "-40");
      conf.setProperty("options.debugmode", false);

      // features
      conf.setProperty("features.usewhitelist", false);
      conf.setProperty("features.useglobalbans", true);
      conf.setProperty("features.usebansystem", true);
      conf.setProperty("features.useprofiles", true);
      conf.setProperty("features.usecomments", true);
      conf.setProperty("features.useratings", true);
      conf.save();
    }
  }
Beispiel #8
0
  /**
   * Sets the new location of the new player spawn.
   *
   * @param spawn The location to set the new player spawn to (world based).
   * @return Whether or not the spawn exists after the operation.
   */
  public Boolean setNewPlayerSpawn(Location spawn) {
    String path = "new-player-spawn." + spawn.getWorld().getName() + ".";

    spawns.setProperty(path + "x", spawn.getX());
    spawns.setProperty(path + "y", spawn.getY());
    spawns.setProperty(path + "z", spawn.getZ());
    spawns.setProperty(path + "yaw", spawn.getYaw());
    spawns.setProperty(path + "pitch", spawn.getPitch());

    spawns.save();
    spawns.load();

    return (deathSpawnExists(spawn.getWorld().getName()));
  }
Beispiel #9
0
 public void createPreferenceFile(String name) {
   File pref = new File(root + File.separator + name + ".pref");
   Configuration c = new Configuration(pref);
   if (!doesPlayerHavePreferenceFile(name)) {
     try {
       pref.createNewFile();
     } catch (IOException e) {
       e.printStackTrace();
     }
     c.setProperty("Preferences.ArmourType", "NONE");
     c.setProperty("Preferences.BlockOnHead", "AIR");
     c.setProperty("Preferences.Sword", Material.WOOD_SWORD.toString());
     c.save();
   }
 }
Beispiel #10
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;
      }
    }
  }
Beispiel #11
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);
  }
Beispiel #12
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);
  }
Beispiel #13
0
 public static void compRatio(int amount, Configuration config) {
   BigDecimal base = BigDecimal.valueOf(100000);
   BigDecimal div = BigDecimal.valueOf(amount);
   double ratio = div.divide(base, 2, RoundingMode.HALF_UP).doubleValue();
   config.load();
   config.setProperty("r", ratio);
   config.save();
 }
Beispiel #14
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();
  }
Beispiel #15
0
  /**
   * Toggles exempt status on the given player.
   *
   * @param player The player to toggle exempt on.
   * @return A Boolean representation of the method's success.
   */
  public Boolean toggleExempt(String player) {
    Boolean exempt = players.getBoolean("players." + player + ".exempt", true);

    players.setProperty("players." + player + ".exempt", !exempt);
    players.save();
    players.load();

    return (!exempt == players.getBoolean("players." + player + ".exempt", false));
  }
  private void updateTo8(Configuration config) {
    LightPoles.log("# updated config.yml to VERSION 8", new Object[0]);

    LightPoles.log("# added removeTorchAfterConstruction: false", new Object[0]);
    config.setProperty("Config.modes.power.removeTorchAfterConstruction", Boolean.valueOf(true));

    setVersion(8);
    config.save();
  }
 private boolean migrateConfig(String name, File oldFolder, File newFolder) {
   Configuration newConfig = new Configuration(new File(newFolder, "config.yml"));
   MultiversePortals.staticLog(Level.INFO, "Trying to migrate MultiVerse.yml...");
   Configuration oldConfig = new Configuration(new File(oldFolder, "MultiVerse.yml"));
   oldConfig.load();
   newConfig.setProperty("wand", oldConfig.getInt("setwand", MultiversePortals.DEFAULT_WAND));
   newConfig.save();
   MultiversePortals.staticLog(Level.INFO, "Migration SUCCESS!");
   return true;
 }
  private void updateTo7(Configuration config, LightPoles plugin) {
    LightPoles.log("# updated config.yml to VERSION 7", new Object[0]);

    LightPoles.log("# removed lamplist", new Object[0]);
    String lamplist = config.getString("Config.lamplist", "");
    config.removeProperty("Config.lamplist");

    LightPoles.log("# added separate switches for each lamp", new Object[0]);
    for (String lamp : LampLoader.lamps) {
      config.setProperty("Lamps." + lamp + ".enabled", Boolean.valueOf(false));
    }
    for (String lamp : lamplist.split(";")) {
      if ((lamp != null) && (!lamp.equals(""))) {
        config.setProperty("Lamps." + lamp + ".enabled", Boolean.valueOf(true));
      }
    }

    LightPoles.log("# added detectRepeater", new Object[0]);
    boolean power = config.getBoolean("Config.modes.power", false);
    config.removeProperty("Config.modes.power");
    config.setProperty("Config.modes.power.enabled", Boolean.valueOf(power));
    config.setProperty("Config.modes.power.detectRepeater", Boolean.valueOf(false));

    LightPoles.log("# moved start/end of day", new Object[0]);
    boolean daytime = config.getBoolean("Config.modes.daytime", false);
    config.removeProperty("Config.modes.daytime");
    int start = config.getInt("Config.daytime.night_start", 12500);
    int end = config.getInt("Config.daytime.night_end", 12500);
    config.removeProperty("Config.daytime.night_start");
    config.removeProperty("Config.daytime.night_end");
    config.removeProperty("Config.daytime");
    config.setProperty("Config.modes.daytime.enabled", Boolean.valueOf(daytime));
    config.setProperty("Config.modes.daytime.night_start", Integer.valueOf(start));
    config.setProperty("Config.modes.daytime.night_end", Integer.valueOf(end));

    LightPoles.log("# added pureBulb", new Object[0]);
    config.setProperty("Config.modes.pureBulb.enabled", Boolean.valueOf(false));

    LightPoles.log("# removed disableOnError", new Object[0]);
    config.removeProperty("Config.disableOnError");

    LightPoles.log("# added controller", new Object[0]);
    config.setProperty("Config.modes.controller.enabled", Boolean.valueOf(true));

    setVersion(7);
    config.save();
  }
Beispiel #19
0
  /**
   * Changes the current job of the given 'player'
   *
   * @param player The player whose job is being changed.
   * @param job The job that 'player' is being changed to.
   * @return A Boolean representation of the success of the operation.
   */
  public Boolean changeJob(String player, String job) {
    if (playerExists(player) && jobExists(job)) {
      players.setProperty("players." + player + ".job", job);

      players.save();
      players.load();

      return (getJob(player).equalsIgnoreCase(job));
    } else {
      return false;
    }
  }
Beispiel #20
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);
     }
   }
 }
Beispiel #21
0
  public void onEnable() {
    Configuration properties = this.getConfiguration();
    String tempString;

    // Check the config.yml
    tempString = properties.getString("nether-world-name");
    if ((tempString == null) || tempString.isEmpty()) {
      properties.setProperty("nether-world-name", "netherworld");
      properties.setProperty("default-normal-world", "world");
      properties.save();
    }
    // TODO: reload the properties so it's less lame

    // Register events
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
    pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Priority.High, this);

    // Say hi
    PluginDescriptionFile pdfFile = this.getDescription();
    System.out.println(pdfFile.getName() + " v" + pdfFile.getVersion() + " enabled");
  }
Beispiel #22
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;
   }
 }
Beispiel #23
0
 public static void setf(String player, String name) {
   File db =
       new File(
           TrueEconomy.getStatic().getDataFolder().toString()
               + File.separator
               + "bounties"
               + File.separator
               + player.toLowerCase()
               + ".efd");
   Configuration config = new Configuration(db);
   config.load();
   config.setProperty("f", name.toLowerCase());
   config.save();
 }
Beispiel #24
0
 public static void unlock() {
   write();
   File db =
       new File(
           TrueEconomy.getStatic().getDataFolder().toString()
               + File.separator
               + "ores"
               + File.separator
               + "diamond"
               + ".efd");
   Configuration config = new Configuration(db);
   config.load();
   config.setProperty("l", "false");
   config.save();
 }
Beispiel #25
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();
  }
 @Override
 public void removeNode(String node, String group) {
   List<String> groupNodes = getGroupNodes(group);
   if (groupNodes == null) {
     log("the group:" + group + " does not exist for world:" + world.getName());
     return;
   }
   if (groupNodes.contains(node)) {
     groupNodes.remove(node);
     log("removed node:" + node + " from group:" + group + " for world:" + world.getName());
   } else {
     log("node:" + node + " does not exist in group:" + group + " for world:" + world.getName());
     return;
   }
   c.setProperty("groups." + group, groupNodes);
   c.save();
   setupPlayers();
 }
Beispiel #27
0
 public static void sub(int amount) {
   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("a");
   amount = Integer.parseInt(a) - amount;
   config.setProperty("a", amount);
   config.save();
   compRatio(amount, config);
   double r = ratio();
   if (r <= .01) lock();
 }
 @Override
 public void addGroup(String player, String group) {
   List<String> playerGroups = getGroups(player);
   if (!playerGroups.contains(group)) {
     playerGroups.add(group);
     log("Group:" + group + " added to player:" + player + " in world:" + world.getName());
   } else {
     log(
         "Group:"
             + group
             + " could not be added to player:"
             + player
             + " in world:"
             + world.getName()
             + " as the player already has this group");
     return;
   }
   c.setProperty("players." + player, playerGroups);
   c.save();
   setupPlayers();
 }
 @Override
 public void removeGroup(String player, String group) {
   List<String> playerGroups = c.getStringList("players." + player, null);
   if (playerGroups.contains(group)) {
     playerGroups.remove(group);
     log("Group:" + group + " removed from player:" + player + " in world:" + world.getName());
   } else {
     log(
         "Group:"
             + group
             + " could not be removed from player:"
             + player
             + " in world:"
             + world.getName()
             + " as the player does not have this group");
     return;
   }
   c.setProperty("players." + player, playerGroups);
   c.save();
   setupPlayers();
 }
  private boolean migratePortals(String name, File oldFolder, File newFolder) {
    Configuration newConfig = new Configuration(new File(newFolder, "portals.yml"));
    MultiversePortals.staticLog(Level.INFO, "Trying to migrate Portals.yml...");
    Configuration oldConfig = new Configuration(new File(oldFolder, "Portals.yml"));
    oldConfig.load();
    List<String> keys = oldConfig.getKeys("portals");
    if (keys == null) {
      MultiversePortals.staticLog(Level.SEVERE, "Migration FAILURE!");
      MultiversePortals.staticLog(Level.SEVERE, "Old Folder Location: " + oldFolder);
      MultiversePortals.staticLog(Level.SEVERE, "New Folder Location: " + newFolder);
      MultiversePortals.staticLog(Level.SEVERE, "Old Config Dump: " + oldConfig.getAll());
      return false;
    }
    for (String key : keys) {
      // Since portal names are lowercase, no reason not to do that here.
      String lowerkey = key.toLowerCase();
      if (newConfig.getProperty(lowerkey) != null) {
        MultiversePortals.staticLog(Level.SEVERE, "Portals are now case-insensitive!");
        MultiversePortals.staticLog(Level.SEVERE, "Found at least 2 portals named: " + lowerkey);
        continue;
      }

      newConfig.setProperty(
          "portals." + lowerkey + ".entryfee.amount",
          oldConfig.getDouble("portals." + key + ".price", 0.0));
      newConfig.setProperty("portals." + lowerkey + ".entryfee.amount", -1);
      newConfig.setProperty(
          "portals." + lowerkey + ".destination",
          transformDestination(
              oldConfig.getString("portals." + key + ".destlocation", "i:Invalid")));
      newConfig.setProperty(
          "portals." + lowerkey + ".world", oldConfig.getProperty("portals." + key + ".world"));
      newConfig.setProperty(
          "portals." + lowerkey + ".location",
          oldConfig.getProperty("portals." + key + ".location"));
      newConfig.setProperty(
          "portals." + lowerkey + ".owner", oldConfig.getProperty("portals." + key + ".owner"));
    }
    newConfig.save();
    MultiversePortals.staticLog(Level.INFO, "Migration SUCCESS!");
    return true;
  }