Added selector giver

This commit is contained in:
sekwah41 2018-02-01 21:36:08 +00:00 committed by Sekwah
parent bf5b0a8d2c
commit 47237ba68f
4 changed files with 65 additions and 6 deletions

View File

@ -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.

View File

@ -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);
}

View File

@ -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]));

View File

@ -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<String> 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");
}
}