mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-12-01 14:33:21 +01:00
Add some debug logging for shop sign creation
This commit is contained in:
parent
a78b925181
commit
e3cd50cf75
@ -535,6 +535,12 @@ public class ChestShop extends JavaPlugin {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public static void logDebug(String message) {
|
||||
if (Properties.DEBUG) {
|
||||
getBukkitLogger().info("[DEBUG] " + message);
|
||||
}
|
||||
}
|
||||
|
||||
public static Server getBukkitServer() {
|
||||
return server;
|
||||
}
|
||||
|
@ -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()))) {
|
||||
event.setCancelled(true);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -49,6 +50,7 @@ public class SignCreate implements Listener {
|
||||
if (preEvent.getOutcome().shouldBreakSign()) {
|
||||
event.setCancelled(true);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -57,6 +59,7 @@ public class SignCreate implements Listener {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,12 @@ public class NameManager implements Listener {
|
||||
|
||||
public static boolean canUseName(Player player, Permission base, String 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)) {
|
||||
@ -282,6 +287,7 @@ public class NameManager implements Listener {
|
||||
ChestShop.callEvent(queryEvent);
|
||||
Account account = queryEvent.getAccount();
|
||||
if (account == null) {
|
||||
ChestShop.logDebug(player.getName() + " cannot use the name " + name + " for a shop as no account with that name exists");
|
||||
return false;
|
||||
}
|
||||
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) {
|
||||
if (!event.canAccess()) {
|
||||
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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user