Remove unnecessary checks and add comments

This commit is contained in:
stonar96 2020-04-27 00:50:53 +02:00 committed by wizjany
parent 6030bea13e
commit 60590acfe3
2 changed files with 11 additions and 5 deletions

View File

@ -191,13 +191,12 @@ public void teleport(Location location, String successMessage, String failMessag
PaperLib.teleportAsync(getPlayer(), BukkitAdapter.adapt(location))
.thenApply(success -> {
if (success) {
if (successMessage != null && !successMessage.isEmpty()) {
// The success message can be cleared via flag
if (!successMessage.isEmpty()) {
MessagingUtil.sendStringToChat(this, successMessage);
}
} else {
if (failMessage != null && !failMessage.isEmpty()) {
printError(failMessage);
}
printError(failMessage);
}
return success;
});

View File

@ -1112,8 +1112,15 @@ public void teleport(CommandContext args, Actor sender) throws CommandException
}
String message = existing.getFlag(Flags.TELE_MESSAGE);
// If the flag isn't set, use the default message
// If message.isEmpty(), no message is sent by LocalPlayer#teleport(...)
if (message == null) {
message = Flags.TELE_MESSAGE.getDefault();
}
player.teleport(teleportLocation,
(message == null ? Flags.TELE_MESSAGE.getDefault() : message).replace("%id%", existing.getId()),
message.replace("%id%", existing.getId()),
"Unable to teleport to region '" + existing.getId() + "'.");
}