Add some debug logging for shop sign creation

This commit is contained in:
Phoenix616 2022-07-06 00:54:44 +01:00
parent a78b925181
commit e3cd50cf75
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
3 changed files with 21 additions and 1 deletions

View File

@ -535,6 +535,12 @@ public class ChestShop extends JavaPlugin {
return logger; return logger;
} }
public static void logDebug(String message) {
if (Properties.DEBUG) {
getBukkitLogger().info("[DEBUG] " + message);
}
}
public static Server getBukkitServer() { public static Server getBukkitServer() {
return server; return server;
} }

View File

@ -34,6 +34,7 @@ public class SignCreate implements Listener {
if (ChestShopSign.isValid(event.getLines()) && !NameManager.canUseName(event.getPlayer(), OTHER_NAME_DESTROY, ChestShopSign.getOwner(event.getLines()))) { if (ChestShopSign.isValid(event.getLines()) && !NameManager.canUseName(event.getPlayer(), OTHER_NAME_DESTROY, ChestShopSign.getOwner(event.getLines()))) {
event.setCancelled(true); event.setCancelled(true);
sign.update(); sign.update();
ChestShop.logDebug("Shop sign creation at " + sign.getLocation() + " by " + event.getPlayer().getName() + " was cancelled as they weren't able to create a shop for the account '" + ChestShopSign.getOwner(event.getLines()) + "'");
return; return;
} }
@ -49,6 +50,7 @@ public class SignCreate implements Listener {
if (preEvent.getOutcome().shouldBreakSign()) { if (preEvent.getOutcome().shouldBreakSign()) {
event.setCancelled(true); event.setCancelled(true);
signBlock.breakNaturally(); signBlock.breakNaturally();
ChestShop.logDebug("Shop sign creation at " + sign.getLocation() + " by " + event.getPlayer().getName() + " was cancelled (creation outcome: " + preEvent.getOutcome() + ") and the sign broken");
return; return;
} }
@ -57,6 +59,7 @@ public class SignCreate implements Listener {
} }
if (preEvent.isCancelled()) { if (preEvent.isCancelled()) {
ChestShop.logDebug("Shop sign creation at " + sign.getLocation() + " by " + event.getPlayer().getName() + " was cancelled (creation outcome: " + preEvent.getOutcome() + ") and sign lines were set to " + String.join(", ", preEvent.getSignLines()));
return; return;
} }

View File

@ -271,7 +271,12 @@ public class NameManager implements Listener {
public static boolean canUseName(Player player, Permission base, String name) { public static boolean canUseName(Player player, Permission base, String name) {
if (ChestShopSign.isAdminShop(name)) { if (ChestShopSign.isAdminShop(name)) {
return Permission.has(player, Permission.ADMIN_SHOP); if (Permission.has(player, Permission.ADMIN_SHOP)) {
return true;
} else {
ChestShop.logDebug(player.getName() + " cannot use the name " + name + " as it's an admin shop and they don't have the permission " + Permission.ADMIN_SHOP);
return false;
}
} }
if (Permission.otherName(player, base, name)) { if (Permission.otherName(player, base, name)) {
@ -282,6 +287,7 @@ public class NameManager implements Listener {
ChestShop.callEvent(queryEvent); ChestShop.callEvent(queryEvent);
Account account = queryEvent.getAccount(); Account account = queryEvent.getAccount();
if (account == null) { if (account == null) {
ChestShop.logDebug(player.getName() + " cannot use the name " + name + " for a shop as no account with that name exists");
return false; return false;
} }
if (!account.getName().equalsIgnoreCase(name) && Permission.otherName(player, base, account.getName())) { if (!account.getName().equalsIgnoreCase(name) && Permission.otherName(player, base, account.getName())) {
@ -296,6 +302,11 @@ public class NameManager implements Listener {
public static void onAccountAccessCheck(AccountAccessEvent event) { public static void onAccountAccessCheck(AccountAccessEvent event) {
if (!event.canAccess()) { if (!event.canAccess()) {
event.setAccess(event.getPlayer().getUniqueId().equals(event.getAccount().getUuid())); event.setAccess(event.getPlayer().getUniqueId().equals(event.getAccount().getUuid()));
if (!event.canAccess()) {
ChestShop.logDebug(event.getPlayer().getName() + "/" + event.getPlayer().getUniqueId()
+ " cannot access the account " + event.getAccount().getName() + "/" + event.getAccount().getUuid()
+ " as their UUID doesn't match!");
}
} }
} }