Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Config {
- private ObjectMapper<Config>.BoundInstance configMapper;
- private HoconConfigurationLoader loader;
- private ConfigurationNode node;
- public Config(HoconConfigurationLoader loader) {
- this.loader = loader;
- try {
- this.configMapper = ObjectMapper.forObject(this);
- } catch (ObjectMappingException e) {
- e.printStackTrace();
- }
- this.load();
- }
- public void save() {
- try {
- SimpleConfigurationNode out = SimpleConfigurationNode.root();
- this.configMapper.serialize(out);
- this.loader.save(out);
- } catch (ObjectMappingException | IOException e) {
- e.printStackTrace();
- }
- }
- public void load() {
- try {
- this.configMapper.populate(this.loader.load());
- } catch (ObjectMappingException | IOException e) {
- e.printStackTrace();
- }
- }
- public ConfigurationNode getNode() {
- return node;
- }
- public void doConfig(Player player) {
- UUID uuid = player.getUniqueId();
- //String suuid = uuid.toString();
- PlayerLevel playerLevel = LevelManager.playerLevelList.get(uuid);
- int level = playerLevel.getLevel();
- int xp = playerLevel.getExp();
- try {
- ConfigurationNode node = loader.load();
- node.getNode("Players", "Level", uuid).setValue(TypeTokens.INTEGER_TOKEN, level);
- node.getNode("Players", "XP", uuid).setValue(TypeTokens.INTEGER_TOKEN, xp);
- loader.save(node);
- } catch (IOException | ObjectMappingException e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment