forked from Upstream/mmocore
!Small refactor
This commit is contained in:
parent
80bfe6faba
commit
b2b5693676
@ -8,6 +8,7 @@ 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();
|
||||
|
@ -14,10 +14,10 @@ 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<UUID> friends;
|
||||
private int level;
|
||||
private long lastLogin;
|
||||
private PlayerClass profess;
|
||||
private List<UUID> friends;
|
||||
|
||||
public MySQLOfflinePlayerData(UUID uuid) {
|
||||
super(uuid);
|
||||
@ -25,21 +25,21 @@ public class MySQLOfflinePlayerData extends OfflinePlayerData {
|
||||
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<UUID>();
|
||||
}
|
||||
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<UUID>();
|
||||
}
|
||||
} 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<UUID>();
|
||||
}
|
||||
} 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
|
||||
|
Loading…
Reference in New Issue
Block a user