From cd1de2b59440b9a544d4342a41b1039dd1767c3e Mon Sep 17 00:00:00 2001 From: Simon Rigby Date: Sun, 27 Feb 2011 06:43:39 +0000 Subject: [PATCH] Added basics for the Command Handler. --- .../MultiVerseCore/MVCommandHandler.java | 14 +++++++++ .../MultiVerseCore/MultiVerseCore.java | 29 +++++++++++++++++-- .../MultiVerseCore/commands/MVCoord.java | 21 ++++++++++++++ .../MultiVerseCore/commands/MVCreate.java | 20 +++++++++++++ .../MultiVerseCore/commands/MVImport.java | 21 ++++++++++++++ .../MultiVerseCore/commands/MVList.java | 21 ++++++++++++++ .../MultiVerseCore/commands/MVModify.java | 21 ++++++++++++++ .../MultiVerseCore/commands/MVRemove.java | 21 ++++++++++++++ .../MultiVerseCore/commands/MVSetSpawn.java | 21 ++++++++++++++ .../MultiVerseCore/commands/MVSpawn.java | 21 ++++++++++++++ .../MultiVerseCore/commands/MVTP.java | 21 ++++++++++++++ src/plugin.yml | 3 -- 12 files changed, 229 insertions(+), 5 deletions(-) create mode 100644 src/com/onarandombox/MultiVerseCore/MVCommandHandler.java create mode 100644 src/com/onarandombox/MultiVerseCore/commands/MVCoord.java create mode 100644 src/com/onarandombox/MultiVerseCore/commands/MVCreate.java create mode 100644 src/com/onarandombox/MultiVerseCore/commands/MVImport.java create mode 100644 src/com/onarandombox/MultiVerseCore/commands/MVList.java create mode 100644 src/com/onarandombox/MultiVerseCore/commands/MVModify.java create mode 100644 src/com/onarandombox/MultiVerseCore/commands/MVRemove.java create mode 100644 src/com/onarandombox/MultiVerseCore/commands/MVSetSpawn.java create mode 100644 src/com/onarandombox/MultiVerseCore/commands/MVSpawn.java create mode 100644 src/com/onarandombox/MultiVerseCore/commands/MVTP.java diff --git a/src/com/onarandombox/MultiVerseCore/MVCommandHandler.java b/src/com/onarandombox/MultiVerseCore/MVCommandHandler.java new file mode 100644 index 00000000..12d9dd9c --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/MVCommandHandler.java @@ -0,0 +1,14 @@ +package com.onarandombox.MultiVerseCore; + +import org.bukkit.command.CommandSender; + +public abstract class MVCommandHandler { + + protected final MultiVerseCore plugin; + + public MVCommandHandler(MultiVerseCore plugin){ + this.plugin = plugin; + } + + public abstract boolean perform(CommandSender sender, String[] args); +} diff --git a/src/com/onarandombox/MultiVerseCore/MultiVerseCore.java b/src/com/onarandombox/MultiVerseCore/MultiVerseCore.java index 0d2394c9..c3c9c42b 100644 --- a/src/com/onarandombox/MultiVerseCore/MultiVerseCore.java +++ b/src/com/onarandombox/MultiVerseCore/MultiVerseCore.java @@ -2,6 +2,7 @@ package com.onarandombox.MultiVerseCore; import java.io.File; import java.util.HashMap; +import java.util.Map; import java.util.logging.Logger; import org.bukkit.Server; @@ -19,11 +20,15 @@ import org.bukkit.event.Event.Priority; import com.nijikokun.bukkit.Permissions.Permissions; import com.nijiko.permissions.PermissionHandler; -import com.nijikokun.bukkit.iConomy.iConomy; + +import com.onarandombox.MultiVerseCore.commands.*; import com.onarandombox.MultiVerseCore.configuration.defaultConfiguration; @SuppressWarnings("unused") public class MultiVerseCore extends JavaPlugin { + // Setup our Map for our Commands using the CommandHandler. + private Map commands = new HashMap(); + // Variable to state whether we are displaying Debug Messages or not. public boolean debug = true; @@ -124,6 +129,19 @@ public class MultiVerseCore extends JavaPlugin { * Load up the Worlds & their Settings. */ loadWorlds(); + setupCommands(); + } + + private void setupCommands() { + commands.put("mvcreate", new MVCreate(this)); + commands.put("mvimport", new MVImport(this)); + commands.put("mvremove", new MVRemove(this)); + commands.put("mvmodify", new MVModify(this)); + commands.put("mvtp", new MVTP(this)); + commands.put("mvlist", new MVList(this)); + commands.put("mvsetspawn", new MVSetSpawn(this)); + commands.put("mvspawn", new MVSpawn(this)); + commands.put("mvcoord", new MVCoord(this)); } /** @@ -149,7 +167,14 @@ public class MultiVerseCore extends JavaPlugin { if(Permissions==null || this.isEnabled()==false){ return false; } - return false; + + MVCommandHandler handler = commands.get(command.getName().toLowerCase()); + + if (handler != null) { + return handler.perform(sender, args); + } else { + return false; + } } /** diff --git a/src/com/onarandombox/MultiVerseCore/commands/MVCoord.java b/src/com/onarandombox/MultiVerseCore/commands/MVCoord.java new file mode 100644 index 00000000..f339c079 --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/commands/MVCoord.java @@ -0,0 +1,21 @@ +package com.onarandombox.MultiVerseCore.commands; + +import org.bukkit.command.CommandSender; + +import com.onarandombox.MultiVerseCore.MVCommandHandler; +import com.onarandombox.MultiVerseCore.MultiVerseCore; + +public class MVCoord extends MVCommandHandler { + + public MVCoord(MultiVerseCore plugin) { + super(plugin); + // TODO Auto-generated constructor stub + } + + @Override + public boolean perform(CommandSender sender, String[] args) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/com/onarandombox/MultiVerseCore/commands/MVCreate.java b/src/com/onarandombox/MultiVerseCore/commands/MVCreate.java new file mode 100644 index 00000000..6bdf3ded --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/commands/MVCreate.java @@ -0,0 +1,20 @@ +package com.onarandombox.MultiVerseCore.commands; + +import org.bukkit.command.CommandSender; + +import com.onarandombox.MultiVerseCore.MVCommandHandler; +import com.onarandombox.MultiVerseCore.MultiVerseCore; + +public class MVCreate extends MVCommandHandler { + + public MVCreate(MultiVerseCore plugin) { + super(plugin); + } + + @Override + public boolean perform(CommandSender sender, String[] args) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/com/onarandombox/MultiVerseCore/commands/MVImport.java b/src/com/onarandombox/MultiVerseCore/commands/MVImport.java new file mode 100644 index 00000000..a3ed5933 --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/commands/MVImport.java @@ -0,0 +1,21 @@ +package com.onarandombox.MultiVerseCore.commands; + +import org.bukkit.command.CommandSender; + +import com.onarandombox.MultiVerseCore.MVCommandHandler; +import com.onarandombox.MultiVerseCore.MultiVerseCore; + +public class MVImport extends MVCommandHandler { + + public MVImport(MultiVerseCore plugin) { + super(plugin); + // TODO Auto-generated constructor stub + } + + @Override + public boolean perform(CommandSender sender, String[] args) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/com/onarandombox/MultiVerseCore/commands/MVList.java b/src/com/onarandombox/MultiVerseCore/commands/MVList.java new file mode 100644 index 00000000..46ba737d --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/commands/MVList.java @@ -0,0 +1,21 @@ +package com.onarandombox.MultiVerseCore.commands; + +import org.bukkit.command.CommandSender; + +import com.onarandombox.MultiVerseCore.MVCommandHandler; +import com.onarandombox.MultiVerseCore.MultiVerseCore; + +public class MVList extends MVCommandHandler { + + public MVList(MultiVerseCore plugin) { + super(plugin); + // TODO Auto-generated constructor stub + } + + @Override + public boolean perform(CommandSender sender, String[] args) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/com/onarandombox/MultiVerseCore/commands/MVModify.java b/src/com/onarandombox/MultiVerseCore/commands/MVModify.java new file mode 100644 index 00000000..f11b68fb --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/commands/MVModify.java @@ -0,0 +1,21 @@ +package com.onarandombox.MultiVerseCore.commands; + +import org.bukkit.command.CommandSender; + +import com.onarandombox.MultiVerseCore.MVCommandHandler; +import com.onarandombox.MultiVerseCore.MultiVerseCore; + +public class MVModify extends MVCommandHandler { + + public MVModify(MultiVerseCore plugin) { + super(plugin); + // TODO Auto-generated constructor stub + } + + @Override + public boolean perform(CommandSender sender, String[] args) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/com/onarandombox/MultiVerseCore/commands/MVRemove.java b/src/com/onarandombox/MultiVerseCore/commands/MVRemove.java new file mode 100644 index 00000000..52b235d0 --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/commands/MVRemove.java @@ -0,0 +1,21 @@ +package com.onarandombox.MultiVerseCore.commands; + +import org.bukkit.command.CommandSender; + +import com.onarandombox.MultiVerseCore.MVCommandHandler; +import com.onarandombox.MultiVerseCore.MultiVerseCore; + +public class MVRemove extends MVCommandHandler { + + public MVRemove(MultiVerseCore plugin) { + super(plugin); + // TODO Auto-generated constructor stub + } + + @Override + public boolean perform(CommandSender sender, String[] args) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/com/onarandombox/MultiVerseCore/commands/MVSetSpawn.java b/src/com/onarandombox/MultiVerseCore/commands/MVSetSpawn.java new file mode 100644 index 00000000..262dbf9a --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/commands/MVSetSpawn.java @@ -0,0 +1,21 @@ +package com.onarandombox.MultiVerseCore.commands; + +import org.bukkit.command.CommandSender; + +import com.onarandombox.MultiVerseCore.MVCommandHandler; +import com.onarandombox.MultiVerseCore.MultiVerseCore; + +public class MVSetSpawn extends MVCommandHandler { + + public MVSetSpawn(MultiVerseCore plugin) { + super(plugin); + // TODO Auto-generated constructor stub + } + + @Override + public boolean perform(CommandSender sender, String[] args) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/com/onarandombox/MultiVerseCore/commands/MVSpawn.java b/src/com/onarandombox/MultiVerseCore/commands/MVSpawn.java new file mode 100644 index 00000000..b8d41dc4 --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/commands/MVSpawn.java @@ -0,0 +1,21 @@ +package com.onarandombox.MultiVerseCore.commands; + +import org.bukkit.command.CommandSender; + +import com.onarandombox.MultiVerseCore.MVCommandHandler; +import com.onarandombox.MultiVerseCore.MultiVerseCore; + +public class MVSpawn extends MVCommandHandler { + + public MVSpawn(MultiVerseCore plugin) { + super(plugin); + // TODO Auto-generated constructor stub + } + + @Override + public boolean perform(CommandSender sender, String[] args) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/com/onarandombox/MultiVerseCore/commands/MVTP.java b/src/com/onarandombox/MultiVerseCore/commands/MVTP.java new file mode 100644 index 00000000..326628be --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/commands/MVTP.java @@ -0,0 +1,21 @@ +package com.onarandombox.MultiVerseCore.commands; + +import org.bukkit.command.CommandSender; + +import com.onarandombox.MultiVerseCore.MVCommandHandler; +import com.onarandombox.MultiVerseCore.MultiVerseCore; + +public class MVTP extends MVCommandHandler { + + public MVTP(MultiVerseCore plugin) { + super(plugin); + // TODO Auto-generated constructor stub + } + + @Override + public boolean perform(CommandSender sender, String[] args) { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/plugin.yml b/src/plugin.yml index 546bf0e7..09b6273a 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -18,9 +18,6 @@ commands: mvtp: description: Command to teleport between Worlds usage: / - mvtpt: - description: Command to teleport a target to a World/Portal - usage: / mvlist: description: Print list of loaded Worlds usage: /