Refactor Glow command to optimize logic order.
Reorganized the "off" condition block to execute after clearing existing glow teams.
This commit is contained in:
parent
7cfdc39f75
commit
785a64b7e6
|
|
@ -41,17 +41,17 @@ public class Glow extends SubCommand {
|
|||
|
||||
Player player = playerFromArg.get();
|
||||
|
||||
if (args[1].equalsIgnoreCase("off")) {
|
||||
turnOffGlow(commandSender, player, otherPlayer);
|
||||
return true;
|
||||
}
|
||||
|
||||
Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
board.getTeams().stream()
|
||||
.filter(team -> team.getName().startsWith("Glow"))
|
||||
.filter(team -> team.hasPlayer(player))
|
||||
.forEach(team -> team.removePlayer(player));
|
||||
|
||||
if (args[1].equalsIgnoreCase("off")) {
|
||||
turnOffGlow(commandSender, player, otherPlayer);
|
||||
return true;
|
||||
}
|
||||
|
||||
Optional<DyeColor> any = Arrays.stream(DyeColor.values()).filter(chatColor -> chatColor.name().equalsIgnoreCase(args[1])).findAny();
|
||||
if (any.isEmpty()) {
|
||||
commandSender.sendRichMessage(getHelpMessage());
|
||||
|
|
@ -97,6 +97,7 @@ public class Glow extends SubCommand {
|
|||
private void turnOffGlow(CommandSender commandSender, Player player, boolean otherPlayer) {
|
||||
player.sendRichMessage(Messages.GLOW.GLOW_OFF);
|
||||
player.setGlowing(false);
|
||||
|
||||
if (otherPlayer) {
|
||||
commandSender.sendRichMessage(Messages.GLOW.GLOW_OFF_FOR_PLAYER, Placeholder.component("player", player.name()));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user