From 7e43d8f0904fc37b04f37d04851ae152c03ea6e6 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sun, 6 Aug 2017 13:21:37 -0400 Subject: [PATCH] Started work on ChooseColor Command --- .../java/buttondevteam/presents/Main.java | 4 ++ .../presents/spawn/ChooseColor.java | 38 +++++++++++++++++++ .../presents/spawn/SpawnComponent.java | 15 ++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/main/java/buttondevteam/presents/spawn/ChooseColor.java create mode 100644 src/main/java/buttondevteam/presents/spawn/SpawnComponent.java diff --git a/src/main/java/buttondevteam/presents/Main.java b/src/main/java/buttondevteam/presents/Main.java index af149a5..3cd0777 100644 --- a/src/main/java/buttondevteam/presents/Main.java +++ b/src/main/java/buttondevteam/presents/Main.java @@ -8,6 +8,8 @@ import org.bukkit.plugin.java.JavaPlugin; import buttondevteam.presents.dictionary.DictionaryComponent; import buttondevteam.presents.metrics.MetricsComponent; import buttondevteam.presents.rtp.RandomTeleportComponent; +import buttondevteam.presents.spawn.SpawnComponent; +import buttondevteam.presents.test.TestComponent; public class Main extends JavaPlugin{ public void onEnable(){ @@ -19,6 +21,8 @@ PluginDescriptionFile pdfFile = getDescription(); new DictionaryComponent().register(this); new RandomTeleportComponent().register(this); new MetricsComponent().register(this); + new SpawnComponent().register(this); + new TestComponent().register(this); logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ")."); } diff --git a/src/main/java/buttondevteam/presents/spawn/ChooseColor.java b/src/main/java/buttondevteam/presents/spawn/ChooseColor.java new file mode 100644 index 0000000..d78808c --- /dev/null +++ b/src/main/java/buttondevteam/presents/spawn/ChooseColor.java @@ -0,0 +1,38 @@ +package buttondevteam.presents.spawn; + +import org.bukkit.Server; +import org.bukkit.command.BlockCommandSender; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import buttondevteam.lib.chat.CommandClass; +import buttondevteam.presents.architecture.commands.UniversalCommand; + +@CommandClass(modOnly = false) +public class ChooseColor extends UniversalCommand { + + @Override + public boolean OnCommand(CommandSender sender, String alias, String[] args) { + if (!(sender instanceof BlockCommandSender)){ + sender.sendMessage("You must be a command block to use this command!"); + return false; + } + + Server server = sender.getServer(); + server.broadcastMessage("Arg 0:" + args[0]); + server.broadcastMessage("Arg 1:" + args[1]); + + Player player = server.getPlayer(args[0]); + if (player != null){ + player.sendMessage("Attempting to change your name "+player.getName()+" to the color..."); + player.sendMessage(args[1]); + player.sendMessage("Your new name: " +player.getName()); + }else{ + server.broadcastMessage("Error: Player is null"); + } + + server.broadcastMessage("ENDOFCOMMAND"); + return true; + } + +} diff --git a/src/main/java/buttondevteam/presents/spawn/SpawnComponent.java b/src/main/java/buttondevteam/presents/spawn/SpawnComponent.java new file mode 100644 index 0000000..573f72b --- /dev/null +++ b/src/main/java/buttondevteam/presents/spawn/SpawnComponent.java @@ -0,0 +1,15 @@ +package buttondevteam.presents.spawn; + +import org.bukkit.plugin.java.JavaPlugin; + +import buttondevteam.presents.architecture.Component; + +public class SpawnComponent extends Component{ + + @Override + public void register(JavaPlugin plugin) { + this.registerCommand(plugin, new ChooseColor()); + + } + +}