/**
* 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"));
}
java类org.bukkit.configuration.serialization.ConfigurationSerialization的实例源码
NameTagChanger.java 文件源码
项目:NameTagChanger
阅读 23
收藏 0
点赞 0
评论 0
HCF.java 文件源码
项目:HCFCore
阅读 21
收藏 0
点赞 0
评论 0
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);
}
HCF.java 文件源码
项目:HCFCore
阅读 22
收藏 0
点赞 0
评论 0
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);
}
ConfigurationSerializableAdapter.java 文件源码
项目:MCLibrary
阅读 23
收藏 0
点赞 0
评论 0
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);
}
YamlConstructor.java 文件源码
项目:Thermos-Bukkit
阅读 21
收藏 0
点赞 0
评论 0
@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;
}
BetterKits.java 文件源码
项目:BetterKits
阅读 18
收藏 0
点赞 0
评论 0
@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));
}
BukkitSerializableAdapterFactory.java 文件源码
项目:helper
阅读 27
收藏 0
点赞 0
评论 0
@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);
}
ConfigurationSerializableAdapter.java 文件源码
项目:MCLibrary
阅读 20
收藏 0
点赞 0
评论 0
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;
}
Variables.java 文件源码
项目:Skript
阅读 27
收藏 0
点赞 0
评论 0
@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;
}
Variables.java 文件源码
项目:Skript
阅读 24
收藏 0
点赞 0
评论 0
@Override
@Nullable
public Class<? extends ConfigurationSerializable> getClass(final @NonNull String id) {
if (id.startsWith(configurationSerializablePrefix))
return ConfigurationSerialization.getClassByAlias(id.substring(configurationSerializablePrefix.length()));
return null;
}
JavaPluginLoader.java 文件源码
项目:Thermos-Bukkit
阅读 18
收藏 0
点赞 0
评论 0
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)
}
}
YamlRepresenter.java 文件源码
项目:Thermos-Bukkit
阅读 20
收藏 0
点赞 0
评论 0
@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);
}
BukkitObjectInputStream.java 文件源码
项目:Thermos-Bukkit
阅读 46
收藏 0
点赞 0
评论 0
@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);
}
BukkitSerializableAdapterFactory.java 文件源码
项目:helper
阅读 24
收藏 0
点赞 0
评论 0
@Override
public ConfigurationSerializable read(JsonReader in) {
Map<String, Object> map = gson.fromJson(in, RAW_OUTPUT_TYPE);
deserializeChildren(map);
return ConfigurationSerialization.deserializeObject(map);
}
CaulCrafting.java 文件源码
项目:CaulCrafting
阅读 20
收藏 0
点赞 0
评论 0
@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();
}
}));
}
Main.java 文件源码
项目:NeuralNetworkAPI
阅读 46
收藏 0
点赞 0
评论 0
/**
* 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);
}
GsonTest.java 文件源码
项目:MCLibrary
阅读 22
收藏 0
点赞 0
评论 0
@Before
public void inject() {
Injector.injectServer(MockFactory.createMockServer());
ConfigurationSerialization.registerClass(ItemStack.class);
ConfigurationSerialization.registerClass(MockItemMeta.class);
}
ConfigurationSerializableHelper.java 文件源码
项目:ConfigAPI
阅读 20
收藏 0
点赞 0
评论 0
public static Collection<Class<? extends ConfigurationSerializable>> registeredClasses() {
Map<String, Class<? extends ConfigurationSerializable>> aliases = InternalsHelper.getField(
InternalsHelper.staticFieldFor(ConfigurationSerialization.class, "aliases"), null
);
return aliases.values();
}
ConfigurationSerializableHelper.java 文件源码
项目:ConfigAPI
阅读 21
收藏 0
点赞 0
评论 0
public static <T> T deserialize(Map<String, Object> map, Class<T> cls) {
return cls.cast(ConfigurationSerialization.deserializeObject(map, cls.asSubclass(ConfigurationSerializable.class)));
}
StandardEnemy.java 文件源码
项目:QuestManager
阅读 20
收藏 0
点赞 0
评论 0
/**
* Registers this class as configuration serializable with only the default alias
*/
public static void registerWithoutAliases() {
ConfigurationSerialization.registerClass(StandardEnemy.class);
}
Wrapper.java 文件源码
项目:Thermos-Bukkit
阅读 19
收藏 0
点赞 0
评论 0
static Wrapper<ImmutableMap<String, ?>> newWrapper(ConfigurationSerializable obj) {
return new Wrapper<ImmutableMap<String, ?>>(ImmutableMap.<String, Object>builder().put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(obj.getClass())).putAll(obj.serialize()).build());
}
Loot.java 文件源码
项目:QuestManager
阅读 19
收藏 0
点赞 0
评论 0
/**
* Registers this class as configuration serializable with all defined
* {@link aliases aliases}
*/
public static void registerWithAliases() {
for (aliases alias : aliases.values()) {
ConfigurationSerialization.registerClass(Loot.class, alias.getAlias());
}
}
Loot.java 文件源码
项目:QuestManager
阅读 21
收藏 0
点赞 0
评论 0
/**
* Registers this class as configuration serializable with only the default alias
*/
public static void registerWithoutAliases() {
ConfigurationSerialization.registerClass(Loot.class);
}
DynamicLoot.java 文件源码
项目:QuestManager
阅读 15
收藏 0
点赞 0
评论 0
/**
* Registers this class as configuration serializable with all defined
* {@link aliases aliases}
*/
public static void registerWithAliases() {
for (aliases alias : aliases.values()) {
ConfigurationSerialization.registerClass(DynamicLoot.class, alias.getAlias());
}
}
MuteNPC.java 文件源码
项目:QuestManager
阅读 20
收藏 0
点赞 0
评论 0
/**
* Registers this class as configuration serializable with all defined
* {@link aliases aliases}
*/
public static void registerWithAliases() {
for (aliases alias : aliases.values()) {
ConfigurationSerialization.registerClass(MuteNPC.class, alias.getAlias());
}
}
Party.java 文件源码
项目:QuestManager
阅读 19
收藏 0
点赞 0
评论 0
/**
* Registers this class as configuration serializable with all defined
* {@link aliases aliases}
*/
public static void registerWithAliases() {
for (aliases alias : aliases.values()) {
ConfigurationSerialization.registerClass(Party.class, alias.getAlias());
}
}
Party.java 文件源码
项目:QuestManager
阅读 20
收藏 0
点赞 0
评论 0
/**
* Registers this class as configuration serializable with only the default alias
*/
public static void registerWithoutAliases() {
ConfigurationSerialization.registerClass(Party.class);
}
TeleportNPC.java 文件源码
项目:QuestManager
阅读 20
收藏 0
点赞 0
评论 0
/**
* Registers this class as configuration serializable with all defined
* {@link aliases aliases}
*/
public static void registerWithAliases() {
for (aliases alias : aliases.values()) {
ConfigurationSerialization.registerClass(TeleportNPC.class, alias.getAlias());
}
}
QuestPlayer.java 文件源码
项目:QuestManager
阅读 22
收藏 0
点赞 0
评论 0
/**
* Registers this class as configuration serializable with only the default alias
*/
public static void registerWithoutAliases() {
ConfigurationSerialization.registerClass(QuestPlayer.class);
}
ReflectEffect.java 文件源码
项目:QuestManager
阅读 23
收藏 0
点赞 0
评论 0
/**
* Registers this class as configuration serializable with all defined
* {@link aliases aliases}
*/
public static void registerWithAliases() {
for (aliases alias : aliases.values()) {
ConfigurationSerialization.registerClass(ReflectEffect.class, alias.getAlias());
}
}