Java Code Examples for org.bukkit.configuration.ConfigurationSection#set()
The following examples show how to use
org.bukkit.configuration.ConfigurationSection#set() .
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: CommandTemplate.java From TrMenu with MIT License | 6 votes |
private ConfigurationSection display(ItemStack item) { ConfigurationSection section = new MemoryConfiguration(); ItemMeta meta = item.getItemMeta(); String mat = item.getType().name(); if (meta instanceof SkullMeta) { String texture = Skulls.getTexture(item); mat = texture != null ? "<skull:" + Skulls.getTexture(item) + ">" : mat; } if (item.getAmount() > 1) { section.set("amount", item.getAmount()); } if (meta != null) { if (meta.hasDisplayName()) { section.set("name", meta.getDisplayName()); } if (meta.hasLore()) { section.set("lore", meta.getLore()); } } section.set("mats", mat); return section; }
Example 2
Source File: ParticleData.java From NyaaUtils with MIT License | 6 votes |
@SuppressWarnings("deprecation") @Override public void deserialize(ConfigurationSection config) { if (config.getString("version", "").length() == 0) { String materialName = config.getString("material", null); if (materialName != null) { Material m = Material.matchMaterial(materialName, true); if (m.isBlock() && config.isInt("dataValue")) { config.set("material", Bukkit.getUnsafe().fromLegacy(m, (byte) config.getInt("dataValue")).getMaterial().name()); } else { config.set("material", Bukkit.getUnsafe().fromLegacy(m).name()); } } } ISerializable.deserialize(config, this); }
Example 3
Source File: Configuration.java From NyaaUtils with MIT License | 6 votes |
@Override public void serialize(ConfigurationSection config) { // general values save & standalone config save ISerializable.serialize(config, this); // Enchantment Max Level constraint ConfigurationSection list = config.createSection("enchant.max_level"); for (Enchantment k : enchantMaxLevel.keySet()) { if (k == null || k.getKey() == null || k.getKey().getKey() == null) continue; list.set(k.getKey().getKey(), enchantMaxLevel.get(k)); } config.set("particles.limits", null); for (ParticleType type : particlesLimits.keySet()) { particlesLimits.get(type).serialize(config.createSection("particles.limits." + type.name())); } }
Example 4
Source File: AnniSign.java From AnnihilationPro with MIT License | 6 votes |
public void saveToConfig(ConfigurationSection configSection) { if(configSection != null) { configSection.set("isSignPost", this.isSignPost()); //ConfigManager.saveLocation(this.getLocation(), configSection.createSection("Location")); getLocation().saveToConfig(configSection.createSection("Location")); configSection.set("FacingDirection", this.getFacingDirection().name()); String data; if(this.getType().equals(SignType.Brewing)) data = "Brewing"; else if(this.getType().equals(SignType.Weapon)) data = "Weapon"; else data = "Team-"+this.getType().getTeam().getName(); configSection.set("Data", data); } }
Example 5
Source File: WorldMatcher.java From UHC with MIT License | 6 votes |
public WorldMatcher(ConfigurationSection section, List<String> worldsDefault, boolean isWhitelistDefault) { if (!section.contains(WORLDS_KEY)) { section.set(WORLDS_KEY, worldsDefault); } if (!section.contains(IS_WHITELIST_KEY)) { section.set(IS_WHITELIST_KEY, isWhitelistDefault); } worlds = ImmutableSet.copyOf( Iterables.filter( Iterables.transform(section.getStringList(WORLDS_KEY), TO_LOWER_CASE), Predicates.notNull() ) ); isWhitelist = section.getBoolean(IS_WHITELIST_KEY); }
Example 6
Source File: ConfigUpdater.java From BetonQuest with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("unused") private void update_from_v29() { try { for (ConfigPackage pack : Config.getPackages().values()) { String packName = pack.getName(); ConfigurationSection section = pack.getMain().getConfig().getConfigurationSection("variables"); for (String key : section.getKeys(true)) { String variable = section.getString(key); if (variable.matches( "^\\$[a-zA-Z0-9]+\\$->\\(\\-?\\d+\\.?\\d*,\\-?\\d+\\.?\\d*,\\-?\\d+\\.?\\d*\\)$")) { section.set(key, variable.replace(',', ';')); } } pack.getMain().saveConfig(); } } catch (Exception e) { LogUtils.getLogger().log(Level.WARNING, ERROR); LogUtils.logThrowable(e); } LogUtils.getLogger().log(Level.INFO, "Changed commas to semicolons in vector variables"); config.set("version", "v30"); instance.saveConfig(); }
Example 7
Source File: LevelConfigYmlWriter.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
private void writeToSection(ConfigurationSection section, BlockLevelConfig config, BlockLevelConfig mapDefault) { if (!config.getAdditionalBlocks().isEmpty()) { section.set("additionalBlocks", config.getAdditionalBlocks().stream().distinct().map(m -> m.toString()).collect(Collectors.toList())); } if (config.getScorePerBlock() >= 0 && config.getScorePerBlock() != mapDefault.getScorePerBlock()) { section.set("score", config.getScorePerBlock()); } if (config.getLimit() >= 0 && config.getLimit() != mapDefault.getLimit()) { section.set("limit", config.getLimit()); } if (config.getDiminishingReturns() > 0 && config.getLimit() != mapDefault.getDiminishingReturns()) { section.set("diminishingReturns", config.getDiminishingReturns()); } if (config.getNegativeReturns() > 0 && config.getLimit() != mapDefault.getNegativeReturns()) { section.set("negativeReturns", config.getNegativeReturns()); } }
Example 8
Source File: SignShop.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
@Override protected void save(ConfigurationSection config) { super.save(config); if (signFacing != null) { config.set("signFacing", signFacing.name()); } }
Example 9
Source File: YamlConfiguration.java From Kettle with GNU General Public License v3.0 | 5 votes |
protected void convertMapsToSections(Map<?, ?> input, ConfigurationSection section) { for (Map.Entry<?, ?> entry : input.entrySet()) { String key = entry.getKey().toString(); Object value = entry.getValue(); if (value instanceof Map) { convertMapsToSections((Map<?, ?>) value, section.createSection(key)); } else { section.set(key, value); } } }
Example 10
Source File: TimerConfig.java From NyaaUtils with MIT License | 5 votes |
@Override public void serialize(ConfigurationSection config) { ISerializable.serialize(config, this); config.set("timers", null); if (!timers.isEmpty()) { ConfigurationSection list = config.createSection("timers"); for (String k : timers.keySet()) { timers.get(k).serialize(list.createSection(k)); } } }
Example 11
Source File: HologramDatabase.java From HolographicDisplays with GNU General Public License v3.0 | 5 votes |
public static void saveHologram(NamedHologram hologram) { List<String> serializedLines = new ArrayList<>(); for (CraftHologramLine line : hologram.getLinesUnsafe()) { serializedLines.add(serializeHologramLine(line)); } ConfigurationSection hologramSection = getOrCreateSection(hologram.getName()); hologramSection.set("location", LocationSerializer.locationToString(hologram.getLocation())); hologramSection.set("lines", serializedLines); }
Example 12
Source File: Loc.java From AnnihilationPro with MIT License | 5 votes |
public void saveToConfig(ConfigurationSection section) { section.set("World", world); section.set("X", x); section.set("Y", y); section.set("Z", z); section.set("Pitch", (double)pitch); section.set("Yaw", (double)yaw); }
Example 13
Source File: PlayerShopkeeper.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
@Override protected void save(ConfigurationSection config) { super.save(config); config.set("owner uuid", ownerUUID.toString()); config.set("owner", ownerName); config.set("chestx", chestX); config.set("chesty", chestY); config.set("chestz", chestZ); config.set("forhire", forHire); config.set("hirecost", hireCost); }
Example 14
Source File: CraftServer.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CraftServer(MinecraftServer console, PlayerList playerList) { this.console = console; this.playerList = (DedicatedPlayerList) playerList; this.playerView = Collections.unmodifiableList(Lists.transform(playerList.getPlayers(), EntityPlayerMP::getBukkitEntity)); this.serverVersion = CraftServer.class.getPackage().getImplementationVersion(); online.value = console.getPropertyManager().getBooleanProperty("online-mode", true); Bukkit.setServer(this); // Register all the Enchantments and PotionTypes now so we can stop new registration immediately after Enchantments.SHARPNESS.getClass(); Potion.setPotionBrewer(new CraftPotionBrewer()); MobEffects.BLINDNESS.getClass(); // Ugly hack :( if (!Main.useConsole) { getLogger().info("Console input is disabled due to --noconsole command argument"); } configuration = YamlConfiguration.loadConfiguration(getConfigFile()); configuration.options().copyDefaults(true); configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader( getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"), Charsets.UTF_8))); ConfigurationSection legacyAlias = null; if (!configuration.isString("aliases")) { legacyAlias = configuration.getConfigurationSection("aliases"); configuration.set("aliases", "now-in-commands.yml"); } saveConfig(); if (getCommandsConfigFile().isFile()) { legacyAlias = null; } commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile()); commandsConfiguration.options().copyDefaults(true); commandsConfiguration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader( getClass().getClassLoader().getResourceAsStream("configurations/commands.yml"), Charsets.UTF_8))); saveCommandsConfig(); // Migrate aliases from old file and add previously implicit $1- to pass all arguments if (legacyAlias != null) { ConfigurationSection aliases = commandsConfiguration.createSection("aliases"); for (String key : legacyAlias.getKeys(false)) { ArrayList<String> commands = new ArrayList<String>(); if (legacyAlias.isList(key)) { for (String command : legacyAlias.getStringList(key)) { commands.add(command + " $1-"); } } else { commands.add(legacyAlias.getString(key) + " $1-"); } aliases.set(key, commands); } } saveCommandsConfig(); overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*"); unrestrictedAdvancements = commandsConfiguration.getBoolean("unrestricted-advancements"); pluginManager.useTimings(configuration.getBoolean("settings.plugin-profiling")); monsterSpawn = configuration.getInt("spawn-limits.monsters"); animalSpawn = configuration.getInt("spawn-limits.animals"); waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals"); ambientSpawn = configuration.getInt("spawn-limits.ambient"); console.autosavePeriod = configuration.getInt("ticks-per.autosave"); warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); loadIcon(); // Fixed server ping stalling. chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks"); chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold"); loadIcon(); }
Example 15
Source File: CreeperShop.java From Shopkeepers with GNU General Public License v3.0 | 4 votes |
@Override protected void save(ConfigurationSection config) { super.save(config); config.set("powered", powered); }
Example 16
Source File: XPMain.java From AnnihilationPro with MIT License | 4 votes |
@Override public void onEnable() { configFile = new File(AnnihilationMain.getInstance().getDataFolder(),"AnnihilationXPConfig.yml"); Bukkit.getLogger().info("[AnnihilationXPSystem] Loading XP system..."); Bukkit.getPluginManager().registerEvents(this, this); checkFile(configFile); config = YamlConfiguration.loadConfiguration(configFile); //%# to be replaced by the number int x = 0; x += ConfigManager.setDefaultIfNotSet(config, "Nexus-Hit-XP", 1); x += ConfigManager.setDefaultIfNotSet(config, "Player-Kill-XP", 3); x += ConfigManager.setDefaultIfNotSet(config, "Winning-Team-XP", 100); x += ConfigManager.setDefaultIfNotSet(config, "Second-Place-Team-XP", 75); x += ConfigManager.setDefaultIfNotSet(config, "Third-Place-Team-XP", 50); x += ConfigManager.setDefaultIfNotSet(config, "Last-Place-Team-XP", 25); x += ConfigManager.setDefaultIfNotSet(config, "Gave-XP-Message", "&a+%# Annihilation XP"); x += ConfigManager.setDefaultIfNotSet(config, "MyXP-Command-Message", "&dYou have &a%#&d Annihilation XP."); if(!config.isConfigurationSection("XP-Multipliers")) { ConfigurationSection multipliers = config.createSection("XP-Multipliers"); multipliers.set("Multiplier-1.Permission", "Anni.XP.2"); multipliers.set("Multiplier-1.Multiplier", 2); x++; } ConfigurationSection data = config.getConfigurationSection("Database"); if(data == null) data = config.createSection("Database"); x += ConfigManager.setDefaultIfNotSet(data, "Host", "Test"); x += ConfigManager.setDefaultIfNotSet(data, "Port", "Test"); x += ConfigManager.setDefaultIfNotSet(data, "Database", "Test"); x += ConfigManager.setDefaultIfNotSet(data, "Username", "Test"); x += ConfigManager.setDefaultIfNotSet(data, "Password", "Test"); // data.set("Host", "Test"); // data.set("Port", "Test"); // data.set("Database", "Test"); // data.set("Username", "Test"); // data.set("Password", "Test"); // x++; ConfigurationSection shopSec = config.getConfigurationSection("Kit-Shop"); if(shopSec == null) { shopSec = config.createSection("Kit-Shop"); shopSec.createSection("Kits"); } x += ConfigManager.setDefaultIfNotSet(shopSec, "On", false); x += ConfigManager.setDefaultIfNotSet(shopSec, "Already-Purchased-Kit", "&aPURCHASED"); x += ConfigManager.setDefaultIfNotSet(shopSec, "Not-Yet-Purchased-Kit", "&cLOCKED. PURCHASE FOR &6%# &cXP"); x += ConfigManager.setDefaultIfNotSet(shopSec, "Confirm-Purchase-Kit", "&aPUCHASE BEGUN. CONFIRM FOR &6%# &AXP"); x += ConfigManager.setDefaultIfNotSet(shopSec, "Confirmation-Expired", "&cThe confirmation time has expired. Please try again."); x += ConfigManager.setDefaultIfNotSet(shopSec, "Not-Enough-XP", "&cYou do not have enough XP to purchase this kit."); x += ConfigManager.setDefaultIfNotSet(shopSec, "Kit-Purchased", "&aKit %w purchased!"); x += ConfigManager.setDefaultIfNotSet(shopSec, "No-Kits-To-Purchase", "&cNo kits left to purchase!"); // shopSec.set("On", false); // shopSec.set("Already-Purchased-Kit", "&aPURCHASED"); // shopSec.set("Not-Yet-Purchased-Kit", "&cLOCKED. PURCHASE FOR &6%# &cXP"); // shopSec.set("Confirm-Purchase-Kit", "&aPUCHASE BEGUN. CONFIRM FOR &6%# &AXP"); // shopSec.set("Confirmation-Expired", "&cThe confirmation time has expired. Please try again."); // shopSec.set("Not-Enough-XP", "&cYou do not have enough XP to purchase this kit."); // shopSec.set("Kit-Purchased", "&aKit %w purchased!"); // shopSec.createSection("Kits"); // x++; if(x > 0) this.saveConfig(); this.xpSystem = new XPSystem(config.getConfigurationSection("Database")); if(!this.xpSystem.isActive()) { Bukkit.getLogger().info("[AnnihilationXPSystem] Could NOT connect to the database"); disable(); return; } Bukkit.getLogger().info("[AnnihilationXPSystem] CONNECTED to the database"); boolean useShop = config.getBoolean("Kit-Shop.On"); if(useShop) { Bukkit.getLogger().info("[AnnihilationXPSystem] The shop is ENABLED"); this.getCommand("Shop").setExecutor(new Shop(this.xpSystem,config.getConfigurationSection("Kit-Shop"))); saveConfig(); } else Bukkit.getLogger().info("[AnnihilationXPSystem] The shop is DISABLED"); loadMultipliers(config.getConfigurationSection("XP-Multipliers")); loadXPVars(config); //This also loads the listeners with the values they need AnniCommand.registerArgument(new XPArgument(xpSystem)); AnniCommand.registerArgument(new KitArgument(xpSystem)); for(AnniPlayer p : AnniPlayer.getPlayers()) xpSystem.loadKits(p, null); }
Example 17
Source File: IslandInfo.java From uSkyBlock with GNU General Public License v3.0 | 4 votes |
public void updatePermissionPerks(@NotNull final Player member, @NotNull Perk perk) { Validate.notNull(member, "Member cannot be null"); Validate.notNull(perk, "Perk cannot be null"); boolean updateRegion = false; if (isLeader(member)) { String oldLeaderName = getLeader(); config.set("party.leader", member.getName()); updateRegion |= !oldLeaderName.equals(member.getName()); } ConfigurationSection section = config.getConfigurationSection("party.members." + member.getUniqueId()); boolean dirty = false; if (section != null) { section.set("name", member.getName()); int maxParty = section.getInt("maxPartySizePermission", Settings.general_maxPartySize); if (perk.getMaxPartySize() != maxParty) { section.set("maxPartySizePermission", perk.getMaxPartySize()); dirty = true; } int maxAnimals = section.getInt("maxAnimals", 0); if (perk.getAnimals() != maxAnimals) { section.set("maxAnimals", perk.getAnimals()); dirty = true; } int maxMonsters = section.getInt("maxMonsters", 0); if (perk.getMonsters() != maxMonsters) { section.set("maxMonsters", perk.getMonsters()); dirty = true; } int maxVillagers = section.getInt("maxVillagers", 0); if (perk.getVillagers() != maxVillagers) { section.set("maxVillagers", perk.getVillagers()); dirty = true; } int maxGolems = section.getInt("maxGolems", 0); if (perk.getGolems() != maxGolems) { section.set("maxGolems", perk.getGolems()); dirty = true; } if (section.isConfigurationSection("maxBlocks")) { dirty = true; Map<Material, Integer> blockLimits = perk.getBlockLimits(); section.set("blockLimits ", null); if (!blockLimits.isEmpty()) { ConfigurationSection maxBlocks = section.createSection("blockLimits"); for (Map.Entry<Material,Integer> limit : blockLimits.entrySet()) { maxBlocks.set(limit.getKey().name(), limit.getValue()); } } } } if (dirty) { save(); } if (updateRegion) { WorldGuardHandler.updateRegion(this); } }
Example 18
Source File: ConfigUpdater.java From BetonQuest with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("unused") private void update_from_v19() { try { if (config.getString("tellraw").equalsIgnoreCase("true")) { config.set("default_conversation_IO", "tellraw"); } else { config.set("default_conversation_IO", "simple"); } config.set("tellraw", null); FileConfiguration messages = Config.getMessages().getConfig(); String message; message = messages.getString("global.quester_line_format"); if (message == null) message = "&4%quester%&f: &a&o"; config.set("conversation.quester_line_format", message); message = messages.getString("global.quester_reply_format"); if (message == null) message = "&e%number%. &b"; config.set("conversation.quester_reply_format", message); message = messages.getString("global.player_reply_format"); if (message == null) message = "&2%player%&f: &7"; config.set("conversation.player_reply_format", message); message = messages.getString("global.date_format"); if (message == null) message = "dd.MM.yyyy HH:mm"; config.set("date_format", message); String cancel_color = messages.getString("global.cancel_color", "&2"); messages.set("global", null); LogUtils.getLogger().log(Level.INFO, "Moved 'global' messages to main config."); Config.getMessages().saveConfig(); for (ConfigPackage pack : Config.getPackages().values()) { String packName = pack.getName(); LogUtils.getLogger().log(Level.FINE, "Processing " + packName + " package"); ConfigurationSection cancelers = pack.getMain().getConfig().getConfigurationSection("cancel"); for (String key : cancelers.getKeys(false)) { String canceler = cancelers.getString(key); StringBuilder string = new StringBuilder(); for (String part : canceler.split(" ")) { if (part.startsWith("name")) { string.append(part.replace(":", ":" + cancel_color) + " "); } else { string.append(part + " "); } } cancelers.set(key, string.toString().trim()); LogUtils.getLogger().log(Level.FINE, " Updated " + key + " canceler name color"); } pack.getMain().saveConfig(); for (String convName : pack.getConversationNames()) { ConfigAccessor conv = pack.getConversation(convName); conv.getConfig().set("unknown", null); conv.saveConfig(); LogUtils.getLogger().log(Level.FINE, " Removed 'unknown' messages from " + convName + " conversation"); } } LogUtils.getLogger().log(Level.INFO, "Removed no longer used 'unknown' message from conversations."); } catch (Exception e) { LogUtils.getLogger().log(Level.WARNING, ERROR); LogUtils.logThrowable(e); } config.set("version", "v20"); instance.saveConfig(); }
Example 19
Source File: BookOffer.java From Shopkeepers with GNU General Public License v3.0 | 4 votes |
public static void saveToConfig(ConfigurationSection config, String node, Collection<BookOffer> offers) { ConfigurationSection offersSection = config.createSection(node); for (BookOffer offer : offers) { offersSection.set(offer.getBookTitle(), offer.getPrice()); } }
Example 20
Source File: UHC.java From UHC with MIT License | 4 votes |
protected void setupTeamCommands() { final Optional<TeamModule> teamModuleOptional = registry.get(TeamModule.class); if (!teamModuleOptional.isPresent()) { getLogger().info("Skipping registering team commands as the team module is not loaded"); setupCommand( dummyCommands.forModule("TeamModule"), "teams", "team", "noteam", "pmt", "randomteams", "clearteams", "tc", "teamrequest" ); return; } final TeamModule teamModule = teamModuleOptional.get(); setupCommand(new ListTeamsCommand(commandMessages("teams"), teamModule), "teams"); setupCommand(new NoTeamCommand(commandMessages("noteam"), teamModule), "noteam"); setupCommand(new TeamPMCommand(commandMessages("pmt"), teamModule), "pmt"); setupCommand(new RandomTeamsCommand(commandMessages("randomteams"), teamModule), "randomteams"); setupCommand(new ClearTeamsCommand(commandMessages("clearteams"), teamModule), "clearteams"); setupCommand(new TeamCoordinatesCommand(commandMessages("tc"), teamModule), "tc"); final SubcommandCommand team = new SubcommandCommand(); team.registerSubcommand("teamup", new TeamupCommand(commandMessages("team.teamup"), teamModule)); team.registerSubcommand("add", new TeamAddCommand(commandMessages("team.add"), teamModule)); team.registerSubcommand("remove", new TeamRemoveCommand(commandMessages("team.remove"), teamModule)); setupCommand(team , "team"); final ConfigurationSection teamModuleConfig = teamModule.getConfig(); if (!teamModuleConfig.isSet(RequestManager.AUTO_WHITELIST_KEY)) { teamModuleConfig.set(RequestManager.AUTO_WHITELIST_KEY, true); } final boolean autoWhitelistAcceptedTeams = teamModuleConfig.getBoolean(RequestManager.AUTO_WHITELIST_KEY); final MessageTemplates requestMessages = commandMessages("team.teamrequest"); final RequestManager requestManager = new RequestManager( this, requestMessages, teamModule, 20 * 120, autoWhitelistAcceptedTeams ); final SubcommandCommand teamrequest = new SubcommandCommand(); teamrequest.registerSubcommand( "accept", new RequestResponseCommand(requestMessages, requestManager, RequestManager.AcceptState.ACCEPT) ); teamrequest.registerSubcommand( "deny", new RequestResponseCommand(requestMessages, requestManager, RequestManager.AcceptState.DENY) ); teamrequest.registerSubcommand("request", new TeamRequestCommand(requestMessages, requestManager)); teamrequest.registerSubcommand("list", new RequestListCommand(requestMessages, requestManager)); setupCommand(teamrequest, "teamrequest"); }