From 20e8ce27b80d1231a76eb31b51c41351bd59618a Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 3 Nov 2016 01:22:51 +0100 Subject: [PATCH] Added code for exception handling And other stuff :P --- pom.xml | 134 +++++++++--------- src/alisolarflare/modules/Module.java | 9 +- .../components/flairdoor/FlairDoorModule.java | 9 +- .../flairdoor/commands/FlairMe.java | 30 +++- .../commands/SetFlairDoorColour.java | 54 ++++--- .../components/gpowers/GPowerModule.java | 12 +- .../gpowers/commands/PowerDown.java | 29 +++- .../components/gpowers/commands/PowerUp.java | 32 ++++- .../gpowers/commands/gPowerCommand.java | 52 ++++--- .../components/links/AliLinkModule.java | 23 +-- .../links/commands/PressAliLink.java | 44 ++++-- .../components/links/commands/SetAliLink.java | 112 +++++++++------ .../components/shulker/AliShulkerModule.java | 5 +- .../shulker/commands/AliShulker.java | 48 ++++--- .../modules/events/uhc/UHCModule.java | 11 +- .../modules/events/uhc/commands/AddToUHC.java | 76 ++++++---- .../events/uhc/commands/StartMatch.java | 38 +++-- .../magictrick/aliarrow/AliArrowListener.java | 1 - .../magictrick/aliarrow/AliArrowModule.java | 10 +- .../magictrick/aliarrow/AliArrowTask.java | 22 ++- 20 files changed, 483 insertions(+), 268 deletions(-) diff --git a/pom.xml b/pom.xml index b788546..81da534 100644 --- a/pom.xml +++ b/pom.xml @@ -1,67 +1,73 @@ - - 4.0.0 - com.github.tbmcplugins - AliPresents - 0.0.1-SNAPSHOT - AliPresents - A bucket of aaall the stuff Ali makes. It's a bit smelly. - - src - - - src - - **/*.java - - - - . - - *.yml - - - - - - maven-compiler-plugin - 3.3 - - 1.8 - 1.8 - - - - - - UTF-8 - + + 4.0.0 + com.github.tbmcplugins + AliPresents + 0.0.1-SNAPSHOT + AliPresents + A bucket of aaall the stuff Ali makes. It's a bit smelly. + + src + + + src + + **/*.java + + + + . + + *.yml + + + + + + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + + + + + + UTF-8 + - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - jcenter - http://jcenter.bintray.com - - - jitpack.io - https://jitpack.io - - + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + jcenter + http://jcenter.bintray.com + + + jitpack.io + https://jitpack.io + + - - - org.spigotmc - spigot-api - 1.9.2-R0.1-SNAPSHOT - - - - org.apache.commons - commons-lang3 - 3.4 - - + + + org.spigotmc + spigot-api + 1.9.2-R0.1-SNAPSHOT + + + + org.apache.commons + commons-lang3 + 3.4 + + + com.github.TBMCPlugins.ButtonCore + ButtonCore + master-SNAPSHOT + + diff --git a/src/alisolarflare/modules/Module.java b/src/alisolarflare/modules/Module.java index a68d1f6..2284a28 100644 --- a/src/alisolarflare/modules/Module.java +++ b/src/alisolarflare/modules/Module.java @@ -1,9 +1,11 @@ package alisolarflare.modules; -import org.bukkit.command.CommandExecutor; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; +import buttondevteam.lib.chat.TBMCChatAPI; +import buttondevteam.lib.chat.TBMCCommandBase; + /** * A Module class is a helper class that allows the compacting of projects into one single package. * Each feature, whether game, arrow trail listener, or command tool, can have its command and listener @@ -35,9 +37,8 @@ public abstract class Module implements Registerable{ * @param label Name of the command in plugin.yml * @param commandExecutor Custom coded CommandExecutor class */ - protected CommandExecutor registerCommand(JavaPlugin plugin, String label, CommandExecutor commandExecutor){ - plugin.getCommand(label).setExecutor(commandExecutor); - return commandExecutor; + protected void registerCommand(JavaPlugin plugin, String label, Class commandExecutor){ + TBMCChatAPI.AddCommands(plugin, commandExecutor); } protected Listener registerListener(JavaPlugin plugin, Listener listener){ plugin.getServer().getPluginManager().registerEvents(listener, plugin); diff --git a/src/alisolarflare/modules/components/flairdoor/FlairDoorModule.java b/src/alisolarflare/modules/components/flairdoor/FlairDoorModule.java index 2563a3c..2374f61 100644 --- a/src/alisolarflare/modules/components/flairdoor/FlairDoorModule.java +++ b/src/alisolarflare/modules/components/flairdoor/FlairDoorModule.java @@ -6,13 +6,14 @@ import alisolarflare.modules.Module; import alisolarflare.modules.components.flairdoor.commands.FlairMe; import alisolarflare.modules.components.flairdoor.commands.SetFlairDoorColour; import alisolarflare.modules.components.flairdoor.listeners.PortalListener; +import buttondevteam.lib.TBMCCoreAPI; +import buttondevteam.lib.chat.TBMCChatAPI; -public class FlairDoorModule extends Module{ +public class FlairDoorModule extends Module { @Override public void register(JavaPlugin plugin) { - plugin.getCommand("flairme").setExecutor(new FlairMe()); - plugin.getCommand("setflairdoorcolour").setExecutor(new SetFlairDoorColour()); + TBMCChatAPI.AddCommands(plugin, FlairMe.class); - plugin.getServer().getPluginManager().registerEvents(new PortalListener(plugin), plugin); + TBMCCoreAPI.RegisterEventsForExceptions(new PortalListener(plugin), plugin); } } diff --git a/src/alisolarflare/modules/components/flairdoor/commands/FlairMe.java b/src/alisolarflare/modules/components/flairdoor/commands/FlairMe.java index 5b10c0c..320f3f8 100644 --- a/src/alisolarflare/modules/components/flairdoor/commands/FlairMe.java +++ b/src/alisolarflare/modules/components/flairdoor/commands/FlairMe.java @@ -1,19 +1,39 @@ package alisolarflare.modules.components.flairdoor.commands; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import alisolarflare.modules.components.flairdoor.listeners.PortalListener; +import buttondevteam.lib.chat.TBMCCommandBase; -public class FlairMe implements CommandExecutor{ +public class FlairMe extends TBMCCommandBase { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean OnCommand(CommandSender sender, String label, String[] args) { sender.sendMessage("Flairing..." + sender.getName()); PortalListener.playersToBeFlaired.add(sender.getName()); sender.sendMessage("Finished Preparation! Walk through a portal to get your flair"); - + + return false; + } + + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return new String[] { "" }; + } + + @Override + public String GetCommandPath() { + return "flairme"; + } + + @Override + public boolean GetPlayerOnly() { + return true; + } + + @Override + public boolean GetModOnly() { return false; } diff --git a/src/alisolarflare/modules/components/flairdoor/commands/SetFlairDoorColour.java b/src/alisolarflare/modules/components/flairdoor/commands/SetFlairDoorColour.java index 686350f..63debd0 100644 --- a/src/alisolarflare/modules/components/flairdoor/commands/SetFlairDoorColour.java +++ b/src/alisolarflare/modules/components/flairdoor/commands/SetFlairDoorColour.java @@ -3,46 +3,68 @@ package alisolarflare.modules.components.flairdoor.commands; import java.util.Arrays; import java.util.List; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -public class SetFlairDoorColour implements CommandExecutor { +import buttondevteam.lib.chat.TBMCCommandBase; + +public class SetFlairDoorColour extends TBMCCommandBase { public static String FlairDoorColorMode = "null"; - public static final List COLOURMODES = Arrays.asList("red", "orange", "yellow", "green", "blue", "purple", "gray"); + public static final List COLOURMODES = Arrays.asList("red", "orange", "yellow", "green", "blue", "purple", + "gray"); + @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (args.length > 1){ + public boolean OnCommand(CommandSender sender, String label, String[] args) { + if (args.length > 1) { sender.sendMessage("You must specify and argument, Red-Purple or Null.HHAHHAHAHAHHAHAHAHHA"); } - + String firstCommand = args[0]; firstCommand = firstCommand.toLowerCase(); - if(firstCommand.startsWith("e")|| firstCommand.startsWith("gra")|| firstCommand.startsWith("grey")){ + if (firstCommand.startsWith("e") || firstCommand.startsWith("gra") || firstCommand.startsWith("grey")) { sender.sendMessage("Flair Door Colour Mode set to gray"); FlairDoorColorMode = "gray"; - }else if(firstCommand.startsWith("r")){ + } else if (firstCommand.startsWith("r")) { sender.sendMessage("Flair Door Colour Mode set to Red"); FlairDoorColorMode = "red"; - }else if(firstCommand.startsWith("o")){ + } else if (firstCommand.startsWith("o")) { sender.sendMessage("Flair Door Colour Mode set to Orange"); FlairDoorColorMode = "orange"; - }else if(firstCommand.startsWith("y")){ + } else if (firstCommand.startsWith("y")) { sender.sendMessage("Flair Door Colour Mode set to Yellow"); FlairDoorColorMode = "yellow"; - }else if(firstCommand.startsWith("g")){ + } else if (firstCommand.startsWith("g")) { sender.sendMessage("Flair Door Colour Mode set to Green (use E for grey)"); FlairDoorColorMode = "green"; - }else if(firstCommand.startsWith("b") || firstCommand.startsWith("i")){ + } else if (firstCommand.startsWith("b") || firstCommand.startsWith("i")) { sender.sendMessage("Flair Door Colour Mode set to Blue"); FlairDoorColorMode = "blue"; - }else if(firstCommand.startsWith("v") || firstCommand.startsWith("p")){ + } else if (firstCommand.startsWith("v") || firstCommand.startsWith("p")) { sender.sendMessage("Flair Door Colour Mode set to Purple"); FlairDoorColorMode = "purple"; - }else if(firstCommand.startsWith("n")){ + } else if (firstCommand.startsWith("n")) { sender.sendMessage("Flair Door Colour Mode set to Null"); FlairDoorColorMode = "null"; } return false; - } + } + + @Override + public String[] GetHelpText(String alias) { // TODO + return new String[] { "" }; + } + + @Override + public String GetCommandPath() { + return "setflairdoorcolour"; + } + + @Override + public boolean GetPlayerOnly() { + return true; + } + + @Override + public boolean GetModOnly() { + return false; + } } diff --git a/src/alisolarflare/modules/components/gpowers/GPowerModule.java b/src/alisolarflare/modules/components/gpowers/GPowerModule.java index 8578d46..2e3632c 100644 --- a/src/alisolarflare/modules/components/gpowers/GPowerModule.java +++ b/src/alisolarflare/modules/components/gpowers/GPowerModule.java @@ -7,16 +7,16 @@ import alisolarflare.modules.components.gpowers.commands.PowerDown; import alisolarflare.modules.components.gpowers.commands.PowerUp; import alisolarflare.modules.components.gpowers.commands.gPowerCommand; import alisolarflare.modules.components.gpowers.listeners.gPowerListener; +import buttondevteam.lib.TBMCCoreAPI; +import buttondevteam.lib.chat.TBMCChatAPI; -public class GPowerModule extends Module{ +public class GPowerModule extends Module { @Override public void register(JavaPlugin plugin) { - plugin.getCommand("powerup").setExecutor(new PowerUp()); - plugin.getCommand("powerdown").setExecutor(new PowerDown()); - plugin.getCommand("gpowercommand").setExecutor(new gPowerCommand()); - - plugin.getServer().getPluginManager().registerEvents(new gPowerListener(plugin), plugin); + TBMCChatAPI.AddCommands(plugin, gPowerCommand.class); + + TBMCCoreAPI.RegisterEventsForExceptions(new gPowerListener(plugin), plugin); } } diff --git a/src/alisolarflare/modules/components/gpowers/commands/PowerDown.java b/src/alisolarflare/modules/components/gpowers/commands/PowerDown.java index d7c42e3..5ecb982 100644 --- a/src/alisolarflare/modules/components/gpowers/commands/PowerDown.java +++ b/src/alisolarflare/modules/components/gpowers/commands/PowerDown.java @@ -4,10 +4,35 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -public class PowerDown implements CommandExecutor { +import buttondevteam.lib.chat.TBMCCommandBase; + +public class PowerDown extends TBMCCommandBase { @Override - public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) { + public boolean OnCommand(CommandSender arg0, String arg2, String[] arg3) { + // TODO Auto-generated method stub + return false; + } + + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String GetCommandPath() { + return "powerdown"; + } + + @Override + public boolean GetPlayerOnly() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean GetModOnly() { // TODO Auto-generated method stub return false; } diff --git a/src/alisolarflare/modules/components/gpowers/commands/PowerUp.java b/src/alisolarflare/modules/components/gpowers/commands/PowerUp.java index 3668d8d..38fcffc 100644 --- a/src/alisolarflare/modules/components/gpowers/commands/PowerUp.java +++ b/src/alisolarflare/modules/components/gpowers/commands/PowerUp.java @@ -5,15 +5,35 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import buttondevteam.lib.chat.TBMCCommandBase; -public class PowerUp implements CommandExecutor{ +public class PowerUp extends TBMCCommandBase { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)){ - sender.sendMessage("You must be a player to use this command!"); - } - //gPowerMemory.PowerUpPlayer(player, colour); + public boolean OnCommand(CommandSender sender, String label, String[] args) { + // gPowerMemory.PowerUpPlayer(player, colour); + return false; + } + + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String GetCommandPath() { + return "powerup"; + } + + @Override + public boolean GetPlayerOnly() { + return true; + } + + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub return false; } diff --git a/src/alisolarflare/modules/components/gpowers/commands/gPowerCommand.java b/src/alisolarflare/modules/components/gpowers/commands/gPowerCommand.java index b9b105e..9d6c136 100644 --- a/src/alisolarflare/modules/components/gpowers/commands/gPowerCommand.java +++ b/src/alisolarflare/modules/components/gpowers/commands/gPowerCommand.java @@ -6,53 +6,67 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import alisolarflare.modules.components.gpowers.gPowerMemory; +import buttondevteam.lib.chat.TBMCCommandBase; -public class gPowerCommand implements CommandExecutor{ +public class gPowerCommand extends TBMCCommandBase { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean OnCommand(CommandSender sender, String label, String[] args) { sender.sendMessage("G power activate!"); - if (!(sender instanceof Player)){ - sender.sendMessage("You must be a player to use this command!"); - return false; - } Player player = (Player) sender; - if (args.length < 2){ + if (args.length < 2) { player.sendMessage("Proper Usage to test G-Powers:"); player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]"); return false; } String colour; player.sendMessage("Checking terms..."); - if(args[0].startsWith("r") || - args[0].startsWith("o")|| - args[0].startsWith("y")|| - args[0].startsWith("g")|| - args[0].startsWith("b")|| - args[0].startsWith("p")){ + if (args[0].startsWith("r") || args[0].startsWith("o") || args[0].startsWith("y") || args[0].startsWith("g") + || args[0].startsWith("b") || args[0].startsWith("p")) { colour = args[0]; - }else{ + } else { player.sendMessage("Term Fail: COLOUR. Proper Usage to test G-Powers:"); player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]"); return false; } boolean isActive; - if(args[1].startsWith("t")){ + if (args[1].startsWith("t")) { isActive = true; - }else if (args[1].startsWith("f")){ + } else if (args[1].startsWith("f")) { isActive = false; - }else{ + } else { player.sendMessage("Term Fail: ACTIVE. Proper Usage to test G-Powers:"); player.sendMessage("/gpowertest [colour=red,orange,yellow,green,blue,purple] [active=true/false]"); return false; } player.sendMessage("Terms Vaild!"); - if(isActive){ + if (isActive) { gPowerMemory.PowerUpPlayer(player, colour); - }else{ + } else { gPowerMemory.PowerDownPlayer(player); } return false; } + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return new String[] { "" }; + } + + @Override + public String GetCommandPath() { + return "gpower"; + } + + @Override + public boolean GetPlayerOnly() { + return true; + } + + @Override + public boolean GetModOnly() { + return false; + } + } diff --git a/src/alisolarflare/modules/components/links/AliLinkModule.java b/src/alisolarflare/modules/components/links/AliLinkModule.java index 4861f3a..07a8a51 100644 --- a/src/alisolarflare/modules/components/links/AliLinkModule.java +++ b/src/alisolarflare/modules/components/links/AliLinkModule.java @@ -1,4 +1,5 @@ package alisolarflare.modules.components.links; + import java.util.List; import org.bukkit.plugin.java.JavaPlugin; @@ -7,25 +8,25 @@ import alisolarflare.modules.Module; import alisolarflare.modules.components.links.commands.PressAliLink; import alisolarflare.modules.components.links.commands.SetAliLink; import alisolarflare.modules.components.links.entities.Link; +import buttondevteam.lib.chat.TBMCChatAPI; -public class AliLinkModule extends Module{ +public class AliLinkModule extends Module { private SetAliLink setAliLink; - + @Override - public void register(JavaPlugin plugin){ + public void register(JavaPlugin plugin) { setAliLink = new SetAliLink(plugin); - plugin.getCommand("setalilink").setExecutor(setAliLink); - plugin.getCommand("pressalilink").setExecutor(new PressAliLink(plugin, setAliLink)); - + TBMCChatAPI.AddCommands(plugin, PressAliLink.class); + } - public void saveLinkList(JavaPlugin plugin){ + + public void saveLinkList(JavaPlugin plugin) { plugin.getConfig().set("aliLinkList", setAliLink.linkList); } - + @SuppressWarnings("unchecked") - public List loadLinkList(JavaPlugin plugin){ + public List loadLinkList(JavaPlugin plugin) { return (List) plugin.getConfig().getList("aliLinkList"); } - - + } diff --git a/src/alisolarflare/modules/components/links/commands/PressAliLink.java b/src/alisolarflare/modules/components/links/commands/PressAliLink.java index 7c277fd..c60e43b 100644 --- a/src/alisolarflare/modules/components/links/commands/PressAliLink.java +++ b/src/alisolarflare/modules/components/links/commands/PressAliLink.java @@ -6,26 +6,29 @@ import org.bukkit.command.CommandSender; import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.modules.components.links.entities.Link; +import buttondevteam.lib.chat.TBMCCommandBase; -public class PressAliLink implements CommandExecutor{ +public class PressAliLink extends TBMCCommandBase { private JavaPlugin plugin; private SetAliLink setAliLink; - public PressAliLink(JavaPlugin plugin, SetAliLink setAliLink){ + + public PressAliLink(JavaPlugin plugin, SetAliLink setAliLink) { this.plugin = plugin; - this.setAliLink = setAliLink; + this.setAliLink = setAliLink; } + @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean OnCommand(CommandSender sender, String label, String[] args) { sender.getServer().broadcastMessage(setAliLink.linkList.toString() + "over."); - - if (args.length < 1){ + + if (args.length < 1) { sender.sendMessage("You must specify a link frequency"); sender.sendMessage("/pressalilink [frequency]"); } - for (Link link: setAliLink.linkList){ - for (String inputlink: args){ - if(inputlink.equals(link.frequency)){ + for (Link link : setAliLink.linkList) { + for (String inputlink : args) { + if (inputlink.equals(link.frequency)) { link.press(plugin); } } @@ -33,4 +36,27 @@ public class PressAliLink implements CommandExecutor{ return false; } + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String GetCommandPath() { + return "pressalilink"; + } + + @Override + public boolean GetPlayerOnly() { + // TODO Auto-generated method stub + return false; + } + + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub + return false; + } + } diff --git a/src/alisolarflare/modules/components/links/commands/SetAliLink.java b/src/alisolarflare/modules/components/links/commands/SetAliLink.java index ec3083d..83d7de1 100644 --- a/src/alisolarflare/modules/components/links/commands/SetAliLink.java +++ b/src/alisolarflare/modules/components/links/commands/SetAliLink.java @@ -1,6 +1,5 @@ package alisolarflare.modules.components.links.commands; - import java.util.ArrayList; import java.util.List; @@ -14,66 +13,70 @@ import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.modules.components.links.AliLinkModule; import alisolarflare.modules.components.links.entities.Link; +import buttondevteam.lib.chat.TBMCCommandBase; /** - * This class manages the command /SetAliLink [x] [y] [z]. This command creates an Ali-Link, - * a location in a world that when called on by {@link Class#PressAliLink}, creates a temporary redstone block, - * enabling wireless redstone + * This class manages the command /SetAliLink [x] [y] [z]. This command creates an Ali-Link, a location in a world that when called on by {@link PressAliLink}, creates a temporary redstone + * block, enabling wireless redstone * - * @see Class#PressAliLink + * @see PressAliLink * @author Alisolarflare * */ -public class SetAliLink implements CommandExecutor{ +public class SetAliLink extends TBMCCommandBase { public List linkList = new ArrayList(); AliLinkModule subplugin; private JavaPlugin plugin; - + /** * Constructs the SetAliLink class - * @param plugin The plugin that contains the configuration file of SetAliLink + * + * @param plugin + * The plugin that contains the configuration file of SetAliLink */ - public SetAliLink(JavaPlugin plugin){ + public SetAliLink(JavaPlugin plugin) { this.plugin = plugin; load(); } + /** - * This command creates an Ali-Link which, when activated by the command /PressAliLink, - * creates a temporary redstone block if and only if /PressAliLink [frequency] matches the frequency - * saved when /SetAliLink [frequency] is called. + * This command creates an Ali-Link which, when activated by the command /PressAliLink, creates a temporary redstone block if and only if /PressAliLink [frequency] matches the frequency saved when + * /SetAliLink [frequency] is called. * * @see Class#PressAliLink - * @param sender Player who sent the command - * @param command Command Object created - * @param label Name of the command - * @param args Arguments: [frequency] [x-coordinate] [y-coordinate] [z-coordinate], where the coordinates point - * to the intended location of the Ali-Link + * @param sender + * Player who sent the command + * @param command + * Command Object created + * @param label + * Name of the command + * @param args + * Arguments: [frequency] [x-coordinate] [y-coordinate] [z-coordinate], where the coordinates point to the intended location of the Ali-Link */ @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean OnCommand(CommandSender sender, String label, String[] args) { sender.sendMessage("you pressed shit"); - if (args == null || args.length < 1){ + if (args == null || args.length < 1) { sender.sendMessage("You must specify a link frequency"); sender.sendMessage("/pressalilink [name]"); return false; } - if (!(sender instanceof Player)){ - sender.sendMessage("You must be a player to use this command!"); - } Player player = (Player) sender; - if (args.length < 4){ + if (args.length < 4) { player.sendMessage("short"); linkList.add(new Link(args[0], player.getLocation())); save(player); player.sendMessage("end"); return false; } - if (StringUtils.isNumericSpace(args[1]) && StringUtils.isNumericSpace(args[2]) && StringUtils.isNumericSpace(args[3])){ + if (StringUtils.isNumericSpace(args[1]) && StringUtils.isNumericSpace(args[2]) + && StringUtils.isNumericSpace(args[3])) { player.sendMessage("CUUUSTOM"); - linkList.add(new Link(args[0],new Location(player.getWorld(), Double.parseDouble(args[1]), Double.parseDouble(args[2]), Double.parseDouble(args[3])))); + linkList.add(new Link(args[0], new Location(player.getWorld(), Double.parseDouble(args[1]), + Double.parseDouble(args[2]), Double.parseDouble(args[3])))); save(player); player.sendMessage("FINISHED"); - }else{ + } else { player.sendMessage("UNCUSTOOM"); linkList.add(new Link(args[0], player.getLocation())); save(player); @@ -82,43 +85,58 @@ public class SetAliLink implements CommandExecutor{ } return false; } + /** - * Tries to save the entire SetAliLink class into memory, which includes - * all of the current Ali-links saved and in use. + * Tries to save the entire SetAliLink class into memory, which includes all of the current Ali-links saved and in use. + * * @param player */ - private void save(Player player){ + private void save(Player player) { player.sendMessage("SAAAVING"); player.sendMessage("SAVE FAILED: TELL ALI TO FIX THE SAVE AND UN-COMMENT THE PARAGRAPH SHE COMMENTED"); player.sendMessage("Link will only last until next server restart"); return; /* - subplugin.plugin.getConfig().set("aliLinkList", subplugin.linkList); - try { - player.sendMessage("SAVIN"); - subplugin.plugin.saveConfig(); - player.sendMessage("GOOD SAVE"); - } catch (Exception e) { - player.sendMessage("YOU FUCKED STUFF UP"); - // TODO Auto-generated catch block - e.printStackTrace(); - } - */ + * subplugin.plugin.getConfig().set("aliLinkList", subplugin.linkList); try { player.sendMessage("SAVIN"); subplugin.plugin.saveConfig(); player.sendMessage("GOOD SAVE"); } catch (Exception e) + * { player.sendMessage("YOU FUCKED STUFF UP"); // TODO Auto-generated catch block e.printStackTrace(); } + */ } + /** - * Attempts to load the previous saved state of AliLinks, from the plugin - * configuration file + * Attempts to load the previous saved state of AliLinks, from the plugin configuration file */ @SuppressWarnings("unchecked") - private void load(){ - try{ + private void load() { + try { linkList = (List) plugin.getConfig().getList("aliLinkList"); - if(linkList == null || linkList.isEmpty()){ + if (linkList == null || linkList.isEmpty()) { linkList = new ArrayList(); } - }catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } } - + + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String GetCommandPath() { + return "setalilink"; + } + + @Override + public boolean GetPlayerOnly() { + return true; + } + + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub + return false; + } + } diff --git a/src/alisolarflare/modules/components/shulker/AliShulkerModule.java b/src/alisolarflare/modules/components/shulker/AliShulkerModule.java index 97f2e31..cab720f 100644 --- a/src/alisolarflare/modules/components/shulker/AliShulkerModule.java +++ b/src/alisolarflare/modules/components/shulker/AliShulkerModule.java @@ -4,12 +4,13 @@ import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.modules.Module; import alisolarflare.modules.components.shulker.commands.AliShulker; +import buttondevteam.lib.chat.TBMCChatAPI; -public class AliShulkerModule extends Module{ +public class AliShulkerModule extends Module { @Override public void register(JavaPlugin plugin) { - plugin.getCommand("alishulker").setExecutor(new AliShulker()); + TBMCChatAPI.AddCommands(plugin, AliShulker.class); } } diff --git a/src/alisolarflare/modules/components/shulker/commands/AliShulker.java b/src/alisolarflare/modules/components/shulker/commands/AliShulker.java index cc802c6..10a61f5 100644 --- a/src/alisolarflare/modules/components/shulker/commands/AliShulker.java +++ b/src/alisolarflare/modules/components/shulker/commands/AliShulker.java @@ -10,37 +10,53 @@ import org.bukkit.entity.Player; import org.bukkit.entity.Shulker; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; + +import buttondevteam.lib.chat.TBMCCommandBase; + /** - * @author Alisolarflare - * This class is responsible for the command /aliShulker, which in-game spawns - * a shulker that: - * Has a health of 10 - * Has a wither and invisibility effect present - * Has noAI - * And is Glowing + * @author Alisolarflare This class is responsible for the command /aliShulker, which in-game spawns a shulker that: Has a health of 10 Has a wither and invisibility effect present Has noAI And is + * Glowing */ -public class AliShulker implements CommandExecutor { +public class AliShulker extends TBMCCommandBase { @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)){ - sender.sendMessage("You must be a player to use this command!"); - return false; - } + public boolean OnCommand(CommandSender sender, String label, String[] args) { Player player = (Player) sender; - if(!(player.getName().equals("iie") || player.getName().equals("alisolarflare"))){ + if (!(player.getName().equals("iie") || player.getName().equals("alisolarflare"))) { return false; } Location location = player.getLocation(); Entity entity = player.getWorld().spawnEntity(location, EntityType.SHULKER); Shulker shulker = (Shulker) entity; shulker.setHealth(10); - + shulker.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 1728000, 5, false)); shulker.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1728000, 5, false)); shulker.setAI(false); shulker.setGlowing(true); - + + return false; + } + + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String GetCommandPath() { + return "alishulker"; + } + + @Override + public boolean GetPlayerOnly() { + return true; + } + + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub return false; } diff --git a/src/alisolarflare/modules/events/uhc/UHCModule.java b/src/alisolarflare/modules/events/uhc/UHCModule.java index 77f3ec2..a8b75d7 100644 --- a/src/alisolarflare/modules/events/uhc/UHCModule.java +++ b/src/alisolarflare/modules/events/uhc/UHCModule.java @@ -6,22 +6,25 @@ import alisolarflare.modules.Module; import alisolarflare.modules.events.uhc.commands.AddToUHC; import alisolarflare.modules.events.uhc.commands.StartMatch; import alisolarflare.modules.events.uhc.memory.UHCMatch; +import buttondevteam.lib.chat.TBMCChatAPI; public class UHCModule extends Module { public UHCMatch match; - public void register(JavaPlugin plugin){ + public void register(JavaPlugin plugin) { registerCommands(plugin); registerListeners(plugin); registerMemoryUnits(plugin); } + private void registerListeners(JavaPlugin plugin) { } + private void registerCommands(JavaPlugin plugin) { - registerCommand(plugin, "addToUHC", new AddToUHC(this.match)); - registerCommand(plugin, "startMatch", new StartMatch(this.match)); + TBMCChatAPI.AddCommands(plugin, AddToUHC.class); } - private void registerMemoryUnits(JavaPlugin plugin){ + + private void registerMemoryUnits(JavaPlugin plugin) { match = new UHCMatch(plugin.getConfig(), plugin.getConfig().getString("UHCMatchState")); } } diff --git a/src/alisolarflare/modules/events/uhc/commands/AddToUHC.java b/src/alisolarflare/modules/events/uhc/commands/AddToUHC.java index aa0ed34..f260a83 100644 --- a/src/alisolarflare/modules/events/uhc/commands/AddToUHC.java +++ b/src/alisolarflare/modules/events/uhc/commands/AddToUHC.java @@ -1,58 +1,80 @@ package alisolarflare.modules.events.uhc.commands; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import alisolarflare.modules.events.uhc.memory.UHCMatch; +import buttondevteam.lib.chat.TBMCCommandBase; /** - * This class handles the specific command /addToUHC which, in-game, - * adds a player to a specific UltraHardcore match, that is defined - * by the constructor: {@linkplain #AddToUHC(UHCMatch)} - * @author Alisolarflare + * This class handles the specific command /addToUHC which, in-game, adds a player to a specific UltraHardcore match, that is defined by the constructor: {@linkplain #AddToUHC(UHCMatch)} + * + * @author Alisolarflare */ -public class AddToUHC implements CommandExecutor{ +public class AddToUHC extends TBMCCommandBase { private UHCMatch generalMemory; - - + /** * Constructor for this AddToUHC - * @param generalMemory The Memory Unit for the current match + * + * @param generalMemory + * The Memory Unit for the current match */ - public AddToUHC(UHCMatch generalMemory){ + public AddToUHC(UHCMatch generalMemory) { this.generalMemory = generalMemory; } - + /** * Activated function when /addtoUHC <> is typed in-game - * @param sender CommandSender which sent the command /addToUHC - * @param command Command object created when /addToUHC is called in-game - * @param label Name of the command called - * @param args Arguments passed onto /addToUHC by the player + * + * @param sender + * CommandSender which sent the command /addToUHC + * @param command + * Command object created when /addToUHC is called in-game + * @param label + * Name of the command called + * @param args + * Arguments passed onto /addToUHC by the player */ @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - //INPUT SANITATION - if (!(sender instanceof Player)){ - sender.sendMessage("You must be a player to use this command!"); - return false; - } + public boolean OnCommand(CommandSender sender, String label, String[] args) { + // INPUT SANITATION Player player = (Player) sender; - if (player.getName() != "alisolarflare"){ + if (player.getName() != "alisolarflare") { sender.sendMessage("You must be Ali to use this command, send her a message to change the permissions"); return false; } - if (args.length <= 1){ + if (args.length <= 1) { sender.sendMessage("You must supply at least one playername"); } - - //Adds players to memory - for (int i = 0; i > args.length; i++){ + + // Adds players to memory + for (int i = 0; i > args.length; i++) { generalMemory.matchPlayerUsernames.add(player.getName()); } return false; } + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String GetCommandPath() { + return "addtouhc"; + } + + @Override + public boolean GetPlayerOnly() { + return true; + } + + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub + return false; + } + } diff --git a/src/alisolarflare/modules/events/uhc/commands/StartMatch.java b/src/alisolarflare/modules/events/uhc/commands/StartMatch.java index 8aa5d07..2e2d0de 100644 --- a/src/alisolarflare/modules/events/uhc/commands/StartMatch.java +++ b/src/alisolarflare/modules/events/uhc/commands/StartMatch.java @@ -7,17 +7,17 @@ import org.bukkit.entity.Player; import alisolarflare.modules.events.uhc.memory.MatchState; import alisolarflare.modules.events.uhc.memory.UHCMatch; +import buttondevteam.lib.chat.TBMCCommandBase; -public class StartMatch implements CommandExecutor { +public class StartMatch extends TBMCCommandBase { private UHCMatch match; - public StartMatch(UHCMatch match){ + + public StartMatch(UHCMatch match) { this.match = match; } + @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)){ - sender.sendMessage("You must be a player to use this command! Contact a dev if you think this is wrong"); - } + public boolean OnCommand(CommandSender sender, String label, String[] args) { if (match.getMatchState() == MatchState.NULL) sender.sendMessage("There is no match to begin."); else if (match.getMatchState() == MatchState.IDLE) @@ -28,8 +28,30 @@ public class StartMatch implements CommandExecutor { sender.sendMessage("The match has ended! Would you like to restart?"); else sender.sendMessage("You cannot start a match now, one is already in progress!"); - + + return false; + + } + + @Override + public String[] GetHelpText(String alias) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String GetCommandPath() { + return "startmatch"; + } + + @Override + public boolean GetPlayerOnly() { + return true; + } + + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub return false; - } } diff --git a/src/alisolarflare/modules/magictrick/aliarrow/AliArrowListener.java b/src/alisolarflare/modules/magictrick/aliarrow/AliArrowListener.java index bcdc62f..eeadd4e 100644 --- a/src/alisolarflare/modules/magictrick/aliarrow/AliArrowListener.java +++ b/src/alisolarflare/modules/magictrick/aliarrow/AliArrowListener.java @@ -15,7 +15,6 @@ public class AliArrowListener implements Listener { this.plugin = plugin; } - @SuppressWarnings("deprecation") @EventHandler public void onProjectileLaunch(ProjectileLaunchEvent event){ try{ diff --git a/src/alisolarflare/modules/magictrick/aliarrow/AliArrowModule.java b/src/alisolarflare/modules/magictrick/aliarrow/AliArrowModule.java index 42f02dd..b73167f 100644 --- a/src/alisolarflare/modules/magictrick/aliarrow/AliArrowModule.java +++ b/src/alisolarflare/modules/magictrick/aliarrow/AliArrowModule.java @@ -1,16 +1,16 @@ package alisolarflare.modules.magictrick.aliarrow; - import org.bukkit.plugin.java.JavaPlugin; import alisolarflare.modules.Module; +import buttondevteam.lib.TBMCCoreAPI; -public class AliArrowModule extends Module{ +public class AliArrowModule extends Module { /** * Registers the plugin, activating listeners, commands, and events */ @Override - public void register(JavaPlugin plugin) { - plugin.getServer().getPluginManager().registerEvents(new AliArrowListener(plugin), plugin); - + public void register(JavaPlugin plugin) { + TBMCCoreAPI.RegisterEventsForExceptions(new AliArrowListener(plugin), plugin); + } } diff --git a/src/alisolarflare/modules/magictrick/aliarrow/AliArrowTask.java b/src/alisolarflare/modules/magictrick/aliarrow/AliArrowTask.java index 0a8cdf8..1904830 100644 --- a/src/alisolarflare/modules/magictrick/aliarrow/AliArrowTask.java +++ b/src/alisolarflare/modules/magictrick/aliarrow/AliArrowTask.java @@ -5,35 +5,33 @@ import org.bukkit.entity.Arrow; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; -public class AliArrowTask extends BukkitRunnable{ +public class AliArrowTask extends BukkitRunnable { JavaPlugin plugin; String name; Arrow arrow; - - - - public AliArrowTask(JavaPlugin plugin, Arrow arrow, String name){ + + public AliArrowTask(JavaPlugin plugin, Arrow arrow, String name) { this.name = name; this.plugin = plugin; this.arrow = arrow; } - + @Override public void run() { - if (arrow.isOnGround() || arrow.isDead()){ + if (arrow.isOnGround() || arrow.isDead()) { this.cancel(); } - if (name.equalsIgnoreCase("alisolarflare")){ + if (name.equalsIgnoreCase("alisolarflare")) { arrow.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, arrow.getLocation(), 1); } - if (name.equalsIgnoreCase("Zanthr")){ + if (name.equalsIgnoreCase("Zanthr")) { arrow.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, arrow.getLocation(), 1); arrow.getWorld().spawnParticle(Particle.FLAME, arrow.getLocation(), 1); } - - - + if (name.equals("NorbiPeti")) + arrow.getWorld().spawnParticle(Particle.LAVA, arrow.getLocation(), 1); + } }