Refactored code to make subcommands #23
4 changed files with 73 additions and 17 deletions
|
@ -1,9 +1,19 @@
|
||||||
package buttondevteam.alipresents.architecture.commands.subcommands;
|
package buttondevteam.alipresents.architecture.commands.subcommands;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public abstract class SubCommand {
|
public abstract class SubCommand {
|
||||||
public abstract boolean run(Player player, String label, String[] args);
|
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 getPlayerOnly();
|
||||||
public abstract boolean getModOnly();
|
public abstract boolean getModOnly();
|
||||||
public abstract String[] GetHelpText(String alias);
|
public abstract String[] GetHelpText(String alias);
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package buttondevteam.alipresents.components.alilinks.commands;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import buttondevteam.alipresents.architecture.commands.subcommands.SubCommand;
|
||||||
|
|
||||||
|
public class Press extends SubCommand{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean onCommand(Player player, String label, String[] args) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package buttondevteam.alipresents.components.alilinks.commands;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import buttondevteam.alipresents.architecture.commands.ModCommand;
|
||||||
|
|
||||||
|
public class Set extends ModCommand{
|
||||||
|
@Override
|
||||||
|
public boolean OnCommand(Player player, String alias, String[] args) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue