forked from Upstream/mmocore
Fixed a bug with '/mmocore admin exportdata'
This commit is contained in:
parent
7593226610
commit
be62d73fcb
@ -157,7 +157,7 @@ public class MMOCore extends MMOPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getConfig().isConfigurationSection("default-playerdata"))
|
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();
|
if (Bukkit.getPluginManager().getPlugin("Vault") != null) economy = new VaultEconomy();
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ public class MMOCore extends MMOPlugin {
|
|||||||
playerDataManager.initialize(EventPriority.LOW, EventPriority.NORMAL);
|
playerDataManager.initialize(EventPriority.LOW, EventPriority.NORMAL);
|
||||||
|
|
||||||
// load guild data after loading player data
|
// load guild data after loading player data
|
||||||
dataProvider.getGuildManager().load();
|
nativeGuildManager.load();
|
||||||
|
|
||||||
// Toggleable Commands
|
// Toggleable Commands
|
||||||
ToggleableCommand.register();
|
ToggleableCommand.register();
|
||||||
@ -277,8 +277,8 @@ public class MMOCore extends MMOPlugin {
|
|||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
||||||
// Save guild info
|
// Save guild info
|
||||||
for (Guild guild : dataProvider.getGuildManager().getAll())
|
for (Guild guild : nativeGuildManager.getAll())
|
||||||
dataProvider.getGuildManager().save(guild);
|
nativeGuildManager.save(guild);
|
||||||
|
|
||||||
// Close player data manager
|
// Close player data manager
|
||||||
playerDataManager.close();
|
playerDataManager.close();
|
||||||
|
@ -1293,7 +1293,7 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerData get(@NotNull UUID uuid) {
|
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
|
* @return If player data for that player is loaded
|
||||||
*/
|
*/
|
||||||
public static boolean has(UUID uuid) {
|
public static boolean has(UUID uuid) {
|
||||||
return MMOCore.plugin.dataProvider.getDataManager().isLoaded(uuid);
|
return MMOCore.plugin.playerDataManager.isLoaded(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<PlayerData> getAll() {
|
public static Collection<PlayerData> getAll() {
|
||||||
return MMOCore.plugin.dataProvider.getDataManager().getLoaded();
|
return MMOCore.plugin.playerDataManager.getLoaded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class GuildCommand extends RegisteredCommand {
|
|||||||
final Request req = MMOCore.plugin.requestManager.getRequest(uuid);
|
final Request req = MMOCore.plugin.requestManager.getRequest(uuid);
|
||||||
Validate.isTrue(!req.isTimedOut() && req instanceof GuildInvite);
|
Validate.isTrue(!req.isTimedOut() && req instanceof GuildInvite);
|
||||||
invite = (GuildInvite) req;
|
invite = (GuildInvite) req;
|
||||||
Validate.isTrue(MMOCore.plugin.dataProvider.getGuildManager().isRegistered(invite.getGuild()));
|
Validate.isTrue(MMOCore.plugin.nativeGuildManager.isRegistered(invite.getGuild()));
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ public class ClassCommandTreeNode extends CommandTreeNode {
|
|||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
|
|
||||||
(data.hasSavedClass(profess) ? data.getClassInfo(profess)
|
(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()) {
|
if (data.isOnline()) {
|
||||||
ConfigMessage.fromKey("class-select", "class", profess.getName()).send(data.getPlayer());
|
ConfigMessage.fromKey("class-select", "class", profess.getName()).send(data.getPlayer());
|
||||||
data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, 1, 1);
|
data.getPlayer().playSound(data.getPlayer().getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, 1, 1);
|
||||||
|
@ -6,6 +6,7 @@ import io.lumine.mythic.lib.data.sql.SQLDataSource;
|
|||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.manager.data.sql.SQLDataHandler;
|
import net.Indyuce.mmocore.manager.data.sql.SQLDataHandler;
|
||||||
|
import net.Indyuce.mmocore.manager.data.yaml.YAMLPlayerDataHandler;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@ -42,21 +43,25 @@ public class ExportDataTreeNode extends CommandTreeNode {
|
|||||||
@Override
|
@Override
|
||||||
public CommandResult execute(CommandSender sender, String[] strings) {
|
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. " +
|
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.");
|
"If you are still seeing this message, restart your server and execute this command before any player logs in.");
|
||||||
return CommandResult.FAILURE;
|
return CommandResult.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<UUID> playerIds = Arrays.stream(new File(MMOCore.plugin.getDataFolder() + "/userdata").listFiles())
|
final List<UUID> 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 SQLDataHandler sqlHandler;
|
||||||
|
final YAMLPlayerDataHandler ymlHandler;
|
||||||
try {
|
try {
|
||||||
sqlHandler = new SQLDataHandler(new SQLDataSource(MMOCore.plugin));
|
sqlHandler = new SQLDataHandler(new SQLDataSource(MMOCore.plugin));
|
||||||
|
ymlHandler = new YAMLPlayerDataHandler(MMOCore.plugin);
|
||||||
} catch (RuntimeException exception) {
|
} 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;
|
return CommandResult.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,9 +94,7 @@ public class ExportDataTreeNode extends CommandTreeNode {
|
|||||||
final UUID playerId = playerIds.get(index);
|
final UUID playerId = playerIds.get(index);
|
||||||
try {
|
try {
|
||||||
final PlayerData offlinePlayerData = new PlayerData(new MMOPlayerData(playerId));
|
final PlayerData offlinePlayerData = new PlayerData(new MMOPlayerData(playerId));
|
||||||
MMOCore.plugin.dataProvider.getDataManager().getDataHandler().loadData(offlinePlayerData);
|
ymlHandler.loadData(offlinePlayerData);
|
||||||
|
|
||||||
// Player data is loaded, now it gets saved through SQL
|
|
||||||
sqlHandler.saveData(offlinePlayerData, false);
|
sqlHandler.saveData(offlinePlayerData, false);
|
||||||
} catch (RuntimeException exception) {
|
} catch (RuntimeException exception) {
|
||||||
errorCount++;
|
errorCount++;
|
||||||
|
@ -50,7 +50,7 @@ public class ResetCommandTreeNode extends CommandTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerData data = PlayerData.get(player);
|
PlayerData data = PlayerData.get(player);
|
||||||
MMOCore.plugin.dataProvider.getDataManager().getDefaultData().apply(data);
|
MMOCore.plugin.playerDataManager.getDefaultData().apply(data);
|
||||||
data.setExperience(0);
|
data.setExperience(0);
|
||||||
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
|
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
|
||||||
data.getCollectionSkills().setExperience(profession, 0);
|
data.getCollectionSkills().setExperience(profession, 0);
|
||||||
@ -245,7 +245,7 @@ public class ResetCommandTreeNode extends CommandTreeNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerData data = PlayerData.get(player);
|
PlayerData data = PlayerData.get(player);
|
||||||
data.setLevel(MMOCore.plugin.dataProvider.getDataManager().getDefaultData().getLevel());
|
data.setLevel(MMOCore.plugin.playerDataManager.getDefaultData().getLevel());
|
||||||
data.setExperience(0);
|
data.setExperience(0);
|
||||||
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
|
for (Profession profession : MMOCore.plugin.professionManager.getAll()) {
|
||||||
data.getCollectionSkills().setExperience(profession, 0);
|
data.getCollectionSkills().setExperience(profession, 0);
|
||||||
|
@ -30,7 +30,7 @@ public class SaveDataTreeNode extends CommandTreeNode {
|
|||||||
return CommandResult.FAILURE;
|
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;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ public class ClassConfirmation extends EditableInventory {
|
|||||||
playerData.setClass(profess);
|
playerData.setClass(profess);
|
||||||
else
|
else
|
||||||
(playerData.hasSavedClass(profess) ? playerData.getClassInfo(profess)
|
(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);
|
ConfigMessage.fromKey("class-select", "class", profess.getName()).send(player);
|
||||||
MMOCore.plugin.soundManager.getSound(SoundEvent.SELECT_CLASS).playTo(player);
|
MMOCore.plugin.soundManager.getSound(SoundEvent.SELECT_CLASS).playTo(player);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
|
@ -40,16 +40,16 @@ public class EditableGuildCreation extends EditableInventory {
|
|||||||
|
|
||||||
if (item.getFunction().equals("create")) {
|
if (item.getFunction().equals("create")) {
|
||||||
new ChatInput(player, PlayerInput.InputType.GUILD_CREATION_TAG, context.getInventoryHolder(), input -> {
|
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();
|
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;
|
String tag = input;
|
||||||
|
|
||||||
new ChatInput(player, PlayerInput.InputType.GUILD_CREATION_NAME, context.getInventoryHolder(), name -> {
|
new ChatInput(player, PlayerInput.InputType.GUILD_CREATION_NAME, context.getInventoryHolder(), name -> {
|
||||||
if(check(player, name, MMOCore.plugin.dataProvider.getGuildManager().getConfig().getNameRules())) {
|
if(check(player, name, MMOCore.plugin.nativeGuildManager.getConfig().getNameRules())) {
|
||||||
MMOCore.plugin.dataProvider.getGuildManager().newRegisteredGuild(playerData.getUniqueId(), name, tag);
|
MMOCore.plugin.nativeGuildManager.newRegisteredGuild(playerData.getUniqueId(), name, tag);
|
||||||
MMOCore.plugin.dataProvider.getGuildManager().getGuild(tag.toLowerCase()).addMember(playerData.getUniqueId());
|
MMOCore.plugin.nativeGuildManager.getGuild(tag.toLowerCase()).addMember(playerData.getUniqueId());
|
||||||
|
|
||||||
InventoryManager.GUILD_VIEW.newInventory(playerData).open();
|
InventoryManager.GUILD_VIEW.newInventory(playerData).open();
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
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.length() <= rules.getMax() && input.length() >= rules.getMin())
|
||||||
if(input.matches(rules.getRegex()))
|
if(input.matches(rules.getRegex()))
|
||||||
if(!MMOCore.plugin.dataProvider.getGuildManager().isRegistered(input))
|
if(!MMOCore.plugin.nativeGuildManager.isRegistered(input))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
reason = ConfigMessage.fromKey("guild-creation.reasons.already-taken").asLine();
|
reason = ConfigMessage.fromKey("guild-creation.reasons.already-taken").asLine();
|
||||||
|
@ -190,7 +190,7 @@ public class EditableGuildView extends EditableInventory {
|
|||||||
if (item.getFunction().equals("disband")) {
|
if (item.getFunction().equals("disband")) {
|
||||||
if (!playerData.getGuild().getOwner().equals(playerData.getUniqueId()))
|
if (!playerData.getGuild().getOwner().equals(playerData.getUniqueId()))
|
||||||
return;
|
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.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
return;
|
return;
|
||||||
|
@ -74,7 +74,7 @@ public class Guild implements AbstractGuild {
|
|||||||
|
|
||||||
// Disband the guild if no member left
|
// Disband the guild if no member left
|
||||||
if (members.size() < 1) {
|
if (members.size() < 1) {
|
||||||
MMOCore.plugin.dataProvider.getGuildManager().unregisterGuild(this);
|
MMOCore.plugin.nativeGuildManager.unregisterGuild(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,6 @@ public interface OfflinePlayerData extends OfflineDataHolder {
|
|||||||
public abstract long getLastLogin();
|
public abstract long getLastLogin();
|
||||||
|
|
||||||
public static OfflinePlayerData get(UUID uuid) {
|
public static OfflinePlayerData get(UUID uuid) {
|
||||||
return MMOCore.plugin.dataProvider.getDataManager().getOffline(uuid);
|
return MMOCore.plugin.playerDataManager.getOffline(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public class MMOCoreDataSynchronizer extends SQLDataSynchronizer<PlayerData> {
|
|||||||
}
|
}
|
||||||
getData().setUnlockedItems(unlockedItems);
|
getData().setUnlockedItems(unlockedItems);
|
||||||
if (!isEmpty(result.getString("guild"))) {
|
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 (guild != null) getData().setGuild(guild.hasMember(getData().getUniqueId()) ? guild : null);
|
||||||
}
|
}
|
||||||
if (!isEmpty(result.getString("attributes"))) getData().getAttributes().load(result.getString("attributes"));
|
if (!isEmpty(result.getString("attributes"))) getData().getAttributes().load(result.getString("attributes"));
|
||||||
|
@ -14,7 +14,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|||||||
public class GuildListener implements Listener {
|
public class GuildListener implements Listener {
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void a(AsyncPlayerChatEvent event) {
|
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;
|
return;
|
||||||
|
|
||||||
PlayerData data = PlayerData.get(event.getPlayer());
|
PlayerData data = PlayerData.get(event.getPlayer());
|
||||||
@ -25,7 +25,7 @@ public class GuildListener implements Listener {
|
|||||||
|
|
||||||
// Run it sync
|
// Run it sync
|
||||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> {
|
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());
|
GuildChatEvent called = new GuildChatEvent(data, format.asLine());
|
||||||
Bukkit.getPluginManager().callEvent(called);
|
Bukkit.getPluginManager().callEvent(called);
|
||||||
if (!called.isCancelled())
|
if (!called.isCancelled())
|
||||||
|
Loading…
Reference in New Issue
Block a user