public Board( String name, World world, Location pos1, Location pos2, boolean imported, Games plugin, Configuration conf) { this.data = null; this.field = null; this.conf = conf; this.plugin = plugin; pre = String.format("boards.%s.%s.", world.getName(), name); if (imported) { this.x = conf.getInt(pre + "x", 0); this.z = conf.getInt(pre + "z", 0); this.y = conf.getInt(pre + "y", -1); startBlock = world.getBlockAt( conf.getInt(pre + "sx", -1), conf.getInt(pre + "sy", -1), conf.getInt(pre + "sz", -1)); } else { move(pos1, pos2); } this.name = name; }
/** * Gets the set damage for the given damage type, as defined in config.yml. * * @param player The player to check damage for. * @param dCause The cause of the incurred damage. * @param defaultDamage The default value to return if no option is set for the given damage type. * @return The damage to deal to the player. */ public int getDamage(String player, DamageCause dCause, int defaultDamage) { String job = getJob(player); List<String> damages = config.getKeys("config.all.damages"); int damage = defaultDamage; if (damages != null) { for (String item : damages) { if (item.equalsIgnoreCase(dCause.name())) { damage = config.getInt("config.all.damages." + item, defaultDamage); break; } } } damages = config.getKeys("config.jobs." + job + ".damages"); if (damages != null) { for (String item : damages) { if (item.equalsIgnoreCase(dCause.name())) { damage = config.getInt("config.jobs." + job + ".damages." + item, defaultDamage); break; } } } return damage; }
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 }
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); }
/** * Gets the coordinate set of the given zone. * * @param zone The zone to retrieve coordinates for. * @param type The type of coordinate set to retrieve. * @return The coordinate set of the requested zone, of the requested type. */ public int[] getZoneCoords(String zone, String type) { int[] coords = { zones.getInt("zones." + zone + ".coords." + type + ".x", 0), zones.getInt("zones." + zone + ".coords." + type + ".y", 0), zones.getInt("zones." + zone + ".coords." + type + ".z", 0) }; return coords; }
/** 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(); }
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(); }
public static boolean loadConfig(String dataFolder) { File configFile = new File(dataFolder + File.separator + "config.yml"); if (!configFile.exists()) { try { // Create a new file, and copy the contents of config.yml in the default package! configFile.createNewFile(); InputStream stream = CommunityBans.class.getResourceAsStream("/DefaultConfigFile.yml"); OutputStream out = new FileOutputStream(configFile); byte[] buf = new byte[1024]; int len; while ((len = stream.read(buf)) > 0) { out.write(buf, 0, len); } stream.close(); out.close(); CommunityBans.log.info( CommunityBans.pluginName + "Config file not found, created new file"); } catch (IOException iex) { CommunityBans.log.severe( CommunityBans.pluginName + "Cannot create config file! " + iex.getMessage()); return false; } } config = new Configuration(configFile); config.load(); // language = config.getString("Language", "english"); pAddress = config.getInt("Premium.address", 0); pEnabled = config.getBoolean("Premium.enabled", true); pHTTPServer = config.getBoolean("Premium.http_server", true); pWebPort = config.getInt("Premium.webport", 20034); pRawPort = config.getInt("Premium.rawport", 20035); pPass = config.getString("Premium.pass", "<password>"); bDefaultBan = config.getString("Ban.default_ban_reason", "Griefing"); bDefaultKick = config.getString("Ban.default_kick_reason", "Profanity"); vEnabled = config.getBoolean("Voting.enabled", true); vAnnounceVotes = config.getBoolean("Voting.announce_votes", true); vMessageColor = config.getString("Voting.message_color", "blue"); vYesColor = config.getString("Voting.yes_color", "green"); vNoColor = config.getString("Voting.no_color", "red"); vMinOnlinePlayers = config.getInt("Voting.min_online_players", 4); vPercentVotingPlayers = config.getInt("Voting.percent_voting_players", 50); vPercentKickRequired = config.getInt("Voting.percent_kick_required", 70); return true; }
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() { Configuration config = getConfiguration(); // set default values if necessary if (config.getInt("max_telepad_distance", -1) == -1) { System.out.println("[BlueTelepads] Creating default config file..."); config.setProperty("max_telepad_distance", MAX_DISTANCE); config.setProperty("use_permissions", USE_PERMISSIONS); config.setProperty("op_only", OP_ONLY); config.setProperty("disable_teleport_wait", DISABLE_TELEPORT_WAIT); config.setProperty("telepad_center", TELEPAD_CENTER_ID); config.setProperty("telepad_surrounding", TELEPAD_SURROUNDING_ID); config.save(); } MAX_DISTANCE = config.getInt("max_telepad_distance", MAX_DISTANCE); USE_PERMISSIONS = config.getBoolean("use_permissions", USE_PERMISSIONS); OP_ONLY = config.getBoolean("op_only", OP_ONLY); DISABLE_TELEPORT_WAIT = config.getBoolean("disable_teleport_wait", DISABLE_TELEPORT_WAIT); TELEPAD_CENTER_ID = config.getInt("telepad_center", TELEPAD_CENTER_ID); TELEPAD_SURROUNDING_ID = config.getInt("telepad_surrounding", TELEPAD_SURROUNDING_ID); if (USE_PERMISSIONS) { Plugin perm = this.getServer().getPluginManager().getPlugin("Permissions"); if (perm != null) { System.out.println("[BlueTelePads] Permissions integration enabled"); this.Permissions = ((Permissions) perm).getHandler(); } else { System.out.println("[BlueTelePads] Permissions integration could not be enabled!"); } } PluginManager pm = getServer().getPluginManager(); pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this); PluginDescriptionFile pdfFile = this.getDescription(); System.out.println("[" + pdfFile.getName() + "] version " + pdfFile.getVersion() + " ENABLED"); }
public VehiclesConfiguration(Configuration cfg, File dataFolder) { this.dataFolder = dataFolder; matBoostMax = Material.getMaterial(cfg.getInt("max-boost-block", 41)); matBoost25x = Material.getMaterial(cfg.getInt("25x-boost-block", 14)); matSlow50x = Material.getMaterial(cfg.getInt("50x-slow-block", 88)); matSlow20x = Material.getMaterial(cfg.getInt("20x-slow-block", 13)); matReverse = Material.getMaterial(cfg.getInt("reverse-block", 35)); matStation = Material.getMaterial(cfg.getInt("station-block", 49)); matSorter = Material.getMaterial(cfg.getInt("sort-block", 87)); matEjector = Material.getMaterial(cfg.getInt("eject-block", 42)); matDeposit = Material.getMaterial(cfg.getInt("deposit-block", 15)); matTeleport = Material.getMaterial(cfg.getInt("teleport-block", 89)); matDispenser = Material.getMaterial(54); // this can't be configurable because we need it to be a chest! minecartSlowWhenEmpty = cfg.getBoolean("minecart-slow-when-empty", true); minecartMaxSpeedModifier = cfg.getDouble("minecart-max-speed-modifier", 1); }
public int readInt(File readFile, String root) { Configuration config = load(readFile); return config.getInt(root, 0); }
public void loadFile() { config.load(); int tmp = 0; item = config.getInt("Cost.Item", item); amount = config.getInt("Cost.Amount", amount); icon = config.getBoolean("iConomy.useiConomy", icon); int i = 0; tmp = config.getInt("Buttons.SunnyAnzahl", tmp); worldss = new String[config.getInt("Buttons.SunnyAnzahl", i) + 1]; sunny = new Block[config.getInt("Buttons.SunnyAnzahl", i) + 1]; sunnycost = new int[config.getInt("Buttons.SunnyAnzahl", i) + 1]; while (i < tmp) { worldss[i] = config.getString("Buttons.Sunny.world." + i); sunny[i] = this.getServer() .getWorld(worldss[i]) .getBlockAt( config.getInt("Buttons.Sunny.X." + i, 0), config.getInt("Buttons.Sunny.Y." + i, 0), config.getInt("Buttons.Sunny.Z." + i, 0)); sunnycost[i] = config.getInt("Buttons.Sunny.cost." + i, sunnycost[i]); System.out.println(i + " " + tmp); i++; } i = 0; worldsr = new String[config.getInt("Buttons.RainAnzahl", i) + 1]; rain = new Block[config.getInt("Buttons.RainAnzahl", i) + 1]; tmp = config.getInt("Buttons.RainAnzahl", tmp); raincost = new int[config.getInt("Buttons.RainAnzahl", i) + 1]; while (i < tmp) { worldsr[i] = config.getString("Buttons.Rain.world." + i); rain[i] = this.getServer() .getWorld(worldsr[i]) .getBlockAt( config.getInt("Buttons.Rain.X." + i, 0), config.getInt("Buttons.Rain.Y." + i, 0), config.getInt("Buttons.Rain.Z." + i, 0)); raincost[i] = config.getInt("Buttons.Rain.cost." + i, raincost[i]); i++; } i = 0; worldst = new String[config.getInt("Buttons.ThunderAnzahl", i) + 1]; thunder = new Block[config.getInt("Buttons.ThunderAnzahl", i) + 1]; tmp = config.getInt("Buttons.ThunderAnzahl", tmp); thundercost = new int[config.getInt("Buttons.ThunderAnzahl", i) + 1]; while (i < tmp) { worldst[i] = config.getString("Buttons.Thunder.world." + i); thunder[i] = this.getServer() .getWorld(worldst[i]) .getBlockAt( config.getInt("Buttons.Thunder.X." + i, 0), config.getInt("Buttons.Thunder.Y." + i, 0), config.getInt("Buttons.Thunder.Z." + i, 0)); thundercost[i] = config.getInt("Buttons.Thunder.cost." + i, thundercost[i]); i++; } i = 0; worldsd = new String[config.getInt("Buttons.DayAnzahl", i) + 1]; day = new Block[config.getInt("Buttons.DayAnzahl", i) + 1]; tmp = config.getInt("Buttons.DayAnzahl", tmp); daycost = new int[config.getInt("Buttons.DayAnzahl", i) + 1]; while (i < tmp) { worldsd[i] = config.getString("Buttons.day.world." + i); day[i] = this.getServer() .getWorld(worldsd[i]) .getBlockAt( config.getInt("Buttons.day.X." + i, 0), config.getInt("Buttons.day.Y." + i, 0), config.getInt("Buttons.day.Z." + i, 0)); daycost[i] = config.getInt("Buttons.day.cost." + i, daycost[i]); i++; } i = 0; worldsn = new String[config.getInt("Buttons.NightAnzahl", i) + 1]; night = new Block[config.getInt("Buttons.NightAnzahl", i) + 1]; tmp = config.getInt("Buttons.NightAnzahl", tmp); nightcost = new int[config.getInt("Buttons.NightAnzahl", i) + 1]; while (i < tmp) { worldsn[i] = config.getString("Buttons.night.world." + i); night[i] = this.getServer() .getWorld(worldsn[i]) .getBlockAt( config.getInt("Buttons.night.X." + i, 0), config.getInt("Buttons.night.Y." + i, 0), config.getInt("Buttons.night.Z." + i, 0)); nightcost[i] = config.getInt("Buttons.night.cost." + i, nightcost[i]); i++; } messages[0] = config.getString("Messages.push_a_button", messages[0]); messages[1] = config.getString("Messages.not_permissions", messages[1]); messages[2] = config.getString("Messages.sun_comes", messages[2]); messages[3] = config.getString("Messages.not_enough_money", messages[3]); messages[4] = config.getString("Messages.rain_comes", messages[4]); messages[5] = config.getString("Messages.thunder_comes", messages[5]); messages[6] = config.getString("Messages.rain_set", messages[6]); messages[7] = config.getString("Messages.thunder_set", messages[7]); messages[8] = config.getString("Messages.sunny_set", messages[8]); messages[9] = config.getString("Messages.day_set", messages[9]); messages[10] = config.getString("Messages.night_set", messages[10]); messages[11] = config.getString("Messages.day_comes", messages[11]); messages[12] = config.getString("Messages.night_comes", messages[12]); messages[13] = config.getString("Messages.not_use", messages[13]); acc = config.getString("iConomy.account", acc); cooldown = config.getInt("Cooldown", cooldown); }
public static Integer getInteger(String variable) { return config.getInt(variable, 0); }
private Integer readInteger(String root, Integer def) { // Configuration config = load(); Integer result = config.getInt(root, def); config.save(); return result; }