diff --git a/src/main/java/com/gmail/nossr50/commands/CommandConstants.java b/src/main/java/com/gmail/nossr50/commands/CommandConstants.java new file mode 100644 index 000000000..2590bacbb --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/CommandConstants.java @@ -0,0 +1,10 @@ +package com.gmail.nossr50.commands; + +import com.google.common.collect.ImmutableList; + +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"); +} diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java index be2d444bc..936fb76e0 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyAcceptCommand.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -8,6 +9,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyAcceptCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyAcceptCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (args.length == 1) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java index b80b948bc..7849a9e12 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyChangePasswordCommand.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -8,6 +9,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyChangePasswordCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyChangePasswordCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (UserManager.getPlayer((Player) sender) == null) { 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 a7148f555..5d8b54f7c 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.commands.party; +import com.gmail.nossr50.commands.CommandConstants; import com.gmail.nossr50.commands.chat.PartyChatCommand; import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand; import com.gmail.nossr50.commands.party.teleport.PtpCommand; @@ -22,13 +23,51 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +//TODO: This class horrifies me, rewrite it at some point public class PartyCommand implements TabExecutor { private mcMMO pluginRef; + private CommandExecutor partyJoinCommand; + private CommandExecutor partyAcceptCommand; + private CommandExecutor partyCreateCommand; + private CommandExecutor partyQuitCommand; + private CommandExecutor partyXpShareCommand; + private CommandExecutor partyItemShareCommand; + private CommandExecutor partyInviteCommand; + private CommandExecutor partyKickCommand; + private CommandExecutor partyDisbandCommand; + private CommandExecutor partyChangeOwnerCommand; + private CommandExecutor partyLockCommand; + private CommandExecutor partyChangePasswordCommand; + private CommandExecutor partyRenameCommand; + private CommandExecutor partyInfoCommand; + private CommandExecutor partyHelpCommand; + private CommandExecutor partyTeleportCommand; + private CommandExecutor partyChatCommand; + private CommandExecutor partyAllianceCommand; public PartyCommand(mcMMO pluginRef) { this.pluginRef = pluginRef; initSubCommandList(); + + partyJoinCommand = new PartyJoinCommand(pluginRef); + partyAcceptCommand = new PartyAcceptCommand(pluginRef); + partyCreateCommand = new PartyCreateCommand(pluginRef); + partyQuitCommand = new PartyQuitCommand(pluginRef); + partyXpShareCommand = new PartyXpShareCommand(pluginRef); + partyItemShareCommand = new PartyItemShareCommand(pluginRef); + partyInviteCommand = new PartyInviteCommand(pluginRef); + partyKickCommand = new PartyKickCommand(pluginRef); + partyDisbandCommand = new PartyDisbandCommand(pluginRef); + partyChangeOwnerCommand = new PartyChangeOwnerCommand(pluginRef); + partyLockCommand = new PartyLockCommand(pluginRef); + partyChangePasswordCommand = new PartyChangePasswordCommand(pluginRef); + partyRenameCommand = new PartyRenameCommand(pluginRef); + partyInfoCommand = new PartyInfoCommand(pluginRef); + partyHelpCommand = new PartyHelpCommand(pluginRef); + partyTeleportCommand = new PtpCommand(pluginRef); + partyChatCommand = new PartyChatCommand(pluginRef); + partyAllianceCommand = new PartyAllianceCommand(pluginRef); } private List PARTY_SUBCOMMANDS; @@ -46,24 +85,7 @@ public class PartyCommand implements TabExecutor { PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands); } - private CommandExecutor partyJoinCommand = new PartyJoinCommand(); - private CommandExecutor partyAcceptCommand = new PartyAcceptCommand(); - private CommandExecutor partyCreateCommand = new PartyCreateCommand(); - private CommandExecutor partyQuitCommand = new PartyQuitCommand(); - private CommandExecutor partyXpShareCommand = new PartyXpShareCommand(); - private CommandExecutor partyItemShareCommand = new PartyItemShareCommand(); - private CommandExecutor partyInviteCommand = new PartyInviteCommand(); - private CommandExecutor partyKickCommand = new PartyKickCommand(); - private CommandExecutor partyDisbandCommand = new PartyDisbandCommand(); - private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand(); - private CommandExecutor partyLockCommand = new PartyLockCommand(); - private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand(); - private CommandExecutor partyRenameCommand = new PartyRenameCommand(); - private CommandExecutor partyInfoCommand = new PartyInfoCommand(); - private CommandExecutor partyHelpCommand = new PartyHelpCommand(); - private CommandExecutor partyTeleportCommand = new PtpCommand(); - private CommandExecutor partyChatCommand = new PartyChatCommand(); - private CommandExecutor partyAllianceCommand = new PartyAllianceCommand(); + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -210,7 +232,7 @@ public class PartyCommand implements TabExecutor { case PASSWORD: return StringUtil.copyPartialMatches(args[1], CommandUtils.RESET_OPTIONS, new ArrayList<>(CommandUtils.RESET_OPTIONS.size())); case TELEPORT: - List matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<>(PtpCommand.TELEPORT_SUBCOMMANDS.size())); + List matches = StringUtil.copyPartialMatches(args[1], CommandConstants.TELEPORT_SUBCOMMANDS, new ArrayList<>(CommandConstants.TELEPORT_SUBCOMMANDS.size())); if (matches.size() == 0) { Player player = (Player) sender; diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java index 3d707a660..34ff8dc6a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCreateCommand.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -8,6 +9,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyCreateCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyCreateCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java index a9cbd9c9c..267865055 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyDisbandCommand.java @@ -2,6 +2,7 @@ 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.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -9,6 +10,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyDisbandCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyDisbandCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java index eefa9891a..2df0a9b49 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyHelpCommand.java @@ -1,11 +1,18 @@ package com.gmail.nossr50.commands.party; +import com.gmail.nossr50.mcMMO; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; public class PartyHelpCommand implements CommandExecutor { + private mcMMO pluginRef; + + public PartyHelpCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java index 6bff77540..2eebd922c 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInfoCommand.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.PartyFeature; import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -15,6 +16,13 @@ import java.util.ArrayList; import java.util.List; public class PartyInfoCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyInfoCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { 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 dd8187590..678721310 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java @@ -2,6 +2,7 @@ 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; @@ -10,6 +11,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyInviteCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyInviteCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { 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 8e2a71b38..9273fea9e 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyItemShareCommand.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.party.ItemShareType; import com.gmail.nossr50.datatypes.party.Party; 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; @@ -13,6 +14,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyItemShareCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyItemShareCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (UserManager.getPlayer((Player) sender) == null) { 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 2085d1448..fa17d1b00 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyJoinCommand.java @@ -2,6 +2,7 @@ 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; @@ -10,6 +11,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyJoinCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyJoinCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { 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 55dd0e4b8..12d089fbd 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyKickCommand.java @@ -2,6 +2,7 @@ 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; @@ -11,6 +12,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyKickCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyKickCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { 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 877895801..fbfc2c4d5 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyLockCommand.java @@ -1,6 +1,7 @@ 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; @@ -10,6 +11,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyLockCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyLockCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java index 569b88ec6..0a18f86fe 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyQuitCommand.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -10,6 +11,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyQuitCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyQuitCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java index 129d72ef2..3e97d8a96 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyRenameCommand.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -10,6 +11,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyRenameCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyRenameCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { 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 fe8bba31e..f4d98f074 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyXpShareCommand.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.party; import com.gmail.nossr50.datatypes.party.Party; 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; @@ -12,6 +13,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyXpShareCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyXpShareCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (UserManager.getPlayer((Player) sender) == null) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java index ad30e5d94..95017e69a 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceAcceptCommand.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.commands.party.alliance; import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -8,6 +9,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyAllianceAcceptCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyAllianceAcceptCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { 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 5652de6ec..0e427c5bf 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 @@ -1,8 +1,10 @@ package com.gmail.nossr50.commands.party.alliance; +import com.gmail.nossr50.commands.CommandConstants; 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; @@ -18,13 +20,23 @@ import java.util.ArrayList; import java.util.List; public class PartyAllianceCommand implements TabExecutor { - public static final List ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband"); + + private mcMMO pluginRef; private Player player; private Party playerParty; private Party targetParty; - private CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand(); - private CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand(); - private CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand(); + private CommandExecutor partyAllianceInviteCommand; + private CommandExecutor partyAllianceAcceptCommand; + private CommandExecutor partyAllianceDisbandCommand; + + public PartyAllianceCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + + //Init SubCommands + partyAllianceInviteCommand = new PartyAllianceInviteCommand(pluginRef); + partyAllianceAcceptCommand = new PartyAllianceAcceptCommand(pluginRef); + partyAllianceDisbandCommand = new PartyAllianceDisbandCommand(pluginRef); + } @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -104,7 +116,7 @@ public class PartyAllianceCommand implements TabExecutor { public List onTabComplete(CommandSender commandSender, Command command, String label, String[] args) { switch (args.length) { case 1: - List matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<>(ALLIANCE_SUBCOMMANDS.size())); + List matches = StringUtil.copyPartialMatches(args[0], CommandConstants.ALLIANCE_SUBCOMMANDS, new ArrayList<>(CommandConstants.ALLIANCE_SUBCOMMANDS.size())); if (matches.size() == 0) { List playerNames = CommandUtils.getOnlinePlayerNames(commandSender); diff --git a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java index aef23d8c5..ec2a002fa 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/alliance/PartyAllianceDisbandCommand.java @@ -2,6 +2,7 @@ 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.player.UserManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -9,6 +10,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyAllianceDisbandCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyAllianceDisbandCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { 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 83453ea78..dbfb27474 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 @@ -2,6 +2,7 @@ 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; @@ -10,6 +11,13 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class PartyAllianceInviteCommand implements CommandExecutor { + + private mcMMO pluginRef; + + public PartyAllianceInviteCommand(mcMMO pluginRef) { + this.pluginRef = pluginRef; + } + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { switch (args.length) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java index fd6e8c5e9..535b832ad 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/teleport/PtpAcceptCommand.java @@ -48,7 +48,7 @@ public class PtpAcceptCommand implements CommandExecutor { Player target = ptpRecord.getRequestor(); ptpRecord.removeRequest(); - if (!PtpCommand.canTeleport(sender, player, target.getName())) { + if (!pluginRef.getPartyManager().canTeleport(sender, player, target.getName())) { return true; } @@ -67,7 +67,7 @@ public class PtpAcceptCommand implements CommandExecutor { } } - PtpCommand.handleTeleportWarmup(target, player); + pluginRef.getPartyManager().handleTeleportWarmup(target, player); return true; } } 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 62f8c0002..5927ab164 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 @@ -1,5 +1,6 @@ package com.gmail.nossr50.commands.party.teleport; +import com.gmail.nossr50.commands.CommandConstants; import com.gmail.nossr50.config.WorldBlacklist; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.PartyFeature; @@ -41,8 +42,6 @@ public class PtpCommand implements TabExecutor { ptpAcceptCommand = new PtpAcceptCommand(pluginRef); } - public final List TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall"); - @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (CommandUtils.noConsoleUsage(sender)) { @@ -136,7 +135,7 @@ public class PtpCommand implements TabExecutor { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { switch (args.length) { case 1: - List matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<>(TELEPORT_SUBCOMMANDS.size())); + List matches = StringUtil.copyPartialMatches(args[0], CommandConstants.TELEPORT_SUBCOMMANDS, new ArrayList<>(CommandConstants.TELEPORT_SUBCOMMANDS.size())); if (matches.size() == 0) { if (UserManager.getPlayer((Player) sender) == null) {