Added UUID support for player data

This commit is contained in:
Daniel Saukel 2015-07-17 13:14:59 +02:00
parent ab139fdec9
commit c8434dec64
3 changed files with 10 additions and 7 deletions

View File

@ -144,7 +144,7 @@ public class DPlayer {
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file); FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
playerConfig.set(player.getName(), System.currentTimeMillis()); playerConfig.set(player.getUniqueId().toString(), System.currentTimeMillis());
try { try {
playerConfig.save(file); playerConfig.save(file);

View File

@ -137,7 +137,7 @@ public class GameWorld {
if (config.getTimeToNextPlay() != 0) { if (config.getTimeToNextPlay() != 0) {
// read PlayerConfig // read PlayerConfig
Long time = getPlayerTime(dungeon, player.getName()); Long time = getPlayerTime(dungeon, player);
if (time != -1) { if (time != -1) {
if (time + (config.getTimeToNextPlay() * 1000 * 60 * 60) > System.currentTimeMillis()) { if (time + (config.getTimeToNextPlay() * 1000 * 60 * 60) > System.currentTimeMillis()) {
return false; return false;
@ -177,7 +177,7 @@ public class GameWorld {
if (new File(p.getDataFolder() + "/dungeons/" + dungeonName).isDirectory()) { if (new File(p.getDataFolder() + "/dungeons/" + dungeonName).isDirectory()) {
if (played.equalsIgnoreCase(dungeonName) || played.equalsIgnoreCase("any")) { if (played.equalsIgnoreCase(dungeonName) || played.equalsIgnoreCase("any")) {
Long time = getPlayerTime(dungeonName, player.getName()); Long time = getPlayerTime(dungeonName, player);
if (time != -1) { if (time != -1) {
if (config.getFinishedAll().contains(played)) { if (config.getFinishedAll().contains(played)) {
numOfNeeded++; numOfNeeded++;
@ -214,7 +214,7 @@ public class GameWorld {
return true; return true;
} }
public static long getPlayerTime(String dungeon, String name) { public static long getPlayerTime(String dungeon, Player player) {
File file = new File(p.getDataFolder() + "/dungeons/" + dungeon, "players.yml"); File file = new File(p.getDataFolder() + "/dungeons/" + dungeon, "players.yml");
if (!file.exists()) { if (!file.exists()) {
@ -226,8 +226,11 @@ public class GameWorld {
} }
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file); FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(file);
if (playerConfig.contains(name)) { if (playerConfig.contains(player.getUniqueId().toString())) {
return playerConfig.getLong(name); return playerConfig.getLong(player.getUniqueId().toString());
}
if (playerConfig.contains(player.getName())) {
return playerConfig.getLong(player.getName());
} }
return -1; return -1;
} }

View File

@ -1,6 +1,6 @@
name: DungeonsXL name: DungeonsXL
main: com.dre.dungeonsxl.P main: com.dre.dungeonsxl.P
version: 0.9.3 version: 0.9.4-SNAPSHOT
author: Frank Baumann author: Frank Baumann
authors: [Frank Baumann, Milan Albrecht, Tobias Schmitz, Daniel Saukel] authors: [Frank Baumann, Milan Albrecht, Tobias Schmitz, Daniel Saukel]
website: http://www.dre2n.ml website: http://www.dre2n.ml