Refactored code to make subcommands #23

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

View file

@ -12,7 +12,6 @@ public abstract class ModCommand extends PlayerCommand{
@Override @Override
public boolean GetModOnly() { public boolean GetModOnly() {
// TODO Auto-generated method stub
return true; return true;
} }
} }

View file

@ -18,13 +18,11 @@ public abstract class PlayerCommand extends BaseCommand{
public abstract boolean OnCommand(Player player, String alias, String[] args); public abstract boolean OnCommand(Player player, String alias, String[] args);
@Override @Override
public boolean GetPlayerOnly() { public boolean GetPlayerOnly() {
// TODO Auto-generated method stub
return true; return true;
} }
@Override @Override
public boolean GetModOnly() { public boolean GetModOnly() {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override

View file

@ -3,11 +3,19 @@ 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.AliLink; import buttondevteam.alipresents.components.alilinks.commands.Press;
import buttondevteam.alipresents.components.alilinks.commands.Set;
public class AliLinkComponent extends Component { public class AliLinkComponent extends Component {
private static JavaPlugin p;
public static JavaPlugin getPlugin() {
return p;
}
@Override @Override
public void register(JavaPlugin plugin) { public void register(JavaPlugin plugin) {
registerCommand(plugin, new AliLink(plugin)); registerCommand(p = plugin, new Press());
registerCommand(plugin, new Set());
} }
} }

View file

@ -1,56 +0,0 @@
package buttondevteam.alipresents.components.alilinks.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.alipresents.architecture.commands.BaseCommand;
import buttondevteam.alipresents.components.alilinks.AliLinkAPI;
public class AliLink extends BaseCommand{
private JavaPlugin plugin;
public AliLink(JavaPlugin plugin) {
this.plugin = plugin;
}
@Override
public boolean OnCommand(CommandSender player, String alias, String[] inputFrequencies) {
if(inputFrequencies.length < 1)
return false;
switch (inputFrequencies[0].toLowerCase()){
case "press":
return AliLinkAPI.sendPressEvent(player, inputFrequencies, plugin);
case "set":
return AliLinkAPI.createAliLink((Player) player, inputFrequencies);
default:
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

@ -3,12 +3,19 @@ package buttondevteam.alipresents.components.alilinks.commands;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import buttondevteam.alipresents.architecture.commands.PlayerCommand; import buttondevteam.alipresents.architecture.commands.PlayerCommand;
import buttondevteam.alipresents.components.alilinks.AliLinkAPI;
import buttondevteam.alipresents.components.alilinks.AliLinkComponent;
public class Press extends PlayerCommand { public class Press extends PlayerCommand {
@Override
public String GetCommandPath() {
return "alilink press";
}
@Override @Override
public boolean OnCommand(Player player, String alias, String[] args) { public boolean OnCommand(Player player, String alias, String[] args) {
// TODO Auto-generated method stub if (args.length < 1)
return false; return false;
return AliLinkAPI.sendPressEvent(player, args, AliLinkComponent.getPlugin());
} }
} }

View file

@ -3,12 +3,18 @@ package buttondevteam.alipresents.components.alilinks.commands;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import buttondevteam.alipresents.architecture.commands.ModCommand; import buttondevteam.alipresents.architecture.commands.ModCommand;
import buttondevteam.alipresents.components.alilinks.AliLinkAPI;
public class Set extends ModCommand { public class Set extends ModCommand {
@Override @Override
public boolean OnCommand(Player player, String alias, String[] args) { public String GetCommandPath() {
// TODO Auto-generated method stub return "alilink set";
return false;
} }
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
if (args.length < 1)
return false;
return AliLinkAPI.createAliLink(player, args);
}
} }