本文整理汇总了Java中org.bukkit.configuration.serialization.ConfigurationSerialization类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationSerialization类的具体用法?Java ConfigurationSerialization怎么用?Java ConfigurationSerialization使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationSerialization类属于org.bukkit.configuration.serialization包,在下文中一共展示了ConfigurationSerialization类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enable
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
/**
* Enables NameTagChanger and creates necessary packet handlers.
* Is done automatically by the constructor, so only use this method
* if the disable() method has previously been called.
*/
public void enable() {
if (plugin == null) {
return;
}
if (!ReflectUtil.isVersionHigherThan(1, 7, 10)) {
printMessage("NameTagChanger has detected that you are running 1.7 or lower. This probably means that NameTagChanger will not work or throw errors, but you are still free to try and use it.\nIf you are not a developer, please consider contacting the developer of " + plugin.getName() + " and informing them about this message.");
}
ConfigurationSerialization.registerClass(Skin.class);
Validate.isTrue(!enabled, "NameTagChanger is already enabled");
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
packetHandler = new ProtocolLibPacketHandler(plugin);
} else {
packetHandler = new ChannelPacketHandler(plugin);
}
enabled = true;
Metrics metrics = new Metrics(plugin);
metrics.addCustomChart(new Metrics.SimplePie("packet_implementation", () -> packetHandler instanceof ProtocolLibPacketHandler ? "ProtocolLib" : "ChannelInjector"));
}
示例2: registerConfiguration
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
private void registerConfiguration() {
ConfigurationSerialization.registerClass(CaptureZone.class);
ConfigurationSerialization.registerClass(Deathban.class);
ConfigurationSerialization.registerClass(Claim.class);
ConfigurationSerialization.registerClass(Subclaim.class);
ConfigurationSerialization.registerClass(Deathban.class);
ConfigurationSerialization.registerClass(FactionUser.class);
ConfigurationSerialization.registerClass(ClaimableFaction.class);
ConfigurationSerialization.registerClass(ConquestFaction.class);
ConfigurationSerialization.registerClass(CapturableFaction.class);
ConfigurationSerialization.registerClass(KothFaction.class);
ConfigurationSerialization.registerClass(EndPortalFaction.class);
ConfigurationSerialization.registerClass(Faction.class);
ConfigurationSerialization.registerClass(FactionMember.class);
ConfigurationSerialization.registerClass(PlayerFaction.class);
ConfigurationSerialization.registerClass(RoadFaction.class);
ConfigurationSerialization.registerClass(SpawnFaction.class);
ConfigurationSerialization.registerClass(GlowstoneMountainFaction.class);
ConfigurationSerialization.registerClass(RoadFaction.NorthRoadFaction.class);
ConfigurationSerialization.registerClass(RoadFaction.EastRoadFaction.class);
ConfigurationSerialization.registerClass(RoadFaction.SouthRoadFaction.class);
ConfigurationSerialization.registerClass(RoadFaction.WestRoadFaction.class);
}
示例3: deserialize
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
public static ConfigurationSerializable deserialize(Map<String, Object> map) {
if (map == null)
return null;
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
Object val = entry.getValue();
if (!(val instanceof Map))
continue;
Map<String, Object> subMap = (Map<String, Object>) val;
if (subMap.containsKey(SERIALIZED_TYPE_KEY)) {
map.put(key, deserialize(subMap));
}
}
return ConfigurationSerialization.deserializeObject(map);
}
示例4: construct
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
@Override
public Object construct(Node node) {
if (node.isTwoStepsConstruction()) {
throw new YAMLException("Unexpected referential mapping structure. Node: " + node);
}
Map<?, ?> raw = (Map<?, ?>) super.construct(node);
if (raw.containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) {
Map<String, Object> typed = new LinkedHashMap<String, Object>(raw.size());
for (Map.Entry<?, ?> entry : raw.entrySet()) {
typed.put(entry.getKey().toString(), entry.getValue());
}
try {
return ConfigurationSerialization.deserializeObject(typed);
} catch (IllegalArgumentException ex) {
throw new YAMLException("Could not deserialize object", ex);
}
}
return raw;
}
示例5: onEnable
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
@Override
public void onEnable() {
instance=this;
ConfigurationSerialization.registerClass(Kit.class);
ConfigurationSerialization.registerClass(PlayerData.class);
config = new Config(instance);
this.loadData();
Messages.load(this);
this.getServer().getPluginManager().registerEvents(new EventListener(this), this);
// commands executor
CommandExec ce = new CommandExec(this);
this.getDescription().getCommands().keySet().forEach(cmd -> this.getCommand(cmd).setExecutor(ce));
}
示例6: write
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
@Override
public void write(JsonWriter out, ConfigurationSerializable value) {
Map<String, Object> serialized = value.serialize();
Map<String, Object> map = new LinkedHashMap<>(serialized.size() + 1);
map.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(value.getClass()));
map.putAll(serialized);
gson.toJson(map, RAW_OUTPUT_TYPE, out);
}
示例7: serialize
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
public static Map<String, Object> serialize(ConfigurationSerializable serializable) {
Map<String, Object> serialized = new HashMap<>();
serialized.putAll(serializable.serialize());
for (Map.Entry<String, Object> entry : serialized.entrySet()) {
String key = entry.getKey();
Object val = entry.getValue();
if (val instanceof ConfigurationSerializable) {
serialized.put(key, serialize((ConfigurationSerializable) val));
}
}
serialized.put(SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(serializable.getClass()));
return serialized;
}
示例8: getID
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
@Override
@Nullable
public String getID(final @NonNull Class<?> c) {
if (ConfigurationSerializable.class.isAssignableFrom(c) && Classes.getSuperClassInfo(c) == Classes.getExactClassInfo(Object.class))
return configurationSerializablePrefix + ConfigurationSerialization.getAlias((Class<? extends ConfigurationSerializable>) c);
return null;
}
示例9: getClass
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
@Override
@Nullable
public Class<? extends ConfigurationSerializable> getClass(final @NonNull String id) {
if (id.startsWith(configurationSerializablePrefix))
return ConfigurationSerialization.getClassByAlias(id.substring(configurationSerializablePrefix.length()));
return null;
}
示例10: removeClass
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
private void removeClass(String name) {
Class<?> clazz = classes.remove(name);
try {
if ((clazz != null) && (ConfigurationSerializable.class.isAssignableFrom(clazz))) {
Class<? extends ConfigurationSerializable> serializable = clazz.asSubclass(ConfigurationSerializable.class);
ConfigurationSerialization.unregisterClass(serializable);
}
} catch (NullPointerException ex) {
// Boggle!
// (Native methods throwing NPEs is not fun when you can't stop it before-hand)
}
}
示例11: representData
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
@Override
public Node representData(Object data) {
ConfigurationSerializable serializable = (ConfigurationSerializable) data;
Map<String, Object> values = new LinkedHashMap<String, Object>();
values.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(serializable.getClass()));
values.putAll(serializable.serialize());
return super.representData(values);
}
示例12: resolveObject
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
@Override
protected Object resolveObject(Object obj) throws IOException {
if (obj instanceof Wrapper) {
try {
(obj = ConfigurationSerialization.deserializeObject(((Wrapper<?>) obj).map)).getClass(); // NPE
} catch (Throwable ex) {
throw newIOException("Failed to deserialize object", ex);
}
}
return super.resolveObject(obj);
}
示例13: read
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
@Override
public ConfigurationSerializable read(JsonReader in) {
Map<String, Object> map = gson.fromJson(in, RAW_OUTPUT_TYPE);
deserializeChildren(map);
return ConfigurationSerialization.deserializeObject(map);
}
示例14: onEnable
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
@Override
public void onEnable(){
ConfigurationSerialization.registerClass(CraftArray.class);
//Commands executors
this.getCommand("caulcrafting").setExecutor(new CaulCraftingCommandExecutor(this));
this.getCommand("caulcraftingconfig").setExecutor(new CaulCraftingConfigCommandExecutor(this));
//LISTENERS - EVENTS register
PluginManager plugman = getServer().getPluginManager();
plugman.registerEvents(new AsyncPlayerChatListener(this), this);
plugman.registerEvents(new ItemDropListener(this), this);
plugman.registerEvents(new BlockPistonExtendListener(this), this);
plugman.registerEvents(new BlockPistonRetractListener(this), this);
//Setup languages
languagesAvailable.put("en", "English");
languagesAvailable.put("fr", "Français");
languagesAvailable.put("ru", "Русский");
languagesAvailable.put("nl", "Dutch");
languagesAvailable.put("de", "Deutsch");
languagesAvailable.put("ja", "日本語");
languagesAvailable.put("pl", "Polski");
languagesAvailable.put("vi", "Tiếng Việt");
languagesAvailable.put("es", "Español");
languagesAvailable.put("pt", "Português");
languagesAvailable.put("zh", "中文");
languagesAvailable.put("hu", "Magyar");
languagesAvailable.put("lv", "Latviešu valoda");
//Defaults configs files (locales..)
configUtils.setupDefaults();
//Load defaults configs if empty
saveDefaultConfig();
//Updating config
configUpdate.update();
//nms class for items name utils
if(setupItemsname()){
nmsItemsName = true;
} else {
getLogger().severe(lang.getTranslation("updater_warn_1"));
getLogger().severe(lang.getTranslation("updater_warn_2"));
nmsItemsName = false;
}
//Stats (bstats) https://bstats.org/plugin/bukkit/CaulCrafting
Metrics metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SimplePie("used_languages", new Callable<String>() {
@Override
public String call() throws Exception {
return lang.getLanguage();
}
}));
}
示例15: onLoad
import org.bukkit.configuration.serialization.ConfigurationSerialization; //导入依赖的package包/类
/**
* This class is used to make a Neural Network figure out whether a username
* is valid
*/
public void onLoad() {
ConfigurationSerialization.registerClass(NNBaseEntity.class);
ConfigurationSerialization.registerClass(NNAI.class);
ConfigurationSerialization.registerClass(Layer.class);
ConfigurationSerialization.registerClass(Senses.class);
ConfigurationSerialization.registerClass(Controler.class);
ConfigurationSerialization.registerClass(Senses2D.class);
ConfigurationSerialization.registerClass(Senses3D.class);
ConfigurationSerialization.registerClass(Sensory2D_Booleans.class);
ConfigurationSerialization.registerClass(Sensory2D_Letters.class);
ConfigurationSerialization.registerClass(Sensory2D_Numbers.class);
ConfigurationSerialization.registerClass(Sensory3D_Booleans.class);
ConfigurationSerialization.registerClass(Sensory3D_Numbers.class);
ConfigurationSerialization.registerClass(Neuron.class);
ConfigurationSerialization.registerClass(InputNeuron.class);
ConfigurationSerialization.registerClass(InputBlockNeuron.class);
ConfigurationSerialization.registerClass(InputBooleanNeuron.class);
ConfigurationSerialization.registerClass(InputLetterNeuron.class);
ConfigurationSerialization.registerClass(InputNumberNeuron.class);
ConfigurationSerialization.registerClass(InputTickNeuron.class);
ConfigurationSerialization.registerClass(OutputNeuron.class);
ConfigurationSerialization.registerClass(BiasNeuron.class);
ConfigurationSerialization.registerClass(LogicalAND.class);
ConfigurationSerialization.registerClass(LogicalOR.class);
ConfigurationSerialization.registerClass(LogicalXOR.class);
ConfigurationSerialization.registerClass(LogicalXNOR.class);
ConfigurationSerialization.registerClass(LogicalNAND.class);
ConfigurationSerialization.registerClass(LogicalInverted.class);
ConfigurationSerialization.registerClass(LogicalNOR.class);
ConfigurationSerialization.registerClass(BlackJackHelper.class);
ConfigurationSerialization.registerClass(NumberAdder.class);
ConfigurationSerialization.registerClass(BotGuesser.class);
ConfigurationSerialization.registerClass(PrimeNumberBot.class);
ConfigurationSerialization.registerClass(MusicBot.class);
ConfigurationSerialization.registerClass(SwearBot.class);
}