本文整理汇总了Java中ninja.leaping.configurate.objectmapping.serialize.TypeSerializers类的典型用法代码示例。如果您正苦于以下问题:Java TypeSerializers类的具体用法?Java TypeSerializers怎么用?Java TypeSerializers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypeSerializers类属于ninja.leaping.configurate.objectmapping.serialize包,在下文中一共展示了TypeSerializers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadCameras
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
/**
* loads the cameras from the config
*
* may only be called after the worlds of the server have been loaded
*/
public void loadCameras() {
plugin.getCameras().clear();
// yes i know it is bad to register it every time the config is loaded but i doesn't seem to work otherwise...
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Location.class), new LocationSerializer());
config.getNode("cameras").getChildrenList().forEach((node) -> {
try {
Camera cam = node.getValue(TypeToken.of(Camera.class));
cam.setLocation(node.getNode("location").getValue(TypeToken.of(Location.class)));
plugin.getCameras().put(cam.getId(), cam);
} catch (ObjectMappingException e) {
System.out.println(TypeSerializers.getDefaultSerializers().get(TypeToken.of(Location.class)));
logger.warn("Couldn't load Camera: " + e.getMessage());
}
});
logger.info(String.format("Loaded %d Cameras", plugin.getCameras().size()));
}
示例2: onFirst
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
protected void onFirst() throws PluginDisableException, ServerDisableException {
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(EMessageBuilder.class), new EMessageBuilderSerializer(this));
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(EFormat.class), new EFormatSerializer());
this.threadAsync = this.getGame().getScheduler().createAsyncExecutor(this);
this.threadSync = this.getGame().getScheduler().createSyncExecutor(this);
this.chat = new EChat(this);
this.configs = new EAConfig(this);
this.messages = new EAMessage(this);
this.server = new EServer(this);
this.managerUtils = new ManagerUtils(this);
this.service = new ManagerService(this);
new ManagerRegister(this);
}
示例3: onPreInit
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
@Listener
public void onPreInit(GamePreInitializationEvent evt) {
logger.info("Pre-Initializing...");
DataRegistration.builder()
.dataClass(RottenData.class)
.immutableClass(ImmutableRottenData.class)
.builder(new RottenDataBuilder())
.manipulatorId(PLUGIN_ID + "_rottendata")
.dataName("Rotten Food")
.buildAndRegister(Sponge.getPluginManager().getPlugin(PLUGIN_ID).get());
//Sponge.getDataManager().registerBuilder(RottenData.class, new RottenDataBuilder());
TypeSerializers.getDefaultSerializers().registerType(ItemConfig.TOKEN, new ItemConfigSerializer());
}
示例4: VirtualChestItemStackSerializer
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
VirtualChestItemStackSerializer(VirtualChestPlugin plugin)
{
this.plugin = plugin;
this.serializers = TypeSerializers.getDefaultSerializers().newChild()
.registerType(TypeToken.of(Text.class), TEXT_SERIALIZER)
.registerType(ITEM_ENCHANTMENT, ITEM_ENCHANTMENT_SERIALIZER)
.registerType(TypeToken.of(GameProfile.class), GAME_PROFILE_SERIALIZER);
}
示例5: init
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
public static void init(File rootDir) throws IOException
{
carrotshopsFile = new File(rootDir, "shops.json");
rootDir.mkdirs();
carrotshopsFile.createNewFile();
TypeSerializerCollection serializers = TypeSerializers.getDefaultSerializers().newChild();
serializers.registerType(TypeToken.of(Inventory.class), new InventorySerializer());
serializers.registerType(TypeToken.of(Currency.class), new CurrencySerializer());
ConfigurationOptions options = ConfigurationOptions.defaults().setSerializers(serializers);
loader = HoconConfigurationLoader.builder().setFile(carrotshopsFile).build();
shopsNode = loader.load(options);
}
示例6: reload
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
public void reload() {
try {
this.root = this.loader.load(ConfigurationOptions.defaults()
.setSerializers(
TypeSerializers.getDefaultSerializers().newChild().registerType(TypeToken.of(IpSet.class), new IpSet.IpSetSerializer()))
.setHeader(GriefPreventionPlugin.CONFIG_HEADER));
this.configBase = this.configMapper.populate(this.root.getNode(GriefPreventionPlugin.MOD_ID));
} catch (Exception e) {
SpongeImpl.getLogger().error("Failed to load configuration", e);
}
}
示例7: onInit
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
@Override
public void onInit(GameInitializationEvent event) {
if (!Sponge.getPluginManager().getPlugin("nuvotifier").isPresent()) {
return;
}
Sponge.getEventManager().registerListeners(UltimateCore.get(), new VotifierListener());
UltimateCore.get().getTickService().addRunnable("votifier", new VotifierTickRunnable());
//Config
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Vote.class), new VoteSerializer());
this.config = new RawModuleConfig("votifier");
onReload(null);
}
示例8: onInit
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
@Override
public void onInit(GameInitializationEvent event) {
//Config
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(BloodEffect.class), new BloodEffect.BloodEffectSerializer());
config = new RawModuleConfig("blood");
//Check if all entity types are in the config
CommentedConfigurationNode node = config.get();
boolean modified = false;
//For every entitytype, if it doesnt exist in the config add it
for (EntityType type : Sponge.getRegistry().getAllOf(CatalogTypes.ENTITY_TYPE)) {
if (!Living.class.isAssignableFrom(type.getEntityClass())) {
continue;
}
//If entitytype is not in config
if (node.getNode("types", type.getId(), "enabled").getValue() == null) {
modified = true;
CommentedConfigurationNode typenode = node.getNode("types", type.getId());
try {
typenode.setValue(TypeToken.of(BloodEffect.class), BloodEffects.DEFAULT);
} catch (ObjectMappingException e) {
ErrorLogger.log(e, "Failed to set default blood effect.");
}
}
}
if (modified) {
config.save(node);
}
//Load blood effects from config
BloodEffects.reload();
//Listeners
Sponge.getEventManager().registerListeners(UltimateCore.get(), new BloodListener());
}
示例9: onInit
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
@Override
public void onInit(GameInitializationEvent event) {
//Config
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Automessage.class), new AutomessageSerializer());
config = new RawModuleConfig("automessage");
//Runnables
try {
for (Automessage message : config.get().getNode("automessages").getList(TypeToken.of(Automessage.class))) {
message.start();
}
} catch (ObjectMappingException e) {
ErrorLogger.log(e, "Failed to load automessages from config.");
}
}
示例10: setup
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
private static void setup() {
// cache main thread in this class
getMainThread();
// register configurate serializers
TypeSerializerCollection defs = TypeSerializers.getDefaultSerializers();
defs.registerType(TypeToken.of(JsonArray.class), JsonArraySerializer.INSTANCE);
defs.registerType(TypeToken.of(JsonObject.class), JsonObjectSerializer.INSTANCE);
defs.registerType(TypeToken.of(JsonPrimitive.class), JsonPrimitiveSerializer.INSTANCE);
defs.registerType(TypeToken.of(JsonNull.class), JsonNullSerializer.INSTANCE);
defs.registerType(TypeToken.of(GsonSerializable.class), GsonSerializableConfigurateProxy.INSTANCE);
}
示例11: register
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
public static void register() {
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(CuboidRegion.class), new CuboidRegionSerializer());
}
示例12: register
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
public static void register() {
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(ShopItem.class), new ShopItemSerializer());
}
示例13: register
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
public static void register() {
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Shop.class), new ShopSerializer());
}
示例14: register
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
public static void register() {
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(ShopType.class), new ShopTypeSerializer());
}
示例15: register
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers; //导入依赖的package包/类
public static void register() {
TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(ShopContainer.class), new ShopContainerSerializer());
}