org.bukkit.configuration.Configuration Java Examples
The following examples show how to use
org.bukkit.configuration.Configuration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PacketsModule.java From ExploitFixer with GNU General Public License v3.0 | 7 votes |
final public void reload(final Configuration configYml) { final ConfigurationSection configurationSection = configYml.getConfigurationSection("packets.multipliers"); final String name = "packets"; this.name = "Packets"; this.enabled = configYml.getBoolean(name + ".enabled"); this.cancelVls = configYml.getDouble(name + ".cancel_vls"); this.reduceVls = configYml.getDouble(name + ".reduce_vls"); this.offline = configYml.getBoolean(name + ".offline"); this.dataVls = configYml.getDouble(name + ".data.vls"); this.dataBytes = configYml.getInt(name + ".data.bytes", 24000); this.dataBytesBook = configYml.getInt(name + ".data.bytes_book", 268); this.dataBytesSign = configYml.getInt(name + ".data.bytes_sign", 47); this.dataBytesDivider = configYml.getInt(name + ".data.bytes_divider", 200); this.windowClick = configYml.getDouble(name + ".window_click"); this.blockPlaceVls = configYml.getDouble(name + ".block_place"); this.blockDigVls = configYml.getDouble(name + ".block_dig"); this.setCreativeSlot = configYml.getDouble(name + ".set_creative_slot"); this.violations = new Violations(configYml.getConfigurationSection(name + ".violations")); for (final String key : configurationSection.getKeys(false)) multipliers.put(key, configurationSection.getDouble(key)); }
Example #2
Source File: QuotaConfig.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Inject QuotaConfig(Configuration root) { this.config = root.getConfigurationSection("match-quotas"); if(config == null) { quotas = new TreeSet<>(); } else { quotas = new TreeSet<>(Collections2.transform( config.getKeys(false), new Function<String, Entry>() { @Override public Entry apply(@Nullable String key) { return new Entry(config.getConfigurationSection(key)); } } )); } }
Example #3
Source File: MatchManager.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates a new map manager with a specified map rotation. */ @Inject MatchManager(Loggers loggers, @Named("pluginData") Path pluginDataFolder, Provider<Configuration> config, MapLibrary mapLibrary, MapLoader mapLoader, MapErrorTracker mapErrorTracker, FileRotationProviderFactory fileRotationProviderFactory, EventBus eventBus, MatchLoader matchLoader) throws MapNotFoundException { this.pluginDataFolder = pluginDataFolder; this.mapErrorTracker = mapErrorTracker; this.fileRotationProviderFactory = fileRotationProviderFactory; this.log = loggers.get(getClass()); this.config = config; this.mapLibrary = mapLibrary; this.mapLoader = mapLoader; this.eventBus = eventBus; this.matchLoader = matchLoader; }
Example #4
Source File: FileRotationProviderFactory.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
public Set<RotationProviderInfo> parse(MapLibrary mapLibrary, Path dataPath, Configuration config) { ConfigurationSection base = config.getConfigurationSection("rotation.providers.file"); if(base == null) return Collections.emptySet(); Set<RotationProviderInfo> providers = new HashSet<>(); for(String name : base.getKeys(false)) { ConfigurationSection provider = base.getConfigurationSection(name); Path rotationFile = Paths.get(provider.getString("path")); if(!rotationFile.isAbsolute()) rotationFile = dataPath.resolve(rotationFile); int priority = provider.getInt("priority", 0); if(Files.isRegularFile(rotationFile)) { providers.add(new RotationProviderInfo(new FileRotationProvider(mapLibrary, name, rotationFile, dataPath), name, priority)); } else if(minecraftService.getLocalServer().startup_visibility() == ServerDoc.Visibility.PUBLIC) { // This is not a perfect way to decide whether or not to throw an error, but it's the best we can do right now mapLibrary.getLogger().severe("Missing rotation file: " + rotationFile); } } return providers; }
Example #5
Source File: ModuleManager.java From ExploitFixer with GNU General Public License v3.0 | 6 votes |
public void reload(final Configuration configYml, final Configuration messagesYml, final Configuration spigotYml) { try { this.commandsModule.reload(configYml); this.connectionModule.reload(configYml); this.customPayloadModule.reload(configYml); this.itemsFixModule.reload(configYml); this.messagesModule.reload(messagesYml); this.notificationsModule.reload(configYml); this.packetsModule.reload(configYml); this.exploitPlayerManager.reload(); } catch (final NullPointerException e) { final Server server = plugin.getServer(); server.getLogger().log(Level.SEVERE, "Your ExploitFixer configuration is wrong, please reset it or the plugin wont work!"); server.getPluginManager().disablePlugin(plugin); e.printStackTrace(); } }
Example #6
Source File: BungeemodeAddon.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
private boolean checkCopyConfig() throws IOException { File file = new File(getDataFolder(), CONFIG_FILE_NAME); if (file.exists()) { Configuration config = YamlConfiguration.loadConfiguration(file); int version = config.getInt("config-version"); if (version < BungeemodeConfig.CURRENT_CONFIG_VERSION) { Path dataFolderPath = getDataFolder().toPath(); Files.move(file.toPath(), dataFolderPath.resolve("config_old.yml"), StandardCopyOption.REPLACE_EXISTING); return true; } } else { return true; } return false; }
Example #7
Source File: InventoryEntryConfig.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@Override public final void inflateUnsafe(Configuration config, Object[] args) throws ParseException { ConfigurationSection layoutSection = config.getConfigurationSection("layout"); String title; List<String> lore; if (layoutSection != null) { title = layoutSection.getString("title", DEFAULT_TITLE); lore = layoutSection.getStringList("lore"); if (lore == null || lore.isEmpty()) { lore = DEFAULT_LORE; } } else { title = DEFAULT_TITLE; lore = DEFAULT_LORE; } layout = new InventoryEntryLayout(title, lore); }
Example #8
Source File: HeavySpleef.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
private void checkConfigVersions(Configuration config, Path dataFolder) { if (config.getInt("config-version") < DefaultConfig.CURRENT_CONFIG_VERSION) { Path configSource = dataFolder.resolve(ConfigType.DEFAULT_CONFIG.getDestinationFileName()); Path configTarget = dataFolder.resolve("config_old.yml"); try { Files.move(configSource, configTarget, StandardCopyOption.REPLACE_EXISTING); URL configResource = getClass().getResource(ConfigType.DEFAULT_CONFIG.getClasspathResourceName()); copyResource(configResource, configSource.toFile()); ConsoleCommandSender sender = Bukkit.getConsoleSender(); sender.sendMessage(ChatColor.RED + "Due to a HeavySpleef update your old configuration has been renamed"); sender.sendMessage(ChatColor.RED + "to config_old.yml and a new one has been generated. Make sure to"); sender.sendMessage(ChatColor.RED + "apply your old changes to the new config"); } catch (IOException e) { getLogger().log(Level.SEVERE, "Could not create updated configuration due to an IOException", e); } } }
Example #9
Source File: DatabaseConfig.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@Override public void inflate(Configuration config, Object... args) { Validate.isTrue(args.length > 0, "args.length must be greater than 0"); Validate.isTrue(args[0] instanceof File, "args[0] must be an instance of " + File.class.getCanonicalName()); File baseDir = (File) args[0]; ConfigurationSection moduleSection = config.getConfigurationSection("database-modules"); this.statisticsEnabled = moduleSection.getBoolean("statistics.enabled"); this.maxStatisticCacheSize = moduleSection.getInt("statistics.max-cache-size", DEFAULT_MAX_CACHE_SIZE); this.connections = Lists.newArrayList(); ConfigurationSection connectionsSection = config.getConfigurationSection("persistence-connection"); for (String key : connectionsSection.getKeys(false)) { connections.add(new DatabaseConnection(connectionsSection.getConfigurationSection(key), baseDir)); } }
Example #10
Source File: DefaultConfig.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
public void loadConfiguration() { Configuration configuration = Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).getConfig(); configuration.addDefault(SUPERMOB_STACK_AMOUNT, 50); configuration.addDefault(MMORPG_COLORS, true); configuration.addDefault(CREEPER_PASSIVE_DAMAGE_PREVENTER, true); configuration.addDefault(ENABLE_PERMISSION_TITLES, true); configuration.addDefault(ENABLE_POWER_SCOREBOARDS, false); configuration.addDefault(ALWAYS_SHOW_NAMETAGS, false); configuration.addDefault(HIDE_ENCHANTMENTS_ATTRIBUTE, false); configuration.addDefault(PREVENT_ITEM_PICKUP, true); configuration.addDefault(PREVENT_ELITE_MOB_CONVERSION_OF_NAMED_MOBS, true); configuration.addDefault(STRICT_SPAWNING_RULES, false); configuration.addDefault(PREVENT_MOUNT_EXPLOIT, true); configuration.addDefault(PREVENT_TOWER_EXPLOIT, true); configuration.addDefault(PREVENT_DARKROOM_EXPLOIT, true); configuration.addDefault(PREVENT_ENDERMAN_HEIGHT_EXPLOIT, true); configuration.addDefault(SKULL_SIGNATURE_ITEM, true); configuration.options().copyDefaults(true); UnusedNodeHandler.clearNodes(configuration); //save the config when changed Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).saveConfig(); Bukkit.getPluginManager().getPlugin(MetadataHandler.ELITE_MOBS).saveDefaultConfig(); Bukkit.getLogger().info("EliteMobs config loaded!"); }
Example #11
Source File: ConnectionModule.java From ExploitFixer with GNU General Public License v3.0 | 5 votes |
public void reload(final Configuration configYml) { final YamlConfiguration configYml1 = (YamlConfiguration) configYml; this.uuidSpoofEnabled = configYml1.getBoolean("connection.uuidspoof"); this.nullAddressEnabled = configYml1.getBoolean("connection.nulladdress"); this.name = "UUID-Spoof"; this.punishments = new HashSet<>(configYml1.getStringList("connection.punishments")); }
Example #12
Source File: Settings.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
public static void loadLanguageConfiguration(Configuration config) { try { Field[] fields = Settings.class.getDeclaredFields(); for (Field field : fields) { if (field.getType() == String.class && field.getName().startsWith("msg")) { String configKey = toConfigKey(field.getName()); field.set(null, Utils.colorize(config.getString(configKey, (String) field.get(null)))); } } } catch (Exception e) { e.printStackTrace(); } }
Example #13
Source File: NPCEntity.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
/** * Spawns NPC based off of the values in the NPCConfig config file. Runs at startup and on reload. * * @param key Name of the config key for this NPC */ public NPCEntity(String key) { this.key = key; key += "."; Configuration configuration = ConfigValues.npcConfig; if (!setSpawnLocation(configuration.getString(key + NPCConfig.LOCATION))) return; if (!configuration.getBoolean(key + NPCConfig.ENABLED)) return; this.villager = (Villager) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.VILLAGER); this.villager.setRemoveWhenFarAway(true); setName(configuration.getString(key + NPCConfig.NAME)); initializeRole(configuration.getString(key + NPCConfig.ROLE)); setProfession(configuration.getString(key + NPCConfig.TYPE)); setGreetings(configuration.getStringList(key + NPCConfig.GREETINGS)); setDialog(configuration.getStringList(key + NPCConfig.DIALOG)); setFarewell(configuration.getStringList(key + NPCConfig.FAREWELL)); setCanMove(configuration.getBoolean(key + NPCConfig.CAN_MOVE)); setCanTalk(configuration.getBoolean(key + NPCConfig.CAN_TALK)); setActivationRadius(configuration.getDouble(key + NPCConfig.ACTIVATION_RADIUS)); setDisappearsAtNight(configuration.getBoolean(key + NPCConfig.DISAPPEARS_AT_NIGHT)); setNpcInteractionType(configuration.getString(key + NPCConfig.INTERACTION_TYPE)); EntityTracker.registerNPCEntity(this); addNPCEntity(this); }
Example #14
Source File: LevelConfigYmlWriter.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
public YmlConfiguration writeToConfig(YmlConfiguration config, BlockLevelConfigMap map) { Configuration root = config.getRoot(); ConfigurationSection blocks = root.createSection("blocks"); BlockLevelConfig mapDefault = map.getDefault(); map.values().stream() .distinct() .filter(f -> !isDefaultValues(f, mapDefault)) .sorted(Comparator.comparing(BlockLevelConfig::getKey)) .forEach(e -> writeToSection(blocks.createSection(createSectionKey(e)), e, mapDefault)); return config; }
Example #15
Source File: ConfigAssembler.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
public static void assemble(Configuration configuration, String path, String itemType, String itemName, List<String> itemLore, List<String> enchantments, List<String> potionEffects, String itemWeight, String itemScalability) { configuration.addDefault("Items." + path + ".Item Type", itemType); configuration.addDefault("Items." + path + ".Item Name", itemName); configuration.addDefault("Items." + path + ".Item Lore", itemLore); configuration.addDefault("Items." + path + ".Enchantments", enchantments); configuration.addDefault("Items." + path + ".Potion Effects", potionEffects); configuration.addDefault("Items." + path + ".Drop Weight", itemWeight); configuration.addDefault("Items." + path + ".Scalability", itemScalability); }
Example #16
Source File: ModuleManager.java From ExploitFixer with GNU General Public License v3.0 | 5 votes |
public ModuleManager(final Plugin plugin, final Configuration configYml, final Configuration messagesYml) { this.plugin = plugin; this.commandsModule = new CommandsModule(configYml); this.connectionModule = new ConnectionModule(configYml); this.customPayloadModule = new CustomPayloadModule(plugin, this, configYml); this.itemsFixModule = new ItemsFixModule(plugin, configYml); this.messagesModule = new MessagesModule(plugin.getDescription().getVersion(), messagesYml); this.notificationsModule = new NotificationsModule(plugin.getServer().getConsoleSender(), configYml); this.packetsModule = new PacketsModule(plugin, this, configYml); this.exploitPlayerManager = new ExploitPlayerManager(plugin, plugin.getServer(), this); }
Example #17
Source File: ItemsFixModule.java From ExploitFixer with GNU General Public License v3.0 | 5 votes |
final public void reload(final Configuration configYml) { final String name = getName().toLowerCase(); this.enabled = configYml.getBoolean(name + ".enabled", true); this.enchantLimit = configYml.getInt(name + ".enchant_limit", 10); this.maxStackSize = configYml.getInt(name + ".max_stack_size", 64); this.blacklist = new HashSet<>(configYml.getStringList(name + ".blacklist")); }
Example #18
Source File: ThrowingConfigurationObject.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
@Override public void inflate(Configuration config, Object... args) { try { inflateUnsafe(config, args); } catch (Exception e) { Class<? extends E> clazz = getExceptionClass(); if (clazz.isInstance(e)) { throw new UnsafeException(e); } else if (e instanceof RuntimeException) { throw (RuntimeException) e; } //This part shouldn't be executed } }
Example #19
Source File: YamlConfiguration.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override protected String buildHeader() { String header = options().header(); if (options().copyHeader()) { Configuration def = getDefaults(); if ((def != null) && (def instanceof FileConfiguration)) { FileConfiguration filedefaults = (FileConfiguration) def; String defaultsHeader = filedefaults.buildHeader(); if ((defaultsHeader != null) && (defaultsHeader.length() > 0)) { return defaultsHeader; } } } if (header == null) { return ""; } StringBuilder builder = new StringBuilder(); String[] lines = header.split("\r?\n", -1); boolean startedHeader = false; for (int i = lines.length - 1; i >= 0; i--) { builder.insert(0, "\n"); if ((startedHeader) || (lines[i].length() != 0)) { builder.insert(0, lines[i]); builder.insert(0, COMMENT_PREFIX); startedHeader = true; } } return builder.toString(); }
Example #20
Source File: Config.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public static Configuration getConfiguration() { PGM pgm = PGM.get(); if(pgm != null) { return pgm.getConfig(); } else { return new YamlConfiguration(); } }
Example #21
Source File: RotationManager.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public RotationManager(Logger logger, Configuration config, PGMMap defaultMap, Collection<RotationProviderInfo> providers) { this.logger = ClassLogger.get(checkNotNull(logger, "logger"), getClass()); this.config = config; this.providers = Collections.synchronizedSortedSet(Sets.newTreeSet(providers)); load(defaultMap); }
Example #22
Source File: HuntingBoots.java From EliteMobs with GNU General Public License v3.0 | 4 votes |
@Override public void assembleConfigItem(Configuration configuration) { super.assembleConfigItem(configuration); }
Example #23
Source File: DefaultConfig.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
@Override public void inflate(Configuration config, Object... args) { ConfigurationSection generalSection = config.getConfigurationSection("general"); this.generalSection = new GeneralSection(generalSection); ConfigurationSection queueSection = config.getConfigurationSection("queues"); this.queueSection = new QueueSection(queueSection); defaultGameProperties = new EnumMap<GameProperty, Object>(GameProperty.class); ConfigurationSection propsSection = config.getConfigurationSection("default-game-properties"); Set<String> keys = propsSection.getKeys(false); for (GameProperty property : GameProperty.values()) { for (String key : keys) { GameProperty mappedProperty = mapPropertyString(key); Object value; if (mappedProperty != null) { value = propsSection.get(key, mappedProperty.getDefaultValue()); } else { value = property.getDefaultValue(); } defaultGameProperties.put(mappedProperty, value); } } ConfigurationSection localizationSection = config.getConfigurationSection("localization"); this.localization = new Localization(localizationSection); ConfigurationSection flagSection = config.getConfigurationSection("flags"); this.flagSection = new FlagSection(flagSection); ConfigurationSection signSection = config.getConfigurationSection("signs"); this.signSection = new SignSection(signSection); ConfigurationSection spectateSection = config.getConfigurationSection("spectate"); this.spectateSection = new SpectateSection(spectateSection); ConfigurationSection lobbySection = config.getConfigurationSection("lobby"); this.lobbySection = new LobbySection(lobbySection); ConfigurationSection updateSection = config.getConfigurationSection("update"); this.updateSection = new UpdateSection(updateSection); this.configVersion = config.getInt("config-version", CURRENT_CONFIG_VERSION); }
Example #24
Source File: DefaultConfig.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
public DefaultConfig(Configuration config) { super(config); }
Example #25
Source File: BungeemodeAddon.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
@Override public void enable() { if (!MinecraftVersion.isSpigot()) { getLogger().warning("Bungeemode requires a Spigot server to operate!"); return; } HeavySpleef heavySpleef = getHeavySpleef(); try { File configFile = new File(getDataFolder(), CONFIG_FILE_NAME); if (checkCopyConfig()) { if (configFile.exists()) { configFile.delete(); } configFile.createNewFile(); copyResource(CONFIG_RESOURCE_NAME, configFile); } Configuration yamlConfig = YamlConfiguration.loadConfiguration(configFile); config = new BungeemodeConfig(yamlConfig); } catch (IOException e) { getLogger().log(Level.SEVERE, "Failed to generate/load config", e); } if (!config.isEnabled()) { return; } Bukkit.getMessenger().registerOutgoingPluginChannel(heavySpleef.getPlugin(), BUNGEECORD_CHANNEL); this.sendBackExceptions = Sets.newHashSet(); listener = new BungeemodeListener(this); Bukkit.getPluginManager().registerEvents(listener, heavySpleef.getPlugin()); if (heavySpleef.isGamesLoaded()) { callback.onGamesLoaded(null); //Fix for HeavySpleef version 2.1 or below //that doesn't load unloaded flags on add-on enable FlagRegistry reg = getHeavySpleef().getFlagRegistry(); String path = reg.getFlagPath(FlagTeleportAll.class); for (Game game : heavySpleef.getGameManager().getGames()) { for (AbstractFlag<?> flag : game.getFlagManager().getFlags()) { if (!(flag instanceof UnloadedFlag)) { continue; } UnloadedFlag unloaded = (UnloadedFlag) flag; if (!unloaded.getFlagName().equals(path)) { continue; } game.removeFlag(path); FlagTeleportAll newFlag = reg.newFlagInstance(path, FlagTeleportAll.class, game); newFlag.unmarshal(unloaded.getXmlElement()); game.addFlag(newFlag); } } } else { heavySpleef.addGamesLoadCallback(callback); } }
Example #26
Source File: LeaderboardAddOn.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
@Override public void enable() { File dataFolder = getDataFolder(); dataFolder.mkdir(); File xmlFile = new File(dataFolder, "extensions.xml"); xmlHandler = new ExtensionXmlHandler(xmlFile, getHeavySpleef().getExtensionRegistry()); globalExtensionManager = new GlobalExtensionManager(getHeavySpleef()); podiumFile = new File(getDataFolder(), "layout-podium.yml"); wallFile = new File(getDataFolder(), "layout-wall.yml"); copyLayouts(); Configuration podiumYml = YamlConfiguration.loadConfiguration(podiumFile); podiumConfig = new SignLayoutConfiguration(podiumYml); Configuration wallYml = YamlConfiguration.loadConfiguration(wallFile); wallConfig = new SignLayoutConfiguration(wallYml); Set<GameExtension> set = Sets.newHashSet(); try { xmlHandler.loadExtensions(set); } catch (IOException | DocumentException e) { getLogger().log(Level.SEVERE, "Failed to load extensions from xml", e); } for (GameExtension extension : set) { globalExtensionManager.addExtension(extension); if (extension instanceof ExtensionLeaderboardPodium) { ExtensionLeaderboardPodium podium = (ExtensionLeaderboardPodium) extension; podium.setLayoutConfig(podiumConfig); podium.update(false); } else if (extension instanceof ExtensionLeaderboardWall) { ExtensionLeaderboardWall wall = (ExtensionLeaderboardWall) extension; wall.setLayoutConfig(wallConfig); wall.update(); } } }
Example #27
Source File: HuntingChestplate.java From EliteMobs with GNU General Public License v3.0 | 4 votes |
@Override public void assembleConfigItem(Configuration configuration) { super.assembleConfigItem(configuration); }
Example #28
Source File: HuntingHelmet.java From EliteMobs with GNU General Public License v3.0 | 4 votes |
@Override public void assembleConfigItem(Configuration configuration) { super.assembleConfigItem(configuration); }
Example #29
Source File: UniqueItem.java From EliteMobs with GNU General Public License v3.0 | 4 votes |
public void assembleConfigItem(Configuration configuration) { ConfigAssembler.assemble(configuration, definePath(), defineType(), defineName(), defineLore(), defineEnchantments(), definePotionEffects(), defineDropWeight(), defineScalability()); }
Example #30
Source File: InactivePlayerListener.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@Inject Config(Configuration config, ExceptionHandler<Throwable> exceptionHandler) { this.config = config; this.exceptionHandler = exceptionHandler; }