diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java index 6015c9cc..cf5e0ad6 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/MMOCore.java @@ -157,7 +157,7 @@ public class MMOCore extends MMOPlugin { } if (getConfig().isConfigurationSection("default-playerdata")) - dataProvider.getDataManager().loadDefaultData(getConfig().getConfigurationSection("default-playerdata")); + playerDataManager.loadDefaultData(getConfig().getConfigurationSection("default-playerdata")); if (Bukkit.getPluginManager().getPlugin("Vault") != null) economy = new VaultEconomy(); @@ -262,7 +262,7 @@ public class MMOCore extends MMOPlugin { playerDataManager.initialize(EventPriority.LOW, EventPriority.NORMAL); // load guild data after loading player data - dataProvider.getGuildManager().load(); + nativeGuildManager.load(); // Toggleable Commands ToggleableCommand.register(); @@ -277,8 +277,8 @@ public class MMOCore extends MMOPlugin { public void onDisable() { // Save guild info - for (Guild guild : dataProvider.getGuildManager().getAll()) - dataProvider.getGuildManager().save(guild); + for (Guild guild : nativeGuildManager.getAll()) + nativeGuildManager.save(guild); // Close player data manager playerDataManager.close(); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 3a058dfc..4c4c3f4c 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -1293,7 +1293,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD } public static PlayerData get(@NotNull UUID uuid) { - return MMOCore.plugin.dataProvider.getDataManager().get(uuid); + return MMOCore.plugin.playerDataManager.get(uuid); } /** @@ -1325,10 +1325,10 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD * @return If player data for that player is loaded */ public static boolean has(UUID uuid) { - return MMOCore.plugin.dataProvider.getDataManager().isLoaded(uuid); + return MMOCore.plugin.playerDataManager.isLoaded(uuid); } public static Collection getAll() { - return MMOCore.plugin.dataProvider.getDataManager().getLoaded(); + return MMOCore.plugin.playerDataManager.getLoaded(); } } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/GuildCommand.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/GuildCommand.java index 7f0437ff..1e3f0d64 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/GuildCommand.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/GuildCommand.java @@ -49,7 +49,7 @@ public class GuildCommand extends RegisteredCommand { final Request req = MMOCore.plugin.requestManager.getRequest(uuid); Validate.isTrue(!req.isTimedOut() && req instanceof GuildInvite); invite = (GuildInvite) req; - Validate.isTrue(MMOCore.plugin.dataProvider.getGuildManager().isRegistered(invite.getGuild())); + Validate.isTrue(MMOCore.plugin.nativeGuildManager.isRegistered(invite.getGuild())); } catch (Exception exception) { return true; } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ClassCommandTreeNode.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ClassCommandTreeNode.java index ed88d719..ac215d41 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ClassCommandTreeNode.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ClassCommandTreeNode.java @@ -52,7 +52,7 @@ public class ClassCommandTreeNode extends CommandTreeNode { return CommandResult.SUCCESS; (data.hasSavedClass(profess) ? data.getClassInfo(profess) - : new SavedClassInformation(MMOCore.plugin.dataProvider.getDataManager().getDefaultData())).load(profess, data); + : new SavedClassInformation(MMOCore.plugin.playerDataManager.getDefaultData())).load(profess, data); if (data.isOnline()) { ConfigMessage.fromKey("class-select", "class", profess.getName()).send(data.getPlayer()); data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, 1, 1); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ExportDataTreeNode.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ExportDataTreeNode.java index f5b36328..223d09bd 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ExportDataTreeNode.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ExportDataTreeNode.java @@ -6,6 +6,7 @@ import io.lumine.mythic.lib.data.sql.SQLDataSource; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.manager.data.sql.SQLDataHandler; +import net.Indyuce.mmocore.manager.data.yaml.YAMLPlayerDataHandler; import org.bukkit.command.CommandSender; import org.bukkit.scheduler.BukkitRunnable; @@ -42,21 +43,25 @@ public class ExportDataTreeNode extends CommandTreeNode { @Override public CommandResult execute(CommandSender sender, String[] strings) { - if (!MMOCore.plugin.dataProvider.getDataManager().getLoaded().isEmpty()) { + if (!MMOCore.plugin.playerDataManager.getLoaded().isEmpty()) { sender.sendMessage("Please make sure no players are logged in when using this command. " + "If you are still seeing this message, restart your server and execute this command before any player logs in."); return CommandResult.FAILURE; } final List playerIds = Arrays.stream(new File(MMOCore.plugin.getDataFolder() + "/userdata").listFiles()) - .map(file -> UUID.fromString(file.getName().replace(".yml", ""))).collect(Collectors.toList()); + .map(file -> UUID.fromString(file.getName().replace(".yml", ""))) + .toList(); - // Initialize fake SQL data provider + // Initialize fake SQL & YAML data provider final SQLDataHandler sqlHandler; + final YAMLPlayerDataHandler ymlHandler; try { sqlHandler = new SQLDataHandler(new SQLDataSource(MMOCore.plugin)); + ymlHandler = new YAMLPlayerDataHandler(MMOCore.plugin); } catch (RuntimeException exception) { - sender.sendMessage("Could not initialize SQL provider (see console for stack trace): " + exception.getMessage()); + sender.sendMessage("Could not initialize SQL/YAML provider (see console for stack trace): " + exception.getMessage()); + exception.printStackTrace(); return CommandResult.FAILURE; } @@ -89,9 +94,7 @@ public class ExportDataTreeNode extends CommandTreeNode { final UUID playerId = playerIds.get(index); try { final PlayerData offlinePlayerData = new PlayerData(new MMOPlayerData(playerId)); - MMOCore.plugin.dataProvider.getDataManager().getDataHandler().loadData(offlinePlayerData); - - // Player data is loaded, now it gets saved through SQL + ymlHandler.loadData(offlinePlayerData); sqlHandler.saveData(offlinePlayerData, false); } catch (RuntimeException exception) { errorCount++; diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ResetCommandTreeNode.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ResetCommandTreeNode.java index 86b3467c..40cfee22 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ResetCommandTreeNode.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/ResetCommandTreeNode.java @@ -50,7 +50,7 @@ public class ResetCommandTreeNode extends CommandTreeNode { } PlayerData data = PlayerData.get(player); - MMOCore.plugin.dataProvider.getDataManager().getDefaultData().apply(data); + MMOCore.plugin.playerDataManager.getDefaultData().apply(data); data.setExperience(0); for (Profession profession : MMOCore.plugin.professionManager.getAll()) { data.getCollectionSkills().setExperience(profession, 0); @@ -245,7 +245,7 @@ public class ResetCommandTreeNode extends CommandTreeNode { } PlayerData data = PlayerData.get(player); - data.setLevel(MMOCore.plugin.dataProvider.getDataManager().getDefaultData().getLevel()); + data.setLevel(MMOCore.plugin.playerDataManager.getDefaultData().getLevel()); data.setExperience(0); for (Profession profession : MMOCore.plugin.professionManager.getAll()) { data.getCollectionSkills().setExperience(profession, 0); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/SaveDataTreeNode.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/SaveDataTreeNode.java index 5e389121..1e768f3e 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/SaveDataTreeNode.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/command/rpg/admin/SaveDataTreeNode.java @@ -30,7 +30,7 @@ public class SaveDataTreeNode extends CommandTreeNode { return CommandResult.FAILURE; } - MMOCore.plugin.dataProvider.getDataManager().getDataHandler().saveData(PlayerData.get(player), false); + MMOCore.plugin.playerDataManager.getDataHandler().saveData(PlayerData.get(player), false); return CommandResult.SUCCESS; } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassConfirmation.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassConfirmation.java index 135662fa..3d079ebc 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassConfirmation.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/ClassConfirmation.java @@ -145,7 +145,7 @@ public class ClassConfirmation extends EditableInventory { playerData.setClass(profess); else (playerData.hasSavedClass(profess) ? playerData.getClassInfo(profess) - : new SavedClassInformation(MMOCore.plugin.dataProvider.getDataManager().getDefaultData())).load(profess, playerData); + : new SavedClassInformation(MMOCore.plugin.playerDataManager.getDefaultData())).load(profess, playerData); ConfigMessage.fromKey("class-select", "class", profess.getName()).send(player); MMOCore.plugin.soundManager.getSound(SoundEvent.SELECT_CLASS).playTo(player); player.closeInventory(); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildCreation.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildCreation.java index 7a942933..eef891e2 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildCreation.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildCreation.java @@ -40,16 +40,16 @@ public class EditableGuildCreation extends EditableInventory { if (item.getFunction().equals("create")) { new ChatInput(player, PlayerInput.InputType.GUILD_CREATION_TAG, context.getInventoryHolder(), input -> { - if(MMOCore.plugin.dataProvider.getGuildManager().getConfig().shouldUppercaseTags()) + if(MMOCore.plugin.nativeGuildManager.getConfig().shouldUppercaseTags()) input = input.toUpperCase(); - if(check(player, input, MMOCore.plugin.dataProvider.getGuildManager().getConfig().getTagRules())) { + if(check(player, input, MMOCore.plugin.nativeGuildManager.getConfig().getTagRules())) { String tag = input; new ChatInput(player, PlayerInput.InputType.GUILD_CREATION_NAME, context.getInventoryHolder(), name -> { - if(check(player, name, MMOCore.plugin.dataProvider.getGuildManager().getConfig().getNameRules())) { - MMOCore.plugin.dataProvider.getGuildManager().newRegisteredGuild(playerData.getUniqueId(), name, tag); - MMOCore.plugin.dataProvider.getGuildManager().getGuild(tag.toLowerCase()).addMember(playerData.getUniqueId()); + if(check(player, name, MMOCore.plugin.nativeGuildManager.getConfig().getNameRules())) { + MMOCore.plugin.nativeGuildManager.newRegisteredGuild(playerData.getUniqueId(), name, tag); + MMOCore.plugin.nativeGuildManager.getGuild(tag.toLowerCase()).addMember(playerData.getUniqueId()); InventoryManager.GUILD_VIEW.newInventory(playerData).open(); player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); @@ -76,7 +76,7 @@ public class EditableGuildCreation extends EditableInventory { if(input.length() <= rules.getMax() && input.length() >= rules.getMin()) if(input.matches(rules.getRegex())) - if(!MMOCore.plugin.dataProvider.getGuildManager().isRegistered(input)) + if(!MMOCore.plugin.nativeGuildManager.isRegistered(input)) return true; else reason = ConfigMessage.fromKey("guild-creation.reasons.already-taken").asLine(); diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildView.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildView.java index 7e4d22e6..95bea9e8 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildView.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/gui/social/guild/EditableGuildView.java @@ -190,7 +190,7 @@ public class EditableGuildView extends EditableInventory { if (item.getFunction().equals("disband")) { if (!playerData.getGuild().getOwner().equals(playerData.getUniqueId())) return; - MMOCore.plugin.dataProvider.getGuildManager().unregisterGuild(playerData.getGuild()); + MMOCore.plugin.nativeGuildManager.unregisterGuild(playerData.getGuild()); player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); player.closeInventory(); return; diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/guild/provided/Guild.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/guild/provided/Guild.java index 93feefc8..380d155b 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/guild/provided/Guild.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/guild/provided/Guild.java @@ -74,7 +74,7 @@ public class Guild implements AbstractGuild { // Disband the guild if no member left if (members.size() < 1) { - MMOCore.plugin.dataProvider.getGuildManager().unregisterGuild(this); + MMOCore.plugin.nativeGuildManager.unregisterGuild(this); return; } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/OfflinePlayerData.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/OfflinePlayerData.java index 1ee00c1c..8cdb710c 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/OfflinePlayerData.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/OfflinePlayerData.java @@ -19,6 +19,6 @@ public interface OfflinePlayerData extends OfflineDataHolder { public abstract long getLastLogin(); public static OfflinePlayerData get(UUID uuid) { - return MMOCore.plugin.dataProvider.getDataManager().getOffline(uuid); + return MMOCore.plugin.playerDataManager.getOffline(uuid); } } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/sql/MMOCoreDataSynchronizer.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/sql/MMOCoreDataSynchronizer.java index bd8eaff0..3335bf49 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/sql/MMOCoreDataSynchronizer.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/manager/data/sql/MMOCoreDataSynchronizer.java @@ -75,7 +75,7 @@ public class MMOCoreDataSynchronizer extends SQLDataSynchronizer { } getData().setUnlockedItems(unlockedItems); if (!isEmpty(result.getString("guild"))) { - final Guild guild = MMOCore.plugin.dataProvider.getGuildManager().getGuild(result.getString("guild")); + final Guild guild = MMOCore.plugin.nativeGuildManager.getGuild(result.getString("guild")); if (guild != null) getData().setGuild(guild.hasMember(getData().getUniqueId()) ? guild : null); } if (!isEmpty(result.getString("attributes"))) getData().getAttributes().load(result.getString("attributes")); diff --git a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/GuildListener.java b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/GuildListener.java index 784e4b2e..71e411f9 100644 --- a/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/GuildListener.java +++ b/MMOCore-Dist/src/main/java/net/Indyuce/mmocore/listener/GuildListener.java @@ -14,7 +14,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; public class GuildListener implements Listener { @EventHandler(priority = EventPriority.LOW) public void a(AsyncPlayerChatEvent event) { - if (!event.getMessage().startsWith(MMOCore.plugin.dataProvider.getGuildManager().getConfig().getPrefix())) + if (!event.getMessage().startsWith(MMOCore.plugin.nativeGuildManager.getConfig().getPrefix())) return; PlayerData data = PlayerData.get(event.getPlayer()); @@ -25,7 +25,7 @@ public class GuildListener implements Listener { // Run it sync Bukkit.getScheduler().runTask(MMOCore.plugin, () -> { - ConfigMessage format = ConfigMessage.fromKey("guild-chat", "player", data.getPlayer().getName(), "tag", data.getGuild().getTag(), "message", event.getMessage().substring(MMOCore.plugin.dataProvider.getGuildManager().getConfig().getPrefix().length())); + ConfigMessage format = ConfigMessage.fromKey("guild-chat", "player", data.getPlayer().getName(), "tag", data.getGuild().getTag(), "message", event.getMessage().substring(MMOCore.plugin.nativeGuildManager.getConfig().getPrefix().length())); GuildChatEvent called = new GuildChatEvent(data, format.asLine()); Bukkit.getPluginManager().callEvent(called); if (!called.isCancelled())