/** * Deletes the given zone. * * @param zone The zone to delete. * @return A Boolean value representative of the success of the operation. */ public Boolean deleteZone(String zone) { zones.removeProperty("zones." + zone); zones.save(); zones.load(); return (!zoneExists(zone)); }
/** * Attempts to delete the ticket opened by player. * * @param player The player whose ticket is being closed. * @return A Boolean representation of the operation's success. */ public Boolean closeTicket(String player) { tickets.removeProperty("tickets." + player); tickets.save(); tickets.load(); return (!ticketExists(player)); }
/** * 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); }
/** * 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); }
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(); } }
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; } } }
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(); }
/** * 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); }
/** * 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 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(); }
/** * 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)); }
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 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]); }
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; }
public void onEnable() { ButtonControlPermissions.initialize(getServer()); new File(mainDir).mkdir(); if (!BW.exists()) { try { BW.createNewFile(); config.setProperty("Duration.sun", sd); config.setProperty("Duration.rain", rd); config.setProperty("Duration.thunder", td); config.setProperty("Cost.Item", item); config.setProperty("iConomy.useiConomy", icon); config.setProperty("Buttons.SunnyAnzahl", 0); config.setProperty("Buttons.RainAnzahl", 0); config.setProperty("Buttons.ThunderAnzahl", 0); config.setProperty("Messages.push_a_button", messages[0]); config.setProperty("Messages.not_permissions", messages[1]); config.setProperty("Messages.sun_comes", messages[2]); config.setProperty("Messages.not_enough_money", messages[3]); config.setProperty("Messages.rain_comes", messages[4]); config.setProperty("Messages.thunder_comes", messages[5]); config.setProperty("Messages.rain_set", messages[6]); config.setProperty("Messages.thunder_set", messages[7]); config.setProperty("Messages.sunny_set", messages[8]); config.setProperty("Messages.day_set", messages[9]); config.setProperty("Messages.night_set", messages[10]); config.setProperty("Messages.day_comes", messages[11]); config.setProperty("Messages.night_comes", messages[12]); config.setProperty("Messages.not_use", messages[13]); config.setProperty("iConomy.account", acc); config.setProperty("Cooldown", cooldown); config.save(); System.out.println("[ButtonControl] Config-File created."); this.loadFile(); } catch (IOException e) { e.printStackTrace(); } } else { loadFile(); } this.PL = new ButtonControlPlayerListener(this); this.BL = new ButtonControlBlockListener(this); this.SL = new ButtonControlServerListener(this); this.WL = new ButtonControlWeatherListener(this); PluginManager pm = this.getServer().getPluginManager(); pm.registerEvent(Event.Type.BLOCK_BREAK, BL, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_INTERACT, PL, Priority.Normal, this); pm.registerEvent(Event.Type.WEATHER_CHANGE, WL, Priority.Highest, this); pm.registerEvent(Event.Type.PLUGIN_ENABLE, SL, Priority.Normal, this); pm.registerEvent(Event.Type.PLUGIN_DISABLE, SL, Priority.Normal, this); PluginDescriptionFile pdf = this.getDescription(); System.out.println("ButtonControl v" + pdf.getVersion() + " aktiviert."); }
/** * 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; } }
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]); }
public Strings(File file) { config = new Configuration(file); config.load(); fillDefaults(); if (file.exists()) { updateKeys(); removeKeys(); } load(); config.save(); }
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(); }
/** * 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())); }
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(); } }
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(); }
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(); }
@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(); }
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; }
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(); }
/** * Creates a new zone from the provided values. * * @param name The name of the new zone being created. * @param upper An integer array of the upper-left coordinates of the zone. * @param lower An integer array of the lower-right coordinates of the zone. * @param order The access order (allow,deny/deny,allow) of the zone. * @param acl The access list for the new zone. * @return Returns true if zone exists as determined by zoneExists. */ public Boolean createZone( String name, Integer[] upper, Integer[] lower, String order, String acl) { String base = "zones." + name + "."; String[] tmp = order.split(","); String fromType = tmp[1]; zones.setProperty(base + "order", order); zones.setProperty(base + fromType + "-from", acl); zones.setProperty(base + "deny-msg", "A mysterious force pushes you away..."); zones.setProperty(base + "coords.upper.x", upper[0]); zones.setProperty(base + "coords.upper.y", upper[1]); zones.setProperty(base + "coords.upper.z", upper[2]); zones.setProperty(base + "coords.lower.x", lower[0]); zones.setProperty(base + "coords.lower.y", lower[1]); zones.setProperty(base + "coords.lower.z", lower[2]); zones.save(); zones.load(); return (zoneExists(name)); }
@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(); }