From 264c0e2c78170a306781996552f9b7eb4c6bb560 Mon Sep 17 00:00:00 2001 From: Griffin Kubesa Date: Tue, 10 Aug 2021 16:17:37 -0500 Subject: [PATCH] Add / keep (#4512) * Add / keep * Add keep to tab completion * Case insensitive --- .../nossr50/commands/skills/SkillCommand.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 6e2926062..df3f8a8a4 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -59,18 +59,17 @@ public abstract class SkillCommand implements TabExecutor { return true; } - if(UserManager.getPlayer((Player) sender) == null) - { + Player player = (Player) sender; + McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + + if (mcMMOPlayer == null) { sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad")); return true; } if (args.length == 0) { - Player player = (Player) sender; - McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); - boolean isLucky = Permissions.lucky(player, skill); - boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0); + boolean hasEndurance = PerksUtils.handleActivationPerks(player, 0, 0) != 0; float skillValue = mcMMOPlayer.getSkillLevel(skill); //Send the players a few blank lines to make finding the top of the skill command easier @@ -116,8 +115,21 @@ public abstract class SkillCommand implements TabExecutor { ScoreboardManager.enablePlayerSkillScoreboard(player, skill); } + return true; + } else if ("keep".equals(args[0].toLowerCase())) { + if (!mcMMO.p.getGeneralConfig().getAllowKeepBoard() + || !mcMMO.p.getGeneralConfig().getScoreboardsEnabled() + || !mcMMO.p.getGeneralConfig().getSkillUseBoard()) { + sender.sendMessage(LocaleLoader.getString("Commands.Disabled")); + return true; + } + + ScoreboardManager.enablePlayerSkillScoreboard(player, skill); + ScoreboardManager.keepBoard(sender.getName()); + sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep")); return true; } + return skillGuideCommand.onCommand(sender, command, label, args); } @@ -211,7 +223,7 @@ public abstract class SkillCommand implements TabExecutor { @Override public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if (args.length == 1) { - return ImmutableList.of("?"); + return ImmutableList.of("?", "keep"); } return ImmutableList.of(); }