Add debug to chunk load tracking, clarify charging logic in commands

This commit is contained in:
fullwall 2022-02-15 00:40:24 +08:00
parent 5bf9fdc6c9
commit 88ab30840b
2 changed files with 7 additions and 5 deletions

View File

@ -159,7 +159,7 @@ public class EventListen implements Listener {
}
};
if (Messaging.isDebugging() && Setting.DEBUG_CHUNK_LOADS.asBoolean()) {
new Exception().printStackTrace();
new Exception("CITIZENS CHUNK LOAD DEBUG " + new ChunkCoord(event.getChunk())).printStackTrace();
}
if (event instanceof Cancellable) {
runnable.run();
@ -202,7 +202,7 @@ public class EventListen implements Listener {
}
}
if (Messaging.isDebugging() && Setting.DEBUG_CHUNK_LOADS.asBoolean()) {
new Exception().printStackTrace();
new Exception("CITIZENS CHUNK UNLOAD DEBUG " + coord).printStackTrace();
}
if (loadChunk) {
if (Messaging.isDebugging()) {

View File

@ -84,7 +84,7 @@ public class CommandTrait extends Trait {
return id;
}
private boolean checkPreconditions(Player player, Hand hand) {
private boolean chargeCommandCosts(Player player, Hand hand) {
if (cost > 0) {
try {
RegisteredServiceProvider<Economy> provider = Bukkit.getServicesManager()
@ -249,9 +249,11 @@ public class CommandTrait extends Trait {
if (info != null && !info.canUse(CommandTrait.this, player, command)) {
return;
}
if (!charged && !checkPreconditions(player, hand)) {
if (!charged) {
charged = true;
return;
if (!chargeCommandCosts(player, hand)) {
return;
}
}
PermissionAttachment attachment = player.addAttachment(CitizensAPI.getPlugin());
if (temporaryPermissions.size() > 0) {