From 57b7050a2c55b7f2045da791e5ab53966918ab4d Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 2 Jul 2019 19:00:06 -0700 Subject: [PATCH] Static Abuse Removal - CommandUtils -> CommandTools --- .../nossr50/commands/CommandConstants.java | 2 + .../nossr50/commands/McscoreboardCommand.java | 5 +- .../gmail/nossr50/commands/ToggleCommand.java | 13 ++-- .../gmail/nossr50/commands/XprateCommand.java | 11 ++-- .../nossr50/commands/chat/ChatCommand.java | 20 +++--- .../commands/database/McremoveCommand.java | 7 +-- .../commands/experience/AddlevelsCommand.java | 1 - .../experience/ExperienceCommand.java | 11 ++-- .../commands/experience/MmoeditCommand.java | 1 - .../experience/SkillresetCommand.java | 12 ++-- .../party/PartyChangeOwnerCommand.java | 3 +- .../nossr50/commands/party/PartyCommand.java | 11 ++-- .../commands/party/PartyInviteCommand.java | 5 +- .../commands/party/PartyItemShareCommand.java | 5 +- .../commands/party/PartyJoinCommand.java | 5 +- .../commands/party/PartyKickCommand.java | 3 +- .../commands/party/PartyLockCommand.java | 5 +- .../commands/party/PartyXpShareCommand.java | 5 +- .../party/alliance/PartyAllianceCommand.java | 5 +- .../alliance/PartyAllianceInviteCommand.java | 5 +- .../commands/party/teleport/PtpCommand.java | 7 +-- .../commands/player/InspectCommand.java | 23 ++++--- .../commands/player/MccooldownCommand.java | 5 +- .../commands/player/McrankCommand.java | 13 ++-- .../commands/player/McstatsCommand.java | 11 ++-- .../nossr50/commands/player/MctopCommand.java | 9 ++- .../nossr50/commands/skills/SkillCommand.java | 5 +- .../gmail/nossr50/datatypes/party/Party.java | 1 - .../nossr50/datatypes/party/ShareMode.java | 4 +- .../nossr50/datatypes/player/McMMOPlayer.java | 1 - .../skills/subskills/acrobatics/Roll.java | 1 - .../nossr50/listeners/BlockListener.java | 1 - src/main/java/com/gmail/nossr50/mcMMO.java | 10 +++ .../com/gmail/nossr50/party/PartyManager.java | 3 +- .../runnables/items/TeleportationWarmup.java | 1 - .../runnables/skills/AbilityDisableTask.java | 1 - .../runnables/skills/BleedTimerTask.java | 1 - .../skills/fishing/FishingManager.java | 5 +- .../nossr50/skills/mining/MiningManager.java | 1 - .../skills/salvage/SalvageManager.java | 1 - .../skills/unarmed/UnarmedManager.java | 1 - .../woodcutting/WoodcuttingManager.java | 5 +- .../{CommandUtils.java => CommandTools.java} | 62 +++++++++---------- .../util/player/NotificationManager.java | 1 - .../nossr50/util/random/RandomChanceUtil.java | 1 - .../nossr50/util/skills/CombatUtils.java | 4 +- 46 files changed, 145 insertions(+), 168 deletions(-) rename src/main/java/com/gmail/nossr50/util/commands/{CommandUtils.java => CommandTools.java} (79%) diff --git a/src/main/java/com/gmail/nossr50/commands/CommandConstants.java b/src/main/java/com/gmail/nossr50/commands/CommandConstants.java index 2590bacbb..2dfaf1b06 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandConstants.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandConstants.java @@ -7,4 +7,6 @@ import java.util.List; public class CommandConstants { public static final List TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall"); public static final List ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband"); + public static final List TRUE_FALSE_OPTIONS = ImmutableList.of("on", "off", "true", "false", "enabled", "disabled"); + public static final List RESET_OPTIONS = ImmutableList.of("clear", "reset"); } diff --git a/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java b/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java index 1fd532927..f4e7b3717 100644 --- a/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; @@ -24,7 +23,7 @@ public class McscoreboardCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } @@ -56,7 +55,7 @@ public class McscoreboardCommand implements TabExecutor { case 2: if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) { - if (CommandUtils.isInvalidInteger(sender, args[1])) { + if (pluginRef.getCommandTools().isInvalidInteger(sender, args[1])) { return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java b/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java index 5e71618a9..421118ec2 100644 --- a/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/ToggleCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; @@ -17,7 +16,7 @@ public abstract class ToggleCommand implements TabExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 0: - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } @@ -26,7 +25,7 @@ public abstract class ToggleCommand implements TabExecutor { return true; } - if (!CommandUtils.hasPlayerDataKey(sender)) { + if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) { return true; } @@ -39,14 +38,14 @@ public abstract class ToggleCommand implements TabExecutor { return true; } - String playerName = CommandUtils.getMatchedPlayerName(args[0]); + String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName); - if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) { + if (!pluginRef.getCommandTools().checkPlayerExistence(sender, playerName, mcMMOPlayer)) { return true; } - if (CommandUtils.isOffline(sender, mcMMOPlayer.getPlayer())) { + if (pluginRef.getCommandTools().isOffline(sender, mcMMOPlayer.getPlayer())) { return true; } @@ -63,7 +62,7 @@ public abstract class ToggleCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - List playerNames = CommandUtils.getOnlinePlayerNames(sender); + List playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); default: return ImmutableList.of(); diff --git a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java index e4074dc9a..52a5d5edc 100644 --- a/src/main/java/com/gmail/nossr50/commands/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/XprateCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.commands.CommandUtils; import com.google.common.collect.ImmutableList; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -60,7 +59,7 @@ public class XprateCommand implements TabExecutor { return true; case 2: - if (CommandUtils.isInvalidInteger(sender, args[0])) { + if (pluginRef.getCommandTools().isInvalidInteger(sender, args[0])) { return true; } @@ -69,9 +68,9 @@ public class XprateCommand implements TabExecutor { return true; } - if (CommandUtils.shouldDisableToggle(args[1])) { + if (pluginRef.getCommandTools().shouldDisableToggle(args[1])) { pluginRef.setXPEventEnabled(false); - } else if (CommandUtils.shouldEnableToggle(args[1])) { + } else if (pluginRef.getCommandTools().shouldEnableToggle(args[1])) { pluginRef.setXPEventEnabled(true); } else { return false; @@ -116,9 +115,9 @@ public class XprateCommand implements TabExecutor { return ImmutableList.of(); } - return StringUtil.copyPartialMatches(args[0], CommandUtils.RESET_OPTIONS, new ArrayList<>(CommandUtils.RESET_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[0], CommandConstants.RESET_OPTIONS, new ArrayList<>(CommandConstants.RESET_OPTIONS.size())); case 2: - return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[1], CommandConstants.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandConstants.TRUE_FALSE_OPTIONS.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java index b99117205..a44a03151 100644 --- a/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/chat/ChatCommand.java @@ -1,10 +1,10 @@ package com.gmail.nossr50.commands.chat; +import com.gmail.nossr50.commands.CommandConstants; import com.gmail.nossr50.datatypes.chat.ChatMode; import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; @@ -31,11 +31,11 @@ public abstract class ChatCommand implements TabExecutor { switch (args.length) { case 0: - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } - if (!CommandUtils.hasPlayerDataKey(sender)) { + if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) { return true; } @@ -50,11 +50,11 @@ public abstract class ChatCommand implements TabExecutor { return true; case 1: - if (CommandUtils.shouldEnableToggle(args[0])) { - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().shouldEnableToggle(args[0])) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } - if (!CommandUtils.hasPlayerDataKey(sender)) { + if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) { return true; } @@ -62,11 +62,11 @@ public abstract class ChatCommand implements TabExecutor { return true; } - if (CommandUtils.shouldDisableToggle(args[0])) { - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().shouldDisableToggle(args[0])) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } - if (!CommandUtils.hasPlayerDataKey(sender)) { + if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) { return true; } @@ -86,7 +86,7 @@ public abstract class ChatCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[0], CommandConstants.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandConstants.TRUE_FALSE_OPTIONS.size())); default: return ImmutableList.of(); } diff --git a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java index 28912d6e9..92f4124d7 100644 --- a/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/database/McremoveCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands.database; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableList; import org.bukkit.Bukkit; @@ -25,9 +24,9 @@ public class McremoveCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (args.length == 1) { - String playerName = CommandUtils.getMatchedPlayerName(args[0]); + String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]); - if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, pluginRef.getDatabaseManager().loadPlayerProfile(playerName, false))) { + if (UserManager.getOfflinePlayer(playerName) == null && pluginRef.getCommandTools().unloadedProfile(sender, pluginRef.getDatabaseManager().loadPlayerProfile(playerName, false))) { return true; } @@ -52,7 +51,7 @@ public class McremoveCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - List playerNames = CommandUtils.getOnlinePlayerNames(sender); + List playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); default: return ImmutableList.of(); diff --git a/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java index 8d430f4ef..7429d366c 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/AddlevelsCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Permissions; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java index b33149310..8b4ad63d5 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/ExperienceCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableList; import org.bukkit.OfflinePlayer; @@ -40,7 +39,7 @@ public abstract class ExperienceCommand implements TabExecutor { switch (args.length) { case 2: - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } @@ -97,7 +96,7 @@ public abstract class ExperienceCommand implements TabExecutor { int value = Integer.parseInt(args[2]); - String playerName = CommandUtils.getMatchedPlayerName(args[0]); + String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]); McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. @@ -109,7 +108,7 @@ public abstract class ExperienceCommand implements TabExecutor { } PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, uuid, false); - if (CommandUtils.unloadedProfile(sender, profile)) { + if (pluginRef.getCommandTools().unloadedProfile(sender, profile)) { return true; } @@ -130,7 +129,7 @@ public abstract class ExperienceCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - List playerNames = CommandUtils.getOnlinePlayerNames(sender); + List playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); case 2: return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size())); @@ -150,7 +149,7 @@ public abstract class ExperienceCommand implements TabExecutor { protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill); private boolean validateArguments(CommandSender sender, String skillName, String value) { - return !(CommandUtils.isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && CommandUtils.isInvalidSkill(sender, skillName))); + return !(pluginRef.getCommandTools().isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && pluginRef.getCommandTools().isInvalidSkill(sender, skillName))); } protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value) { diff --git a/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java index 18b220030..15dc4898d 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/MmoeditCommand.java @@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Permissions; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java index 9581b9e0f..c77edd6b3 100644 --- a/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/experience/SkillresetCommand.java @@ -5,9 +5,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableList; import org.bukkit.OfflinePlayer; @@ -46,7 +44,7 @@ public class SkillresetCommand implements TabExecutor { PrimarySkillType skill; switch (args.length) { case 1: - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } @@ -84,7 +82,7 @@ public class SkillresetCommand implements TabExecutor { skill = PrimarySkillType.getSkill(args[1]); } - String playerName = CommandUtils.getMatchedPlayerName(args[0]); + String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]); McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. @@ -96,7 +94,7 @@ public class SkillresetCommand implements TabExecutor { } PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, uuid, false); - if (CommandUtils.unloadedProfile(sender, profile)) { + if (pluginRef.getCommandTools().unloadedProfile(sender, profile)) { return true; } @@ -117,7 +115,7 @@ public class SkillresetCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - List playerNames = CommandUtils.getOnlinePlayerNames(sender); + List playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); case 2: return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size())); @@ -157,7 +155,7 @@ public class SkillresetCommand implements TabExecutor { } private boolean validateArguments(CommandSender sender, String skillName) { - return skillName.equalsIgnoreCase("all") || !CommandUtils.isInvalidSkill(sender, skillName); + return skillName.equalsIgnoreCase("all") || !pluginRef.getCommandTools().isInvalidSkill(sender, skillName); } protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java index 26f129819..d33d1849b 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangeOwnerCommand.java @@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; @@ -29,7 +28,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor { } Party playerParty = UserManager.getPlayer((Player) sender).getParty(); - String targetName = CommandUtils.getMatchedPlayerName(args[1]); + String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]); OfflinePlayer target = pluginRef.getServer().getOfflinePlayer(targetName); if (!playerParty.hasMember(target.getUniqueId())) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java index 5d8b54f7c..9b6de6729 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; @@ -93,7 +92,7 @@ public class PartyCommand implements TabExecutor { if (!pluginRef.getConfigManager().getConfigParty().isPartySystemEnabled()) return true; - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } @@ -220,7 +219,7 @@ public class PartyCommand implements TabExecutor { case INVITE: case KICK: case OWNER: - List playerNames = CommandUtils.getOnlinePlayerNames(sender); + List playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender); return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size())); case XPSHARE: return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<>(XPSHARE_COMPLETIONS.size())); @@ -228,9 +227,9 @@ public class PartyCommand implements TabExecutor { return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList<>(ITEMSHARE_COMPLETIONS.size())); case LOCK: case CHAT: - return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[1], CommandConstants.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandConstants.TRUE_FALSE_OPTIONS.size())); case PASSWORD: - return StringUtil.copyPartialMatches(args[1], CommandUtils.RESET_OPTIONS, new ArrayList<>(CommandUtils.RESET_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[1], CommandConstants.RESET_OPTIONS, new ArrayList<>(CommandConstants.RESET_OPTIONS.size())); case TELEPORT: List matches = StringUtil.copyPartialMatches(args[1], CommandConstants.TELEPORT_SUBCOMMANDS, new ArrayList<>(CommandConstants.TELEPORT_SUBCOMMANDS.size())); @@ -255,7 +254,7 @@ public class PartyCommand implements TabExecutor { } case 3: if (PartySubcommandType.getSubcommand(args[0]) == PartySubcommandType.ITEMSHARE && isItemShareCategory(args[1])) { - return StringUtil.copyPartialMatches(args[2], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size())); + return StringUtil.copyPartialMatches(args[2], CommandConstants.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandConstants.TRUE_FALSE_OPTIONS.size())); } return ImmutableList.of(); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java index 678721310..f7e9c5a8d 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -22,10 +21,10 @@ public class PartyInviteCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 2: - String targetName = CommandUtils.getMatchedPlayerName(args[1]); + String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]); McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); - if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { + if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) { return false; } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java index 9273fea9e..4587c2251 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -50,9 +49,9 @@ public class PartyItemShareCommand implements CommandExecutor { case 3: boolean toggle; - if (CommandUtils.shouldEnableToggle(args[2])) { + if (pluginRef.getCommandTools().shouldEnableToggle(args[2])) { toggle = true; - } else if (CommandUtils.shouldDisableToggle(args[2])) { + } else if (pluginRef.getCommandTools().shouldDisableToggle(args[2])) { toggle = false; } else { sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", " ")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java index fa17d1b00..4b98ca6dc 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -23,10 +22,10 @@ public class PartyJoinCommand implements CommandExecutor { switch (args.length) { case 2: case 3: - String targetName = CommandUtils.getMatchedPlayerName(args[1]); + String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]); McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName); - if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { + if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) { return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java index 12d089fbd..d28b824a8 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; @@ -29,7 +28,7 @@ public class PartyKickCommand implements CommandExecutor { } Party playerParty = UserManager.getPlayer((Player) sender).getParty(); - String targetName = CommandUtils.getMatchedPlayerName(args[1]); + String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]); if (!playerParty.hasMember(targetName)) { sender.sendMessage(pluginRef.getLocaleManager().getString("Party.NotInYourParty", targetName)); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java index fbfc2c4d5..0ccc90f2f 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -36,9 +35,9 @@ public class PartyLockCommand implements CommandExecutor { return true; } - if (CommandUtils.shouldEnableToggle(args[1])) { + if (pluginRef.getCommandTools().shouldEnableToggle(args[1])) { togglePartyLock(sender, true); - } else if (CommandUtils.shouldDisableToggle(args[1])) { + } else if (pluginRef.getCommandTools().shouldDisableToggle(args[1])) { togglePartyLock(sender, false); } else { sendUsageStrings(sender); diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java index f4d98f074..140432117 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -36,9 +35,9 @@ public class PartyXpShareCommand implements CommandExecutor { switch (args.length) { case 2: - if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) { + if (args[1].equalsIgnoreCase("none") || pluginRef.getCommandTools().shouldDisableToggle(args[1])) { handleChangingShareMode(party, ShareMode.NONE); - } else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) { + } else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || pluginRef.getCommandTools().shouldEnableToggle(args[1])) { handleChangingShareMode(party, ShareMode.EQUAL); } else { sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "xpshare", "")); diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java index 0e427c5bf..ead6ce3cf 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableList; import org.bukkit.ChatColor; @@ -40,7 +39,7 @@ public class PartyAllianceCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } @@ -119,7 +118,7 @@ public class PartyAllianceCommand implements TabExecutor { List matches = StringUtil.copyPartialMatches(args[0], CommandConstants.ALLIANCE_SUBCOMMANDS, new ArrayList<>(CommandConstants.ALLIANCE_SUBCOMMANDS.size())); if (matches.size() == 0) { - List playerNames = CommandUtils.getOnlinePlayerNames(commandSender); + List playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(commandSender); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); } diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java index dbfb27474..ce2e9eaf9 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceInviteCommand.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party.alliance; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -22,10 +21,10 @@ public class PartyAllianceInviteCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 3: - String targetName = CommandUtils.getMatchedPlayerName(args[2]); + String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[2]); McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); - if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { + if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) { return false; } diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java index 5927ab164..68b549c0e 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpCommand.java @@ -7,11 +7,8 @@ import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.runnables.items.TeleportationWarmup; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils; @@ -44,7 +41,7 @@ public class PtpCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } @@ -125,7 +122,7 @@ public class PtpCommand implements TabExecutor { } } - sendTeleportRequest(sender, player, CommandUtils.getMatchedPlayerName(args[0])); + sendTeleportRequest(sender, player, pluginRef.getCommandTools().getMatchedPlayerName(args[0])); return true; } return false; diff --git a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java index 0ab6c1aeb..956d9c430 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.google.common.collect.ImmutableList; @@ -30,14 +29,14 @@ public class InspectCommand implements TabExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 1: - String playerName = CommandUtils.getMatchedPlayerName(args[0]); + String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]); McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. if (mcMMOPlayer == null) { PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile - if (!CommandUtils.isLoaded(sender, profile)) { + if (!pluginRef.getCommandTools().isLoaded(sender, profile)) { return true; } @@ -55,27 +54,27 @@ public class InspectCommand implements TabExecutor { sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Gathering")); for (PrimarySkillType skill : PrimarySkillType.GATHERING_SKILLS) { - sender.sendMessage(CommandUtils.displaySkill(profile, skill)); + sender.sendMessage(pluginRef.getCommandTools().displaySkill(profile, skill)); } sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Combat")); for (PrimarySkillType skill : PrimarySkillType.COMBAT_SKILLS) { - sender.sendMessage(CommandUtils.displaySkill(profile, skill)); + sender.sendMessage(pluginRef.getCommandTools().displaySkill(profile, skill)); } sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Misc")); for (PrimarySkillType skill : PrimarySkillType.MISC_SKILLS) { - sender.sendMessage(CommandUtils.displaySkill(profile, skill)); + sender.sendMessage(pluginRef.getCommandTools().displaySkill(profile, skill)); } } else { Player target = mcMMOPlayer.getPlayer(); - if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) { + if (pluginRef.getCommandTools().hidden(sender, target, Permissions.inspectHidden(sender))) { sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Offline")); return true; } - else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) { + else if (pluginRef.getCommandTools().tooFar(sender, target, Permissions.inspectFar(sender))) { return true; } @@ -88,9 +87,9 @@ public class InspectCommand implements TabExecutor { } sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Stats", target.getName())); - CommandUtils.printGatheringSkills(target, sender); - CommandUtils.printCombatSkills(target, sender); - CommandUtils.printMiscSkills(target, sender); + pluginRef.getCommandTools().printGatheringSkills(target, sender); + pluginRef.getCommandTools().printCombatSkills(target, sender); + pluginRef.getCommandTools().printMiscSkills(target, sender); sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); } @@ -105,7 +104,7 @@ public class InspectCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - List playerNames = CommandUtils.getOnlinePlayerNames(sender); + List playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); default: return ImmutableList.of(); diff --git a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java index fb46ea38b..d48f40596 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.player; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.google.common.collect.ImmutableList; @@ -24,11 +23,11 @@ public class MccooldownCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } - if (!CommandUtils.hasPlayerDataKey(sender)) { + if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) { return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java index 05b0f5f25..eeb6e8b3e 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.google.common.collect.ImmutableList; @@ -31,7 +30,7 @@ public class McrankCommand implements TabExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { case 0: - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } @@ -40,7 +39,7 @@ public class McrankCommand implements TabExecutor { return true; } - if (!CommandUtils.hasPlayerDataKey(sender)) { + if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) { return true; } @@ -54,18 +53,18 @@ public class McrankCommand implements TabExecutor { return true; } - if (!CommandUtils.hasPlayerDataKey(sender)) { + if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) { return true; } - String playerName = CommandUtils.getMatchedPlayerName(args[0]); + String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]); McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); if (mcMMOPlayer != null) { Player player = mcMMOPlayer.getPlayer(); playerName = player.getName(); - if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) { + if (pluginRef.getCommandTools().tooFar(sender, player, Permissions.mcrankFar(sender))) { return true; } } @@ -82,7 +81,7 @@ public class McrankCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - List playerNames = CommandUtils.getOnlinePlayerNames(sender); + List playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); default: return ImmutableList.of(); diff --git a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java index d811fc05f..ad5442d5e 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.commands.player; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.google.common.collect.ImmutableList; @@ -22,11 +21,11 @@ public class McstatsCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } - if (!CommandUtils.hasPlayerDataKey(sender)) { + if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) { return true; } @@ -50,9 +49,9 @@ public class McstatsCommand implements TabExecutor { player.sendMessage(pluginRef.getLocaleManager().getString("Stats.Own.Stats")); player.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoSkillNote")); - CommandUtils.printGatheringSkills(player); - CommandUtils.printCombatSkills(player); - CommandUtils.printMiscSkills(player); + pluginRef.getCommandTools().printGatheringSkills(player); + pluginRef.getCommandTools().printCombatSkills(player); + pluginRef.getCommandTools().printMiscSkills(player); int powerLevelCap = pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().getLevelCap(); diff --git a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java index 440f4f151..30906aee1 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -7,7 +7,6 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.google.common.collect.ImmutableList; @@ -54,7 +53,7 @@ public class MctopCommand implements TabExecutor { return true; case 2: - if (CommandUtils.isInvalidInteger(sender, args[1])) { + if (pluginRef.getCommandTools().isInvalidInteger(sender, args[1])) { return true; } @@ -89,7 +88,7 @@ public class MctopCommand implements TabExecutor { } if (sender instanceof Player) { - if (!CommandUtils.hasPlayerDataKey(sender)) { + if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) { return; } @@ -127,13 +126,13 @@ public class MctopCommand implements TabExecutor { } private PrimarySkillType extractSkill(CommandSender sender, String skillName) { - if (CommandUtils.isInvalidSkill(sender, skillName)) { + if (pluginRef.getCommandTools().isInvalidSkill(sender, skillName)) { return null; } PrimarySkillType skill = PrimarySkillType.getSkill(skillName); - if (CommandUtils.isChildSkill(sender, skill)) { + if (pluginRef.getCommandTools().isChildSkill(sender, skill)) { return null; } 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 370079903..b2c06a479 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -8,7 +8,6 @@ import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.TextComponentFactory; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; @@ -55,11 +54,11 @@ public abstract class SkillCommand implements TabExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandUtils.noConsoleUsage(sender)) { + if (pluginRef.getCommandTools().noConsoleUsage(sender)) { return true; } - if (!CommandUtils.hasPlayerDataKey(sender)) { + if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) { return true; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java index 9e7f86bdf..92cf7e4a3 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/Party.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/Party.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.datatypes.party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.sounds.SoundManager; diff --git a/src/main/java/com/gmail/nossr50/datatypes/party/ShareMode.java b/src/main/java/com/gmail/nossr50/datatypes/party/ShareMode.java index 33d64e51b..3e3518ddb 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/party/ShareMode.java +++ b/src/main/java/com/gmail/nossr50/datatypes/party/ShareMode.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.datatypes.party; -import com.gmail.nossr50.util.commands.CommandUtils; - public enum ShareMode { NONE, EQUAL, @@ -13,7 +11,7 @@ public enum ShareMode { } catch (IllegalArgumentException ex) { if (string.equalsIgnoreCase("even")) { return EQUAL; - } else if (CommandUtils.shouldDisableToggle(string)) { + } else if (pluginRef.getCommandTools().shouldDisableToggle(string)) { return NONE; } diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index bef26bcde..d66610e1d 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -32,7 +32,6 @@ import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.experience.ExperienceBarManager; diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java index 91f908c82..f59c33a13 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/subskills/acrobatics/Roll.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.random.RandomChanceSkill; diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index ecc442e88..73dba174a 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -18,7 +18,6 @@ import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.util.BlockUtils; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 9c0c84c61..c7285e6ad 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -32,6 +32,7 @@ import com.gmail.nossr50.util.*; import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager; import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory; import com.gmail.nossr50.util.commands.CommandRegistrationManager; +import com.gmail.nossr50.util.commands.CommandTools; import com.gmail.nossr50.util.experience.FormulaManager; import com.gmail.nossr50.util.nbt.NBTManager; import com.gmail.nossr50.util.player.NotificationManager; @@ -73,6 +74,9 @@ public class mcMMO extends JavaPlugin { private MobHealthBarManager mobHealthBarManager; private EventManager eventManager; + /* Not-Managers but my naming scheme sucks */ + private CommandTools commandTools; + /* File Paths */ private String mainDirectory; private String localesDirectory; @@ -201,6 +205,8 @@ public class mcMMO extends JavaPlugin { //Init Event Manager eventManager = new EventManager(this); + + commandTools = new CommandTools(this); } @Override @@ -639,4 +645,8 @@ public class mcMMO extends JavaPlugin { public EventManager getEventManager() { return eventManager; } + + public CommandTools getCommandTools() { + return commandTools; + } } diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index f4b713ad1..267be082b 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -11,7 +11,6 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.runnables.items.TeleportationWarmup; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundType; @@ -41,7 +40,7 @@ public final class PartyManager { public boolean canTeleport(CommandSender sender, Player player, String targetName) { McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName); - if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { + if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) { return false; } diff --git a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java index 491fd1f42..ba0249d5b 100644 --- a/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java +++ b/src/main/java/com/gmail/nossr50/runnables/items/TeleportationWarmup.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.runnables.items; import com.gmail.nossr50.datatypes.player.McMMOPlayer; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.skills.SkillUtils; import org.bukkit.Location; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java index 6bf1733bf..06af3b4b8 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AbilityDisableTask.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.SkillUtils; diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java index d305552af..755ab10fb 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/BleedTimerTask.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.runnables.skills; import com.gmail.nossr50.datatypes.interactions.NotificationType; -import com.gmail.nossr50.util.MobHealthBarManager; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.sounds.SoundManager; diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index bc84e6ae7..ce23a0600 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -15,7 +15,10 @@ import com.gmail.nossr50.datatypes.treasure.ShakeTreasure; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent; import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.util.*; +import com.gmail.nossr50.util.BlockUtils; +import com.gmail.nossr50.util.ItemUtils; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.skills.CombatUtils; diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index a698b1705..e950f1c1f 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.runnables.skills.AbilityCooldownTask; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.util.BlockUtils; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.random.RandomChanceUtil; diff --git a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java index 15de27307..27e9d6e76 100644 --- a/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java +++ b/src/main/java/com/gmail/nossr50/skills/salvage/SalvageManager.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index 2ea7d9a1c..2231a76c0 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java index c0ce16b89..dbf062c3e 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingManager.java @@ -7,7 +7,10 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.util.*; +import com.gmail.nossr50.util.BlockUtils; +import com.gmail.nossr50.util.ItemUtils; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.RankUtils; diff --git a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java b/src/main/java/com/gmail/nossr50/util/commands/CommandTools.java similarity index 79% rename from src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java rename to src/main/java/com/gmail/nossr50/util/commands/CommandTools.java index a1fe9335e..b34fa19da 100644 --- a/src/main/java/com/gmail/nossr50/util/commands/CommandUtils.java +++ b/src/main/java/com/gmail/nossr50/util/commands/CommandTools.java @@ -4,11 +4,11 @@ import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.skills.SkillUtils; -import com.google.common.collect.ImmutableList; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -16,14 +16,14 @@ import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.List; -public final class CommandUtils { - public static final List TRUE_FALSE_OPTIONS = ImmutableList.of("on", "off", "true", "false", "enabled", "disabled"); - public static final List RESET_OPTIONS = ImmutableList.of("clear", "reset"); +public final class CommandTools { + private mcMMO pluginRef; - private CommandUtils() { + public CommandTools(mcMMO pluginRef) { + this.pluginRef = pluginRef; } - public static boolean isChildSkill(CommandSender sender, PrimarySkillType skill) { + public boolean isChildSkill(CommandSender sender, PrimarySkillType skill) { if (skill == null || !skill.isChildSkill()) { return false; } @@ -32,7 +32,7 @@ public final class CommandUtils { return true; } - public static boolean tooFar(CommandSender sender, Player target, boolean hasPermission) { + public boolean tooFar(CommandSender sender, Player target, boolean hasPermission) { if(!target.isOnline() && !hasPermission) { sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Offline")); return true; @@ -48,11 +48,11 @@ public final class CommandUtils { return false; } - public static boolean hidden(CommandSender sender, Player target, boolean hasPermission) { + public boolean hidden(CommandSender sender, Player target, boolean hasPermission) { return sender instanceof Player && !((Player) sender).canSee(target) && !hasPermission; } - public static boolean noConsoleUsage(CommandSender sender) { + public boolean noConsoleUsage(CommandSender sender) { if (sender instanceof Player) { return false; } @@ -61,7 +61,7 @@ public final class CommandUtils { return true; } - public static boolean isOffline(CommandSender sender, OfflinePlayer player) { + public boolean isOffline(CommandSender sender, OfflinePlayer player) { if (player.isOnline()) { return false; } @@ -78,9 +78,9 @@ public final class CommandUtils { * @param mcMMOPlayer mcMMOPlayer object of the target player * @return true if the player is online and a valid mcMMOPlayer object was found */ - public static boolean checkPlayerExistence(CommandSender sender, String playerName, McMMOPlayer mcMMOPlayer) { + public boolean checkPlayerExistence(CommandSender sender, String playerName, McMMOPlayer mcMMOPlayer) { if (mcMMOPlayer != null) { - if (CommandUtils.hidden(sender, mcMMOPlayer.getPlayer(), false)) { + if (hidden(sender, mcMMOPlayer.getPlayer(), false)) { sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Offline")); return false; } @@ -97,7 +97,7 @@ public final class CommandUtils { return false; } - public static boolean unloadedProfile(CommandSender sender, PlayerProfile profile) { + public boolean unloadedProfile(CommandSender sender, PlayerProfile profile) { if (profile.isLoaded()) { return false; } @@ -106,7 +106,7 @@ public final class CommandUtils { return true; } - public static boolean hasPlayerDataKey(CommandSender sender) { + public boolean hasPlayerDataKey(CommandSender sender) { if (!(sender instanceof Player)) { return false; } @@ -120,7 +120,7 @@ public final class CommandUtils { return hasPlayerDataKey; } - public static boolean isLoaded(CommandSender sender, PlayerProfile profile) { + public boolean isLoaded(CommandSender sender, PlayerProfile profile) { if (profile.isLoaded()) { return true; } @@ -129,7 +129,7 @@ public final class CommandUtils { return false; } - public static boolean isInvalidInteger(CommandSender sender, String value) { + public boolean isInvalidInteger(CommandSender sender, String value) { if (StringUtils.isInt(value)) { return false; } @@ -138,7 +138,7 @@ public final class CommandUtils { return true; } - public static boolean isInvalidDouble(CommandSender sender, String value) { + public boolean isInvalidDouble(CommandSender sender, String value) { if (StringUtils.isDouble(value)) { return false; } @@ -147,7 +147,7 @@ public final class CommandUtils { return true; } - public static boolean isInvalidSkill(CommandSender sender, String skillName) { + public boolean isInvalidSkill(CommandSender sender, String skillName) { if (SkillUtils.isSkill(skillName)) { return false; } @@ -156,11 +156,11 @@ public final class CommandUtils { return true; } - public static boolean shouldEnableToggle(String arg) { + public boolean shouldEnableToggle(String arg) { return arg.equalsIgnoreCase("on") || arg.equalsIgnoreCase("true") || arg.equalsIgnoreCase("enabled"); } - public static boolean shouldDisableToggle(String arg) { + public boolean shouldDisableToggle(String arg) { return arg.equalsIgnoreCase("off") || arg.equalsIgnoreCase("false") || arg.equalsIgnoreCase("disabled"); } @@ -170,11 +170,11 @@ public final class CommandUtils { * @param inspect The player to retrieve stats for * @param display The sender to display stats to */ - public static void printGatheringSkills(Player inspect, CommandSender display) { + public void printGatheringSkills(Player inspect, CommandSender display) { printGroupedSkillData(inspect, display, pluginRef.getLocaleManager().getString("Stats.Header.Gathering"), PrimarySkillType.GATHERING_SKILLS); } - public static void printGatheringSkills(Player player) { + public void printGatheringSkills(Player player) { printGatheringSkills(player, player); } @@ -184,11 +184,11 @@ public final class CommandUtils { * @param inspect The player to retrieve stats for * @param display The sender to display stats to */ - public static void printCombatSkills(Player inspect, CommandSender display) { + public void printCombatSkills(Player inspect, CommandSender display) { printGroupedSkillData(inspect, display, pluginRef.getLocaleManager().getString("Stats.Header.Combat"), PrimarySkillType.COMBAT_SKILLS); } - public static void printCombatSkills(Player player) { + public void printCombatSkills(Player player) { printCombatSkills(player, player); } @@ -198,15 +198,15 @@ public final class CommandUtils { * @param inspect The player to retrieve stats for * @param display The sender to display stats to */ - public static void printMiscSkills(Player inspect, CommandSender display) { + public void printMiscSkills(Player inspect, CommandSender display) { printGroupedSkillData(inspect, display, pluginRef.getLocaleManager().getString("Stats.Header.Misc"), PrimarySkillType.MISC_SKILLS); } - public static void printMiscSkills(Player player) { + public void printMiscSkills(Player player) { printMiscSkills(player, player); } - public static String displaySkill(PlayerProfile profile, PrimarySkillType skill) { + public String displaySkill(PlayerProfile profile, PrimarySkillType skill) { if (skill.isChildSkill()) { return pluginRef.getLocaleManager().getString("Skills.ChildStats", pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill)); } @@ -214,7 +214,7 @@ public final class CommandUtils { return pluginRef.getLocaleManager().getString("Skills.Stats", pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)); } - private static void printGroupedSkillData(Player inspect, CommandSender display, String header, List skillGroup) { + private void printGroupedSkillData(Player inspect, CommandSender display, String header, List skillGroup) { if (UserManager.getPlayer(inspect) == null) return; @@ -236,7 +236,7 @@ public final class CommandUtils { } } - public static List getOnlinePlayerNames(CommandSender sender) { + public List getOnlinePlayerNames(CommandSender sender) { Player player = sender instanceof Player ? (Player) sender : null; List onlinePlayerNames = new ArrayList<>(); @@ -255,7 +255,7 @@ public final class CommandUtils { * @param partialName Name to match * @return Matched name or {@code partialName} if no match was found */ - public static String getMatchedPlayerName(String partialName) { + public String getMatchedPlayerName(String partialName) { if (pluginRef.getConfigManager().getConfigCommands().getMisc().isMatchOfflinePlayers()) { List matches = matchPlayer(partialName); @@ -282,7 +282,7 @@ public final class CommandUtils { * @param partialName Name to match * @return List of all possible names */ - private static List matchPlayer(String partialName) { + private List matchPlayer(String partialName) { List matchedPlayers = new ArrayList<>(); for (OfflinePlayer offlinePlayer : pluginRef.getServer().getOfflinePlayers()) { diff --git a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java index cf884e94e..47c7d1b19 100644 --- a/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java +++ b/src/main/java/com/gmail/nossr50/util/player/NotificationManager.java @@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.sounds.SoundManager; diff --git a/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java b/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java index 599fdf6c6..fab4438e3 100644 --- a/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java +++ b/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java @@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent; import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillRandomCheckEvent; -import com.gmail.nossr50.util.EventManager; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.skills.SkillActivationType; import org.bukkit.entity.Player; diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 01f7e95ee..9caebed64 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -19,7 +19,9 @@ import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.unarmed.Unarmed; import com.gmail.nossr50.skills.unarmed.UnarmedManager; -import com.gmail.nossr50.util.*; +import com.gmail.nossr50.util.ItemUtils; +import com.gmail.nossr50.util.Misc; +import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; import com.google.common.collect.ImmutableMap; import org.bukkit.GameMode;