本文整理汇总了Java中org.bukkit.configuration.MemoryConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java MemoryConfiguration类的具体用法?Java MemoryConfiguration怎么用?Java MemoryConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MemoryConfiguration类属于org.bukkit.configuration包,在下文中一共展示了MemoryConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
@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;
}
示例2: read
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
@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;
}
示例3: replaceParameters
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
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;
}
示例4: save
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
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);
}
示例5: getItemAttributes
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
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();
}
}
示例6: LoadFromList
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
@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;
}
示例7: LoadFromList
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
@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;
}
示例8: _getKitTimestamps
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
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();
}
示例9: _getCommandCosts
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
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;
}
示例10: _getKits
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
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;
}
示例11: read
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
@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;
}
示例12: getConfig
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
public ConfigurationSection getConfig() {
ConfigurationSection section = new MemoryConfiguration();
section.set("id", id);
section.set("world", world.getName());
section.set("image", imgName);
return section;
}
示例13: testFlatten
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
@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"));
}
示例14: loadResource
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
/**
* 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;
}
示例15: serialize
import org.bukkit.configuration.MemoryConfiguration; //导入依赖的package包/类
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;
}