Skip to content

Commit

Permalink
Use UUID. Fix /cremoveall, /climits, /lwc admin purge <player>
Browse files Browse the repository at this point in the history
  • Loading branch information
rumickon committed Mar 19, 2015
1 parent 021f8d1 commit e1967ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/com/griefcraft/lwc/LWC.java
Expand Up @@ -938,7 +938,8 @@ public static String materialToString(Block block) {
*/
public int fastRemoveProtectionsByPlayer(CommandSender sender, String player, boolean shouldRemoveBlocks) {
// remove their protections first
int ret = fastRemoveProtections(sender, "Lower(owner) = Lower('" + player + "')", shouldRemoveBlocks);
UUID uuid = UUIDRegistry.getUUID(player);
int ret = fastRemoveProtections(sender, "Lower(owner) = Lower('" + (uuid != null ? uuid.toString() : player) + "')", shouldRemoveBlocks);

// invalid any history objects associated with the player
physicalDatabase.invalidateHistory(player);
Expand Down
12 changes: 8 additions & 4 deletions core/src/main/java/com/griefcraft/sql/PhysDB.java
Expand Up @@ -166,7 +166,8 @@ public int getProtectionCount(String player) {

try {
PreparedStatement statement = prepare("SELECT COUNT(*) as count FROM " + prefix + "protections WHERE owner = ?");
statement.setString(1, player);
UUID uuid = UUIDRegistry.getUUID(player);
statement.setString(1, uuid != null ? uuid.toString() : player);

ResultSet set = statement.executeQuery();

Expand All @@ -193,7 +194,8 @@ public int getHistoryCount(String player) {

try {
PreparedStatement statement = prepare("SELECT COUNT(*) AS count FROM " + prefix + "history WHERE LOWER(player) = LOWER(?)");
statement.setString(1, player);
UUID uuid = UUIDRegistry.getUUID(player);
statement.setString(1, uuid != null ? uuid.toString() : player);

ResultSet set = statement.executeQuery();

Expand All @@ -220,7 +222,8 @@ public int getProtectionCount(String player, int blockId) {

try {
PreparedStatement statement = prepare("SELECT COUNT(*) AS count FROM " + prefix + "protections WHERE owner = ? AND blockId = ?");
statement.setString(1, player);
UUID uuid = UUIDRegistry.getUUID(player);
statement.setString(1, uuid != null ? uuid.toString() : player);
statement.setInt(2, blockId);

ResultSet set = statement.executeQuery();
Expand Down Expand Up @@ -1074,7 +1077,8 @@ public List<Protection> loadProtectionsByPlayer(String player) {

try {
PreparedStatement statement = prepare("SELECT id, owner, type, x, y, z, data, blockId, world, password, date, last_accessed FROM " + prefix + "protections WHERE owner = ?");
statement.setString(1, player);
UUID uuid = UUIDRegistry.getUUID(player);
statement.setString(1, uuid != null ? uuid.toString() : player);

return resolveProtections(statement);
} catch (Exception e) {
Expand Down

0 comments on commit e1967ff

Please sign in to comment.