Static Abuse Removal - CommandUtils -> CommandTools

This commit is contained in:
nossr50 2019-07-02 19:00:06 -07:00
parent 762c3bd04e
commit 57b7050a2c
46 changed files with 145 additions and 168 deletions

View File

@ -7,4 +7,6 @@ import java.util.List;
public class CommandConstants { public class CommandConstants {
public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall"); public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall");
public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband"); public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband");
public static final List<String> TRUE_FALSE_OPTIONS = ImmutableList.of("on", "off", "true", "false", "enabled", "disabled");
public static final List<String> RESET_OPTIONS = ImmutableList.of("clear", "reset");
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands; package com.gmail.nossr50.commands;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -24,7 +23,7 @@ public class McscoreboardCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
@ -56,7 +55,7 @@ public class McscoreboardCommand implements TabExecutor {
case 2: case 2:
if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) { if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
if (CommandUtils.isInvalidInteger(sender, args[1])) { if (pluginRef.getCommandTools().isInvalidInteger(sender, args[1])) {
return true; return true;
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands; package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; 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) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 0: case 0:
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
@ -26,7 +25,7 @@ public abstract class ToggleCommand implements TabExecutor {
return true; return true;
} }
if (!CommandUtils.hasPlayerDataKey(sender)) { if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true; return true;
} }
@ -39,14 +38,14 @@ public abstract class ToggleCommand implements TabExecutor {
return true; return true;
} }
String playerName = CommandUtils.getMatchedPlayerName(args[0]); String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) { if (!pluginRef.getCommandTools().checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
return true; return true;
} }
if (CommandUtils.isOffline(sender, mcMMOPlayer.getPlayer())) { if (pluginRef.getCommandTools().isOffline(sender, mcMMOPlayer.getPlayer())) {
return true; return true;
} }
@ -63,7 +62,7 @@ public abstract class ToggleCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -60,7 +59,7 @@ public class XprateCommand implements TabExecutor {
return true; return true;
case 2: case 2:
if (CommandUtils.isInvalidInteger(sender, args[0])) { if (pluginRef.getCommandTools().isInvalidInteger(sender, args[0])) {
return true; return true;
} }
@ -69,9 +68,9 @@ public class XprateCommand implements TabExecutor {
return true; return true;
} }
if (CommandUtils.shouldDisableToggle(args[1])) { if (pluginRef.getCommandTools().shouldDisableToggle(args[1])) {
pluginRef.setXPEventEnabled(false); pluginRef.setXPEventEnabled(false);
} else if (CommandUtils.shouldEnableToggle(args[1])) { } else if (pluginRef.getCommandTools().shouldEnableToggle(args[1])) {
pluginRef.setXPEventEnabled(true); pluginRef.setXPEventEnabled(true);
} else { } else {
return false; return false;
@ -116,9 +115,9 @@ public class XprateCommand implements TabExecutor {
return ImmutableList.of(); 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: 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: default:
return ImmutableList.of(); return ImmutableList.of();
} }

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.chat; package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.commands.CommandConstants;
import com.gmail.nossr50.datatypes.chat.ChatMode; import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -31,11 +31,11 @@ public abstract class ChatCommand implements TabExecutor {
switch (args.length) { switch (args.length) {
case 0: case 0:
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
if (!CommandUtils.hasPlayerDataKey(sender)) { if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true; return true;
} }
@ -50,11 +50,11 @@ public abstract class ChatCommand implements TabExecutor {
return true; return true;
case 1: case 1:
if (CommandUtils.shouldEnableToggle(args[0])) { if (pluginRef.getCommandTools().shouldEnableToggle(args[0])) {
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
if (!CommandUtils.hasPlayerDataKey(sender)) { if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true; return true;
} }
@ -62,11 +62,11 @@ public abstract class ChatCommand implements TabExecutor {
return true; return true;
} }
if (CommandUtils.shouldDisableToggle(args[0])) { if (pluginRef.getCommandTools().shouldDisableToggle(args[0])) {
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
if (!CommandUtils.hasPlayerDataKey(sender)) { if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true; return true;
} }
@ -86,7 +86,7 @@ public abstract class ChatCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: 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: default:
return ImmutableList.of(); return ImmutableList.of();
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands.database; package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -25,9 +24,9 @@ public class McremoveCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 1) { 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; return true;
} }
@ -52,7 +51,7 @@ public class McremoveCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EventManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -40,7 +39,7 @@ public abstract class ExperienceCommand implements TabExecutor {
switch (args.length) { switch (args.length) {
case 2: case 2:
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
@ -97,7 +96,7 @@ public abstract class ExperienceCommand implements TabExecutor {
int value = Integer.parseInt(args[2]); int value = Integer.parseInt(args[2]);
String playerName = CommandUtils.getMatchedPlayerName(args[0]); String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); 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 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); PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
if (CommandUtils.unloadedProfile(sender, profile)) { if (pluginRef.getCommandTools().unloadedProfile(sender, profile)) {
return true; return true;
} }
@ -130,7 +129,7 @@ public abstract class ExperienceCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
case 2: case 2:
return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size())); 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); protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill);
private boolean validateArguments(CommandSender sender, String skillName, String value) { 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) { protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EventManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -5,9 +5,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EventManager;
import com.gmail.nossr50.util.Permissions; 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.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -46,7 +44,7 @@ public class SkillresetCommand implements TabExecutor {
PrimarySkillType skill; PrimarySkillType skill;
switch (args.length) { switch (args.length) {
case 1: case 1:
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
@ -84,7 +82,7 @@ public class SkillresetCommand implements TabExecutor {
skill = PrimarySkillType.getSkill(args[1]); skill = PrimarySkillType.getSkill(args[1]);
} }
String playerName = CommandUtils.getMatchedPlayerName(args[0]); String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); 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 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); PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
if (CommandUtils.unloadedProfile(sender, profile)) { if (pluginRef.getCommandTools().unloadedProfile(sender, profile)) {
return true; return true;
} }
@ -117,7 +115,7 @@ public class SkillresetCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
case 2: case 2:
return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<>(PrimarySkillType.SKILL_NAMES.size())); 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) { 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) { protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill) {

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -29,7 +28,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
} }
Party playerParty = UserManager.getPlayer((Player) sender).getParty(); 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); OfflinePlayer target = pluginRef.getServer().getOfflinePlayer(targetName);
if (!playerParty.hasMember(target.getUniqueId())) { if (!playerParty.hasMember(target.getUniqueId())) {

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; 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.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -93,7 +92,7 @@ public class PartyCommand implements TabExecutor {
if (!pluginRef.getConfigManager().getConfigParty().isPartySystemEnabled()) if (!pluginRef.getConfigManager().getConfigParty().isPartySystemEnabled())
return true; return true;
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
@ -220,7 +219,7 @@ public class PartyCommand implements TabExecutor {
case INVITE: case INVITE:
case KICK: case KICK:
case OWNER: case OWNER:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size())); return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));
case XPSHARE: case XPSHARE:
return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<>(XPSHARE_COMPLETIONS.size())); 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())); return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList<>(ITEMSHARE_COMPLETIONS.size()));
case LOCK: case LOCK:
case CHAT: 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: 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: case TELEPORT:
List<String> matches = StringUtil.copyPartialMatches(args[1], CommandConstants.TELEPORT_SUBCOMMANDS, new ArrayList<>(CommandConstants.TELEPORT_SUBCOMMANDS.size())); List<String> 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: case 3:
if (PartySubcommandType.getSubcommand(args[0]) == PartySubcommandType.ITEMSHARE && isItemShareCategory(args[1])) { 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(); return ImmutableList.of();

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; 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) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
String targetName = CommandUtils.getMatchedPlayerName(args[1]); String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false; return false;
} }

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils; 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.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -50,9 +49,9 @@ public class PartyItemShareCommand implements CommandExecutor {
case 3: case 3:
boolean toggle; boolean toggle;
if (CommandUtils.shouldEnableToggle(args[2])) { if (pluginRef.getCommandTools().shouldEnableToggle(args[2])) {
toggle = true; toggle = true;
} else if (CommandUtils.shouldDisableToggle(args[2])) { } else if (pluginRef.getCommandTools().shouldDisableToggle(args[2])) {
toggle = false; toggle = false;
} else { } else {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>")); sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -23,10 +22,10 @@ public class PartyJoinCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 2: case 2:
case 3: case 3:
String targetName = CommandUtils.getMatchedPlayerName(args[1]); String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName); McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return true; return true;
} }

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -29,7 +28,7 @@ public class PartyKickCommand implements CommandExecutor {
} }
Party playerParty = UserManager.getPlayer((Player) sender).getParty(); Party playerParty = UserManager.getPlayer((Player) sender).getParty();
String targetName = CommandUtils.getMatchedPlayerName(args[1]); String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[1]);
if (!playerParty.hasMember(targetName)) { if (!playerParty.hasMember(targetName)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Party.NotInYourParty", targetName)); sender.sendMessage(pluginRef.getLocaleManager().getString("Party.NotInYourParty", targetName));

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; 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.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -36,9 +35,9 @@ public class PartyLockCommand implements CommandExecutor {
return true; return true;
} }
if (CommandUtils.shouldEnableToggle(args[1])) { if (pluginRef.getCommandTools().shouldEnableToggle(args[1])) {
togglePartyLock(sender, true); togglePartyLock(sender, true);
} else if (CommandUtils.shouldDisableToggle(args[1])) { } else if (pluginRef.getCommandTools().shouldDisableToggle(args[1])) {
togglePartyLock(sender, false); togglePartyLock(sender, false);
} else { } else {
sendUsageStrings(sender); sendUsageStrings(sender);

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils; 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.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -36,9 +35,9 @@ public class PartyXpShareCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 2: 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); 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); handleChangingShareMode(party, ShareMode.EQUAL);
} else { } else {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>")); sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>"));

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -40,7 +39,7 @@ public class PartyAllianceCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
@ -119,7 +118,7 @@ public class PartyAllianceCommand implements TabExecutor {
List<String> matches = StringUtil.copyPartialMatches(args[0], CommandConstants.ALLIANCE_SUBCOMMANDS, new ArrayList<>(CommandConstants.ALLIANCE_SUBCOMMANDS.size())); List<String> matches = StringUtil.copyPartialMatches(args[0], CommandConstants.ALLIANCE_SUBCOMMANDS, new ArrayList<>(CommandConstants.ALLIANCE_SUBCOMMANDS.size()));
if (matches.size() == 0) { if (matches.size() == 0) {
List<String> playerNames = CommandUtils.getOnlinePlayerNames(commandSender); List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(commandSender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
} }

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; 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) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 3: case 3:
String targetName = CommandUtils.getMatchedPlayerName(args[2]); String targetName = pluginRef.getCommandTools().getMatchedPlayerName(args[2]);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName); McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false; return false;
} }

View File

@ -7,11 +7,8 @@ import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; 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.Misc;
import com.gmail.nossr50.util.Permissions; 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.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.worldguard.WorldGuardUtils; import com.gmail.nossr50.worldguard.WorldGuardUtils;
@ -44,7 +41,7 @@ public class PtpCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; 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 true;
} }
return false; return false;

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; 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.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; 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) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
String playerName = CommandUtils.getMatchedPlayerName(args[0]); String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); 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 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) { if (mcMMOPlayer == null) {
PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile PlayerProfile profile = pluginRef.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile
if (!CommandUtils.isLoaded(sender, profile)) { if (!pluginRef.getCommandTools().isLoaded(sender, profile)) {
return true; return true;
} }
@ -55,27 +54,27 @@ public class InspectCommand implements TabExecutor {
sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Gathering")); sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Gathering"));
for (PrimarySkillType skill : PrimarySkillType.GATHERING_SKILLS) { 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")); sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Combat"));
for (PrimarySkillType skill : PrimarySkillType.COMBAT_SKILLS) { 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")); sender.sendMessage(pluginRef.getLocaleManager().getString("Stats.Header.Misc"));
for (PrimarySkillType skill : PrimarySkillType.MISC_SKILLS) { for (PrimarySkillType skill : PrimarySkillType.MISC_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill)); sender.sendMessage(pluginRef.getCommandTools().displaySkill(profile, skill));
} }
} else { } else {
Player target = mcMMOPlayer.getPlayer(); 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")); sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Offline"));
return true; return true;
} }
else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) { else if (pluginRef.getCommandTools().tooFar(sender, target, Permissions.inspectFar(sender))) {
return true; return true;
} }
@ -88,9 +87,9 @@ public class InspectCommand implements TabExecutor {
} }
sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Stats", target.getName())); sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Stats", target.getName()));
CommandUtils.printGatheringSkills(target, sender); pluginRef.getCommandTools().printGatheringSkills(target, sender);
CommandUtils.printCombatSkills(target, sender); pluginRef.getCommandTools().printCombatSkills(target, sender);
CommandUtils.printMiscSkills(target, sender); pluginRef.getCommandTools().printMiscSkills(target, sender);
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel())); sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
} }
@ -105,7 +104,7 @@ public class InspectCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -24,11 +23,11 @@ public class MccooldownCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
if (!CommandUtils.hasPlayerDataKey(sender)) { if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true; return true;
} }

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask; import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.util.Permissions; 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.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; 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) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 0: case 0:
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
@ -40,7 +39,7 @@ public class McrankCommand implements TabExecutor {
return true; return true;
} }
if (!CommandUtils.hasPlayerDataKey(sender)) { if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true; return true;
} }
@ -54,18 +53,18 @@ public class McrankCommand implements TabExecutor {
return true; return true;
} }
if (!CommandUtils.hasPlayerDataKey(sender)) { if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true; return true;
} }
String playerName = CommandUtils.getMatchedPlayerName(args[0]); String playerName = pluginRef.getCommandTools().getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName); McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
if (mcMMOPlayer != null) { if (mcMMOPlayer != null) {
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
playerName = player.getName(); playerName = player.getName();
if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) { if (pluginRef.getCommandTools().tooFar(sender, player, Permissions.mcrankFar(sender))) {
return true; return true;
} }
} }
@ -82,7 +81,7 @@ public class McrankCommand implements TabExecutor {
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) { switch (args.length) {
case 1: case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender); List<String> playerNames = pluginRef.getCommandTools().getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size())); return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<>(playerNames.size()));
default: default:
return ImmutableList.of(); return ImmutableList.of();

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands.player; package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -22,11 +21,11 @@ public class McstatsCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
if (!CommandUtils.hasPlayerDataKey(sender)) { if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true; return true;
} }
@ -50,9 +49,9 @@ public class McstatsCommand implements TabExecutor {
player.sendMessage(pluginRef.getLocaleManager().getString("Stats.Own.Stats")); player.sendMessage(pluginRef.getLocaleManager().getString("Stats.Own.Stats"));
player.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoSkillNote")); player.sendMessage(pluginRef.getLocaleManager().getString("mcMMO.NoSkillNote"));
CommandUtils.printGatheringSkills(player); pluginRef.getCommandTools().printGatheringSkills(player);
CommandUtils.printCombatSkills(player); pluginRef.getCommandTools().printCombatSkills(player);
CommandUtils.printMiscSkills(player); pluginRef.getCommandTools().printMiscSkills(player);
int powerLevelCap = pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().getLevelCap(); int powerLevelCap = pluginRef.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().getLevelCap();

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask; import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; 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.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -54,7 +53,7 @@ public class MctopCommand implements TabExecutor {
return true; return true;
case 2: case 2:
if (CommandUtils.isInvalidInteger(sender, args[1])) { if (pluginRef.getCommandTools().isInvalidInteger(sender, args[1])) {
return true; return true;
} }
@ -89,7 +88,7 @@ public class MctopCommand implements TabExecutor {
} }
if (sender instanceof Player) { if (sender instanceof Player) {
if (!CommandUtils.hasPlayerDataKey(sender)) { if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return; return;
} }
@ -127,13 +126,13 @@ public class MctopCommand implements TabExecutor {
} }
private PrimarySkillType extractSkill(CommandSender sender, String skillName) { private PrimarySkillType extractSkill(CommandSender sender, String skillName) {
if (CommandUtils.isInvalidSkill(sender, skillName)) { if (pluginRef.getCommandTools().isInvalidSkill(sender, skillName)) {
return null; return null;
} }
PrimarySkillType skill = PrimarySkillType.getSkill(skillName); PrimarySkillType skill = PrimarySkillType.getSkill(skillName);
if (CommandUtils.isChildSkill(sender, skill)) { if (pluginRef.getCommandTools().isChildSkill(sender, skill)) {
return null; return null;
} }

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.TextComponentFactory; 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.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
@ -55,11 +54,11 @@ public abstract class SkillCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (pluginRef.getCommandTools().noConsoleUsage(sender)) {
return true; return true;
} }
if (!CommandUtils.hasPlayerDataKey(sender)) { if (!pluginRef.getCommandTools().hasPlayerDataKey(sender)) {
return true; return true;
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.datatypes.party; package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.EventManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.datatypes.party; package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.util.commands.CommandUtils;
public enum ShareMode { public enum ShareMode {
NONE, NONE,
EQUAL, EQUAL,
@ -13,7 +11,7 @@ public enum ShareMode {
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
if (string.equalsIgnoreCase("even")) { if (string.equalsIgnoreCase("even")) {
return EQUAL; return EQUAL;
} else if (CommandUtils.shouldDisableToggle(string)) { } else if (pluginRef.getCommandTools().shouldDisableToggle(string)) {
return NONE; return NONE;
} }

View File

@ -32,7 +32,6 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.EventManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.experience.ExperienceBarManager; import com.gmail.nossr50.util.experience.ExperienceBarManager;

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EventManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceSkill; import com.gmail.nossr50.util.random.RandomChanceSkill;

View File

@ -18,7 +18,6 @@ import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.salvage.Salvage; import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventManager;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;

View File

@ -32,6 +32,7 @@ import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager; import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory; import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
import com.gmail.nossr50.util.commands.CommandRegistrationManager; 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.experience.FormulaManager;
import com.gmail.nossr50.util.nbt.NBTManager; import com.gmail.nossr50.util.nbt.NBTManager;
import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.NotificationManager;
@ -73,6 +74,9 @@ public class mcMMO extends JavaPlugin {
private MobHealthBarManager mobHealthBarManager; private MobHealthBarManager mobHealthBarManager;
private EventManager eventManager; private EventManager eventManager;
/* Not-Managers but my naming scheme sucks */
private CommandTools commandTools;
/* File Paths */ /* File Paths */
private String mainDirectory; private String mainDirectory;
private String localesDirectory; private String localesDirectory;
@ -201,6 +205,8 @@ public class mcMMO extends JavaPlugin {
//Init Event Manager //Init Event Manager
eventManager = new EventManager(this); eventManager = new EventManager(this);
commandTools = new CommandTools(this);
} }
@Override @Override
@ -639,4 +645,8 @@ public class mcMMO extends JavaPlugin {
public EventManager getEventManager() { public EventManager getEventManager() {
return eventManager; return eventManager;
} }
public CommandTools getCommandTools() {
return commandTools;
}
} }

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.items.TeleportationWarmup; import com.gmail.nossr50.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; 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.player.UserManager;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
@ -41,7 +40,7 @@ public final class PartyManager {
public boolean canTeleport(CommandSender sender, Player player, String targetName) { public boolean canTeleport(CommandSender sender, Player player, String targetName) {
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName); McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { if (!pluginRef.getCommandTools().checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false; return false;
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.runnables.items; package com.gmail.nossr50.runnables.items;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.EventManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.util.EventManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.runnables.skills; package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.interactions.NotificationType; 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.CombatUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;

View File

@ -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.McMMOPlayerFishingTreasureEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent; import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent;
import com.gmail.nossr50.skills.SkillManager; 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.RandomChanceSkillStatic;
import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.CombatUtils;

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask; import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventManager;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.random.RandomChanceUtil;

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; 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.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.EventManager;
import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;

View File

@ -7,7 +7,10 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.skills.SkillManager; 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.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.CombatUtils; import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.RankUtils; import com.gmail.nossr50.util.skills.RankUtils;

View File

@ -4,11 +4,11 @@ import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -16,14 +16,14 @@ import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public final class CommandUtils { public final class CommandTools {
public static final List<String> TRUE_FALSE_OPTIONS = ImmutableList.of("on", "off", "true", "false", "enabled", "disabled"); private mcMMO pluginRef;
public static final List<String> RESET_OPTIONS = ImmutableList.of("clear", "reset");
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()) { if (skill == null || !skill.isChildSkill()) {
return false; return false;
} }
@ -32,7 +32,7 @@ public final class CommandUtils {
return true; 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) { if(!target.isOnline() && !hasPermission) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Offline")); sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.Offline"));
return true; return true;
@ -48,11 +48,11 @@ public final class CommandUtils {
return false; 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; return sender instanceof Player && !((Player) sender).canSee(target) && !hasPermission;
} }
public static boolean noConsoleUsage(CommandSender sender) { public boolean noConsoleUsage(CommandSender sender) {
if (sender instanceof Player) { if (sender instanceof Player) {
return false; return false;
} }
@ -61,7 +61,7 @@ public final class CommandUtils {
return true; return true;
} }
public static boolean isOffline(CommandSender sender, OfflinePlayer player) { public boolean isOffline(CommandSender sender, OfflinePlayer player) {
if (player.isOnline()) { if (player.isOnline()) {
return false; return false;
} }
@ -78,9 +78,9 @@ public final class CommandUtils {
* @param mcMMOPlayer mcMMOPlayer object of the target player * @param mcMMOPlayer mcMMOPlayer object of the target player
* @return true if the player is online and a valid mcMMOPlayer object was found * @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 (mcMMOPlayer != null) {
if (CommandUtils.hidden(sender, mcMMOPlayer.getPlayer(), false)) { if (hidden(sender, mcMMOPlayer.getPlayer(), false)) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Offline")); sender.sendMessage(pluginRef.getLocaleManager().getString("Commands.Offline"));
return false; return false;
} }
@ -97,7 +97,7 @@ public final class CommandUtils {
return false; return false;
} }
public static boolean unloadedProfile(CommandSender sender, PlayerProfile profile) { public boolean unloadedProfile(CommandSender sender, PlayerProfile profile) {
if (profile.isLoaded()) { if (profile.isLoaded()) {
return false; return false;
} }
@ -106,7 +106,7 @@ public final class CommandUtils {
return true; return true;
} }
public static boolean hasPlayerDataKey(CommandSender sender) { public boolean hasPlayerDataKey(CommandSender sender) {
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
return false; return false;
} }
@ -120,7 +120,7 @@ public final class CommandUtils {
return hasPlayerDataKey; return hasPlayerDataKey;
} }
public static boolean isLoaded(CommandSender sender, PlayerProfile profile) { public boolean isLoaded(CommandSender sender, PlayerProfile profile) {
if (profile.isLoaded()) { if (profile.isLoaded()) {
return true; return true;
} }
@ -129,7 +129,7 @@ public final class CommandUtils {
return false; return false;
} }
public static boolean isInvalidInteger(CommandSender sender, String value) { public boolean isInvalidInteger(CommandSender sender, String value) {
if (StringUtils.isInt(value)) { if (StringUtils.isInt(value)) {
return false; return false;
} }
@ -138,7 +138,7 @@ public final class CommandUtils {
return true; return true;
} }
public static boolean isInvalidDouble(CommandSender sender, String value) { public boolean isInvalidDouble(CommandSender sender, String value) {
if (StringUtils.isDouble(value)) { if (StringUtils.isDouble(value)) {
return false; return false;
} }
@ -147,7 +147,7 @@ public final class CommandUtils {
return true; return true;
} }
public static boolean isInvalidSkill(CommandSender sender, String skillName) { public boolean isInvalidSkill(CommandSender sender, String skillName) {
if (SkillUtils.isSkill(skillName)) { if (SkillUtils.isSkill(skillName)) {
return false; return false;
} }
@ -156,11 +156,11 @@ public final class CommandUtils {
return true; return true;
} }
public static boolean shouldEnableToggle(String arg) { public boolean shouldEnableToggle(String arg) {
return arg.equalsIgnoreCase("on") || arg.equalsIgnoreCase("true") || arg.equalsIgnoreCase("enabled"); 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"); 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 inspect The player to retrieve stats for
* @param display The sender to display stats to * @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); 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); printGatheringSkills(player, player);
} }
@ -184,11 +184,11 @@ public final class CommandUtils {
* @param inspect The player to retrieve stats for * @param inspect The player to retrieve stats for
* @param display The sender to display stats to * @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); 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); printCombatSkills(player, player);
} }
@ -198,15 +198,15 @@ public final class CommandUtils {
* @param inspect The player to retrieve stats for * @param inspect The player to retrieve stats for
* @param display The sender to display stats to * @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); 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); printMiscSkills(player, player);
} }
public static String displaySkill(PlayerProfile profile, PrimarySkillType skill) { public String displaySkill(PlayerProfile profile, PrimarySkillType skill) {
if (skill.isChildSkill()) { if (skill.isChildSkill()) {
return pluginRef.getLocaleManager().getString("Skills.ChildStats", pluginRef.getLocaleManager().getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill)); 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)); 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<PrimarySkillType> skillGroup) { private void printGroupedSkillData(Player inspect, CommandSender display, String header, List<PrimarySkillType> skillGroup) {
if (UserManager.getPlayer(inspect) == null) if (UserManager.getPlayer(inspect) == null)
return; return;
@ -236,7 +236,7 @@ public final class CommandUtils {
} }
} }
public static List<String> getOnlinePlayerNames(CommandSender sender) { public List<String> getOnlinePlayerNames(CommandSender sender) {
Player player = sender instanceof Player ? (Player) sender : null; Player player = sender instanceof Player ? (Player) sender : null;
List<String> onlinePlayerNames = new ArrayList<>(); List<String> onlinePlayerNames = new ArrayList<>();
@ -255,7 +255,7 @@ public final class CommandUtils {
* @param partialName Name to match * @param partialName Name to match
* @return Matched name or {@code partialName} if no match was found * @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()) { if (pluginRef.getConfigManager().getConfigCommands().getMisc().isMatchOfflinePlayers()) {
List<String> matches = matchPlayer(partialName); List<String> matches = matchPlayer(partialName);
@ -282,7 +282,7 @@ public final class CommandUtils {
* @param partialName Name to match * @param partialName Name to match
* @return List of all possible names * @return List of all possible names
*/ */
private static List<String> matchPlayer(String partialName) { private List<String> matchPlayer(String partialName) {
List<String> matchedPlayers = new ArrayList<>(); List<String> matchedPlayers = new ArrayList<>();
for (OfflinePlayer offlinePlayer : pluginRef.getServer().getOfflinePlayers()) { for (OfflinePlayer offlinePlayer : pluginRef.getServer().getOfflinePlayers()) {

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent; import com.gmail.nossr50.events.skills.McMMOPlayerNotificationEvent;
import com.gmail.nossr50.util.EventManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory; import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent; import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SubSkillRandomCheckEvent; 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.Permissions;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -19,7 +19,9 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.Unarmed; import com.gmail.nossr50.skills.unarmed.Unarmed;
import com.gmail.nossr50.skills.unarmed.UnarmedManager; 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.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.bukkit.GameMode; import org.bukkit.GameMode;