@Override
public Object read(String key, ConfigurationSection section) {
List<?> list;
if (section.isConfigurationSection(key)) {
list = new ArrayList<>(section.getConfigurationSection(key).getValues(false).values());
} else {
list = section.getList(key);
}
Object array = Array.newInstance(type, list.size());
for (int i = 0; i < list.size(); i++) {
Object obj = list.get(i);
ConfigurationSection dummySection = new MemoryConfiguration();
dummySection.set("dummy", obj);
Array.set(array, i, handler.adaptIn(dummySection, "dummy", obj.getClass()));
}
return array;
}
java类org.bukkit.configuration.MemoryConfiguration的实例源码
ArrayAdapter.java 文件源码
项目:ConfigAPI
阅读 20
收藏 0
点赞 0
评论 0
CollectionAdapter.java 文件源码
项目:ConfigAPI
阅读 53
收藏 0
点赞 0
评论 0
@Override
public Collection read(String key, ConfigurationSection section) {
Collection collection;
List<?> originalList;
if (section.isConfigurationSection(key)) {
originalList = new ArrayList<>(section.getConfigurationSection(key).getValues(false).values());
} else {
originalList = section.getList(key);
}
try {
collection = implementationClass.getDeclaredConstructor(int.class).newInstance(originalList.size());
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
throw new InternalProcessingException("Could not create new instance of " + implementationClass.getName(), e);
}
for (Object obj: originalList) {
ConfigurationSection dummySection = new MemoryConfiguration();
dummySection.set("dummy", obj);
collection.add(handler.adaptIn(dummySection, "dummy", type));
}
return collection;
}
ConfigurationUtils.java 文件源码
项目:MagicLib
阅读 19
收藏 0
点赞 0
评论 0
public static ConfigurationSection replaceParameters(ConfigurationSection configuration, ConfigurationSection parameters)
{
if (configuration == null) return null;
ConfigurationSection replaced = new MemoryConfiguration();
Set<String> keys = configuration.getKeys(false);
for (String key : keys) {
Object value = configuration.get(key);
if (value == null) continue;
Object replacement = replaceParameters(value, parameters);
if (replacement != null) {
replaced.set(key, replacement);
}
}
return replaced;
}
ArenaStage.java 文件源码
项目:MagicArenas
阅读 24
收藏 0
点赞 0
评论 0
public void save(ConfigurationSection configuration) {
List<ConfigurationSection> mobsConfigurations = new ArrayList<ConfigurationSection>();
for (ArenaMobSpawner mob : mobs) {
ConfigurationSection section = new MemoryConfiguration();
mob.save(section);
mobsConfigurations.add(section);
}
configuration.set("mobs", mobsConfigurations);
configuration.set("spell_start", startSpell);
configuration.set("spell_end", endSpell);
List<String> mobSpawnList = new ArrayList<String>();
for (Location spawn : mobSpawns) {
mobSpawnList.add(ConfigurationUtils.fromLocation(spawn));
}
configuration.set("mob_spawns", mobSpawnList);
}
STBItemRegistry.java 文件源码
项目:sensibletoolbox
阅读 23
收藏 0
点赞 0
评论 0
private Configuration getItemAttributes(ItemStack stack) {
AttributeStorage storage = AttributeStorage.newTarget(stack, STB_ATTRIBUTE_ID);
YamlConfiguration conf = new YamlConfiguration();
try {
String s = storage.getData("");
if (s != null) {
conf.loadFromString(s);
if (Debugger.getInstance().getLevel() > 2) {
Debugger.getInstance().debug(3, "get item attributes for " + STBUtil.describeItemStack(stack) + ":");
for (String k : conf.getKeys(false)) {
Debugger.getInstance().debug(3, "- " + k + " = " + conf.get(k));
}
}
return conf;
} else {
throw new IllegalStateException("ItemStack " + stack + " has no STB attribute data!");
}
} catch (InvalidConfigurationException e) {
e.printStackTrace();
return new MemoryConfiguration();
}
}
OreRule.java 文件源码
项目:OrePlus
阅读 19
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
public static List<OreRule> LoadFromList (List<Map<?, ?>> configList) {
List<OreRule> result = new ArrayList<OreRule>();
if (configList == null)
return result;
for (Map<?, ?> item : configList) {
Map<String, Object> castItem = (Map<String, Object>)item;
MemoryConfiguration config = new MemoryConfiguration();
config.addDefaults(castItem);
result.add(new OreRule(config.getDefaults()));
}
return result;
}
ClearRule.java 文件源码
项目:OrePlus
阅读 20
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
public static List<ClearRule> LoadFromList (List<Map<?, ?>> configList) {
List<ClearRule> result = new ArrayList<ClearRule>();
if (configList == null)
return result;
for (Map<?, ?> item : configList) {
Map<String, Object> castItem = (Map<String, Object>)item;
MemoryConfiguration config = new MemoryConfiguration();
config.addDefaults(castItem);
result.add(new ClearRule(config.getDefaults()));
}
return result;
}
UserData.java 文件源码
项目:Essentials
阅读 22
收藏 0
点赞 0
评论 0
private ConfigurationSection _getKitTimestamps()
{
if (config.isConfigurationSection("timestamps.kits"))
{
final ConfigurationSection section = config.getConfigurationSection("timestamps.kits");
final ConfigurationSection newSection = new MemoryConfiguration();
for (String command : section.getKeys(false))
{
if (section.isLong(command))
{
newSection.set(command.toLowerCase(Locale.ENGLISH), section.getLong(command));
}
else if (section.isInt(command))
{
newSection.set(command.toLowerCase(Locale.ENGLISH), (long)section.getInt(command));
}
}
return newSection;
}
return new MemoryConfiguration();
}
Settings.java 文件源码
项目:Essentials
阅读 27
收藏 0
点赞 0
评论 0
public ConfigurationSection _getCommandCosts()
{
if (config.isConfigurationSection("command-costs"))
{
final ConfigurationSection section = config.getConfigurationSection("command-costs");
final ConfigurationSection newSection = new MemoryConfiguration();
for (String command : section.getKeys(false))
{
if (section.isDouble(command))
{
newSection.set(command.toLowerCase(Locale.ENGLISH), section.getDouble(command));
}
else if (section.isInt(command))
{
newSection.set(command.toLowerCase(Locale.ENGLISH), (double)section.getInt(command));
}
}
return newSection;
}
return null;
}
Settings.java 文件源码
项目:Essentials
阅读 27
收藏 0
点赞 0
评论 0
public ConfigurationSection _getKits()
{
if (config.isConfigurationSection("kits"))
{
final ConfigurationSection section = config.getConfigurationSection("kits");
final ConfigurationSection newSection = new MemoryConfiguration();
for (String kitItem : section.getKeys(false))
{
if (section.isConfigurationSection(kitItem))
{
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
}
}
return newSection;
}
return null;
}
MapAdapter.java 文件源码
项目:ConfigAPI
阅读 18
收藏 0
点赞 0
评论 0
@Override
public Map read(String key, ConfigurationSection section) {
ConfigurationSection originalMap = section.getConfigurationSection(key);
Map map = new HashMap();
originalMap.getValues(false).forEach((k, v) -> {
ConfigurationSection dummySection = new MemoryConfiguration();
dummySection.set("dummy", v);
map.put(k, handler.adaptIn(dummySection, "dummy", valueClass));
});
return map;
}
SavedMap.java 文件源码
项目:RpgPlus
阅读 20
收藏 0
点赞 0
评论 0
public ConfigurationSection getConfig() {
ConfigurationSection section = new MemoryConfiguration();
section.set("id", id);
section.set("world", world.getName());
section.set("image", imgName);
return section;
}
ConfigurationSectionUtilTest.java 文件源码
项目:RpgPlus
阅读 20
收藏 0
点赞 0
评论 0
@Test
public void testFlatten() throws Exception {
ConfigurationSection config = new MemoryConfiguration();
config.set("foo", "bar");
config.set("deeply.nested.property", "value");
Map<String, String> flattened = ConfigurationSectionUtil.flatten(config);
assertEquals(2, flattened.size());
assertEquals("bar", flattened.get("foo"));
assertEquals("value", flattened.get("deeply.nested.property"));
}
Lib.java 文件源码
项目:PopulationDensity
阅读 23
收藏 0
点赞 0
评论 0
/**
* Loads a file into memory as a MemoryConfiguration
*
* @param file The file to load, then delete after loading
* @return The MemoryConfiguration resulting from loading the file
*/
public static MemoryConfiguration loadResource(String file) {
initFiles(file);
FileConfiguration fc = loadFile(file);
MemoryConfiguration mc = new MemoryConfiguration(fc);
deleteFile(file);
return mc;
}
Transaction.java 文件源码
项目:ItemToChat
阅读 28
收藏 0
点赞 0
评论 0
public static MemorySection serialize(Transaction transaction) {
MemoryConfiguration serialized = new MemoryConfiguration();
serialized.set("sender", transaction.getSender().toString());
serialized.set("itemstack", transaction.getItemStack());
serialized.set("timestamp", transaction.getTimeStamp());
serialized.set("lifetime", transaction.getLifeTime());
return serialized;
}
ConfigUtils.java 文件源码
项目:EffectLib
阅读 38
收藏 0
点赞 0
评论 0
public static ConfigurationSection toConfigurationSection(Map<?, ?> nodeMap) {
ConfigurationSection newSection = new MemoryConfiguration();
for (Map.Entry<?, ?> entry : nodeMap.entrySet()) {
set(newSection, entry.getKey().toString(), entry.getValue());
}
return newSection;
}
ConfigurationUtils.java 文件源码
项目:MagicLib
阅读 23
收藏 0
点赞 0
评论 0
public static ConfigurationSection cloneConfiguration(ConfigurationSection section)
{
return addConfigurations(new MemoryConfiguration(), section);
}
ActionSpell.java 文件源码
项目:MagicLib
阅读 21
收藏 0
点赞 0
评论 0
@Override
protected void loadTemplate(ConfigurationSection template)
{
castOnNoTarget = true;
super.loadTemplate(template);
undoable = false;
requiresBuildPermission = false;
requiresBreakPermission = false;
usesBrush = template.getBoolean("uses_brush", false);
if (template.contains("actions"))
{
ConfigurationSection parameters = template.getConfigurationSection("parameters");
ConfigurationSection actionsNode = template.getConfigurationSection("actions");
Object baseActions = actionsNode.get("cast");
Collection<String> templateKeys = template.getKeys(false);
for (String templateKey : templateKeys)
{
if (templateKey.endsWith("_parameters"))
{
ConfigurationSection overrides = new MemoryConfiguration();
ConfigurationUtils.addConfigurations(overrides, template.getConfigurationSection(templateKey));
String handlerKey = templateKey.substring(0, templateKey.length() - 11);
handlerParameters.put(handlerKey, overrides);
// Auto-register base actions, kind of hacky to check for alternates though.
if (baseActions != null && !actionsNode.contains(handlerKey) && handlerKey.startsWith("alternate_"))
{
actionsNode.set(handlerKey, baseActions);
}
}
}
actionsNode = ConfigurationUtils.replaceParameters(actionsNode, parameters);
if (actionsNode != null)
{
Collection<String> actionKeys = actionsNode.getKeys(false);
for (String actionKey : actionKeys)
{
ActionHandler handler = new ActionHandler();
handler.load(this, actionsNode, actionKey);
handler.initialize(this, parameters);
usesBrush = usesBrush || handler.usesBrush();
undoable = undoable || handler.isUndoable();
requiresBuildPermission = requiresBuildPermission || handler.requiresBuildPermission();
requiresBreakPermission = requiresBreakPermission || handler.requiresBreakPermission();
actions.put(actionKey, handler);
}
}
}
undoable = template.getBoolean("undoable", undoable);
}
MemoryConfigurationOptions.java 文件源码
项目:BedrockAPI
阅读 20
收藏 0
点赞 0
评论 0
protected MemoryConfigurationOptions(MemoryConfiguration configuration) {
super(configuration);
}
MemoryConfigurationOptions.java 文件源码
项目:BedrockAPI
阅读 25
收藏 0
点赞 0
评论 0
public MemoryConfiguration configuration() {
return null;
}
FileConfigurationOptions.java 文件源码
项目:BedrockAPI
阅读 22
收藏 0
点赞 0
评论 0
protected FileConfigurationOptions(MemoryConfiguration configuration) {
super(configuration);
}
BukkitConfigurationLocalizationHandler.java 文件源码
项目:SimpleDev
阅读 17
收藏 0
点赞 0
评论 0
/**
* Updates the configuration data.
*
* @param configuration The new ConfigurationSection.
*/
public void update(MemoryConfiguration configuration) {
this.section = configuration;
// A little hack to enforce a cast from Map<String, String> to Map<String, Object>.
this.section.addDefaults((Map<String, Object>) (Map) TranslationManager.getDefaults());
}
BukkitConfigurationLocalizationHandler.java 文件源码
项目:SimpleDev
阅读 18
收藏 0
点赞 0
评论 0
/**
* Initializes the command handler.
*
* @param configuration The configuration to use.
*/
public BukkitConfigurationLocalizationHandler(MemoryConfiguration configuration) {
update(configuration);
}