Refactored code to make subcommands #23

Merged
alisolarflare merged 6 commits from Refactoring into master 2016-12-17 07:43:27 +00:00
5 changed files with 29 additions and 76 deletions
Showing only changes of commit 7af3544c61 - Show all commits

View file

@ -1,15 +0,0 @@
package buttondevteam.alipresents.architecture.commands.subcommands;
public abstract class ModSubCommand extends SubCommand{
@Override
public boolean getPlayerOnly() {
// TODO Auto-generated method stub
return true;
}
@Override
public boolean getModOnly() {
// TODO Auto-generated method stub
return true;
}
}

View file

@ -1,16 +0,0 @@
package buttondevteam.alipresents.architecture.commands.subcommands;
public abstract class PlayerSubCommand extends SubCommand{
@Override
public boolean getModOnly() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean getPlayerOnly() {
// TODO Auto-generated method stub
return true;
}
}

View file

@ -1,20 +0,0 @@
package buttondevteam.alipresents.architecture.commands.subcommands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public abstract class SubCommand {
public boolean run(CommandSender sender, String label, String[] args){
if (getPlayerOnly() && (sender instanceof Player))
return false;
if (getModOnly() && (sender.hasPermission("Moderator")))
return false;
return onCommand((Player) sender, label, args);
}
protected abstract boolean onCommand(Player player, String label, String[] args);
public abstract boolean getPlayerOnly();
public abstract boolean getModOnly();
public abstract String[] GetHelpText(String alias);
}

View file

@ -1,19 +1,21 @@
package buttondevteam.alipresents.components.alilinks.commands; package buttondevteam.alipresents.components.alilinks.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.alipresents.architecture.commands.PlayerCommand; import buttondevteam.alipresents.architecture.commands.BaseCommand;
import buttondevteam.alipresents.components.alilinks.AliLinkAPI; import buttondevteam.alipresents.components.alilinks.AliLinkAPI;
public class AliLink extends PlayerCommand{ public class AliLink extends BaseCommand{
private JavaPlugin plugin; private JavaPlugin plugin;
public AliLink(JavaPlugin plugin) { public AliLink(JavaPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public boolean OnCommand(Player player, String alias, String[] inputFrequencies) { public boolean OnCommand(CommandSender player, String alias, String[] inputFrequencies) {
if(inputFrequencies.length < 1) if(inputFrequencies.length < 1)
return false; return false;
@ -21,12 +23,32 @@ public class AliLink extends PlayerCommand{
case "press": case "press":
return AliLinkAPI.sendPressEvent(player, inputFrequencies, plugin); return AliLinkAPI.sendPressEvent(player, inputFrequencies, plugin);
case "set": case "set":
return AliLinkAPI.createAliLink(player, inputFrequencies); return AliLinkAPI.createAliLink((Player) player, inputFrequencies);
default: default:
return false; return false;
} }
} }
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
// TODO Auto-generated method stub
return false;
}
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean GetPlayerOnly() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean GetModOnly() {
// TODO Auto-generated method stub
return false;
}

View file

@ -2,31 +2,13 @@ package buttondevteam.alipresents.components.alilinks.commands;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import buttondevteam.alipresents.architecture.commands.subcommands.SubCommand; import buttondevteam.alipresents.architecture.commands.PlayerCommand;
public class Press extends SubCommand{ public class Press extends PlayerCommand{
@Override @Override
protected boolean onCommand(Player player, String label, String[] args) { public boolean OnCommand(Player player, String alias, String[] args) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return false; return false;
} }
@Override
public boolean getPlayerOnly() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean getModOnly() {
// TODO Auto-generated method stub
return false;
}
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return null;
}
} }