Skip to content

Commit

Permalink
Merge pull request #902 from rumickon/uuidfix
Browse files Browse the repository at this point in the history
Use UUID. Fix /cremoveall, /climits, /lwc admin purge <player>
  • Loading branch information
Hidendra committed Mar 1, 2016
2 parents 6ba6d41 + e1967ff commit 6528722
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

8 comments on commit 6528722

@andrewkm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lags like no tomorrow.

@Hidendra
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewkm Did it only start after this? The only changes look like they're in places only used by commands (listed in the msg).

@andrewkm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hidendra yes we did this months ago xP
http://i.imgur.com/qozB57w.png

Exact same way, it is absolute lag destruction. Server death. Cats die. Etc. (Upon using the commands)
We reverted immediately. (We run our own LWC builds now since I thought you've gone totally MIA)

We just ended up agreeing with the fact cremoveall will forever be broken.

CC: @JamieSinn

@JamieSinn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, can confirm. Living hell on lag.

@Hidendra
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I will go ahead and revert for now @andrewkm

@TKwSni
Copy link

@TKwSni TKwSni commented on 6528722 Mar 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I been using that fork since the mojang uuid update and I havent lagged at all, maybe it's because my private limits are low, but it works for me.

Except for the hopper check on private chests that i had to set to false, everything else works fine.

@JamieSinn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The database we have is quite large... several hundred MB. This is also across 3 or so worlds, with the map size being 30k x 30k.

@mibby
Copy link

@mibby mibby commented on 6528722 May 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hidendra Any plans on re-adding support for /lwc admin purge <PLAYERNAME>? Typing the UUID every time someone needs to be purged is silly.

Please sign in to comment.