From 880d03fba93c2c64ace1f951199dbb441d3ddd19 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sun, 18 Dec 2016 22:18:11 -0500 Subject: [PATCH] Links now work with command blocks --- .../architecture/commands/BaseCommand.java | 14 ++++++++++++ .../commands/CommandBlockCommand.java | 21 ++++++++++++++++++ .../components/alilinks/AliLinkAPI.java | 2 +- .../components/alilinks/AliLinkComponent.java | 2 ++ .../alilinks/commands/ListLinks.java | 22 +++++++++++++++++++ .../components/alilinks/commands/Press.java | 21 ++++++++++-------- 6 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 src/buttondevteam/alipresents/architecture/commands/CommandBlockCommand.java create mode 100644 src/buttondevteam/alipresents/components/alilinks/commands/ListLinks.java diff --git a/src/buttondevteam/alipresents/architecture/commands/BaseCommand.java b/src/buttondevteam/alipresents/architecture/commands/BaseCommand.java index 6233d3a..16d6127 100644 --- a/src/buttondevteam/alipresents/architecture/commands/BaseCommand.java +++ b/src/buttondevteam/alipresents/architecture/commands/BaseCommand.java @@ -1,8 +1,22 @@ package buttondevteam.alipresents.architecture.commands; +import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; import buttondevteam.lib.chat.TBMCCommandBase; public abstract class BaseCommand extends TBMCCommandBase implements CommandExecutor{ + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + // TODO Auto-generated method stub + return OnCommand(sender, label, args); + } + @Override + public String[] GetHelpText(String alias){ + return new String[] { + "This command doesn't have help text ask a dev to write one", + "If you're a dev, write the help text you lazy bastard. -Ali" + }; + } } diff --git a/src/buttondevteam/alipresents/architecture/commands/CommandBlockCommand.java b/src/buttondevteam/alipresents/architecture/commands/CommandBlockCommand.java new file mode 100644 index 0000000..57775e4 --- /dev/null +++ b/src/buttondevteam/alipresents/architecture/commands/CommandBlockCommand.java @@ -0,0 +1,21 @@ +package buttondevteam.alipresents.architecture.commands; + +public abstract class CommandBlockCommand extends BaseCommand{ + @Override + public String[] GetHelpText(String alias){ + return new String[] { + "This command doesn't have help text. ", + }; + } + + public boolean GetPlayerOnly() { + // TODO Auto-generated method stub + return false; + } + + public boolean GetModOnly() { + // TODO Auto-generated method stub + return false; + } + +} diff --git a/src/buttondevteam/alipresents/components/alilinks/AliLinkAPI.java b/src/buttondevteam/alipresents/components/alilinks/AliLinkAPI.java index 8115268..919ec34 100644 --- a/src/buttondevteam/alipresents/components/alilinks/AliLinkAPI.java +++ b/src/buttondevteam/alipresents/components/alilinks/AliLinkAPI.java @@ -15,7 +15,7 @@ import org.bukkit.plugin.java.JavaPlugin; import buttondevteam.alipresents.components.alilinks.entities.Link; public class AliLinkAPI { - private static List linkList; + public static List linkList = new ArrayList(); /**"Usage: /pressalilink "*/ public static boolean sendPressEvent(CommandSender sender, String[] inputFrequencies, JavaPlugin plugin) { if (inputFrequencies.length == 0) { diff --git a/src/buttondevteam/alipresents/components/alilinks/AliLinkComponent.java b/src/buttondevteam/alipresents/components/alilinks/AliLinkComponent.java index c36f5cc..d1d59b6 100644 --- a/src/buttondevteam/alipresents/components/alilinks/AliLinkComponent.java +++ b/src/buttondevteam/alipresents/components/alilinks/AliLinkComponent.java @@ -3,6 +3,7 @@ package buttondevteam.alipresents.components.alilinks; import org.bukkit.plugin.java.JavaPlugin; import buttondevteam.alipresents.architecture.Component; +import buttondevteam.alipresents.components.alilinks.commands.ListLinks; import buttondevteam.alipresents.components.alilinks.commands.Press; import buttondevteam.alipresents.components.alilinks.commands.Set; @@ -18,5 +19,6 @@ public class AliLinkComponent extends Component { p = plugin; registerCommand(plugin, new Press()); registerCommand(plugin, new Set()); + registerCommand(plugin, new ListLinks()); } } diff --git a/src/buttondevteam/alipresents/components/alilinks/commands/ListLinks.java b/src/buttondevteam/alipresents/components/alilinks/commands/ListLinks.java new file mode 100644 index 0000000..1806166 --- /dev/null +++ b/src/buttondevteam/alipresents/components/alilinks/commands/ListLinks.java @@ -0,0 +1,22 @@ +package buttondevteam.alipresents.components.alilinks.commands; + +import org.bukkit.entity.Player; + +import buttondevteam.alipresents.architecture.commands.PlayerCommand; +import buttondevteam.alipresents.components.alilinks.AliLinkAPI; +import buttondevteam.alipresents.components.alilinks.entities.Link; + +public class ListLinks extends PlayerCommand { + @Override + public boolean OnCommand(Player player, String alias, String[] args) { + for (Link link : AliLinkAPI.linkList){ + player.sendMessage(link.toString()); + } + return false; + } + @Override + public String GetCommandPath() { + return "alilink listlinks"; + } + +} diff --git a/src/buttondevteam/alipresents/components/alilinks/commands/Press.java b/src/buttondevteam/alipresents/components/alilinks/commands/Press.java index ac8d642..44dc38e 100644 --- a/src/buttondevteam/alipresents/components/alilinks/commands/Press.java +++ b/src/buttondevteam/alipresents/components/alilinks/commands/Press.java @@ -1,23 +1,17 @@ package buttondevteam.alipresents.components.alilinks.commands; -import org.bukkit.entity.Player; +import org.bukkit.command.CommandSender; -import buttondevteam.alipresents.architecture.commands.PlayerCommand; +import buttondevteam.alipresents.architecture.commands.CommandBlockCommand; import buttondevteam.alipresents.components.alilinks.AliLinkAPI; import buttondevteam.alipresents.components.alilinks.AliLinkComponent; -public class Press extends PlayerCommand { +public class Press extends CommandBlockCommand { @Override public String GetCommandPath() { return "alilink press"; } - @Override - public boolean OnCommand(Player player, String alias, String[] args) { - if (args.length < 1) - return false; - return AliLinkAPI.sendPressEvent(player, args, AliLinkComponent.getPlugin()); - } @Override public String[] GetHelpText(String alias){ return new String[] { @@ -25,4 +19,13 @@ public class Press extends PlayerCommand { "to your frequency of choice" }; } + + @Override + public boolean OnCommand(CommandSender sender, String alias, String[] args) { + if (args.length < 1) + return false; + return AliLinkAPI.sendPressEvent(sender, args, AliLinkComponent.getPlugin()); + } + + }