From 56d46a763f92fd8d8c99bfe3e11db6b2284f18db Mon Sep 17 00:00:00 2001 From: sekwah Date: Fri, 19 Jan 2018 04:14:54 +0000 Subject: [PATCH] Started adding the base of the command registry --- .../core/AdvancedPortalsCore.java | 14 +++++++++++--- .../core/commands/DestiCommand.java | 18 ++++++++++++++++++ .../core/commands/PortalCommand.java | 16 +++++++++++++++- .../command/CommandRegister.java | 19 +++++++++++++++++++ 4 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 src/com/sekwah/advancedportals/core/commands/DestiCommand.java create mode 100644 src/com/sekwah/advancedportals/coreconnector/command/CommandRegister.java diff --git a/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java b/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java index f3a4a54..2be9047 100644 --- a/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java +++ b/src/com/sekwah/advancedportals/core/AdvancedPortalsCore.java @@ -1,26 +1,34 @@ package com.sekwah.advancedportals.core; +import com.sekwah.advancedportals.core.commands.DestiCommand; +import com.sekwah.advancedportals.core.commands.PortalCommand; import com.sekwah.advancedportals.core.util.Config; import com.sekwah.advancedportals.core.util.DataStorage; import com.sekwah.advancedportals.core.util.InfoLogger; +import com.sekwah.advancedportals.coreconnector.command.CommandRegister; public class AdvancedPortalsCore { private static AdvancedPortalsCore instance; - private DataStorage dataStorage; - private InfoLogger infoLogger; + private final CommandRegister commandRegister; + private final DataStorage dataStorage; + private final InfoLogger infoLogger; private Config config; - public AdvancedPortalsCore(DataStorage dataStorage, InfoLogger infoLogger) { + public AdvancedPortalsCore(DataStorage dataStorage, InfoLogger infoLogger, CommandRegister commandRegister) { this.dataStorage = dataStorage; this.infoLogger = infoLogger; this.instance = this; + this.commandRegister = commandRegister; this.onEnable(); } private void onEnable() { this.loadPortalData(); infoLogger.log("Advanced portals have been successfully enabled!"); + + this.commandRegister.registerCommand("portal", new PortalCommand()); + this.commandRegister.registerCommand("destination", new DestiCommand()); } /** diff --git a/src/com/sekwah/advancedportals/core/commands/DestiCommand.java b/src/com/sekwah/advancedportals/core/commands/DestiCommand.java new file mode 100644 index 0000000..e0197a1 --- /dev/null +++ b/src/com/sekwah/advancedportals/core/commands/DestiCommand.java @@ -0,0 +1,18 @@ +package com.sekwah.advancedportals.core.commands; + +import com.sun.corba.se.impl.activation.CommandHandler; + +import java.util.List; + +public class DestiCommand implements CommandTemplate { + + @Override + public void onCommand(CommandHandler sender, String[] args) { + + } + + @Override + public List onTabComplete(CommandHandler sender, String[] args) { + return null; + } +} diff --git a/src/com/sekwah/advancedportals/core/commands/PortalCommand.java b/src/com/sekwah/advancedportals/core/commands/PortalCommand.java index fa36282..d02c205 100644 --- a/src/com/sekwah/advancedportals/core/commands/PortalCommand.java +++ b/src/com/sekwah/advancedportals/core/commands/PortalCommand.java @@ -1,4 +1,18 @@ package com.sekwah.advancedportals.core.commands; -public class PortalCommand { +import com.sun.corba.se.impl.activation.CommandHandler; + +import java.util.List; + +public class PortalCommand implements CommandTemplate { + + @Override + public void onCommand(CommandHandler sender, String[] args) { + + } + + @Override + public List onTabComplete(CommandHandler sender, String[] args) { + return null; + } } diff --git a/src/com/sekwah/advancedportals/coreconnector/command/CommandRegister.java b/src/com/sekwah/advancedportals/coreconnector/command/CommandRegister.java new file mode 100644 index 0000000..b31dde2 --- /dev/null +++ b/src/com/sekwah/advancedportals/coreconnector/command/CommandRegister.java @@ -0,0 +1,19 @@ +package com.sekwah.advancedportals.coreconnector.command; + +import com.sekwah.advancedportals.core.commands.CommandTemplate; +import com.sekwah.advancedportals.core.commands.PortalCommand; + +/** + * Register the CommandTemplate files to the appropriate system + */ +public class CommandRegister { + + /** + * Registers the command to the appropriate system + * @param commandName + * @param commandExecutor + */ + public void registerCommand(String commandName, CommandTemplate commandExecutor) { + + } +}