diff --git a/Resources/lang/en_GB.lang b/Resources/lang/en_GB.lang index 369474e7..62907521 100644 --- a/Resources/lang/en_GB.lang +++ b/Resources/lang/en_GB.lang @@ -40,12 +40,18 @@ command.create.error= There was an error making the portal: command.create.console= You cannot create a portal using the console. command.create.detailedhelp=List tags after create in the format tag:value, if your value needs spaces use the format tag:"value with spaces" +command.playeronly= Sorry but that command can only be run by a player. + command.remove.noname= You need to give the name of the portal you want to remove. command.remove.error= Removing the portal was blocked: command.remove.noname=No portal by that name was found command.remove.invalidselection=The portal selection you had is no longer valid command.remove.noselection=You don't have a portal selected +command.selector= You have been given a portal selector. +command.selector.help=Gives you a portal region selector +command.selector.detailedhelp=Gives you a portal selector to select the regions for making portals. You can also use /portal + portal.invalidselection=You must have both pos1 and pos2 selected to create a portal. portal.noname=No name for the portal has been given. portal.takenname=The name given for the portal is already taken. diff --git a/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java b/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java index a9a04a1c..04e24a17 100644 --- a/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java +++ b/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java @@ -6,9 +6,7 @@ import com.sekwah.advancedportals.core.api.managers.PortalManager; import com.sekwah.advancedportals.core.api.registry.TagRegistry; import com.sekwah.advancedportals.core.api.registry.WarpEffectRegistry; import com.sekwah.advancedportals.core.commands.CommandWithSubCommands; -import com.sekwah.advancedportals.core.commands.subcommands.portal.ReloadSubCommand; -import com.sekwah.advancedportals.core.commands.subcommands.portal.TransUpdateSubCommand; -import com.sekwah.advancedportals.core.commands.subcommands.portal.VersionSubCommand; +import com.sekwah.advancedportals.core.commands.subcommands.portal.*; import com.sekwah.advancedportals.core.util.Config; import com.sekwah.advancedportals.core.util.DataStorage; import com.sekwah.advancedportals.core.util.InfoLogger; @@ -123,6 +121,7 @@ public class AdvancedPortalsCore { this.portalCommand.registerSubCommand("version", new VersionSubCommand()); this.portalCommand.registerSubCommand("transupdate", new TransUpdateSubCommand(this)); this.portalCommand.registerSubCommand("reload", new ReloadSubCommand(this)); + this.portalCommand.registerSubCommand("selector", new SelectorSubCommand(this), "wand"); this.commandRegister.registerCommand("portal", this.portalCommand); } diff --git a/src/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java b/src/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java index 21bd5154..b9660d66 100644 --- a/src/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java +++ b/src/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java @@ -18,7 +18,10 @@ public class CommandWithSubCommands implements CommandTemplate { this.subCommandRegistry = new SubCommandRegistry(); } - public boolean registerSubCommand(String arg, SubCommand subCommand) { + public boolean registerSubCommand(String arg, SubCommand subCommand, String... additionalArgs) { + for(String additionalArg : additionalArgs) { + this.subCommandRegistry.registerSubCommand(additionalArg,subCommand); + } return this.subCommandRegistry.registerSubCommand(arg,subCommand); } @@ -57,8 +60,7 @@ public class CommandWithSubCommands implements CommandTemplate { if(this.subCommandRegistry.isArgRegistered(subCommand)) { sender.sendMessage(Lang.translateInsertVariablesColor("command.help.subcommandheader", commandExecuted.substring(0,1).toUpperCase() + commandExecuted.substring(1).toLowerCase(), subCommand)); - sender.sendMessage(Lang.translateInsertVariablesColor("command.help.invalidhelp", args[1])); - sender.sendMessage(this.getSubCommand(subCommand).getDetailedHelpText()); + sender.sendMessage("\u00A7e" + this.getSubCommand(subCommand).getDetailedHelpText()); } else { sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateInsertVariablesColor("command.help.invalidhelp", args[1])); diff --git a/src/com/sekwah/advancedportals/core/commands/subcommands/portal/SelectorSubCommand.java b/src/com/sekwah/advancedportals/core/commands/subcommands/portal/SelectorSubCommand.java new file mode 100644 index 00000000..231fa086 --- /dev/null +++ b/src/com/sekwah/advancedportals/core/commands/subcommands/portal/SelectorSubCommand.java @@ -0,0 +1,52 @@ +package com.sekwah.advancedportals.core.commands.subcommands.portal; + +import com.sekwah.advancedportals.core.AdvancedPortalsCore; +import com.sekwah.advancedportals.core.api.commands.SubCommand; +import com.sekwah.advancedportals.core.util.Lang; +import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer; +import com.sekwah.advancedportals.coreconnector.container.PlayerContainer; + +import java.util.List; + +public class SelectorSubCommand implements SubCommand { + + private final AdvancedPortalsCore portalsCore; + + public SelectorSubCommand(AdvancedPortalsCore portalsCore) { + this.portalsCore = portalsCore; + } + + @Override + public void onCommand(CommandSenderContainer sender, String[] args) { + PlayerContainer player = sender.getPlayerContainer(); + if(player == null) { + sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("command.playeronly")); + } + else { + player.giveItem(this.portalsCore.getConfig().getSelectorMaterial(), "\u00A7ePortal Region Selector" + , "\u00A7rThis wand with has the power to help", "\u00A7r create portals bistowed upon it!"); + sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("command.selector")); + } + + } + + @Override + public boolean hasPermission(CommandSenderContainer sender) { + return sender.isOp() || sender.hasPermission("advancedportals.createportal"); + } + + @Override + public List onTabComplete(CommandSenderContainer sender, String[] args) { + return null; + } + + @Override + public String getBasicHelpText() { + return Lang.translate("command.selector.help"); + } + + @Override + public String getDetailedHelpText() { + return Lang.translate("command.selector.detailedhelp"); + } +}