當前位置: 首頁>>代碼示例>>Java>>正文


Java ConfigurationSerialization類代碼示例

本文整理匯總了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"));
}
 
開發者ID:Alvin-LB,項目名稱:NameTagChanger,代碼行數:24,代碼來源:NameTagChanger.java

示例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);
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:24,代碼來源:HCF.java

示例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);
}
 
開發者ID:EntryPointKR,項目名稱:MCLibrary,代碼行數:19,代碼來源:ConfigurationSerializableAdapter.java

示例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;
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:24,代碼來源:YamlConstructor.java

示例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));
}
 
開發者ID:KaiKikuchi,項目名稱:BetterKits,代碼行數:18,代碼來源:BetterKits.java

示例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);
}
 
開發者ID:lucko,項目名稱:helper,代碼行數:11,代碼來源:BukkitSerializableAdapterFactory.java

示例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;
}
 
開發者ID:EntryPointKR,項目名稱:MCLibrary,代碼行數:15,代碼來源:ConfigurationSerializableAdapter.java

示例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;
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:9,代碼來源:Variables.java

示例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;
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:8,代碼來源:Variables.java

示例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)
    }
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:14,代碼來源:JavaPluginLoader.java

示例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);
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:10,代碼來源:YamlRepresenter.java

示例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);
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:13,代碼來源:BukkitObjectInputStream.java

示例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);
}
 
開發者ID:lucko,項目名稱:helper,代碼行數:7,代碼來源:BukkitSerializableAdapterFactory.java

示例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();
        }
    }));
}
 
開發者ID:Slaymd,項目名稱:CaulCrafting,代碼行數:50,代碼來源:CaulCrafting.java

示例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);
}
 
開發者ID:ZombieStriker,項目名稱:NeuralNetworkAPI,代碼行數:45,代碼來源:Main.java


注:本文中的org.bukkit.configuration.serialization.ConfigurationSerialization類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。