Fixed bug with running onLeave commands (#1929)

In discord, it was reported that running the admin delete command produces a null-pointer if `[player]` placeholder is used.

With fast checking I found out the issue: incorrect user was passed to the command.
Also, I moved runCommands below all resets, so commands could be used to give items, or xp or other stuff that is removed.
This commit is contained in:
BONNe 2022-01-29 04:42:02 +02:00 committed by GitHub
parent da98bbcf38
commit 3ecdda65b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -96,8 +96,6 @@ public class AdminDeleteCommand extends ConfirmableCommand {
}
private void cleanUp(User user, User target) {
// Execute commands when leaving
Util.runCommands(user, getIWM().getOnLeaveCommands(getWorld()), "leave");
// Remove money inventory etc.
if (getIWM().isOnLeaveResetEnderChest(getWorld())) {
target.getPlayer().getEnderChest().clear();
@ -123,6 +121,8 @@ public class AdminDeleteCommand extends ConfirmableCommand {
target.getPlayer().setTotalExperience(0);
}
// Execute commands when leaving
Util.runCommands(target, getIWM().getOnLeaveCommands(getWorld()), "leave");
}
@Override
@ -135,4 +135,4 @@ public class AdminDeleteCommand extends ConfirmableCommand {
List<String> options = new ArrayList<>(Util.getOnlinePlayerList(user));
return Optional.of(Util.tabLimit(options, lastArg));
}
}
}