/** * Reloads the content from the fileSystem */ @Override public void reload() { this.items.clear(); this.plugin.reloadConfig(); final Map<String, Object> data = ((MemorySection) this.plugin.getConfig().get("gui.items")).getValues(false); for (final String key : data.keySet()) { try { final GUIItemContainer container = new ItemContainer(0, ((MemorySection) data.get(key)).getValues(false)); if (key.equals("suggest-heads")) { ((ItemContainer) container).setDisplayName(ChatColor.AQUA + "" + ChatColor.BOLD + "Suggest Heads"); } this.items.put(key, container); } catch (final Exception e) { PetBlocksPlugin.logger().log(Level.WARNING, "Failed to load guiItem " + key + '.', e); } } }
public void fixJoinDefaultPet(PetMeta petData) { final PetData petMeta = (PetData) petData; petMeta.setSkin(this.getData("join.settings.id"), (short) (int) this.getData("join.settings.damage"), this.getData("join.settings.skin"), this.getData("unbreakable")); petMeta.setEngine(this.engineController.getById(this.getData("join.settings.engine"))); petMeta.setPetDisplayName(this.getData("join.settings.petname")); petMeta.setEnabled(this.getData("join.settings.enabled")); petMeta.setAge(this.getData("join.settings.age")); if (!((String) this.getData("join.settings.particle.name")).equalsIgnoreCase("none")) { final ParticleEffectMeta meta; try { meta = new ParticleEffectData(((MemorySection) this.getData("effect")).getValues(false)); petMeta.setParticleEffectMeta(meta); } catch (final Exception e) { PetBlocksPlugin.logger().log(Level.WARNING, "Failed to load particle effect for join pet."); } } }
/** * Reloads the content from the fileSystem */ @Override public void reload() { this.particleCache.clear(); this.plugin.reloadConfig(); final Map<String, Object> data = ((MemorySection) this.plugin.getConfig().get("particles")).getValues(false); for (final String key : data.keySet()) { try { final GUIItemContainer container = new ItemContainer(Integer.parseInt(key), ((MemorySection) data.get(key)).getValues(false)); final ParticleEffectMeta meta = new ParticleEffectData(((MemorySection) ((MemorySection) data.get(key)).getValues(false).get("effect")).getValues(true)); this.particleCache.put(container, meta); } catch (final Exception e) { PetBlocksPlugin.logger().log(Level.WARNING, "Failed to load particle " + key + '.', e); } } }
@SuppressWarnings("unchecked") public ArgsKnot(String name, MemorySection section) { this.name = name; Map<String, Object> kids = section.getValues(false); for(Entry<String, Object> element : kids.entrySet()) { String key = element.getKey(); Object obj = element.getValue(); if(obj instanceof MemorySection) { childreen.put(key, new ArgsKnot((MemorySection) obj)); } else if(obj instanceof List) { if("args".equals(key)) { argumentList = (List<String>) obj; } } } }
BallMetaEntity(Map<String, Object> items) throws Exception { super(); this.ballSkin = (String) items.get("skin"); this.rotating = !(boolean) items.get("rotating"); this.horizontalStrength = (double) items.get("horizontal-strength"); this.verticalStrength = (double) items.get("vertical-strength"); this.ballSpawnTime = (int) items.get("spawnduration"); this.genericHitParticle = new SParticle(((MemorySection) items.get("particles.generic-hit")).getValues(true)); this.playerTeamRedHitParticle = new SParticle(((MemorySection) items.get("particles.red-hit")).getValues(true)); this.playerTeamBlueHitParticle = new SParticle(((MemorySection) items.get("particles.blue-hit")).getValues(true)); this.ballSpawnParticle = new SParticle(((MemorySection) items.get("particles.spawn")).getValues(true)); this.ballGoalParticle = new SParticle(((MemorySection) items.get("particles.goal")).getValues(true)); this.genericHitSound = new FastSound(((MemorySection) items.get("sounds.generic-hit")).getValues(true)); this.ballSpawnSound = new FastSound(((MemorySection) items.get("sounds.spawn")).getValues(true)); this.ballGoalSound = new FastSound(((MemorySection) items.get("sounds.goal")).getValues(true)); }
LobbyMetaEntity(Map<String, Object> items) throws Exception { super(); if (items.get("spawnpoint") != null) this.lobbySpawn = new SLocation(((MemorySection) items.get("spawnpoint")).getValues(true)); this.gameTime = (int) items.get("gameduration"); this.countdown = (int) items.get("lobbyduration"); for (int i = 0; i < 10000 && items.containsKey("signs.join." + i); i++) this.signLocations.add(new SLocation(((MemorySection) items.get("signs.join." + i)).getValues(true))); for (int i = 0; i < 10000 && items.containsKey("signs.leave." + i); i++) this.leaveSignLocations.add(new SLocation(((MemorySection) items.get("signs.leave." + i)).getValues(true))); for (int i = 0; i < 10000 && items.containsKey("signs.red." + i); i++) this.redTeamSignLocations.add(new SLocation(((MemorySection) items.get("signs.red." + i)).getValues(true))); for (int i = 0; i < 10000 && items.containsKey("signs.blue." + i); i++) this.blueTeamSignLocations.add(new SLocation(((MemorySection) items.get("signs.blue." + i)).getValues(true))); this.gameTitleMessage = (String) items.get("messages.countdown-title"); this.gameSubTitleMessage = (String) items.get("messages.countdown-subtitle"); }
ArenaEntity(Map<String, Object> items, List<String> wallBouncing) throws Exception { super(); this.setName(String.valueOf(items.get("id"))); this.setCornerLocations(new SLocation(((MemorySection) items.get("corner-1")).getValues(true)).toLocation(), new SLocation(((MemorySection) items.get("corner-2")).getValues(true)).toLocation()); this.alias = (String) items.get("name"); this.isEnabled = (boolean) items.get("enabled"); this.gameType = GameType.getGameTypeFromName((String) items.get("gamemode")); this.redGoal = new GoalEntity(((MemorySection) items.get("goals.red")).getValues(true)); this.blueGoal = new GoalEntity(((MemorySection) items.get("goals.blue")).getValues(true)); this.ballSpawnLocation = new SLocation(((MemorySection) items.get("ball.spawn")).getValues(true)); this.properties = new BallMetaEntity(((MemorySection) items.get("ball.properties")).getValues(true)); this.lobbyMetaEntity = new LobbyMetaEntity(((MemorySection) items.get("lobby")).getValues(true)); if (items.get("event") != null) this.properties3 = new EventMetaEntity(((MemorySection) items.get("event")).getValues(true)); final Map<String, Object> data = ((MemorySection) items.get("properties")).getValues(true); this.properties2 = new TeamMetaEntity(data); this.bounce_types = new ArrayList<>(wallBouncing); if (data.containsKey("boost-items")) this.boostItemHandler = new ItemSpawner(((MemorySection) data.get("boost-items")).getValues(true)); }
public static boolean init(RPGInventory instance) { MemorySection config = (MemorySection) Config.getConfig().get("craft"); if (!config.getBoolean("enabled") || !config.contains("extensions")) { return false; } try { capItem = ItemUtils.getTexturedItem(config.getString("extendable")); Set<String> extensionNames = config.getConfigurationSection("extensions").getKeys(false); for (String extensionName : extensionNames) { EXTENSIONS.add(new CraftExtension(extensionName, config.getConfigurationSection("extensions." + extensionName))); } } catch (Exception e) { e.printStackTrace(); return false; } // Register listeners ProtocolLibrary.getProtocolManager().addPacketListener(new CraftListener(instance)); return true; }
@Override public void load(Config config) { super.load(config); Object object = config.get("event-key-loot"); if (object instanceof MemorySection) { MemorySection section = (MemorySection) object; for (String key : section.getKeys(false)) { try { Object value = config.get(section.getCurrentPath() + '.' + key); if (value instanceof List<?>) { List<?> list = (List<?>) value; for (Object each : list) { if (each instanceof String) { inventories.put(key, InventorySerialisation.fromBase64((String) each)); } } } } catch (IOException ex) { ex.printStackTrace(); } } } }
public void reloadPlaytimeData() { Object object = this.config.getConfig().get("playing-times"); if (object instanceof MemorySection) { MemorySection section = (MemorySection) object; for (Object id : section.getKeys(false)) { this.totalPlaytimeMap.put(UUID.fromString((String) id), this.config.getConfig().getLong("playing-times." + id, 0L)); } } long millis = System.currentTimeMillis(); for (Player target : Bukkit.getOnlinePlayers()) { this.sessionTimestamps.put(target.getUniqueId(), millis); } }
@Override public void handleLoad() { // Clearing in case of configuration reload strings.clear(); lists.clear(); for (String path : base.getKeys(true)) { Object value = base.get(path); if (value == null || value instanceof MemorySection) { continue; } if (value instanceof String && !((String) value).isEmpty()) { strings.put(path, (String) value); } else if (value instanceof List && !((List) value).isEmpty()){ lists.put(path, base.getStringList(path)); } } }
private void parse(ConfigurationSection config) { for (Map.Entry<String, Object> entry : config.getValues(false).entrySet()) { MemorySection section = (MemorySection) entry.getValue(); String message = ChatColor.translateAlternateColorCodes('`', entry.getKey()); String exemptPermission = section.getString("exempt-permission"); String receivePermission = section.getString("receive-permission"); if (exemptPermission != null && receivePermission != null && exemptPermission.equals(receivePermission)) { throw new IllegalArgumentException("exempt permission and receive permission are at the same value"); } String formatterName = section.getString("formatter"); TipFormatter formatter = this.plugin.getTipsManager().getFormatter(formatterName); if (formatter == null) { throw new IllegalArgumentException("that formatter does not exist"); } this.tips.add(new Tip(receivePermission, exemptPermission, message, formatter)); } }
public static void LoadMailBoxes() { MemorySection ms = (MemorySection) MailYML.get("mailboxes"); if(ms == null) { return; } for(String s : ms.getKeys(false)) { OfflinePlayer p = Bukkit.getOfflinePlayer(MailYML.getString("mailboxes." + s + ".owner")); World w = Bukkit.getWorld(MailYML.getString("mailboxes." + s + ".world")); if(w == null) { continue; } Block b = w.getBlockAt(MailYML.getInt("mailboxes." + s + ".x"), MailYML.getInt("mailboxes." + s + ".y"), MailYML.getInt("mailboxes." + s + ".z")); if(!isChest(b)) { continue; } Chest c = getChest(b); MailItemBox mailBox = new MailItemBox(c, p); } }
@Nullable @Override public String getString(String keyPath, @Nullable String def) { Object value = getStringObject(keyPath); if (value instanceof MemorySection) return def; if (value != null) return String.valueOf(value); if (def != null && isDefaultsSaved()) set(keyPath, def); return def; }
/** * Recursively visits every MemorySection and creates a {@link PermissionDefinition} when applicable. * * @param node the node to visit * @param collection the collection to add constructed permission definitions to */ private static void addChildren(MemorySection node, Map<String, PermissionDefinition> collection) { // A MemorySection may have a permission entry, as well as MemorySection children boolean hasPermissionEntry = false; for (String key : node.getKeys(false)) { if (node.get(key) instanceof MemorySection && !"children".equals(key)) { addChildren((MemorySection) node.get(key), collection); } else if (PERMISSION_FIELDS.contains(key)) { hasPermissionEntry = true; } else { throw new IllegalStateException("Unexpected key '" + key + "'"); } } if (hasPermissionEntry) { PermissionDefinition permDef = new PermissionDefinition(node); collection.put(permDef.node, permDef); } }
/** * Recursively walks through the given memory section to gather all keys. * Assumes that the ending value is a boolean and throws an exception otherwise. * * @param parentSection the memory section to traverse * @param children list to add all results to */ private static void collectChildren(MemorySection parentSection, List<String> children) { for (Map.Entry<String, Object> entry : parentSection.getValues(false).entrySet()) { if (entry.getValue() instanceof MemorySection) { collectChildren((MemorySection) entry.getValue(), children); } else if (entry.getValue() instanceof Boolean) { if (!Boolean.TRUE.equals(entry.getValue())) { throw new IllegalStateException("Child entry '" + entry.getKey() + "' has unexpected value '" + entry.getValue() + "'"); } children.add(parentSection.getCurrentPath() + "." + entry.getKey()); } else { throw new IllegalStateException("Found child entry at '" + entry.getKey() + "' with value " + "of unexpected type: '" + parentSection.getCurrentPath() + "." + entry.getValue() + "'"); } } }
/** * Reads plugin.yml and returns the defined commands by main label and aliases. * * @return collection of all labels and their aliases */ @SuppressWarnings("unchecked") private static Map<String, List<String>> getLabelsFromPluginFile() { FileConfiguration pluginFile = YamlConfiguration.loadConfiguration(getJarFile("/plugin.yml")); MemorySection commandList = (MemorySection) pluginFile.get("commands"); Map<String, Object> commandDefinitions = commandList.getValues(false); Map<String, List<String>> commandLabels = new HashMap<>(); for (Map.Entry<String, Object> commandDefinition : commandDefinitions.entrySet()) { MemorySection definition = (MemorySection) commandDefinition.getValue(); List<String> alternativeLabels = definition.get("aliases") == null ? Collections.EMPTY_LIST : (List<String>) definition.get("aliases"); commandLabels.put(commandDefinition.getKey(), alternativeLabels); } return commandLabels; }
@Override public void reload() { this.items = new ArrayList<>(); if (! plugin.getConfig().isSet("shopItems")) { plugin.getLogHandler().log(Level.WARNING, "Shop list is empty!"); return; } Map<String, Object> values = plugin.getConfig().getConfigurationSection("shopItems").getValues(false); for (Entry<String, Object> entry : values.entrySet()) { try { ShopItem item = readItem(entry.getKey(), (MemorySection) entry.getValue()); if (item != null) items.add(item); } catch (Throwable ex) { plugin.getLogHandler().log(Level.WARNING, Util.getUsefulStack(ex, "loading shop item " + entry.getKey())); } } }
static void index(DataManager manager) { DataManager.setManager(manager); HashMap<String, Object> groups = DataManager.getGroups(); if (groups != null) for (String key : groups.keySet()) { if (!(groups.get(key) instanceof MemorySection)) continue; PermissionsGroup pg = registerGroup((MemorySection) groups.get(key), key); if (pg != null) KevsPermissions.groups.put(key, pg); } if (KevsPermissions.groups.size() == 0 || KevsPermissions.groups.get(DataManager.getDefaultGroup()) == null) { HashMap<String, Object> options = new HashMap<>(); options.put("prefix", ""); options.put("suffix", ""); KevsPermissions.groups .put(DataManager.getDefaultGroup(), PermissionsFactory.createGroup( PermissionsFactory.createMeta(0, 0, DataManager.getDefaultGroup(), PermissionsOrigin.FILE, options, false), new PermissionsList(new ArrayList<>()))); } for (Player p : Bukkit.getOnlinePlayers()) { registerPlayer(p); } }
/** * Initializes a new engine data * * @param id id * @param data data * @throws Exception exception */ public EngineData(long id, Map<String, Object> data) throws Exception { super(); this.setId(id); this.itemContainer = new ItemContainer((int) id, ((MemorySection) data.get("gui")).getValues(false)); this.entity = (String) data.get("behaviour.entity"); this.rideType = RideType.valueOf((String) data.get("behaviour.riding")); this.ambientSound = new SoundBuilder((String) data.get("sound.ambient.name"), (double) data.get("sound.ambient.volume"), (double) data.get("sound.ambient.pitch")); this.walkingSound = new SoundBuilder((String) data.get("sound.walking.name"), (double) data.get("sound.walking.volume"), (double) data.get("sound.walking.pitch")); }
/** * Returns the feeding click sound. * * @return sound */ public SoundMeta getFeedingClickSound() { if (this.feedingClickSoundCache == null) { try { this.feedingClickSoundCache = new SoundBuilder(((MemorySection) this.getData("pet.feeding.click-sound")).getValues(false)); } catch (final Exception e) { PetBlocksPlugin.logger().log(Level.WARNING, "Failed to load feeding click-sound.", e); } } return this.feedingClickSoundCache; }
/** * Returns the feeding particleEffect. * * @return particleEffect */ public ParticleEffectMeta getFeedingClickParticleEffect() { if (this.feedingClickParticleCache == null) { try { this.feedingClickParticleCache = new ParticleEffectData(((MemorySection) this.getData("pet.feeding.click-particle")).getValues(false)); } catch (final Exception e) { PetBlocksPlugin.logger().log(Level.WARNING, "Failed to load feeding click-sound.", e); } } return this.feedingClickParticleCache; }
/** * Reloads the content from the fileSystem */ @Override public void reload() { this.engineContainers.clear(); this.plugin.reloadConfig(); final Map<String, Object> data = ((MemorySection) this.plugin.getConfig().get("engines")).getValues(false); for (final String key : data.keySet()) { final Map<String, Object> content = ((MemorySection) this.plugin.getConfig().get("engines." + key)).getValues(true); try { this.engineContainers.add(new EngineData(Integer.parseInt(key), content)); } catch (final Exception e) { PetBlocksPlugin.logger().log(Level.WARNING, "Failed to add content " + key + '.', e); } } }
/** * Reloads the content from the fileSystem */ @Override public void reload() { this.items.clear(); this.plugin.reloadConfig(); final Map<String, Object> data = ((MemorySection) this.plugin.getConfig().get("wardrobe." + this.costumeCategory)).getValues(false); for (final String key : data.keySet()) { try { final GUIItemContainer container = new ItemContainer(Integer.parseInt(key), ((MemorySection) data.get(key)).getValues(true)); this.items.add(container); } catch (final Exception e) { PetBlocksPlugin.logger().log(Level.WARNING, "Failed to load guiItem " + this.costumeCategory + '.' + key + '.'); } } }
/** * Returns the configuration values. * * @param configuration configuration * @return values */ @SuppressWarnings("unchecked") private static Map<String, Object> getConfigValues(Object configuration) { final Map<String, Object> configurationMap; if (!(configuration instanceof Map)) { final MemorySection section = (MemorySection) configuration; configurationMap = section.getValues(true); } else { configurationMap = (Map<String, Object>) configuration; } return configurationMap; }
@SuppressWarnings({ "unchecked"}) public TreeElement(String name, MemorySection section) { this.name = name; Map<String, Object> kids = section.getValues(false); for(Entry<String, Object> element : kids.entrySet()) { String key = element.getKey(); Object obj = element.getValue(); if(obj instanceof MemorySection) { childreen.put(key, new TreeElement<T>(key, (MemorySection) obj)); } else { try { T castedValue = (T) obj; if("data".equals(key)) { value = castedValue; } else if(value == null) { value = castedValue; } } catch(ClassCastException e) { //Ignore its the wrong type } } } }
SpawnItem(Map<String, Object> items) throws Exception { super(); this.id = (int) items.get("id"); this.damage = (int) items.get("damage"); this.owner = (String) items.get("owner"); this.displayName = (String) items.get("name"); this.spawnrate = Spawnrate.getSpawnrateFromName((String) items.get("rate")); for (final PotionEffectType potionEffectType : PotionEffectType.values()) { if (potionEffectType != null && items.containsKey("potioneffects." + potionEffectType.getId())) { this.potioneffectList.put(potionEffectType.getId(), new FastPotioneffect(((MemorySection) items.get("potioneffects." + potionEffectType.getId())).getValues(true))); } } }
/** * DeSerializes the given dataSource to an array * * @param clazz type of the object * @param dataSource dataSource like map or fileConfiguration * @param <T> type of the object * @return deSerialized array * @throws InstantiationException exception * @throws IllegalAccessException exception */ public static <T> T[] deserializeArray(Class<T> clazz, Object dataSource) throws InstantiationException, IllegalAccessException { final Map<String, Object> data = getDataFromSource(dataSource); final T[] objects = (T[]) Array.newInstance(clazz, data.size()); int i = 0; for (final String key : data.keySet()) { objects[i] = deserializeObject(clazz, ((MemorySection) data.get(key)).getValues(false)); i++; } return objects; }
/** * DeSerializes the given dataSource to a collection * * @param clazz type of the object * @param collectionClazz type of the collection * @param dataSource dataSource like map or fileConfiguration * @param <T> ype of the object * @param <E> type of the collection * @return deSerialized collection * @throws IllegalAccessException exception * @throws InstantiationException exception */ public static <T extends Collection, E> T deserializeCollection(Class<E> clazz, Class<T> collectionClazz, Object dataSource) throws IllegalAccessException, InstantiationException { final Map<String, Object> data = getDataFromSource(dataSource); Class<?> instanceClass = collectionClazz; if (instanceClass == List.class) instanceClass = ArrayList.class; else if (instanceClass == Set.class) instanceClass = HashSet.class; final T collection = (T) instanceClass.newInstance(); for (final String key : data.keySet()) { collection.add(deserializeObject(clazz, ((MemorySection) data.get(key)).getValues(false))); } return collection; }
/** * DeSerializes the given dataSource to an object * * @param clazz type of the object * @param dataSource dataSource like map or fileConfiguration * @param <T> type of the object * @return deSerialized object * @throws IllegalAccessException exception * @throws InstantiationException exception */ public static <T> T deserializeObject(Class<T> clazz, Object dataSource) throws IllegalAccessException, InstantiationException { final Map<String, Object> data = getDataFromSource(dataSource); final T object = clazz.newInstance(); Class<?> clazzQuery = clazz; while (clazzQuery != null) { for (final Field field : clazzQuery.getDeclaredFields()) { for (final Annotation annotation : field.getAnnotations()) { if (annotation.annotationType() == YamlSerialize.class) { final YamlSerialize yamlAnnotation = (YamlSerialize) annotation; field.setAccessible(true); if (data.containsKey(yamlAnnotation.value())) { if (isPrimitive(field.getType())) { field.set(object, data.get(yamlAnnotation.value())); } else if (field.getType().isArray()) { field.set(object, deserializeArray(clazzQuery, ((MemorySection) data.get(yamlAnnotation.value())).getValues(false))); } else if (Collection.class.isAssignableFrom(field.getType())) { field.set(object, deserializeCollection(getTypeFromHeavyField(field, 0), (Class<Collection>) field.getType(), ((MemorySection) data.get(yamlAnnotation.value())).getValues(false))); } else if (Map.class.isAssignableFrom(field.getType())) { field.set(object, deserializeMap(getTypeFromHeavyField(field, 1), (Class<Map>) field.getType(), ((MemorySection) data.get(yamlAnnotation.value())).getValues(false))); } else { field.set(object, deserializeObject(clazzQuery, ((MemorySection) data.get(yamlAnnotation.value())).getValues(false))); } } } } } clazzQuery = clazzQuery.getSuperclass(); } return object; }
/** * Returns the data from the dataSource * * @param dataSource dataSource * @return data */ private static Map<String, Object> getDataFromSource(Object dataSource) { if (dataSource instanceof Map) return (Map<String, Object>) dataSource; else return ((MemorySection) dataSource).getValues(false); }
/** * Loads the user data from storage. */ public void reloadUserData() { this.userConfig = new Config(plugin, "faction-users"); Object object = userConfig.get("users"); if (object instanceof MemorySection) { MemorySection section = (MemorySection) object; Collection<String> keys = section.getKeys(false); for (String id : keys) { users.put(UUID.fromString(id), (FactionUser) userConfig.get(section.getCurrentPath() + '.' + id)); } } }
@Override public void reloadEconomyData() { Object object = (this.balanceConfig = new Config(HCF.getPlugin(), "balances")).get("balances"); if (object instanceof MemorySection) { MemorySection section = (MemorySection) object; Set<String> keys = section.getKeys(false); for (String id : keys) { this.balanceMap.put(UUID.fromString(id), this.balanceConfig.getInt("balances." + id)); } } }
@Override public void reloadDeathbanData() { livesConfig = new Config(plugin, "lives"); Object object = livesConfig.get("lives"); if (object instanceof MemorySection) { MemorySection section = (MemorySection) object; Set<String> keys = section.getKeys(false); livesMap = new TObjectIntHashMap<>(keys.size(), Constants.DEFAULT_LOAD_FACTOR, 0); for (String id : keys) { livesMap.put(UUID.fromString(id), livesConfig.getInt(section.getCurrentPath() + "." + id)); } } else { livesMap = new TObjectIntHashMap<>(Constants.DEFAULT_CAPACITY, Constants.DEFAULT_LOAD_FACTOR, 0); } }
/** * Preforms all logic necessary to build a list of weights. * * @return The current state of the factory. */ public TemplateFactory build() { ConfigurationSection words = this.plugin.getConfig().getConfigurationSection(path + ".words"); for(Map.Entry<String, Object> entry : words.getValues(false).entrySet()) { MemorySection word = (MemorySection) entry.getValue(); String wordName = entry.getKey(); String templateBase = null; if(word.getString("template") == null) { if (plugin.isDebugEnabled()) { plugin.getLogger().info("Searching for default template for word: " + entry.getKey()); } templateBase = this.defaultTemplateBase; } else { String templateName = word.getString("template"); templateBase = this.getTemplateSectionForName(templateName).getString("expression"); } Double level = ((MemorySection) entry.getValue()).getDouble("level"); Pattern pattern = new Template(templateBase, wordName).build().getPattern(); this.weights.put(pattern, level); if (plugin.isDebugEnabled()) { plugin.getLogger().info(pattern.toString() + " -- " + level); } } return this; }
/** * Gets the default template for a section. * * @return The default template, if there is one. */ private String getDefaultTemplateBase() { ConfigurationSection section = plugin.getConfig().getConfigurationSection(path + ".templates"); for(Map.Entry<String, Object> entry : section.getValues(false).entrySet()) { if (((MemorySection)entry.getValue()).getBoolean("default")) { return ((MemorySection) entry.getValue()).getString("expression"); } } return null; }