Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion core/src/main/java/com/griefcraft/model/Protection.java
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,16 @@ public World getBukkitWorld() {
* @return the Bukkit Player object of the owner
*/
public Player getBukkitOwner() {
return Bukkit.getServer().getPlayer(owner);

UUID uuid = UUIDRegistry.getUUID(owner);
if(uuid == null) {
uuid = UUID.fromString(owner);
}

if(uuid == null) {
return Bukkit.getServer().getPlayer(owner);
}
return Bukkit.getServer().getPlayer(uuid);
}

/**
Expand Down
39 changes: 39 additions & 0 deletions core/src/main/java/com/griefcraft/sql/PhysDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ public int getHistoryCount() {
public int getProtectionCount(String player) {
int count = 0;

UUID uuid = UUIDRegistry.getUUID(player);
if(uuid != null) {
player = uuid.toString();
}

try {
PreparedStatement statement = prepare("SELECT COUNT(*) as count FROM " + prefix + "protections WHERE owner = ?");
statement.setString(1, player);
Expand All @@ -190,6 +195,11 @@ public int getProtectionCount(String player) {
*/
public int getHistoryCount(String player) {
int count = 0;

UUID uuid = UUIDRegistry.getUUID(player);
if(uuid != null) {
player = uuid.toString();
}

try {
PreparedStatement statement = prepare("SELECT COUNT(*) AS count FROM " + prefix + "history WHERE LOWER(player) = LOWER(?)");
Expand Down Expand Up @@ -217,6 +227,11 @@ public int getHistoryCount(String player) {
*/
public int getProtectionCount(String player, int blockId) {
int count = 0;

UUID uuid = UUIDRegistry.getUUID(player);
if(uuid != null) {
player = uuid.toString();
}

try {
PreparedStatement statement = prepare("SELECT COUNT(*) AS count FROM " + prefix + "protections WHERE owner = ? AND blockId = ?");
Expand Down Expand Up @@ -1071,6 +1086,11 @@ public List<Protection> loadProtections(String world, int x1, int x2, int y1, in
*/
public List<Protection> loadProtectionsByPlayer(String player) {
List<Protection> protections = new ArrayList<Protection>();

UUID uuid = UUIDRegistry.getUUID(player);
if(uuid != null) {
player = uuid.toString();
}

try {
PreparedStatement statement = prepare("SELECT id, owner, type, x, y, z, data, blockId, world, password, date, last_accessed FROM " + prefix + "protections WHERE owner = ?");
Expand Down Expand Up @@ -1359,6 +1379,15 @@ public List<History> loadHistory(String player) {
if (!LWC.getInstance().isHistoryEnabled()) {
return temp;
}

UUID uuid = UUIDRegistry.getUUID(player);
if(uuid == null) {
uuid = UUID.fromString(player);
}

if(uuid != null) {
player = uuid.toString();
}

try {
PreparedStatement statement = prepare("SELECT * FROM " + prefix + "history WHERE LOWER(player) = LOWER(?) ORDER BY id DESC");
Expand Down Expand Up @@ -1441,6 +1470,11 @@ public List<History> loadHistory(String player, int start, int count) {
if (!LWC.getInstance().isHistoryEnabled()) {
return temp;
}

UUID uuid = UUIDRegistry.getUUID(player);
if(uuid != null) {
player = uuid.toString();
}

try {
PreparedStatement statement = prepare("SELECT * FROM " + prefix + "history WHERE LOWER(player) = LOWER(?) ORDER BY id DESC LIMIT ?,?");
Expand Down Expand Up @@ -1589,6 +1623,11 @@ public List<History> loadHistory(String player, int x, int y, int z) {
if (!LWC.getInstance().isHistoryEnabled()) {
return temp;
}

UUID uuid = UUIDRegistry.getUUID(player);
if(uuid != null) {
player = uuid.toString();
}

try {
PreparedStatement statement = prepare("SELECT * FROM " + prefix + "history WHERE LOWER(player) = LOWER(?) AND x = ? AND y = ? AND z = ?");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ public void onPostRegistration(LWCProtectionRegistrationPostEvent event) {
history.addMetaData("discount=true");

// Was the discount's id non-null?
String discountId = resolveValue(protection.getBukkitOwner(), "discount.id");
Player puuid = protection.getBukkitOwner();

String discountId = resolveValue(puuid, "discount.id");

if (!discountId.isEmpty()) {
history.addMetaData("discountId=" + discountId);
Expand Down