Replaced hard-coded registerCommands with general registerCommand from
Module
This commit is contained in:
parent
ae01b1d250
commit
70b2e89e10
10 changed files with 30 additions and 37 deletions
|
@ -3,6 +3,7 @@ package alisolarflare;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
|
||||
|
@ -37,11 +38,11 @@ public abstract class Module{
|
|||
* @param label Name of the command in plugin.yml
|
||||
* @param commandExecutor Custom coded CommandExecutor class
|
||||
*/
|
||||
protected <T extends TBMCCommandBase> void registerCommand(JavaPlugin plugin, String label, Class<T> commandExecutor){
|
||||
TBMCChatAPI.AddCommands(plugin, commandExecutor);
|
||||
protected void registerCommand(JavaPlugin plugin, TBMCCommandBase commandBase){
|
||||
TBMCChatAPI.AddCommand(plugin, commandBase);
|
||||
}
|
||||
protected Listener registerListener(JavaPlugin plugin, Listener listener){
|
||||
plugin.getServer().getPluginManager().registerEvents(listener, plugin);
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(listener, plugin);
|
||||
return listener;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,11 @@ import alisolarflare.Module;
|
|||
import alisolarflare.components.flairdoor.commands.FlairMe;
|
||||
import alisolarflare.components.flairdoor.listeners.PortalListener;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
|
||||
public class FlairDoorModule extends Module {
|
||||
@Override
|
||||
public void register(JavaPlugin plugin) {
|
||||
TBMCChatAPI.AddCommands(plugin, FlairMe.class);
|
||||
registerCommand(plugin, new FlairMe());
|
||||
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(new PortalListener(plugin), plugin);
|
||||
}
|
||||
|
|
|
@ -6,13 +6,12 @@ import alisolarflare.Module;
|
|||
import alisolarflare.components.gpowers.commands.gPowerCommand;
|
||||
import alisolarflare.components.gpowers.listeners.gPowerListener;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
|
||||
public class GPowerModule extends Module {
|
||||
|
||||
@Override
|
||||
public void register(JavaPlugin plugin) {
|
||||
TBMCChatAPI.AddCommands(plugin, gPowerCommand.class);
|
||||
registerCommand(plugin, new gPowerCommand());
|
||||
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(new gPowerListener(plugin), plugin);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import alisolarflare.Module;
|
|||
import alisolarflare.components.links.commands.PressAliLink;
|
||||
import alisolarflare.components.links.commands.SetAliLink;
|
||||
import alisolarflare.components.links.entities.Link;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
|
||||
public class AliLinkModule extends Module {
|
||||
private SetAliLink setAliLink;
|
||||
|
@ -16,8 +15,8 @@ public class AliLinkModule extends Module {
|
|||
@Override
|
||||
public void register(JavaPlugin plugin) {
|
||||
setAliLink = new SetAliLink(plugin);
|
||||
TBMCChatAPI.AddCommands(plugin, PressAliLink.class);
|
||||
TBMCChatAPI.AddCommands(plugin, SetAliLink.class);
|
||||
registerCommand(plugin, new PressAliLink(plugin, setAliLink));
|
||||
registerCommand(plugin, setAliLink);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,12 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
|
||||
import alisolarflare.Module;
|
||||
import alisolarflare.components.shulker.commands.AliShulker;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
|
||||
public class AliShulkerModule extends Module {
|
||||
|
||||
@Override
|
||||
public void register(JavaPlugin plugin) {
|
||||
TBMCChatAPI.AddCommands(plugin, AliShulker.class);
|
||||
registerCommand(plugin, new AliShulker());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,10 +4,9 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
|
||||
import alisolarflare.Module;
|
||||
import alisolarflare.events.uhc.commands.AddToUHC;
|
||||
import alisolarflare.events.uhc.memory.MatchState;
|
||||
import alisolarflare.events.uhc.commands.StartMatch;
|
||||
import alisolarflare.events.uhc.memory.MatchState;
|
||||
import alisolarflare.events.uhc.memory.UHCMatch;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
|
||||
public class UHCModule extends Module {
|
||||
public UHCMatch match;
|
||||
|
@ -17,15 +16,6 @@ public class UHCModule extends Module {
|
|||
registerCommands(plugin);
|
||||
registerListeners(plugin);
|
||||
}
|
||||
|
||||
private void registerListeners(JavaPlugin plugin) {
|
||||
}
|
||||
|
||||
private void registerCommands(JavaPlugin plugin) {
|
||||
TBMCChatAPI.AddCommand(plugin, AddToUHC.class, match);
|
||||
TBMCChatAPI.AddCommand(plugin, new StartMatch(match));
|
||||
}
|
||||
|
||||
private void registerMemoryUnits(JavaPlugin plugin) {
|
||||
if (plugin.getConfig().contains("UHCMatchState")){
|
||||
match = new UHCMatch(plugin.getConfig(), MatchState.valueOf(plugin.getConfig().getString("UHCMatchState")));
|
||||
|
@ -33,4 +23,13 @@ public class UHCModule extends Module {
|
|||
match = new UHCMatch(plugin.getConfig(), MatchState.IDLE);
|
||||
}
|
||||
}
|
||||
private void registerListeners(JavaPlugin plugin) {
|
||||
}
|
||||
|
||||
private void registerCommands(JavaPlugin plugin) {
|
||||
registerCommand(plugin, new AddToUHC(match));
|
||||
registerCommand(plugin, new StartMatch(match));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package alisolarflare.events.uhc.commands;
|
|||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import alisolarflare.events.uhc.memory.MatchState;
|
||||
import alisolarflare.events.uhc.memory.UHCMatch;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
|
||||
|
|
|
@ -5,14 +5,13 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
import alisolarflare.Module;
|
||||
import alisolarflare.magic.aliarrow.AliArrowListener;
|
||||
import alisolarflare.magic.boombow.BoomBowListener;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
|
||||
public class MagicModule extends Module{
|
||||
|
||||
@Override
|
||||
public void register(JavaPlugin plugin) {
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(new AliArrowListener(plugin), plugin);
|
||||
TBMCCoreAPI.RegisterEventsForExceptions(new BoomBowListener(), plugin);
|
||||
registerListener(plugin, new AliArrowListener(plugin));
|
||||
registerListener(plugin, new BoomBowListener());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
import alisolarflare.Module;
|
||||
import alisolarflare.minigames.freeforall.commands.SetFFAS;
|
||||
import alisolarflare.minigames.freeforall.data.SpawnSet;
|
||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||
|
||||
public class FreeForAllModule extends Module{
|
||||
public SpawnSet spawnSet;
|
||||
|
@ -13,20 +12,21 @@ public class FreeForAllModule extends Module{
|
|||
|
||||
@Override
|
||||
public void register(JavaPlugin plugin) {
|
||||
registerMemory();
|
||||
registerEvents();
|
||||
registerCommands(plugin);
|
||||
registerMemory();
|
||||
}
|
||||
private void registerMemory() {
|
||||
this.spawnSet = new SpawnSet();
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
}
|
||||
|
||||
private void registerCommands(JavaPlugin plugin) {
|
||||
TBMCChatAPI.AddCommands(plugin, SetFFAS.class);
|
||||
}
|
||||
private void registerMemory() {
|
||||
this.spawnSet = new SpawnSet();
|
||||
registerCommand(plugin, new SetFFAS(spawnSet));
|
||||
}
|
||||
|
||||
public int getGameState() {return GameState;}
|
||||
public void setGameState(int gameState) {GameState = gameState;}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ 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;
|
||||
|
@ -21,8 +20,8 @@ public class LobbyModule extends Module{
|
|||
}
|
||||
|
||||
private void registerCommands(JavaPlugin plugin) {
|
||||
TBMCChatAPI.AddCommands(plugin, ButtonFight.class);
|
||||
TBMCChatAPI.AddCommands(plugin, ButtonLeave.class);
|
||||
TBMCChatAPI.AddCommands(plugin, ListFighters.class);
|
||||
registerCommand(plugin, new ButtonFight(this));
|
||||
registerCommand(plugin, new ButtonLeave(this));
|
||||
registerCommand(plugin, new ListFighters(this));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue