Fixed command adding

This commit is contained in:
Norbi Peti 2016-11-03 17:38:20 +01:00
parent 73bdb7e0bf
commit 254a0cdf10
9 changed files with 82 additions and 46 deletions

View file

@ -16,7 +16,8 @@ public class AliLinkModule extends Module {
@Override
public void register(JavaPlugin plugin) {
setAliLink = new SetAliLink(plugin);
TBMCChatAPI.AddCommands(plugin, PressAliLink.class);
TBMCChatAPI.AddCommand(plugin, new PressAliLink(plugin, setAliLink));
TBMCChatAPI.AddCommand(plugin, setAliLink);
}

View file

@ -10,7 +10,7 @@ public class AliShulkerModule extends Module {
@Override
public void register(JavaPlugin plugin) {
TBMCChatAPI.AddCommands(plugin, AliShulker.class);
TBMCChatAPI.AddCommand(plugin, AliShulker.class);
}
}

View file

@ -4,6 +4,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.Module;
import alisolarflare.events.uhc.commands.AddToUHC;
import alisolarflare.events.uhc.commands.StartMatch;
import alisolarflare.events.uhc.memory.UHCMatch;
import buttondevteam.lib.chat.TBMCChatAPI;
@ -20,7 +21,8 @@ public class UHCModule extends Module {
}
private void registerCommands(JavaPlugin plugin) {
TBMCChatAPI.AddCommands(plugin, AddToUHC.class);
TBMCChatAPI.AddCommand(plugin, AddToUHC.class, match);
TBMCChatAPI.AddCommand(plugin, new StartMatch(match));
}
private void registerMemoryUnits(JavaPlugin plugin) {

View file

@ -3,11 +3,9 @@ package alisolarflare.magic;
import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.Module;
import alisolarflare.events.uhc.commands.AddToUHC;
import alisolarflare.magic.aliarrow.AliArrowListener;
import alisolarflare.magic.boombow.BoomBowListener;
import buttondevteam.lib.TBMCCoreAPI;
import buttondevteam.lib.chat.TBMCChatAPI;
public class MagicModule extends Module{
@ -15,7 +13,6 @@ public class MagicModule extends Module{
public void register(JavaPlugin plugin) {
TBMCCoreAPI.RegisterEventsForExceptions(new AliArrowListener(plugin), plugin);
TBMCCoreAPI.RegisterEventsForExceptions(new BoomBowListener(), plugin);
TBMCChatAPI.AddCommands(plugin, AddToUHC.class);
}

View file

@ -22,7 +22,7 @@ public class FreeForAllModule extends Module{
}
private void registerCommands(JavaPlugin plugin) {
TBMCChatAPI.AddCommands(plugin, SetFFAS.class);
TBMCChatAPI.AddCommand(plugin, SetFFAS.class, spawnSet);
}
private void registerMemory() {
this.spawnSet = new SpawnSet();

View file

@ -8,6 +8,7 @@ import alisolarflare.Module;
import alisolarflare.minigames.lobby.commands.ButtonFight;
import alisolarflare.minigames.lobby.commands.ButtonLeave;
import alisolarflare.minigames.lobby.commands.ListFighters;
import buttondevteam.lib.chat.TBMCChatAPI;
public class LobbyModule extends Module{
public List<String> fighters;
@ -20,8 +21,8 @@ public class LobbyModule extends Module{
}
private void registerCommands(JavaPlugin plugin) {
plugin.getCommand("buttonfight").setExecutor(new ButtonFight(this));
plugin.getCommand("buttonleave").setExecutor(new ButtonLeave(this));
plugin.getCommand("listfighters").setExecutor(new ListFighters(this));
TBMCChatAPI.AddCommand(plugin, new ButtonFight(this));
TBMCChatAPI.AddCommand(plugin, new ButtonLeave(this));
TBMCChatAPI.AddCommand(plugin, new ListFighters(this));
}
}

View file

@ -1,13 +1,12 @@
package alisolarflare.minigames.lobby.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import alisolarflare.minigames.lobby.LobbyModule;
import buttondevteam.lib.chat.TBMCCommandBase;
public class ButtonFight implements CommandExecutor{
public class ButtonFight extends TBMCCommandBase {
private LobbyModule lobby;
public ButtonFight(LobbyModule lobby) {
@ -15,28 +14,38 @@ public class ButtonFight implements CommandExecutor{
}
@Override
public boolean onCommand(CommandSender sender, Command arg1, String arg2, String[] arg3) {
if(!(sender instanceof Player)){
sender.sendMessage("You must be a player to be using this command!");
return false;
}
public boolean OnCommand(CommandSender sender, String arg2, String[] arg3) {
Player player = (Player) sender;
player.sendMessage(player.toString());
String name = player.getName();
if(lobby.fighters.contains(name)){
if (lobby.fighters.contains(name)) {
player.sendMessage("You are already in the button fight!");
return false;
}
lobby.fighters.add(name);
if(lobby.fighters.contains(name)){
if (lobby.fighters.contains(name)) {
player.sendMessage("You have joined the fighters category!");
}
}
return false;
}
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean GetModOnly() {
return false;
}
}

View file

@ -1,15 +1,13 @@
package alisolarflare.minigames.lobby.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import alisolarflare.minigames.lobby.LobbyModule;
import buttondevteam.lib.chat.TBMCCommandBase;
public class ButtonLeave extends TBMCCommandBase {
public class ButtonLeave implements CommandExecutor{
private LobbyModule lobby;
public ButtonLeave(LobbyModule lobby) {
@ -17,23 +15,34 @@ public class ButtonLeave implements CommandExecutor{
}
@Override
public boolean onCommand(CommandSender sender, Command arg1, String arg2, String[] arg3) {
if(!(sender instanceof Player)){
sender.sendMessage("You must be a player to be using this command!");
return false;
}
public boolean OnCommand(CommandSender sender, String arg2, String[] arg3) {
Player player = (Player) sender;
String name = player.getName();
if (!(lobby.fighters.contains(name))){
if (!(lobby.fighters.contains(name))) {
player.sendMessage("You are not fighting!");
return false;
}
lobby.fighters.remove(name);
if(!(lobby.fighters.contains(name))){
if (!(lobby.fighters.contains(name))) {
player.sendMessage("You have left the fighters category!");
}
return false;
}
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean GetPlayerOnly() {
return true;
}
@Override
public boolean GetModOnly() {
return false;
}
}

View file

@ -1,12 +1,13 @@
package alisolarflare.minigames.lobby.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import java.util.stream.Collectors;
import org.bukkit.command.CommandSender;
import alisolarflare.minigames.lobby.LobbyModule;
import buttondevteam.lib.chat.TBMCCommandBase;
public class ListFighters implements CommandExecutor{
public class ListFighters extends TBMCCommandBase {
private LobbyModule lobby;
public ListFighters(LobbyModule lobby) {
@ -14,9 +15,25 @@ public class ListFighters implements CommandExecutor{
}
@Override
public boolean onCommand(CommandSender sender, Command arg1, String arg2, String[] arg3) {
sender.sendMessage(lobby.fighters.toString());
public boolean OnCommand(CommandSender sender, String arg2, String[] arg3) {
sender.sendMessage(lobby.fighters.stream().map(Object::toString).collect(Collectors.joining(", ")));
return false;
}
@Override
public String[] GetHelpText(String alias) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean GetPlayerOnly() {
return false;
}
@Override
public boolean GetModOnly() {
return false;
}
}