Links now work with command blocks

This commit is contained in:
alisolarflare 2016-12-18 22:18:11 -05:00
parent 871d32027b
commit 880d03fba9
6 changed files with 72 additions and 10 deletions

View file

@ -1,8 +1,22 @@
package buttondevteam.alipresents.architecture.commands; package buttondevteam.alipresents.architecture.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import buttondevteam.lib.chat.TBMCCommandBase; import buttondevteam.lib.chat.TBMCCommandBase;
public abstract class BaseCommand extends TBMCCommandBase implements CommandExecutor{ 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"
};
}
} }

View file

@ -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;
}
}

View file

@ -15,7 +15,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.alipresents.components.alilinks.entities.Link; import buttondevteam.alipresents.components.alilinks.entities.Link;
public class AliLinkAPI { public class AliLinkAPI {
private static List<Link> linkList; public static List<Link> linkList = new ArrayList<Link>();
/**"Usage: /pressalilink <frequency>"*/ /**"Usage: /pressalilink <frequency>"*/
public static boolean sendPressEvent(CommandSender sender, String[] inputFrequencies, JavaPlugin plugin) { public static boolean sendPressEvent(CommandSender sender, String[] inputFrequencies, JavaPlugin plugin) {
if (inputFrequencies.length == 0) { if (inputFrequencies.length == 0) {

View file

@ -3,6 +3,7 @@ package buttondevteam.alipresents.components.alilinks;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.alipresents.architecture.Component; 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.Press;
import buttondevteam.alipresents.components.alilinks.commands.Set; import buttondevteam.alipresents.components.alilinks.commands.Set;
@ -18,5 +19,6 @@ public class AliLinkComponent extends Component {
p = plugin; p = plugin;
registerCommand(plugin, new Press()); registerCommand(plugin, new Press());
registerCommand(plugin, new Set()); registerCommand(plugin, new Set());
registerCommand(plugin, new ListLinks());
} }
} }

View file

@ -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";
}
}

View file

@ -1,23 +1,17 @@
package buttondevteam.alipresents.components.alilinks.commands; 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.AliLinkAPI;
import buttondevteam.alipresents.components.alilinks.AliLinkComponent; import buttondevteam.alipresents.components.alilinks.AliLinkComponent;
public class Press extends PlayerCommand { public class Press extends CommandBlockCommand {
@Override @Override
public String GetCommandPath() { public String GetCommandPath() {
return "alilink press"; 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 @Override
public String[] GetHelpText(String alias){ public String[] GetHelpText(String alias){
return new String[] { return new String[] {
@ -25,4 +19,13 @@ public class Press extends PlayerCommand {
"to your frequency of choice" "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());
}
} }