mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-10-06 11:37:50 +02:00
Added a simple subcommand as a test
This commit is contained in:
parent
1f5b474e19
commit
6ffa9ce979
@ -1,6 +1,8 @@
|
||||
package com.sekwah.advancedportals.core;
|
||||
|
||||
import com.sekwah.advancedportals.core.api.commands.SubCommand;
|
||||
import com.sekwah.advancedportals.core.commands.CommandWithSubCommands;
|
||||
import com.sekwah.advancedportals.core.commands.subcommands.portal.VersionSubCommand;
|
||||
import com.sekwah.advancedportals.core.util.Config;
|
||||
import com.sekwah.advancedportals.core.util.DataStorage;
|
||||
import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
@ -21,6 +23,9 @@ public class AdvancedPortalsCore {
|
||||
private CommandWithSubCommands portalCommand;
|
||||
private CommandWithSubCommands destiCommand;
|
||||
|
||||
public static final String version = "1.0.0";
|
||||
public static final String lastTranslationUpdate = "1.0.0";
|
||||
|
||||
public AdvancedPortalsCore(DataStorage dataStorage, InfoLogger infoLogger, CommandRegister commandRegister) {
|
||||
this.dataStorage = dataStorage;
|
||||
this.infoLogger = infoLogger;
|
||||
@ -36,14 +41,33 @@ public class AdvancedPortalsCore {
|
||||
this.loadPortalConfig();
|
||||
Lang.loadLanguage(config.getTranslation());
|
||||
|
||||
this.portalCommand = new CommandWithSubCommands();
|
||||
this.destiCommand = new CommandWithSubCommands();
|
||||
this.commandRegister.registerCommand("portal", this.portalCommand);
|
||||
this.commandRegister.registerCommand("destination", this.destiCommand);
|
||||
this.registerPortalCommand();
|
||||
this.registerDestinationCommand();
|
||||
|
||||
infoLogger.log(Lang.translate("logger.pluginenable"));
|
||||
}
|
||||
|
||||
private void registerPortalCommand() {
|
||||
this.portalCommand = new CommandWithSubCommands();
|
||||
|
||||
this.portalCommand.registerSubCommand("version", new VersionSubCommand());
|
||||
|
||||
this.commandRegister.registerCommand("portal", this.portalCommand);
|
||||
}
|
||||
|
||||
private void registerDestinationCommand() {
|
||||
this.destiCommand = new CommandWithSubCommands();
|
||||
this.commandRegister.registerCommand("destination", this.destiCommand);
|
||||
}
|
||||
|
||||
public static boolean registerDestiSubCommand(String arg, SubCommand subCommand) {
|
||||
return instance.destiCommand.registerSubCommand(arg, subCommand);
|
||||
}
|
||||
|
||||
public static boolean registerPortalSubCommand(String arg, SubCommand subCommand) {
|
||||
return instance.portalCommand.registerSubCommand(arg, subCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the portal config into the memory and saves from the memory to check in case certain things have changed
|
||||
* (basically if values are missing or whatever)
|
||||
|
@ -7,7 +7,7 @@ public class CoreListeners {
|
||||
|
||||
public void playerJoin(PlayerContainer player) {
|
||||
if(player.isOp()) {
|
||||
if(!Lang.translate("translatedata.lastchange").equals("1.0.0")) {
|
||||
if(!Lang.translate("translatedata.lastchange").equals(AdvancedPortalsCore.lastTranslationUpdate)) {
|
||||
player.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateColor("translatedata.translationsoutdated"));
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public interface SubCommand {
|
||||
* @param args arguments including the subcommand that has been specified.
|
||||
* @return if the command has worked (if false it will just display a message from the command suggesting to check help)
|
||||
*/
|
||||
boolean onCommand(CommandSenderContainer sender, String[] args);
|
||||
void onCommand(CommandSenderContainer sender, String[] args);
|
||||
|
||||
boolean hasPermission(CommandSenderContainer sender);
|
||||
|
||||
|
@ -0,0 +1,4 @@
|
||||
package com.sekwah.advancedportals.core.commands.subcommands.desti;
|
||||
|
||||
public class TestSubCommand {
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
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 java.util.List;
|
||||
|
||||
public class VersionSubCommand implements SubCommand {
|
||||
@Override
|
||||
public void onCommand(CommandSenderContainer sender, String[] args) {
|
||||
sender.sendMessage(Lang.translateColor("messageprefix.positive") + " Advanced Portals v" + AdvancedPortalsCore.version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSenderContainer sender) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSenderContainer sender, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBasicHelpText() {
|
||||
return "This is basic help text";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDetailedHelpText() {
|
||||
return "This help text is a lot more detailed than the basic one";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user