java类org.bukkit.configuration.MemorySection的实例源码

FixedItemConfiguration.java 文件源码 项目:PetBlocks 阅读 19 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    }
}
Config.java 文件源码 项目:PetBlocks 阅读 21 收藏 0 点赞 0 评论 0
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.");
        }
    }
}
ParticleConfiguration.java 文件源码 项目:PetBlocks 阅读 17 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    }
}
FeedbackCreator.java 文件源码 项目:FusePort 阅读 20 收藏 0 点赞 0 评论 0
@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.java 文件源码 项目:BlockBall 阅读 17 收藏 0 点赞 0 评论 0
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.java 文件源码 项目:BlockBall 阅读 15 收藏 0 点赞 0 评论 0
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.java 文件源码 项目:BlockBall 阅读 21 收藏 0 点赞 0 评论 0
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));
}
CraftManager.java 文件源码 项目:RPGInventory 阅读 18 收藏 0 点赞 0 评论 0
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;
}
EventKey.java 文件源码 项目:HCFCore 阅读 19 收藏 0 点赞 0 评论 0
@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();
            }
        }
    }
}
EventKey.java 文件源码 项目:HCFCore 阅读 18 收藏 0 点赞 0 评论 0
@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();
            }
        }
    }
}
PlayTimeManager.java 文件源码 项目:ZorahPractice 阅读 19 收藏 0 点赞 0 评论 0
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);
    }
}
MessagesConfig.java 文件源码 项目:Duels 阅读 19 收藏 0 点赞 0 评论 0
@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));
        }
    }
}
TipsFactory.java 文件源码 项目:tips 阅读 15 收藏 0 点赞 0 评论 0
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));
    }
}
MailItemsMailManager.java 文件源码 项目:MailItems 阅读 19 收藏 0 点赞 0 评论 0
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);
    }
}
AbstractDataNode.java 文件源码 项目:NucleusFramework 阅读 17 收藏 0 点赞 0 评论 0
@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;
}
PermissionConsistencyTest.java 文件源码 项目:AuthMeReloaded 阅读 18 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
PermissionConsistencyTest.java 文件源码 项目:AuthMeReloaded 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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() + "'");
        }
    }
}
CommandConsistencyTest.java 文件源码 项目:AuthMeReloaded 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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;
}
ShopHandler.java 文件源码 项目:TeamSparkle 阅读 18 收藏 0 点赞 0 评论 0
@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()));
        }
    }
}
KevsPermissions.java 文件源码 项目:KevsPermissions 阅读 22 收藏 0 点赞 0 评论 0
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);
    }
}
EngineData.java 文件源码 项目:PetBlocks 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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"));
}
ConfigPet.java 文件源码 项目:PetBlocks 阅读 17 收藏 0 点赞 0 评论 0
/**
 * 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;
}
ConfigPet.java 文件源码 项目:PetBlocks 阅读 17 收藏 0 点赞 0 评论 0
/**
 * 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;
}
EngineConfiguration.java 文件源码 项目:PetBlocks 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    }
}
CostumeConfiguration.java 文件源码 项目:PetBlocks 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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 + '.');
        }
    }
}
SimpleCommandExecutor.java 文件源码 项目:PetBlocks 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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;
}
TreeElement.java 文件源码 项目:FusePort 阅读 19 收藏 0 点赞 0 评论 0
@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.java 文件源码 项目:BlockBall 阅读 19 收藏 0 点赞 0 评论 0
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)));
        }
    }
}
YamlSerializer.java 文件源码 项目:BlockBall 阅读 23 收藏 0 点赞 0 评论 0
/**
 * 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;
}
YamlSerializer.java 文件源码 项目:BlockBall 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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;
}


问题


面经


文章

微信
公众号

扫码关注公众号