mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-01-21 14:21:21 +01:00
Converted to core command system & added auto complete.
This commit is contained in:
parent
0eae353afa
commit
af93fa83ef
@ -3,4 +3,9 @@ main: ${plugin.main}
|
||||
version: ${plugin.version}
|
||||
author: ${plugin.author}
|
||||
api-version: 1.13
|
||||
softdepend: [PlaceholderAPI] # TODO: Add other softdepends
|
||||
softdepend: [PlaceholderAPI] # TODO: Add other softdepends
|
||||
commands:
|
||||
Boss:
|
||||
description: Used to handle all CustomBosses related commands.
|
||||
default: true
|
||||
aliases: [bosses, eb, epicbosses]
|
@ -2,12 +2,13 @@ package com.songoda.epicbosses;
|
||||
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.SongodaPlugin;
|
||||
import com.songoda.core.commands.CommandManager;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.hooks.WorldGuardHook;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.commands.BossCmd;
|
||||
import com.songoda.epicbosses.commands.*;
|
||||
import com.songoda.epicbosses.container.BossEntityContainer;
|
||||
import com.songoda.epicbosses.container.MinionEntityContainer;
|
||||
import com.songoda.epicbosses.file.DisplayFileHandler;
|
||||
@ -51,7 +52,6 @@ public class EpicBosses extends SongodaPlugin implements IReloadable {
|
||||
private BossMechanicManager bossMechanicManager;
|
||||
private BossLocationManager bossLocationManager;
|
||||
private BossListenerManager bossListenerManager;
|
||||
private BossCommandManager bossCommandManager;
|
||||
private BossEntityManager bossEntityManager;
|
||||
private BossTargetManager bossTargetManager;
|
||||
private BossPanelManager bossPanelManager;
|
||||
@ -65,6 +65,8 @@ public class EpicBosses extends SongodaPlugin implements IReloadable {
|
||||
private MinionMechanicManager minionMechanicManager;
|
||||
private MinionEntityContainer minionEntityContainer;
|
||||
|
||||
private CommandManager commandManager;
|
||||
|
||||
private DebugManager debugManager = new DebugManager();
|
||||
|
||||
private YmlFileHandler langFileHandler, editorFileHandler, displayFileHandler;
|
||||
@ -153,7 +155,33 @@ public class EpicBosses extends SongodaPlugin implements IReloadable {
|
||||
this.dropTableFileManager.reload();
|
||||
this.autoSpawnFileManager.reload();
|
||||
|
||||
this.bossCommandManager = new BossCommandManager(new BossCmd(), this);
|
||||
// Register commands
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.commandManager.addCommand(new CommandBoss())
|
||||
.addSubCommands(
|
||||
new CommandCreate(bossEntityContainer),
|
||||
new CommandDebug(debugManager),
|
||||
new CommandDropTable(bossPanelManager),
|
||||
new CommandEdit(bossPanelManager, bossEntityContainer),
|
||||
new CommandGiveEgg(bossesFileManager, bossEntityManager),
|
||||
new CommandInfo(bossesFileManager, bossEntityManager),
|
||||
new CommandItems(bossPanelManager),
|
||||
new CommandKillAll(bossEntityManager),
|
||||
new CommandList(bossPanelManager),
|
||||
new CommandMenu(bossPanelManager),
|
||||
new CommandNearby(this),
|
||||
new CommandNewSkill(skillsFileManager, bossSkillManager),
|
||||
new CommandNewAutoSpawn(autoSpawnFileManager),
|
||||
new CommandNewCommand(bossCommandFileManager),
|
||||
new CommandNewMessage(bossCommandFileManager, bossMessagesFileManager),
|
||||
new CommandNewDropTable(dropTableFileManager, bossDropTableManager),
|
||||
new CommandReload(this, bossEntityManager),
|
||||
new CommandShop(this),
|
||||
new CommandSkills(bossPanelManager),
|
||||
new CommandSpawn(bossesFileManager),
|
||||
new CommandTime(this)
|
||||
);
|
||||
|
||||
this.bossListenerManager = new BossListenerManager(this);
|
||||
|
||||
this.bossPanelManager.load();
|
||||
@ -167,7 +195,6 @@ public class EpicBosses extends SongodaPlugin implements IReloadable {
|
||||
|
||||
saveMessagesToFile();
|
||||
|
||||
this.bossCommandManager.load();
|
||||
this.bossListenerManager.load();
|
||||
|
||||
this.autoSpawnManager.startIntervalSystems();
|
||||
@ -295,10 +322,6 @@ public class EpicBosses extends SongodaPlugin implements IReloadable {
|
||||
return this.bossListenerManager;
|
||||
}
|
||||
|
||||
public BossCommandManager getBossCommandManager() {
|
||||
return this.bossCommandManager;
|
||||
}
|
||||
|
||||
public BossEntityManager getBossEntityManager() {
|
||||
return this.bossEntityManager;
|
||||
}
|
||||
@ -339,6 +362,10 @@ public class EpicBosses extends SongodaPlugin implements IReloadable {
|
||||
return this.minionEntityContainer;
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public DebugManager getDebugManager() {
|
||||
return this.debugManager;
|
||||
}
|
||||
|
@ -1,36 +0,0 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.epicbosses.utils.command.SubCommandService;
|
||||
import com.songoda.epicbosses.utils.command.attributes.Alias;
|
||||
import com.songoda.epicbosses.utils.command.attributes.Description;
|
||||
import com.songoda.epicbosses.utils.command.attributes.Name;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 18-Jul-18
|
||||
*/
|
||||
@Name("boss")
|
||||
@Alias({"bosses", "b", "bs", "eb", "epicbosses"})
|
||||
@Description("Used to handle all CustomBosses related commands.")
|
||||
|
||||
public class BossCmd extends SubCommandService<CommandSender> {
|
||||
|
||||
public BossCmd() {
|
||||
super(BossCmd.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (args.length == 0) {
|
||||
Bukkit.dispatchCommand(sender, "boss help");
|
||||
return;
|
||||
}
|
||||
|
||||
if (handleSubCommand(sender, args)) return;
|
||||
|
||||
Bukkit.dispatchCommand(sender, "boss help");
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBoss extends AbstractCommand {
|
||||
|
||||
EpicBosses instance;
|
||||
|
||||
public CommandBoss() {
|
||||
super(false, "Boss");
|
||||
instance = EpicBosses.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(TextUtils.formatText("&b&lEpicBosses &8» &7Version " + instance.getDescription().getVersion()
|
||||
+ " Created with <3 by &5&l&oSongoda"));
|
||||
|
||||
for (AbstractCommand command : instance.getCommandManager().getAllCommands()) {
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
sender.sendMessage(TextUtils.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
|
||||
}
|
||||
}
|
||||
sender.sendMessage("");
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender cs, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Displays this page.";
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.container.BossEntityContainer;
|
||||
import com.songoda.epicbosses.entity.BossEntity;
|
||||
@ -7,69 +8,91 @@ import com.songoda.epicbosses.utils.EntityFinder;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class BossCreateCmd extends SubCommand {
|
||||
public class CommandCreate extends AbstractCommand {
|
||||
|
||||
private BossEntityContainer bossEntityContainer;
|
||||
|
||||
public BossCreateCmd(BossEntityContainer bossEntityContainer) {
|
||||
super("create");
|
||||
|
||||
public CommandCreate(BossEntityContainer bossEntityContainer) {
|
||||
super(true, "create");
|
||||
this.bossEntityContainer = bossEntityContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.create.hasPermission(sender)) {
|
||||
Message.Boss_Create_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
case 1:
|
||||
List<EntityFinder> availableEntities = new ArrayList<>(Arrays.asList(EntityFinder.values()));
|
||||
String list = StringUtils.get().appendList(availableEntities);
|
||||
|
||||
Message.Boss_Create_NoEntitySpecified.msg(sender, list);
|
||||
return;
|
||||
case 3:
|
||||
String name = args[1];
|
||||
String entityTypeInput = args[2];
|
||||
return ReturnType.FAILURE;
|
||||
case 2:
|
||||
String name = args[0];
|
||||
String entityTypeInput = args[1];
|
||||
|
||||
if (this.bossEntityContainer.exists(name)) {
|
||||
Message.Boss_Create_NameAlreadyExists.msg(sender, name);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
EntityFinder entityFinder = EntityFinder.get(entityTypeInput);
|
||||
|
||||
if (entityFinder == null) {
|
||||
Message.Boss_Create_EntityTypeNotFound.msg(sender, entityTypeInput);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
BossEntity bossEntity = BossAPI.createBaseBossEntity(name, entityTypeInput);
|
||||
|
||||
if (bossEntity == null) {
|
||||
Message.Boss_Create_SomethingWentWrong.msg(sender);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
Message.Boss_Create_SuccessfullyCreated.msg(sender, name, entityFinder.getFancyName());
|
||||
return;
|
||||
return ReturnType.SUCCESS;
|
||||
default:
|
||||
Message.Boss_Create_InvalidArgs.msg(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return Collections.singletonList("name");
|
||||
} else if (args.length == 2) {
|
||||
return Arrays.stream(EntityType.values()).map(Enum::name).collect(Collectors.toList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.create";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss create <[>name> <entity>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Start the creation of a boss.";
|
||||
}
|
||||
}
|
@ -1,39 +1,30 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.managers.DebugManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 09-Oct-18
|
||||
*/
|
||||
public class BossDebugCmd extends SubCommand {
|
||||
public class CommandDebug extends AbstractCommand {
|
||||
|
||||
private DebugManager debugManager;
|
||||
|
||||
public BossDebugCmd(DebugManager debugManager) {
|
||||
super("debug");
|
||||
|
||||
public CommandDebug(DebugManager debugManager) {
|
||||
super(true, "debug");
|
||||
this.debugManager = debugManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.debug.hasPermission(sender)) {
|
||||
Message.Boss_Debug_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
Message.General_MustBePlayer.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player player = (Player) sender;
|
||||
String toggled;
|
||||
|
||||
@ -46,5 +37,26 @@ public class BossDebugCmd extends SubCommand {
|
||||
}
|
||||
|
||||
Message.Boss_Debug_Toggled.msg(player, toggled);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Reloads EpicBosses and its configurations.";
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 04-Oct-18
|
||||
*/
|
||||
public class CommandDropTable extends AbstractCommand {
|
||||
|
||||
private BossPanelManager bossPanelManager;
|
||||
|
||||
public CommandDropTable(BossPanelManager bossPanelManager) {
|
||||
super(true, "droptable");
|
||||
this.bossPanelManager = bossPanelManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
this.bossPanelManager.getDropTables().openFor((Player) sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss droptable";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Shows the current drop table";
|
||||
}
|
||||
}
|
@ -1,56 +1,47 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.container.BossEntityContainer;
|
||||
import com.songoda.epicbosses.entity.BossEntity;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class BossEditCmd extends SubCommand {
|
||||
public class CommandEdit extends AbstractCommand {
|
||||
|
||||
private BossEntityContainer bossEntityContainer;
|
||||
private BossPanelManager bossPanelManager;
|
||||
|
||||
public BossEditCmd(BossPanelManager bossPanelManager, BossEntityContainer bossEntityContainer) {
|
||||
super("edit");
|
||||
|
||||
public CommandEdit(BossPanelManager bossPanelManager, BossEntityContainer bossEntityContainer) {
|
||||
super(true, "edit");
|
||||
this.bossPanelManager = bossPanelManager;
|
||||
this.bossEntityContainer = bossEntityContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.admin.hasPermission(sender)) {
|
||||
Message.Boss_Edit_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
Message.General_MustBePlayer.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
switch (args.length) {
|
||||
default:
|
||||
case 1:
|
||||
case 0:
|
||||
this.bossPanelManager.getBosses().openFor(player);
|
||||
break;
|
||||
case 2:
|
||||
String input = args[1];
|
||||
case 1:
|
||||
String input = args[0];
|
||||
|
||||
if (!this.bossEntityContainer.exists(input)) {
|
||||
Message.Boss_Edit_DoesntExist.msg(sender);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
BossEntity bossEntity = this.bossEntityContainer.getData().get(input);
|
||||
@ -58,5 +49,29 @@ public class BossEditCmd extends SubCommand {
|
||||
this.bossPanelManager.getMainBossEditMenu().openFor(player, bossEntity);
|
||||
break;
|
||||
}
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return Collections.singletonList("name");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.edit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss edit <name>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Edit a specified boss.";
|
||||
}
|
||||
}
|
@ -1,80 +1,81 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.entity.BossEntity;
|
||||
import com.songoda.epicbosses.managers.BossEntityManager;
|
||||
import com.songoda.epicbosses.managers.files.BossesFileManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.NumberUtils;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 14-Nov-18
|
||||
*/
|
||||
public class BossGiveEggCmd extends SubCommand {
|
||||
public class CommandGiveEgg extends AbstractCommand {
|
||||
|
||||
private BossEntityManager bossEntityManager;
|
||||
private BossesFileManager bossesFileManager;
|
||||
|
||||
public BossGiveEggCmd(BossesFileManager bossesFileManager, BossEntityManager bossEntityManager) {
|
||||
super("give", "giveegg");
|
||||
public CommandGiveEgg(BossesFileManager bossesFileManager, BossEntityManager bossEntityManager) {
|
||||
super(false, "give", "giveegg");
|
||||
|
||||
this.bossesFileManager = bossesFileManager;
|
||||
this.bossEntityManager = bossEntityManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.give.hasPermission(sender)) {
|
||||
Message.Boss_GiveEgg_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
|
||||
if (args.length < 3) {
|
||||
if (args.length < 2) {
|
||||
Message.Boss_GiveEgg_InvalidArgs.msg(sender);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
int amount = 1;
|
||||
|
||||
if (args.length == 4) {
|
||||
String amountInput = args[3];
|
||||
if (args.length == 3) {
|
||||
String amountInput = args[2];
|
||||
|
||||
if (NumberUtils.get().isInt(amountInput)) {
|
||||
amount = Integer.valueOf(amountInput);
|
||||
} else {
|
||||
Message.General_NotNumber.msg(sender);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
String playerInput = args[2];
|
||||
String playerInput = args[1];
|
||||
Player player = Bukkit.getPlayer(playerInput);
|
||||
|
||||
if (player == null) {
|
||||
Message.General_NotOnline.msg(sender, playerInput);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
String bossInput = args[1];
|
||||
String bossInput = args[0];
|
||||
BossEntity bossEntity = this.bossesFileManager.getBossEntity(bossInput);
|
||||
|
||||
if (bossEntity == null) {
|
||||
Message.Boss_GiveEgg_InvalidBoss.msg(sender);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
ItemStack spawnItem = this.bossEntityManager.getSpawnItem(bossEntity);
|
||||
|
||||
if (spawnItem == null) {
|
||||
Message.Boss_GiveEgg_NotSet.msg(sender);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
spawnItem.setAmount(amount);
|
||||
@ -82,5 +83,33 @@ public class BossGiveEggCmd extends SubCommand {
|
||||
|
||||
Message.Boss_GiveEgg_Given.msg(sender, player.getName(), amount, bossInput);
|
||||
Message.Boss_GiveEgg_Received.msg(player, amount, bossInput);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return new ArrayList<>(bossesFileManager.getBossEntitiesMap().keySet());
|
||||
} else if (args.length == 2) {
|
||||
return Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName).collect(Collectors.toList());
|
||||
} else if (args.length == 3) {
|
||||
return Arrays.asList("1", "2", "3", "4", "5");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.give";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss giveegg <name> <player> [amount]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Gives you the spawn egg of a boss.";
|
||||
}
|
||||
}
|
@ -1,48 +1,44 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.entity.BossEntity;
|
||||
import com.songoda.epicbosses.managers.BossEntityManager;
|
||||
import com.songoda.epicbosses.managers.files.BossesFileManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class BossInfoCmd extends SubCommand {
|
||||
public class CommandInfo extends AbstractCommand {
|
||||
|
||||
private BossEntityManager bossEntityManager;
|
||||
private BossesFileManager bossesFileManager;
|
||||
|
||||
public BossInfoCmd(BossesFileManager bossesFileManager, BossEntityManager bossEntityManager) {
|
||||
super("info");
|
||||
|
||||
public CommandInfo(BossesFileManager bossesFileManager, BossEntityManager bossEntityManager) {
|
||||
super(false, "info");
|
||||
this.bossesFileManager = bossesFileManager;
|
||||
this.bossEntityManager = bossEntityManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.admin.hasPermission(sender)) {
|
||||
Message.Boss_Info_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length != 2) {
|
||||
protected AbstractCommand.ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1) {
|
||||
Message.Boss_Info_InvalidArgs.msg(sender);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
String input = args[1];
|
||||
String input = args[0];
|
||||
BossEntity bossEntity = this.bossesFileManager.getBossEntity(input);
|
||||
|
||||
if (bossEntity == null) {
|
||||
Message.Boss_Info_CouldntFindBoss.msg(sender);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
boolean editing = bossEntity.isEditing();
|
||||
@ -50,5 +46,29 @@ public class BossInfoCmd extends SubCommand {
|
||||
boolean complete = bossEntity.isCompleteEnoughToSpawn();
|
||||
|
||||
Message.Boss_Info_Display.msg(sender, input, editing, active, complete);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return new ArrayList<>(bossesFileManager.getBossEntitiesMap().keySet());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss info <name>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Displays info on the specified boss.";
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 04-Oct-18
|
||||
*/
|
||||
public class CommandItems extends AbstractCommand {
|
||||
|
||||
private BossPanelManager bossPanelManager;
|
||||
|
||||
public CommandItems(BossPanelManager bossPanelManager) {
|
||||
super(true, "item", "items");
|
||||
this.bossPanelManager = bossPanelManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCommand.ReturnType runCommand(CommandSender sender, String... args) {
|
||||
this.bossPanelManager.getCustomItems().openFor((Player) sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss items";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Shows all current items.";
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.managers.BossEntityManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class CommandKillAll extends AbstractCommand {
|
||||
|
||||
private BossEntityManager bossEntityManager;
|
||||
|
||||
public CommandKillAll(BossEntityManager bossEntityManager) {
|
||||
super(false, "killall");
|
||||
this.bossEntityManager = bossEntityManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCommand.ReturnType runCommand(CommandSender sender, String... args) {
|
||||
World world = null;
|
||||
|
||||
if (args.length == 1) {
|
||||
String worldArgs = args[0];
|
||||
|
||||
world = Bukkit.getWorld(worldArgs);
|
||||
|
||||
if (world == null) {
|
||||
Message.Boss_KillAll_WorldNotFound.msg(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
int amount = this.bossEntityManager.killAllHolders(world);
|
||||
|
||||
if (args.length == 1) Message.Boss_KillAll_KilledWorld.msg(sender, amount, world.getName());
|
||||
else Message.Boss_KillAll_KilledAll.msg(sender, amount);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss killall [world]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Removes all current bosses in the specified world.";
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class CommandList extends AbstractCommand {
|
||||
|
||||
private BossPanelManager bossPanelManager;
|
||||
|
||||
public CommandList(BossPanelManager bossPanelManager) {
|
||||
super(true, "list", "show");
|
||||
this.bossPanelManager = bossPanelManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCommand.ReturnType runCommand(CommandSender sender, String... args) {
|
||||
this.bossPanelManager.getBosses().openFor((Player) sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Shows all the list of current boss entities.";
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 10-Oct-18
|
||||
*/
|
||||
public class CommandMenu extends AbstractCommand {
|
||||
|
||||
private BossPanelManager bossPanelManager;
|
||||
|
||||
public CommandMenu(BossPanelManager bossPanelManager) {
|
||||
super(true, "menu");
|
||||
this.bossPanelManager = bossPanelManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractCommand.ReturnType runCommand(CommandSender sender, String... args) {
|
||||
this.bossPanelManager.getMainMenu().openFor((Player) sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "/boss menu";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Opens up the menu to edit all current created bosses.";
|
||||
}
|
||||
}
|
@ -1,13 +1,17 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.utils.*;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import com.songoda.epicbosses.utils.MapUtils;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.NumberUtils;
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -17,42 +21,31 @@ import java.util.Map;
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class BossNearbyCmd extends SubCommand {
|
||||
public class CommandNearby extends AbstractCommand {
|
||||
|
||||
private EpicBosses plugin;
|
||||
|
||||
public BossNearbyCmd(EpicBosses plugin) {
|
||||
super("nearby");
|
||||
|
||||
public CommandNearby(EpicBosses plugin) {
|
||||
super(true, "nearby");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.nearby.hasPermission(sender)) {
|
||||
Message.Boss_Nearby_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
Message.General_MustBePlayer.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
protected AbstractCommand.ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player player = (Player) sender;
|
||||
Location location = player.getLocation();
|
||||
double radius = this.plugin.getConfig().getDouble("Settings.defaultNearbyRadius", 250.0);
|
||||
double maxRadius = this.plugin.getConfig().getDouble("Limits.maxNearbyRadius", 500.0);
|
||||
String nearbyFormat = this.plugin.getConfig().getString("Settings.nearbyFormat", "{name} ({distance}m)");
|
||||
|
||||
if (args.length == 2) {
|
||||
Integer newNumber = NumberUtils.get().getInteger(args[1]);
|
||||
if (args.length == 1) {
|
||||
Integer newNumber = NumberUtils.get().getInteger(args[0]);
|
||||
|
||||
if (newNumber != null) radius = newNumber;
|
||||
|
||||
if (radius > maxRadius) {
|
||||
Message.Boss_Nearby_MaxRadius.msg(player, maxRadius);
|
||||
return;
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,15 +54,38 @@ public class BossNearbyCmd extends SubCommand {
|
||||
|
||||
if (sortedMap.isEmpty()) {
|
||||
Message.Boss_Nearby_NoneNearby.msg(player);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
List<String> input = new LinkedList<>();
|
||||
|
||||
sortedMap.forEach(((activeBossHolder, distance) -> {
|
||||
input.add(nearbyFormat.replace("{name}", activeBossHolder.getName()).replace("{distance}", NumberUtils.get().formatDouble(distance)));
|
||||
}));
|
||||
sortedMap.forEach(((activeBossHolder, distance) ->
|
||||
input.add(nearbyFormat.replace("{name}", activeBossHolder.getName()).replace("{distance}", NumberUtils.get().formatDouble(distance)))));
|
||||
|
||||
Message.Boss_Nearby_Near.msg(player, StringUtils.get().appendList(input));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return Arrays.asList("1", "2", "3", "4", "5");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.nearby";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss nearby [radius]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Displays all nearby bosses within the specified radius.";
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.autospawns.AutoSpawn;
|
||||
import com.songoda.epicbosses.managers.BossSkillManager;
|
||||
import com.songoda.epicbosses.managers.files.AutoSpawnFileManager;
|
||||
import com.songoda.epicbosses.managers.files.SkillsFileManager;
|
||||
import com.songoda.epicbosses.skills.SkillMode;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandNewAutoSpawn extends AbstractCommand {
|
||||
|
||||
private AutoSpawnFileManager autoSpawnFileManager;
|
||||
|
||||
public CommandNewAutoSpawn(AutoSpawnFileManager autoSpawnFileManager) {
|
||||
super(false, " ");
|
||||
this.autoSpawnFileManager = autoSpawnFileManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
String nameInput = args[0];
|
||||
|
||||
if (this.autoSpawnFileManager.getAutoSpawn(nameInput) != null) {
|
||||
Message.Boss_New_AlreadyExists.msg(sender, "AutoSpawn");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
AutoSpawn autoSpawn = BossAPI.createBaseAutoSpawn(nameInput);
|
||||
|
||||
if (autoSpawn == null) {
|
||||
Message.Boss_New_SomethingWentWrong.msg(sender, "AutoSpawn");
|
||||
} else {
|
||||
Message.Boss_New_AutoSpawn.msg(sender, nameInput);
|
||||
}
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return Collections.singletonList("name");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss new autospawn <name>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Create a new auto spawn section.";
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.managers.files.CommandsFileManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandNewCommand extends AbstractCommand {
|
||||
|
||||
private CommandsFileManager commandsFileManager;
|
||||
|
||||
public CommandNewCommand(CommandsFileManager commandsFileManager) {
|
||||
super(false, "new command");
|
||||
this.commandsFileManager = commandsFileManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 2)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
String nameInput = args[0];
|
||||
|
||||
if (this.commandsFileManager.getCommands(nameInput) != null) {
|
||||
Message.Boss_New_AlreadyExists.msg(sender, "Command");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
List<String> commands = appendList(args);
|
||||
|
||||
this.commandsFileManager.addNewCommand(nameInput, commands);
|
||||
this.commandsFileManager.save();
|
||||
|
||||
Message.Boss_New_Command.msg(sender, nameInput);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return Collections.singletonList("name");
|
||||
}
|
||||
return Collections.singletonList("command");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss new command <name> <commands...>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Create a new command section.";
|
||||
}
|
||||
|
||||
private List<String> appendList(String[] args) {
|
||||
String[] params = Arrays.copyOfRange(args, 2, args.length);
|
||||
|
||||
List<String> sections = new ArrayList<>();
|
||||
StringBuilder currentSection = new StringBuilder();
|
||||
|
||||
for (String param : params) {
|
||||
String[] split = param.split("\\|");
|
||||
if (split.length == 1) {
|
||||
currentSection.append(split[0]).append(" ");
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean firstAdded = false;
|
||||
for (String piece : split) {
|
||||
currentSection.append(piece).append(" ");
|
||||
|
||||
if (!firstAdded) {
|
||||
sections.add(currentSection.toString().trim());
|
||||
currentSection = new StringBuilder();
|
||||
firstAdded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentSection.toString().trim().isEmpty())
|
||||
sections.add(currentSection.toString().trim());
|
||||
|
||||
return sections;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.droptable.DropTable;
|
||||
import com.songoda.epicbosses.managers.BossDropTableManager;
|
||||
import com.songoda.epicbosses.managers.BossSkillManager;
|
||||
import com.songoda.epicbosses.managers.files.DropTableFileManager;
|
||||
import com.songoda.epicbosses.managers.files.SkillsFileManager;
|
||||
import com.songoda.epicbosses.skills.SkillMode;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandNewDropTable extends AbstractCommand {
|
||||
|
||||
private DropTableFileManager dropTableFileManager;
|
||||
private BossDropTableManager bossDropTableManager;
|
||||
|
||||
public CommandNewDropTable(DropTableFileManager dropTableFileManager, BossDropTableManager bossDropTableManager) {
|
||||
super(false, "new droptable");
|
||||
this.dropTableFileManager = dropTableFileManager;
|
||||
this.bossDropTableManager = bossDropTableManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 2)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
String nameInput = args[0];
|
||||
String typeInput = args[1];
|
||||
boolean validType = false;
|
||||
|
||||
if (this.dropTableFileManager.getDropTable(nameInput) != null) {
|
||||
Message.Boss_New_AlreadyExists.msg(sender, "DropTable");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
for (String s : this.bossDropTableManager.getValidDropTableTypes()) {
|
||||
if (s.equalsIgnoreCase(typeInput)) {
|
||||
validType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!validType) {
|
||||
Message.Boss_New_InvalidDropTableType.msg(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
DropTable dropTable = BossAPI.createBaseDropTable(nameInput, typeInput);
|
||||
|
||||
if (dropTable == null) {
|
||||
Message.Boss_New_SomethingWentWrong.msg(sender, "DropTable");
|
||||
} else {
|
||||
Message.Boss_New_DropTable.msg(sender, nameInput, typeInput);
|
||||
}
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return Collections.singletonList("name");
|
||||
} else if (args.length == 2) {
|
||||
return this.bossDropTableManager.getValidDropTableTypes();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss new droptable <name> <type>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Create a new drop table section.";
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.managers.files.CommandsFileManager;
|
||||
import com.songoda.epicbosses.managers.files.MessagesFileManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandNewMessage extends AbstractCommand {
|
||||
|
||||
private CommandsFileManager commandsFileManager;
|
||||
private MessagesFileManager messagesFileManager;
|
||||
|
||||
public CommandNewMessage(CommandsFileManager commandsFileManager, MessagesFileManager messagesFileManager) {
|
||||
super(false, "new message");
|
||||
this.commandsFileManager = commandsFileManager;
|
||||
this.messagesFileManager = messagesFileManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 2)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
String nameInput = args[0];
|
||||
|
||||
if (this.commandsFileManager.getCommands(nameInput) != null) {
|
||||
Message.Boss_New_AlreadyExists.msg(sender, "Message");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
List<String> messages = appendList(args);
|
||||
|
||||
this.messagesFileManager.addNewMessage(nameInput, messages);
|
||||
this.messagesFileManager.save();
|
||||
|
||||
Message.Boss_New_Message.msg(sender, nameInput);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return Collections.singletonList("name");
|
||||
}
|
||||
return Collections.singletonList("message");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss new message <name> <message...>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Create a new message section.";
|
||||
}
|
||||
|
||||
private List<String> appendList(String[] args) {
|
||||
String[] params = Arrays.copyOfRange(args, 2, args.length);
|
||||
|
||||
List<String> sections = new ArrayList<>();
|
||||
StringBuilder currentSection = new StringBuilder();
|
||||
|
||||
for (String param : params) {
|
||||
String[] split = param.split("\\|");
|
||||
if (split.length == 1) {
|
||||
currentSection.append(split[0]).append(" ");
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean firstAdded = false;
|
||||
for (String piece : split) {
|
||||
currentSection.append(piece).append(" ");
|
||||
|
||||
if (!firstAdded) {
|
||||
sections.add(currentSection.toString().trim());
|
||||
currentSection = new StringBuilder();
|
||||
firstAdded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentSection.toString().trim().isEmpty())
|
||||
sections.add(currentSection.toString().trim());
|
||||
|
||||
return sections;
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.managers.BossSkillManager;
|
||||
import com.songoda.epicbosses.managers.files.SkillsFileManager;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.SkillMode;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandNewSkill extends AbstractCommand {
|
||||
|
||||
private SkillsFileManager skillsFileManager;
|
||||
private BossSkillManager bossSkillManager;
|
||||
|
||||
public CommandNewSkill(SkillsFileManager skillsFileManager, BossSkillManager bossSkillManager) {
|
||||
super(false, "new skill");
|
||||
this.skillsFileManager = skillsFileManager;
|
||||
this.bossSkillManager = bossSkillManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 3)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
String nameInput = args[0];
|
||||
String typeInput = args[1];
|
||||
String modeInput = args[2];
|
||||
boolean validType = false, validMode = false;
|
||||
List<SkillMode> skillModes = SkillMode.getSkillModes();
|
||||
|
||||
if (this.skillsFileManager.getSkill(nameInput) != null) {
|
||||
Message.Boss_New_AlreadyExists.msg(sender, "Skill");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
for (String s : this.bossSkillManager.getValidSkillTypes()) {
|
||||
if (s.equalsIgnoreCase(typeInput)) {
|
||||
validType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (SkillMode skillMode : skillModes) {
|
||||
if (skillMode.name().equalsIgnoreCase(modeInput)) {
|
||||
validMode = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!validType) {
|
||||
Message.Boss_New_InvalidSkillType.msg(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (!validMode) {
|
||||
Message.Boss_New_InvalidSkillMode.msg(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
Skill skill = BossAPI.createBaseSkill(nameInput, typeInput, modeInput);
|
||||
|
||||
if (skill == null) {
|
||||
Message.Boss_New_SomethingWentWrong.msg(sender, "Skill");
|
||||
} else {
|
||||
Message.Boss_New_Skill.msg(sender, nameInput, typeInput);
|
||||
}
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return Collections.singletonList("name");
|
||||
} else if (args.length == 2) {
|
||||
return this.bossSkillManager.getValidSkillTypes();
|
||||
} else if (args.length == 3) {
|
||||
return SkillMode.getSkillModes().stream().map(SkillMode::name).collect(Collectors.toList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss new skill <name> <type> <mods>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Create a new skill section.";
|
||||
}
|
||||
}
|
@ -1,41 +1,57 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.managers.BossEntityManager;
|
||||
import com.songoda.epicbosses.utils.IReloadable;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class BossReloadCmd extends SubCommand {
|
||||
public class CommandReload extends AbstractCommand {
|
||||
|
||||
private BossEntityManager bossEntityManager;
|
||||
private IReloadable masterReloadable;
|
||||
|
||||
public BossReloadCmd(IReloadable reloadable, BossEntityManager bossEntityManager) {
|
||||
super("reload");
|
||||
|
||||
public CommandReload(IReloadable reloadable, BossEntityManager bossEntityManager) {
|
||||
super(false, "reload");
|
||||
this.masterReloadable = reloadable;
|
||||
this.bossEntityManager = bossEntityManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.reload.hasPermission(sender)) {
|
||||
Message.Boss_Reload_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
long currentMs = System.currentTimeMillis();
|
||||
|
||||
this.masterReloadable.reload();
|
||||
this.bossEntityManager.killAllHolders((World) null);
|
||||
Message.Boss_Reload_Successful.msg(sender, (System.currentTimeMillis() - currentMs));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Reloads EpicBosses and its configurations.";
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 10-Oct-18
|
||||
*/
|
||||
public class CommandShop extends AbstractCommand {
|
||||
|
||||
private EpicBosses plugin;
|
||||
|
||||
public CommandShop(EpicBosses plugin) {
|
||||
super(true, "shop", "buy", "store");
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (!this.plugin.getConfig().getBoolean("Toggles.bossShop", true)) {
|
||||
Message.Boss_Shop_Disabled.msg(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
plugin.getBossPanelManager().getShopPanel().openFor((Player) sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.shop";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss shop";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Opens the shop for a player to purchase boss eggs themselves.";
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 04-Oct-18
|
||||
*/
|
||||
public class CommandSkills extends AbstractCommand {
|
||||
|
||||
private BossPanelManager bossPanelManager;
|
||||
|
||||
public CommandSkills(BossPanelManager bossPanelManager) {
|
||||
super(true, "skills", "skill");
|
||||
this.bossPanelManager = bossPanelManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
this.bossPanelManager.getCustomSkills().openFor((Player) sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss skills";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Shows all current configured skills.";
|
||||
}
|
||||
}
|
@ -1,72 +1,94 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.entity.BossEntity;
|
||||
import com.songoda.epicbosses.managers.files.BossesFileManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class BossSpawnCmd extends SubCommand {
|
||||
public class CommandSpawn extends AbstractCommand {
|
||||
|
||||
private BossesFileManager bossesFileManager;
|
||||
|
||||
public BossSpawnCmd(BossesFileManager bossesFileManager) {
|
||||
super("spawn");
|
||||
public CommandSpawn(BossesFileManager bossesFileManager) {
|
||||
super(false, "spawn");
|
||||
|
||||
this.bossesFileManager = bossesFileManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.admin.hasPermission(sender)) {
|
||||
Message.Boss_Spawn_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
Message.Boss_Spawn_InvalidArgs.msg(sender);
|
||||
return;
|
||||
}
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length == 0)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Location spawnLocation;
|
||||
|
||||
if (args.length == 3) {
|
||||
Location input = StringUtils.get().fromStringToLocation(args[2]);
|
||||
if (args.length == 2) {
|
||||
Location input = StringUtils.get().fromStringToLocation(args[1]);
|
||||
|
||||
if (input == null) {
|
||||
Message.Boss_Spawn_InvalidLocation.msg(sender);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
spawnLocation = input;
|
||||
} else {
|
||||
if (!(sender instanceof Player)) {
|
||||
Message.Boss_Spawn_MustBePlayer.msg(sender);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
spawnLocation = ((Player) sender).getLocation();
|
||||
}
|
||||
|
||||
String bossInput = args[1];
|
||||
String bossInput = args[0];
|
||||
BossEntity bossEntity = this.bossesFileManager.getBossEntity(bossInput);
|
||||
|
||||
if (bossEntity == null) {
|
||||
Message.Boss_Spawn_InvalidBoss.msg(sender);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
BossAPI.spawnNewBoss(bossEntity, spawnLocation, null, null, false);
|
||||
Message.Boss_Spawn_Spawned.msg(sender, bossInput, StringUtils.get().translateLocation(spawnLocation));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return new ArrayList<>(bossesFileManager.getBossEntitiesMap().keySet());
|
||||
} else if (args.length == 2) {
|
||||
return Collections.singletonList("world,0,100,0");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss spawn <name> [location]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Spawns a specific boss at the defined location.";
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
package com.songoda.epicbosses.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.holder.ActiveAutoSpawnHolder;
|
||||
import com.songoda.epicbosses.holder.autospawn.ActiveIntervalAutoSpawnHolder;
|
||||
import com.songoda.epicbosses.managers.AutoSpawnManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.NumberUtils;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import com.songoda.epicbosses.utils.time.TimeUnit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -19,35 +19,27 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class BossTimeCmd extends SubCommand {
|
||||
public class CommandTime extends AbstractCommand {
|
||||
|
||||
private AutoSpawnManager autoSpawnManager;
|
||||
|
||||
public BossTimeCmd(EpicBosses plugin) {
|
||||
super("time");
|
||||
|
||||
public CommandTime(EpicBosses plugin) {
|
||||
super(false, "time");
|
||||
this.autoSpawnManager = plugin.getAutoSpawnManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.time.hasPermission(sender)) {
|
||||
Message.Boss_Time_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
if (args.length != 2) {
|
||||
Message.Boss_Time_InvalidArgs.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
String section = args[1];
|
||||
String section = args[0];
|
||||
boolean exists = this.autoSpawnManager.exists(section);
|
||||
List<String> currentActive = this.autoSpawnManager.getIntervalAutoSpawns();
|
||||
|
||||
if (!exists) {
|
||||
Message.Boss_Time_DoesntExist.msg(sender, StringUtils.get().appendList(currentActive));
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
ActiveAutoSpawnHolder activeAutoSpawnHolder = this.autoSpawnManager.getActiveAutoSpawnHolder(section);
|
||||
@ -56,7 +48,7 @@ public class BossTimeCmd extends SubCommand {
|
||||
|
||||
if (remainingMs == 0 && activeIntervalAutoSpawnHolder.isSpawnAfterLastBossIsKilled()) {
|
||||
Message.Boss_Time_CurrentlyActive.msg(sender);
|
||||
return;
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
String s = Message.General_TimeLayout.toString();
|
||||
@ -72,5 +64,29 @@ public class BossTimeCmd extends SubCommand {
|
||||
s = s.replace("{sec}", NumberUtils.get().formatDouble(remainingSecs));
|
||||
|
||||
Message.Boss_Time_GetRemainingTime.msg(sender, s, section);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender commandSender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return new ArrayList<>(this.autoSpawnManager.getAutoSpawns().keySet());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "boss.time";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/boss time <section>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Shows the time left till next auto spawn.";
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 04-Oct-18
|
||||
*/
|
||||
public class BossDropTableCmd extends SubCommand {
|
||||
|
||||
private BossPanelManager bossPanelManager;
|
||||
|
||||
public BossDropTableCmd(BossPanelManager bossPanelManager) {
|
||||
super("droptable");
|
||||
|
||||
this.bossPanelManager = bossPanelManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.admin.hasPermission(sender)) {
|
||||
Message.Boss_DropTable_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
Message.General_MustBePlayer.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
this.bossPanelManager.getDropTables().openFor(player);
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.NumberUtils;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class BossHelpCmd extends SubCommand {
|
||||
|
||||
public BossHelpCmd() {
|
||||
super("help");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (Permission.admin.hasPermission(sender) || Permission.help.hasPermission(sender)) {
|
||||
int pageNumber = 0;
|
||||
|
||||
if (args.length > 1) {
|
||||
Integer newNumber = NumberUtils.get().getInteger(args[1]);
|
||||
|
||||
if (newNumber != null) pageNumber = newNumber;
|
||||
}
|
||||
|
||||
switch (pageNumber) {
|
||||
default:
|
||||
case 1:
|
||||
Message.Boss_Help_Page1.msg(sender);
|
||||
break;
|
||||
case 2:
|
||||
Message.Boss_Help_Page2.msg(sender);
|
||||
break;
|
||||
case 3:
|
||||
Message.Boss_Help_Page3.msg(sender);
|
||||
break;
|
||||
case 4:
|
||||
Message.Boss_Help_Page4.msg(sender);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(StringUtils.get().translateColor("EpicBosses &7Version " + EpicBosses.getInstance().getDescription().getVersion() + " Created with <3 by &5&l&oSongoda"));
|
||||
Message.Boss_Help_NoPermission.msg(sender);
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 04-Oct-18
|
||||
*/
|
||||
public class BossItemsCmd extends SubCommand {
|
||||
|
||||
private BossPanelManager bossPanelManager;
|
||||
|
||||
public BossItemsCmd(BossPanelManager bossPanelManager) {
|
||||
super("item", "items");
|
||||
|
||||
this.bossPanelManager = bossPanelManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.admin.hasPermission(sender)) {
|
||||
Message.Boss_Items_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
Message.General_MustBePlayer.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
this.bossPanelManager.getCustomItems().openFor(player);
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
|
||||
import com.songoda.epicbosses.managers.BossEntityManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class BossKillAllCmd extends SubCommand {
|
||||
|
||||
private BossEntityManager bossEntityManager;
|
||||
|
||||
public BossKillAllCmd(BossEntityManager bossEntityManager) {
|
||||
super("killall");
|
||||
|
||||
this.bossEntityManager = bossEntityManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.admin.hasPermission(sender)) {
|
||||
Message.Boss_KillAll_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
World world = null;
|
||||
|
||||
if (args.length == 2) {
|
||||
String worldArgs = args[1];
|
||||
|
||||
world = Bukkit.getWorld(worldArgs);
|
||||
|
||||
if (world == null) {
|
||||
Message.Boss_KillAll_WorldNotFound.msg(sender);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int amount = this.bossEntityManager.killAllHolders(world);
|
||||
|
||||
if (args.length == 2) Message.Boss_KillAll_KilledWorld.msg(sender, amount, world.getName());
|
||||
else Message.Boss_KillAll_KilledAll.msg(sender, amount);
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class BossListCmd extends SubCommand {
|
||||
|
||||
private BossPanelManager bossPanelManager;
|
||||
|
||||
public BossListCmd(BossPanelManager bossPanelManager) {
|
||||
super("list", "show");
|
||||
|
||||
this.bossPanelManager = bossPanelManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.admin.hasPermission(sender)) {
|
||||
Message.Boss_List_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
Message.General_MustBePlayer.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
this.bossPanelManager.getBosses().openFor(player);
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 10-Oct-18
|
||||
*/
|
||||
public class BossMenuCmd extends SubCommand {
|
||||
|
||||
private BossPanelManager bossPanelManager;
|
||||
|
||||
public BossMenuCmd(BossPanelManager bossPanelManager) {
|
||||
super("menu");
|
||||
|
||||
this.bossPanelManager = bossPanelManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.admin.hasPermission(sender)) {
|
||||
Message.Boss_Menu_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
Message.General_MustBePlayer.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
this.bossPanelManager.getMainMenu().openFor(player);
|
||||
}
|
||||
}
|
@ -1,243 +0,0 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.autospawns.AutoSpawn;
|
||||
import com.songoda.epicbosses.droptable.DropTable;
|
||||
import com.songoda.epicbosses.managers.BossDropTableManager;
|
||||
import com.songoda.epicbosses.managers.BossSkillManager;
|
||||
import com.songoda.epicbosses.managers.files.*;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.SkillMode;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 19-Nov-18
|
||||
* <p>
|
||||
* boss new droptable [name] [type]
|
||||
* boss new skill [name] [type] [mode]
|
||||
* boss new command [name] [commands]
|
||||
* boss new message [name] [message]
|
||||
* boss new autospawn [name]
|
||||
*/
|
||||
public class BossNewCmd extends SubCommand {
|
||||
|
||||
private AutoSpawnFileManager autoSpawnFileManager;
|
||||
private DropTableFileManager dropTableFileManager;
|
||||
private BossDropTableManager bossDropTableManager;
|
||||
private MessagesFileManager messagesFileManager;
|
||||
private CommandsFileManager commandsFileManager;
|
||||
private SkillsFileManager skillsFileManager;
|
||||
private BossSkillManager bossSkillManager;
|
||||
|
||||
public BossNewCmd(EpicBosses plugin) {
|
||||
super("new");
|
||||
|
||||
this.bossSkillManager = plugin.getBossSkillManager();
|
||||
this.skillsFileManager = plugin.getSkillsFileManager();
|
||||
this.dropTableFileManager = plugin.getDropTableFileManager();
|
||||
this.bossDropTableManager = plugin.getBossDropTableManager();
|
||||
this.messagesFileManager = plugin.getBossMessagesFileManager();
|
||||
this.commandsFileManager = plugin.getBossCommandFileManager();
|
||||
this.autoSpawnFileManager = plugin.getAutoSpawnFileManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.admin.hasPermission(sender)) {
|
||||
Message.Boss_New_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------
|
||||
// A U T O S P A W N
|
||||
//--------------------
|
||||
if (args.length == 3 && args[1].equalsIgnoreCase("autospawn")) {
|
||||
String nameInput = args[2];
|
||||
|
||||
if (this.autoSpawnFileManager.getAutoSpawn(nameInput) != null) {
|
||||
Message.Boss_New_AlreadyExists.msg(sender, "AutoSpawn");
|
||||
return;
|
||||
}
|
||||
|
||||
AutoSpawn autoSpawn = BossAPI.createBaseAutoSpawn(nameInput);
|
||||
|
||||
if (autoSpawn == null) {
|
||||
Message.Boss_New_SomethingWentWrong.msg(sender, "AutoSpawn");
|
||||
} else {
|
||||
Message.Boss_New_AutoSpawn.msg(sender, nameInput);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//-------------------
|
||||
// C O M M A N D
|
||||
//-------------------
|
||||
if (args.length >= 4 && args[1].equalsIgnoreCase("command")) {
|
||||
String nameInput = args[2];
|
||||
|
||||
if (this.commandsFileManager.getCommands(nameInput) != null) {
|
||||
Message.Boss_New_AlreadyExists.msg(sender, "Command");
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> commands = appendList(args);
|
||||
|
||||
this.commandsFileManager.addNewCommand(nameInput, commands);
|
||||
this.commandsFileManager.save();
|
||||
|
||||
Message.Boss_New_Command.msg(sender, nameInput);
|
||||
return;
|
||||
}
|
||||
|
||||
//-------------------
|
||||
// M E S S A G E
|
||||
//-------------------
|
||||
if (args.length >= 4 && args[1].equalsIgnoreCase("message")) {
|
||||
String nameInput = args[2];
|
||||
|
||||
if (this.commandsFileManager.getCommands(nameInput) != null) {
|
||||
Message.Boss_New_AlreadyExists.msg(sender, "Message");
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> messages = appendList(args);
|
||||
|
||||
this.messagesFileManager.addNewMessage(nameInput, messages);
|
||||
this.messagesFileManager.save();
|
||||
|
||||
Message.Boss_New_Message.msg(sender, nameInput);
|
||||
return;
|
||||
}
|
||||
|
||||
//----------------------
|
||||
// D R O P T A B L E
|
||||
//----------------------
|
||||
if (args.length == 4 && args[1].equalsIgnoreCase("droptable")) {
|
||||
String nameInput = args[2];
|
||||
String typeInput = args[3];
|
||||
boolean validType = false;
|
||||
|
||||
if (this.dropTableFileManager.getDropTable(nameInput) != null) {
|
||||
Message.Boss_New_AlreadyExists.msg(sender, "DropTable");
|
||||
return;
|
||||
}
|
||||
|
||||
for (String s : this.bossDropTableManager.getValidDropTableTypes()) {
|
||||
if (s.equalsIgnoreCase(typeInput)) {
|
||||
validType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!validType) {
|
||||
Message.Boss_New_InvalidDropTableType.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
DropTable dropTable = BossAPI.createBaseDropTable(nameInput, typeInput);
|
||||
|
||||
if (dropTable == null) {
|
||||
Message.Boss_New_SomethingWentWrong.msg(sender, "DropTable");
|
||||
} else {
|
||||
Message.Boss_New_DropTable.msg(sender, nameInput, typeInput);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//-------------------
|
||||
// S K I L L
|
||||
//-------------------
|
||||
if (args.length == 5 && args[1].equalsIgnoreCase("skill")) {
|
||||
String nameInput = args[2];
|
||||
String typeInput = args[3];
|
||||
String modeInput = args[4];
|
||||
boolean validType = false, validMode = false;
|
||||
List<SkillMode> skillModes = SkillMode.getSkillModes();
|
||||
|
||||
if (this.skillsFileManager.getSkill(nameInput) != null) {
|
||||
Message.Boss_New_AlreadyExists.msg(sender, "Skill");
|
||||
return;
|
||||
}
|
||||
|
||||
for (String s : this.bossSkillManager.getValidSkillTypes()) {
|
||||
if (s.equalsIgnoreCase(typeInput)) {
|
||||
validType = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (SkillMode skillMode : skillModes) {
|
||||
if (skillMode.name().equalsIgnoreCase(modeInput)) {
|
||||
validMode = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!validType) {
|
||||
Message.Boss_New_InvalidSkillType.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!validMode) {
|
||||
Message.Boss_New_InvalidSkillMode.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Skill skill = BossAPI.createBaseSkill(nameInput, typeInput, modeInput);
|
||||
|
||||
if (skill == null) {
|
||||
Message.Boss_New_SomethingWentWrong.msg(sender, "Skill");
|
||||
} else {
|
||||
Message.Boss_New_Skill.msg(sender, nameInput, typeInput);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Message.Boss_New_InvalidArgs.msg(sender);
|
||||
}
|
||||
|
||||
private List<String> appendList(String[] args) {
|
||||
String[] params = Arrays.copyOfRange(args, 3, args.length);
|
||||
|
||||
List<String> sections = new ArrayList<>();
|
||||
StringBuilder currentSection = new StringBuilder();
|
||||
|
||||
for (String param : params) {
|
||||
String[] split = param.split("\\|");
|
||||
if (split.length == 1) {
|
||||
currentSection.append(split[0]).append(" ");
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean firstAdded = false;
|
||||
for (String piece : split) {
|
||||
currentSection.append(piece).append(" ");
|
||||
|
||||
if (!firstAdded) {
|
||||
sections.add(currentSection.toString().trim());
|
||||
currentSection = new StringBuilder();
|
||||
firstAdded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentSection.toString().trim().isEmpty())
|
||||
sections.add(currentSection.toString().trim());
|
||||
|
||||
return sections;
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 10-Oct-18
|
||||
*/
|
||||
public class BossShopCmd extends SubCommand {
|
||||
|
||||
private EpicBosses plugin;
|
||||
|
||||
public BossShopCmd(EpicBosses plugin) {
|
||||
super("shop", "buy", "store");
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.shop.hasPermission(sender)) {
|
||||
Message.Boss_Shop_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
Message.General_MustBePlayer.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.plugin.getConfig().getBoolean("Toggles.bossShop", true)) {
|
||||
Message.Boss_Shop_Disabled.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
plugin.getBossPanelManager().getShopPanel().openFor(player);
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.songoda.epicbosses.commands.boss;
|
||||
|
||||
import com.songoda.epicbosses.managers.BossPanelManager;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.Permission;
|
||||
import com.songoda.epicbosses.utils.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 04-Oct-18
|
||||
*/
|
||||
public class BossSkillsCmd extends SubCommand {
|
||||
|
||||
private BossPanelManager bossPanelManager;
|
||||
|
||||
public BossSkillsCmd(BossPanelManager bossPanelManager) {
|
||||
super("skills", "skill");
|
||||
|
||||
this.bossPanelManager = bossPanelManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Permission.admin.hasPermission(sender)) {
|
||||
Message.Boss_Skills_NoPermission.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
Message.General_MustBePlayer.msg(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
this.bossPanelManager.getCustomSkills().openFor(player);
|
||||
}
|
||||
}
|
@ -11,10 +11,7 @@ import com.songoda.epicbosses.skills.interfaces.ICustomSettingAction;
|
||||
import com.songoda.epicbosses.utils.panel.base.ClickAction;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
@ -67,6 +64,9 @@ public class AutoSpawnManager {
|
||||
|
||||
return intervalAutoSpawns;
|
||||
}
|
||||
public Map<String, ActiveAutoSpawnHolder> getAutoSpawns() {
|
||||
return Collections.unmodifiableMap(this.activeAutoSpawnHolders);
|
||||
}
|
||||
|
||||
public boolean exists(String name) {
|
||||
List<String> keyList = new ArrayList<>(this.activeAutoSpawnHolders.keySet());
|
||||
|
@ -1,53 +0,0 @@
|
||||
package com.songoda.epicbosses.managers;
|
||||
|
||||
import com.songoda.epicbosses.EpicBosses;
|
||||
import com.songoda.epicbosses.commands.boss.*;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.ILoadable;
|
||||
import com.songoda.epicbosses.utils.command.SubCommandService;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 02-Oct-18
|
||||
*/
|
||||
public class BossCommandManager implements ILoadable {
|
||||
|
||||
private SubCommandService<?> commandService;
|
||||
private boolean hasBeenLoaded = false;
|
||||
private EpicBosses epicBosses;
|
||||
|
||||
public BossCommandManager(SubCommandService<?> commandService, EpicBosses epicBosses) {
|
||||
this.commandService = commandService;
|
||||
this.epicBosses = epicBosses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if (this.hasBeenLoaded) {
|
||||
Debug.FAILED_TO_LOAD_BOSSCOMMANDMANAGER.debug();
|
||||
return;
|
||||
}
|
||||
|
||||
this.commandService.registerSubCommand(new BossCreateCmd(this.epicBosses.getBossEntityContainer()));
|
||||
this.commandService.registerSubCommand(new BossDebugCmd(this.epicBosses.getDebugManager()));
|
||||
this.commandService.registerSubCommand(new BossDropTableCmd(this.epicBosses.getBossPanelManager()));
|
||||
this.commandService.registerSubCommand(new BossEditCmd(this.epicBosses.getBossPanelManager(), this.epicBosses.getBossEntityContainer()));
|
||||
this.commandService.registerSubCommand(new BossGiveEggCmd(this.epicBosses.getBossesFileManager(), this.epicBosses.getBossEntityManager()));
|
||||
this.commandService.registerSubCommand(new BossHelpCmd());
|
||||
this.commandService.registerSubCommand(new BossInfoCmd(this.epicBosses.getBossesFileManager(), this.epicBosses.getBossEntityManager()));
|
||||
this.commandService.registerSubCommand(new BossItemsCmd(this.epicBosses.getBossPanelManager()));
|
||||
this.commandService.registerSubCommand(new BossKillAllCmd(this.epicBosses.getBossEntityManager()));
|
||||
this.commandService.registerSubCommand(new BossListCmd(this.epicBosses.getBossPanelManager()));
|
||||
this.commandService.registerSubCommand(new BossMenuCmd(this.epicBosses.getBossPanelManager()));
|
||||
this.commandService.registerSubCommand(new BossNearbyCmd(this.epicBosses));
|
||||
this.commandService.registerSubCommand(new BossNewCmd(this.epicBosses));
|
||||
this.commandService.registerSubCommand(new BossReloadCmd(this.epicBosses, this.epicBosses.getBossEntityManager()));
|
||||
this.commandService.registerSubCommand(new BossShopCmd(this.epicBosses));
|
||||
this.commandService.registerSubCommand(new BossSkillsCmd(this.epicBosses.getBossPanelManager()));
|
||||
this.commandService.registerSubCommand(new BossSpawnCmd(this.epicBosses.getBossesFileManager()));
|
||||
this.commandService.registerSubCommand(new BossTimeCmd(this.epicBosses));
|
||||
|
||||
this.hasBeenLoaded = true;
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
public enum Message {
|
||||
|
||||
General_LocationFormat("{world}, {x}, {y}, {z}"),
|
||||
General_MustBePlayer("&c&l(!) &cYou must be a player to use this command."),
|
||||
General_NotOnline("&c&l(!) &cThe specified player, {0}, is not online or a valid player."),
|
||||
General_CannotSpawn("&c&l(!) &cYou cannot spawn a boss at this location! &c&l(!)"),
|
||||
General_NotNumber("&c&l(!) &cThe number you have provided is not a proper number."),
|
||||
@ -36,14 +35,11 @@ public enum Message {
|
||||
Boss_Create_InvalidArgs("&c&l(!) &cYou must use &n/boss create [name] [entity] &c to create a boss."),
|
||||
Boss_Create_NameAlreadyExists("&c&l(!) &cA boss already exists with the name {0}."),
|
||||
Boss_Create_NoEntitySpecified("&c&l(!) &cNo entity type was specified. Make sure to add an entity type! Possible entity types are: \n&7{0}"),
|
||||
Boss_Create_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Create_SomethingWentWrong("&c&l(!) &cSomething went wrong in the API class while finalising the boss creation."),
|
||||
Boss_Create_SuccessfullyCreated("&b&lEpicBosses &8» &7A boss has successfully been created with the name &f{0}&7 and the entity type &f{1}&7."),
|
||||
|
||||
Boss_Debug_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Debug_Toggled("&b&lEpicBosses &8» &7You have toggled debug mode for &fEpicBosses &7to {0}."),
|
||||
|
||||
Boss_DropTable_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_DropTable_AddedNewReward("&b&lEpicBosses &8» &7You have added a new reward to the drop table &f{0}&7. Now opening the editing panel for the new reward."),
|
||||
Boss_DropTable_RewardChance("&b&lEpicBosses &8» &7You have {0} the chance for the reward section for &f{1}&7 to &f{2}%&7."),
|
||||
Boss_DropTable_RewardRemoved("&b&lEpicBosses &8» &7You have removed the reward section from the drop table."),
|
||||
@ -59,7 +55,6 @@ public enum Message {
|
||||
Boss_DropTable_GiveMaxCommands("&b&lEpicBosses &8» &7You have {0} the max commands for the &f{1}&7 damage section to &f{1}&7."),
|
||||
Boss_DropTable_GiveRequiredPercentage("&b&lEpicBosses &8» &7You have {0} the required percentage for the &f{1}&7 damage section to &f{1}&7."),
|
||||
|
||||
Boss_Edit_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Edit_ItemStackHolderNull("&c&l(!) &cThe itemstack name that is provided for the spawn item doesn't exist or wasn't found."),
|
||||
Boss_Edit_CannotSpawn("&c&l(!) &cYou cannot spawn this boss while editing is enabled. If you think this is a mistake please contact an administrator to disable the editing of the boss."),
|
||||
Boss_Edit_CannotBeModified("&c&l(!) &cYou cannot modify this aspect because you do not have editing mode enabled on this boss."),
|
||||
@ -69,62 +64,12 @@ public enum Message {
|
||||
Boss_Edit_Price("&b&lEpicBosses &8» &7Please input the new price of the &f{0}&7 Boss Entity. Please do not add commas and only use numbers. To cancel this input in to chat &f- &7."),
|
||||
Boss_Edit_PriceSet("&b&lEpicBosses &8» &7You have set the price of &f{0}&7 to &a$&f{1}&7."),
|
||||
|
||||
Boss_GiveEgg_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_GiveEgg_InvalidArgs("&c&l(!) &cYou must use &n/boss giveegg [name] [player] (amount)&c to give an egg."),
|
||||
Boss_GiveEgg_InvalidBoss("&c&l(!) &cThe specified boss is not a valid type."),
|
||||
Boss_GiveEgg_NotSet("&c&l(!) &cThe spawn item for the {0} boss has not been set yet."),
|
||||
Boss_GiveEgg_Given("&b&lEpicBosses &8» &7You have given {0} {1}x {2}'s boss spawn item."),
|
||||
Boss_GiveEgg_Received("&b&lEpicBosses &8» &7You have received {0}x {1} boss spawn item(s)."),
|
||||
|
||||
Boss_Help_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Help_Page1(
|
||||
"&8&m----*--------&3&l[ &b&lBoss Help &7(Page 1/4) &3&l]&8&m--------*----\n" +
|
||||
"&b/boss help (page) &8» &7Displays boss commands.\n" +
|
||||
"&b/boss create [name] [entity] &8» &7Start the creation of a boss.\n" +
|
||||
"&b/boss edit (name) &8» &7Edit the specified boss.\n" +
|
||||
"&b/boss info [name] &8» &7Shows information on the specified boss.\n" +
|
||||
"&b/boss nearby (radius) &8» &7Shows the nearby bosses.\n" +
|
||||
"&b/boss reload &8» &7Reloads the boss plugin.\n" +
|
||||
"&7\n" +
|
||||
"&7Use /boss help 2 to view the next page.\n" +
|
||||
"&8&m----*-----------------------------------*----"),
|
||||
Boss_Help_Page2(
|
||||
"&8&m----*--------&3&l[ &b&lBoss Help &7(Page 2/4) &3&l]&8&m--------*----\n" +
|
||||
"&b/boss spawn [name] (location) &8» &7Spawns a boss at your" +
|
||||
" location or the specified location.\n" +
|
||||
"&7&o(Separate location with commas, an example is: world,0,100,0)\n" +
|
||||
"&b/boss droptable &8» &7Shows all current drop tables.\n" +
|
||||
"&b/boss items &8» &7Shows all current custom items.\n" +
|
||||
"&b/boss skills &8» &7Shows all current set skills.\n" +
|
||||
"&b/boss killall (world) &8» &7Kills all bosses/minions.\n" +
|
||||
"&7\n" +
|
||||
"&7Use /boss help 3 to view the next page.\n" +
|
||||
"&8&m----*-----------------------------------*----"),
|
||||
Boss_Help_Page3(
|
||||
"&8&m----*--------&3&l[ &b&lBoss Help &7(Page 3/4) &3&l]&8&m--------*----\n" +
|
||||
"&b/boss time [section] &8» &7Shows the time left till next auto spawn.\n" +
|
||||
"&b/boss giveegg [name] [player] (amount) &8» &7Used to be given a " +
|
||||
"spawn item of the boss.\n" +
|
||||
"&b/boss list &8» &7Shows all the list of current boss entities.\n" +
|
||||
"&b/boss new skill [name] [type] [mode] &8» &7Create a new skill section.\n" +
|
||||
"&b/boss new droptable [name] [type] &8» &7Create a new drop table section.\n" +
|
||||
"&7\n" +
|
||||
"&7Use /boss help 4 to view the next page.\n" +
|
||||
"&8&m----*-----------------------------------*----"),
|
||||
Boss_Help_Page4(
|
||||
"&8&m----*--------&3&l[ &b&lBoss Help &7(Page 4/4) &3&l]&8&m--------*----\n" +
|
||||
"&b/boss new command [name] [commands] &8» &7Used to create a new command section.\n" +
|
||||
"&7&o(To add a new line use &7||&7&o in-between the messages.)\n" +
|
||||
"&b/boss new message [name] [messages] &8» &7Used to create a new message section.\n" +
|
||||
"&7&o(To add a new line use &7||&7&o in-between the messages.)\n" +
|
||||
"&7/boss new autospawn [name] &8» &7Used to create a new auto spawn section.\n" +
|
||||
"&b/boss debug &8» &7Used to toggle the debug aspect of the plugin.\n" +
|
||||
"&7\n" +
|
||||
"&7\n" +
|
||||
"&7Use /boss help [page] to view the next page.\n" +
|
||||
"&8&m----*-----------------------------------*----"),
|
||||
|
||||
Boss_Info_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Info_InvalidArgs("&c&l(!) &cYou must use &n/boss info [name]&c to view info on a boss."),
|
||||
Boss_Info_CouldntFindBoss("&c&l(!) &cThe specified boss was not able to be retrieved, please try again."),
|
||||
Boss_Info_Display(
|
||||
@ -133,7 +78,6 @@ public enum Message {
|
||||
"&bCurrently Active: &f{2}\n" +
|
||||
"&bComplete enough to spawn: &f{3}"),
|
||||
|
||||
Boss_Items_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Items_CannotBeRemoved("&c&l(!) &cThe selected item cannot be removed because it is still used in {0} different positions on the bosses."),
|
||||
Boss_Items_DefaultCannotBeRemoved("&c&l(!) &cThe selected item cannot be removed because it is the default item for something in one of the boss menu's."),
|
||||
Boss_Items_Removed("&b&lEpicBosses &8» &7The selected item has been removed from the EpicBosses custom items database."),
|
||||
@ -144,11 +88,6 @@ public enum Message {
|
||||
Boss_KillAll_WorldNotFound("&c&l(!) &cThe specified world was not found. If you'd like to kill every boss/minion just use &f/boss killall&c without any arguments."),
|
||||
Boss_KillAll_KilledAll("&b&lEpicBosses &8» &7You have killed the boss(es) and minion(s) that were currently active on the server."),
|
||||
Boss_KillAll_KilledWorld("&b&lEpicBosses &8» &7You have killed the boss(es) and minion(s) that were in the world {1}."),
|
||||
Boss_KillAll_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
|
||||
Boss_List_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
|
||||
Boss_Menu_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
|
||||
Boss_Messages_SetRadiusOnSpawn("&b&lEpicBosses &8» &7You have just {0} the radius for the onSpawn message to &f{1}&7."),
|
||||
Boss_Messages_SetRadiusOnDeath("&b&lEpicBosses &8» &7You have just {0} the radius for the onDeath message to &f{1}&7."),
|
||||
@ -156,13 +95,10 @@ public enum Message {
|
||||
Boss_Messages_SetTauntRadius("&b&lEpicBosses &8» &7You have just {0} the radius for the taunt message to &f{1}&7."),
|
||||
Boss_Messages_SetTauntDelay("&b&lEpicBosses &8» &7You have just {0} the delay for the taunt message to &f{1}&7."),
|
||||
|
||||
Boss_Nearby_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Nearby_MaxRadius("&c&l(!) &cYou cannot check for bosses any further then &f{0}&c away from your position."),
|
||||
Boss_Nearby_NoneNearby("&b&lEpicBosses &8» &7There is currently no nearby bosses."),
|
||||
Boss_Nearby_Near("&b&lEpicBosses &8» &7Nearby bosses: &f{0}."),
|
||||
|
||||
Boss_New_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_New_InvalidArgs("&c&l(!) &cInvalid arguments! You must use &n/boss new droptable [name] (type)&c or &n/boss new skill [name]&c!"),
|
||||
Boss_New_CreateArgumentsDropTable("&b&lEpicBosses &8» &7Create a new droptable with the command &f/boss new droptable [name] [type]&7."),
|
||||
Boss_New_CreateArgumentsSkill("&b&lEpicBosses &8» &7Create a new skill with the command &f/boss new skill [name] [type] [mode]&7."),
|
||||
Boss_New_CreateArgumentsMessage("&b&lEpicBosses &8» &7Create a new message with the command &f/boss new message [name] [message(s)]. \n&7&oUse &f|| &7&oto reference a new line."),
|
||||
@ -179,15 +115,12 @@ public enum Message {
|
||||
Boss_New_Message("&b&lEpicBosses &8» &7You have created a new message with the name &f{0}&7."),
|
||||
Boss_New_SomethingWentWrong("&c&l(!) &cSomething went wrong while trying to create a new &f{0}&c."),
|
||||
|
||||
Boss_Reload_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Reload_Successful("&b&lEpicBosses &8» &7All boss data has been reloaded. The process took &f{0}ms&7."),
|
||||
|
||||
Boss_Shop_Disabled("&c&l(!) &cThe boss shop is currently disabled."),
|
||||
Boss_Shop_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Shop_NotEnoughBalance("&c&l(!) &cYou do not have enough money to make this purchase! You need &a$&f{0}&c."),
|
||||
Boss_Shop_Purchased("&b&lEpicBosses &8» &7You have purchased &f1x {0}&7."),
|
||||
|
||||
Boss_Skills_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Skills_SetChance("&b&lEpicBosses &8» &7You have {0} the overall chance for the skill map to &f{1}%&7."),
|
||||
Boss_Skills_SetMultiplier("&b&lEpicBosses &8» &7You have {0} the multiplier to &f{1}&7."),
|
||||
Boss_Skills_SetRadius("&b&lEpicBosses &8» &7You have {0} the radius for the skill to &f{1}&7."),
|
||||
@ -197,8 +130,6 @@ public enum Message {
|
||||
Boss_Skills_SetCommandChance("&b&lEpicBosses &8» &7You have {0} the chance for the command skill to &f{1}%&7."),
|
||||
Boss_Skills_SetMinionAmount("&b&lEpicBosses &8» &7You have {0} the amount of minions to spawn from this skill to &f{1}&7."),
|
||||
|
||||
Boss_Spawn_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Spawn_InvalidArgs("&c&l(!) &cYou must use &n/boss spawn [name] (location)&c to spawn a boss."),
|
||||
Boss_Spawn_InvalidLocation("&c&l(!) &cThe location string you have entered is not a valid location string. A valid location string should look like this: &fworld,100,65,100"),
|
||||
Boss_Spawn_MustBePlayer("&c&l(!) &cTo use this command without an input of location you must be a player."),
|
||||
Boss_Spawn_InvalidBoss("&c&l(!) &cThe specified boss is not a valid type."),
|
||||
@ -208,8 +139,6 @@ public enum Message {
|
||||
Boss_Statistics_SetDisplayName("&b&lEpicBosses &8» &7Your next input in to chat will be the display name for the entity. If you enter &f-&7 it will remove/clear the display name of the entity. For color codes use the &f& &7sign."),
|
||||
Boss_Statistics_SetEntityFinder("&b&lEpicBosses &8» &7You have selected &f{0}&7 as the entity type for the boss."),
|
||||
|
||||
Boss_Time_NoPermission("&c&l(!) &cYou do not have access to this command."),
|
||||
Boss_Time_InvalidArgs("&c&l(!) &cYou must use &n/boss time [section]&c to check the time left on a boss spawn."),
|
||||
Boss_Time_DoesntExist("&c&l(!) &cThe specified interval spawn system doesn't exist or editing has been toggled on so the section isn't ticking at the moment. Please use one of the following active system names: &f{0}&c."),
|
||||
Boss_Time_CurrentlyActive("&b&lEpicBosses &8» &7There is currently a boss spawned from this section so the countdown will not begin for the next to spawn until the last boss is killed."),
|
||||
Boss_Time_GetRemainingTime("&b&lEpicBosses &8» &7There is currently &f{0}&7 remaining on the &f{1}&7 interval spawn system.");
|
||||
|
@ -1,117 +0,0 @@
|
||||
package com.songoda.epicbosses.utils.command;
|
||||
|
||||
import com.songoda.epicbosses.utils.StringUtils;
|
||||
import com.songoda.epicbosses.utils.command.attributes.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 28-Apr-18
|
||||
*/
|
||||
public abstract class CommandService<T extends CommandSender> extends BukkitCommand {
|
||||
|
||||
private static CommandMap _commandMap = null;
|
||||
|
||||
private String permission, noPermissionMsg;
|
||||
private String command, description;
|
||||
private Class<T> parameterClass;
|
||||
private String[] aliases;
|
||||
|
||||
public CommandService(Class<? extends CommandService> cmd) {
|
||||
super(cmd.getAnnotation(Name.class).value());
|
||||
|
||||
this.command = cmd.getAnnotation(Name.class).value();
|
||||
this.description = cmd.getAnnotation(Description.class).value();
|
||||
this.aliases = new String[]{};
|
||||
|
||||
if (cmd.isAnnotationPresent(Alias.class))
|
||||
this.aliases = cmd.getAnnotation(Alias.class).value();
|
||||
|
||||
if (cmd.isAnnotationPresent(Permission.class))
|
||||
this.permission = cmd.getAnnotation(Permission.class).value();
|
||||
|
||||
if (cmd.isAnnotationPresent(NoPermission.class))
|
||||
this.noPermissionMsg = cmd.getAnnotation(NoPermission.class).value();
|
||||
|
||||
getGenericClass();
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean execute(CommandSender commandSender, String s, String[] args) {
|
||||
if (this.permission != null && !testPermission(commandSender)) return false;
|
||||
|
||||
|
||||
if (!parameterClass.isInstance(commandSender)) {
|
||||
commandSender.sendMessage(StringUtils.get().translateColor("&4You cannot use that command."));
|
||||
return false;
|
||||
}
|
||||
|
||||
execute(parameterClass.cast(commandSender), args);
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract void execute(T sender, String[] args);
|
||||
|
||||
public String getCommand() {
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public String[] getArrayAliases() {
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
private void register() {
|
||||
if (_commandMap != null) {
|
||||
setFields();
|
||||
_commandMap.register(command, this);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Field field = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||
field.setAccessible(true);
|
||||
_commandMap = (CommandMap) field.get(Bukkit.getServer());
|
||||
|
||||
setFields();
|
||||
|
||||
_commandMap.register(command, this);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setFields() {
|
||||
if (this.aliases != null) setAliases(Arrays.asList(this.aliases));
|
||||
if (this.description != null) setDescription(this.description);
|
||||
if (this.permission != null) setPermission(this.permission);
|
||||
if (this.noPermissionMsg != null) setPermissionMessage(this.noPermissionMsg);
|
||||
}
|
||||
|
||||
private void getGenericClass() {
|
||||
if (this.parameterClass == null) {
|
||||
Type superClass = getClass().getGenericSuperclass();
|
||||
Type tType = ((ParameterizedType) superClass).getActualTypeArguments()[0];
|
||||
String className = tType.toString().split(" ")[1];
|
||||
try {
|
||||
this.parameterClass = (Class<T>) Class.forName(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.songoda.epicbosses.utils.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 28-Apr-18
|
||||
*/
|
||||
public interface ISubCommandHandler {
|
||||
|
||||
void registerSubCommand(SubCommand subCommand);
|
||||
|
||||
boolean handleSubCommand(CommandSender commandSender, String[] args);
|
||||
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package com.songoda.epicbosses.utils.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 28-Apr-18
|
||||
*/
|
||||
public abstract class SubCommand {
|
||||
|
||||
private List<String> aliases = new ArrayList<>();
|
||||
private String subCommand;
|
||||
|
||||
public SubCommand(String subCommand) {
|
||||
this.subCommand = subCommand;
|
||||
}
|
||||
|
||||
public SubCommand(String subCommand, String... subCommands) {
|
||||
this(subCommand);
|
||||
|
||||
this.aliases.addAll(Arrays.asList(subCommands));
|
||||
}
|
||||
|
||||
public String getSubCommand() {
|
||||
return this.subCommand;
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
public boolean isSubCommand(String input) {
|
||||
input = input.toLowerCase();
|
||||
|
||||
return (input.equals(this.subCommand) || this.aliases.contains(input));
|
||||
}
|
||||
|
||||
public abstract void execute(CommandSender sender, String[] args);
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package com.songoda.epicbosses.utils.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 28-Apr-18
|
||||
*/
|
||||
public abstract class SubCommandService<T extends CommandSender> extends CommandService<T> implements ISubCommandHandler {
|
||||
|
||||
private List<SubCommand> subCommands = new ArrayList<>();
|
||||
|
||||
public SubCommandService(Class<? extends CommandService> cmd) {
|
||||
super(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerSubCommand(SubCommand subCommand) {
|
||||
this.subCommands.add(subCommand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSubCommand(CommandSender commandSender, String[] args) {
|
||||
for (SubCommand subCommand : this.subCommands) {
|
||||
if (subCommand.isSubCommand(args[0])) {
|
||||
subCommand.execute(commandSender, args);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.songoda.epicbosses.utils.command.attributes;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Created by charl on 03-May-17.
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Alias {
|
||||
|
||||
String[] value();
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.songoda.epicbosses.utils.command.attributes;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Created by charl on 03-May-17.
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Description {
|
||||
|
||||
String value();
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.songoda.epicbosses.utils.command.attributes;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Created by LukeBingham on 03/04/2017.
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Name {
|
||||
|
||||
String value();
|
||||
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package com.songoda.epicbosses.utils.command.attributes;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author AMinecraftDev
|
||||
* @version 1.0.0
|
||||
* @since 08-Jun-17
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface NoPermission {
|
||||
|
||||
String value();
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.songoda.epicbosses.utils.command.attributes;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Created by charl on 11-May-17.
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Permission {
|
||||
|
||||
String value();
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.songoda.epicbosses.utils.command.attributes;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Created by LukeBingham on 03/04/2017.
|
||||
*/
|
||||
@Documented
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Suggest {
|
||||
|
||||
String value();
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user