Added conversion in DB

This commit is contained in:
Norbi Peti 2018-06-30 16:28:32 +02:00
parent ecaecd4136
commit b84ecf8545
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
4 changed files with 14 additions and 8 deletions

View file

@ -82,7 +82,13 @@ public class BlockState {
}
//TODO Rename
public void setPlayerName(String s) {
@SuppressWarnings("deprecation")
public void setPlayerNameOrUUID(String s) {
if(s==null)
uuid=null;
else if(!s.matches("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"))
uuid = Bukkit.getOfflinePlayer(s).getUniqueId(); //If it's a name, get UUID
else
uuid = UUID.fromString(s);
}
@ -115,7 +121,7 @@ public class BlockState {
public void setSource(Source source) {
if (source != Source.PLAYER && source != Source.EDIT && source != Source.COMMAND)
setPlayerName(null);
setPlayerNameOrUUID(null);
this.source = source;
}

View file

@ -131,7 +131,7 @@ public class CreativeControlImportThread extends DatabaseMigrationThread {
bs.setLocation(new Location(c.getWorld(), rs.getInt("x"), rs.getInt("y"), rs.getInt("z")));
bs.setDate(new Date(rs.getLong("time")));
bs.setGameMode(GameMode.CREATIVE);
bs.setPlayerName(rs.getString("player"));
bs.setPlayerNameOrUUID(rs.getString("player"));
bs.setSource(Source.PLAYER);
return bs;
}

View file

@ -42,7 +42,7 @@ public class DBQueries {
bs.setLocation(loc);
bs.setDate(rs.getTimestamp("cdate"));
bs.setGameMode(getGameMode(rs));
bs.setPlayerName(rs.getString("player"));
bs.setPlayerNameOrUUID(rs.getString("player"));
bs.setSource(getSource(rs));
rs.close();
return bs;
@ -72,7 +72,7 @@ public class DBQueries {
bs.setLocation(new Location(c.getWorld(), rs.getInt("x"), rs.getInt("y"), rs.getInt("z")));
bs.setDate(rs.getTimestamp("cdate"));
bs.setGameMode(getGameMode(rs));
bs.setPlayerName(rs.getString("player"));
bs.setPlayerNameOrUUID(rs.getString("player"));
bs.setSource(getSource(rs));
blocks.add(bs);
}
@ -100,7 +100,7 @@ public class DBQueries {
bs.setLocation(new Location(c.getWorld(), rs.getInt("x"), rs.getInt("y"), rs.getInt("z")));
bs.setDate(rs.getTimestamp("cdate"));
bs.setGameMode(getGameMode(rs));
bs.setPlayerName(rs.getString("player"));
bs.setPlayerNameOrUUID(rs.getString("player"));
bs.setSource(getSource(rs));
return bs;
}

View file

@ -46,7 +46,7 @@ public class EditSessionExtent extends AbstractLoggingExtent {
s.setLocation(loc);
}
s.setGameMode(null);
s.setPlayerName(player.getUniqueId().toString());
s.setPlayerNameOrUUID(player.getUniqueId().toString());
s.setDate(new Date());
s.setSource(Source.EDIT);
if (mod.isDebug())