diff --git a/src/main/java/net/Indyuce/mmocore/api/data/YAMLDataProvider.java b/src/main/java/net/Indyuce/mmocore/api/data/YAMLDataProvider.java index 63c8963d..1d89cdc2 100644 --- a/src/main/java/net/Indyuce/mmocore/api/data/YAMLDataProvider.java +++ b/src/main/java/net/Indyuce/mmocore/api/data/YAMLDataProvider.java @@ -8,11 +8,12 @@ import net.Indyuce.mmocore.manager.data.YAMLPlayerDataManager; public class YAMLDataProvider implements DataProvider { private final YAMLPlayerDataManager playerManager; private final YAMLGuildDataManager guildManager; + public YAMLDataProvider() { playerManager = new YAMLPlayerDataManager(); guildManager = new YAMLGuildDataManager(); } - + @Override public PlayerDataManager getDataManager() { return playerManager; diff --git a/src/main/java/net/Indyuce/mmocore/manager/data/MySQLOfflinePlayerData.java b/src/main/java/net/Indyuce/mmocore/manager/data/MySQLOfflinePlayerData.java index ea507891..870ccdcd 100644 --- a/src/main/java/net/Indyuce/mmocore/manager/data/MySQLOfflinePlayerData.java +++ b/src/main/java/net/Indyuce/mmocore/manager/data/MySQLOfflinePlayerData.java @@ -14,32 +14,32 @@ import net.Indyuce.mmocore.api.util.MMOSQL; import net.Indyuce.mmocore.api.util.MMOSQL.Table; public class MySQLOfflinePlayerData extends OfflinePlayerData { - int level; - long lastLogin; - PlayerClass profess; - List friends; - + private int level; + private long lastLogin; + private PlayerClass profess; + private List friends; + public MySQLOfflinePlayerData(UUID uuid) { super(uuid); - + ResultSet result = MMOSQL.getResult("SELECT * FROM mmocore_playerdata WHERE uuid = '" + uuid + "';"); try { - if(!result.next()) { + if (!result.next()) { level = 0; lastLogin = 0; profess = MMOCore.plugin.classManager.getDefaultClass(); friends = new ArrayList(); - } - else while(result.next()) { - level = result.getInt("level"); - lastLogin = result.getLong("last_login"); - profess = result.getString("class").equalsIgnoreCase("null") ? MMOCore.plugin.classManager.getDefaultClass() - : MMOCore.plugin.classManager.get(result.getString("class")); - if(!result.getString("friends").equalsIgnoreCase("null")) - MMOSQL.getJSONArray(result.getString("friends")).forEach(str -> friends.add(UUID.fromString(str))); - else friends = new ArrayList(); - } + } else + while (result.next()) { + level = result.getInt("level"); + lastLogin = result.getLong("last_login"); + profess = result.getString("class").equalsIgnoreCase("null") ? MMOCore.plugin.classManager.getDefaultClass() : MMOCore.plugin.classManager.get(result.getString("class")); + if (!result.getString("friends").equalsIgnoreCase("null")) + MMOSQL.getJSONArray(result.getString("friends")).forEach(str -> friends.add(UUID.fromString(str))); + else + friends = new ArrayList(); + } } catch (SQLException e) { e.printStackTrace(); } @@ -48,8 +48,7 @@ public class MySQLOfflinePlayerData extends OfflinePlayerData { @Override public void removeFriend(UUID uuid) { friends.remove(uuid); - new MMOSQL(Table.PLAYERDATA, uuid).updateData("friends", - friends.stream().map(friend -> friend.toString()).collect(Collectors.toList())); + new MMOSQL(Table.PLAYERDATA, uuid).updateData("friends", friends.stream().map(friend -> friend.toString()).collect(Collectors.toList())); } @Override @@ -59,7 +58,7 @@ public class MySQLOfflinePlayerData extends OfflinePlayerData { @Override public PlayerClass getProfess() { - return profess; + return profess; } @Override