本文整理汇总了Java中ninja.leaping.configurate.objectmapping.ObjectMapper.BoundInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper.BoundInstance方法的具体用法?Java ObjectMapper.BoundInstance怎么用?Java ObjectMapper.BoundInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ninja.leaping.configurate.objectmapping.ObjectMapper
的用法示例。
在下文中一共展示了ObjectMapper.BoundInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GriefPreventionConfig
import ninja.leaping.configurate.objectmapping.ObjectMapper; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public GriefPreventionConfig(Type type, Path path) {
this.type = type;
this.path = path;
try {
Files.createDirectories(path.getParent());
if (Files.notExists(path)) {
Files.createFile(path);
}
this.loader = HoconConfigurationLoader.builder().setPath(path).build();
this.configMapper = (ObjectMapper.BoundInstance) ObjectMapper.forClass(this.type.clazz).bindToNew();
reload();
save();
} catch (Exception e) {
SpongeImpl.getLogger().error("Failed to initialize configuration", e);
}
}
示例2: ClaimTemplateStorage
import ninja.leaping.configurate.objectmapping.ObjectMapper; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public ClaimTemplateStorage(Path path) {
this.filePath = path;
try {
Files.createDirectories(path.getParent());
if (Files.notExists(path)) {
Files.createFile(path);
}
this.loader = HoconConfigurationLoader.builder().setPath(path).build();
this.configMapper = (ObjectMapper.BoundInstance) ObjectMapper.forClass(ClaimTemplateConfig.class).bindToNew();
reload();
save();
} catch (Exception e) {
SpongeImpl.getLogger().error("Failed to initialize claim template data", e);
}
}
示例3: PlayerStorageData
import ninja.leaping.configurate.objectmapping.ObjectMapper; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public PlayerStorageData(Path path) {
try {
Files.createDirectories(path.getParent());
if (Files.notExists(path)) {
Files.createFile(path);
}
this.loader = HoconConfigurationLoader.builder().setPath(path).build();
this.configMapper = (ObjectMapper.BoundInstance) ObjectMapper.forClass(PlayerDataConfig.class).bindToNew();
reload();
save();
} catch (Exception e) {
SpongeImpl.getLogger().error("Failed to initialize configuration", e);
}
}
示例4: MessageStorage
import ninja.leaping.configurate.objectmapping.ObjectMapper; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public MessageStorage(Path path) {
try {
Files.createDirectories(path.getParent());
if (Files.notExists(path)) {
Files.createFile(path);
}
this.loader = HoconConfigurationLoader.builder().setPath(path).build();
this.configMapper = (ObjectMapper.BoundInstance) ObjectMapper.forClass(MessageDataConfig.class).bindToNew();
reload();
save();
} catch (Exception e) {
SpongeImpl.getLogger().error("Failed to initialize configuration", e);
}
}
示例5: resetMessageData
import ninja.leaping.configurate.objectmapping.ObjectMapper; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public void resetMessageData(String message) {
for (Map.Entry<Object, ? extends CommentedConfigurationNode> mapEntry : this.root.getNode(GriefPreventionPlugin.MOD_ID).getChildrenMap().entrySet()) {
CommentedConfigurationNode node = (CommentedConfigurationNode) mapEntry.getValue();
String key = "";
String comment = node.getComment().orElse(null);
if (comment == null && node.getKey() instanceof String) {
key = (String) node.getKey();
if (key.equalsIgnoreCase(message)) {
this.root.getNode(GriefPreventionPlugin.MOD_ID).removeChild(mapEntry.getKey());
}
}
}
try {
this.loader.save(this.root);
this.configMapper = (ObjectMapper.BoundInstance) ObjectMapper.forClass(MessageDataConfig.class).bindToNew();
this.configBase = this.configMapper.populate(this.root.getNode(GriefPreventionPlugin.MOD_ID));
} catch (IOException | ObjectMappingException e) {
e.printStackTrace();
}
GriefPreventionPlugin.instance.messageData = this.configBase;
}
示例6: ClaimStorageData
import ninja.leaping.configurate.objectmapping.ObjectMapper; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public ClaimStorageData(Path path, UUID worldUniqueId, ClaimDataConfig claimData) {
this.filePath = path;
this.folderPath = path.getParent();
try {
Files.createDirectories(path.getParent());
if (Files.notExists(path)) {
Files.createFile(path);
}
this.loader = HoconConfigurationLoader.builder().setPath(path).build();
this.configMapper = (ObjectMapper.BoundInstance) ObjectMapper.forClass(ClaimDataConfig.class).bind(claimData);
this.configMapper.getInstance().setClaimStorageData(this);
reload();
((EconomyDataConfig) this.configMapper.getInstance().getEconomyData()).activeConfig = GriefPreventionPlugin.getActiveConfig(worldUniqueId);
} catch (Exception e) {
SpongeImpl.getLogger().error("Failed to initialize configuration", e);
}
}
示例7: execute
import ninja.leaping.configurate.objectmapping.ObjectMapper; //导入方法依赖的package包/类
@Nonnull
@Override
public CommandResult execute(@Nonnull CommandSource src, @Nonnull CommandContext args)
throws CommandException {
Path potentialFile;
if (args.hasAny(CommandKeys.FILE_PATH)) {
potentialFile = (Path) getOrThrow(args, CommandKeys.FILE_PATH);
} else if (args.hasAny(CommandKeys.FILE_NAME)) {
String potentialFileName = (String) getOrThrow(args, CommandKeys.FILE_NAME);
potentialFile = SurvivalGamesPlugin.CONFIG_DIRECTORY.resolve(potentialFileName);
} else {
throw new CommandException(Text.of("No file name"));
}
SurvivalGame survivalGame = (SurvivalGame) getOrThrow(args, CommandKeys.SURVIVAL_GAME);
ConfigurationLoader<CommentedConfigurationNode> loader =
HoconConfigurationLoader.builder().setPath(potentialFile).build();
try {
CommentedConfigurationNode node = loader.load(ConfigurationOptions.defaults());
ObjectMapper.BoundInstance i = GameConfig.OBJECT_MAPPER.bind(survivalGame.getConfig());
i.serialize(node);
loader.save(node);
} catch (IOException | ObjectMappingException | RuntimeException e) {
e.printStackTrace();
throw new CommandException(Text.of("Error saving to file"), e);
}
sendSuccess(src, "Survival Game Saved", potentialFile.getFileName());
return CommandResult.success();
}
示例8: execute
import ninja.leaping.configurate.objectmapping.ObjectMapper; //导入方法依赖的package包/类
@Nonnull
@Override
public CommandResult execute(@Nonnull CommandSource src, @Nonnull CommandContext args)
throws CommandException {
Path potentialFile = (Path) getOrThrow(args, CommandKeys.FILE_PATH);
String survivalGameName = (String) getOrThrow(args, CommandKeys.SURVIVAL_GAME_NAME);
if (SurvivalGameRepository.contains(survivalGameName)) {
throw new CommandException(Text.of("Already exists a game of the same name"));
}
ConfigurationLoader<CommentedConfigurationNode> loader =
HoconConfigurationLoader.builder().setPath(potentialFile).build();
try {
CommentedConfigurationNode node = loader.load(ConfigurationOptions.defaults());
ObjectMapper.BoundInstance i = GameConfig.OBJECT_MAPPER.bindToNew();
GameConfig config = (GameConfig) i.populate(node);
SurvivalGame game = new SurvivalGame(survivalGameName, config);
SurvivalGameRepository.put(survivalGameName, game);
} catch (IOException | ObjectMappingException | RuntimeException e) {
e.printStackTrace();
throw new CommandException(Text.of("An error occurred when loading"));
}
sendSuccess(src, "Survival Game Loaded", survivalGameName);
return CommandResult.success();
}