3.0.0-SNAPSHOT-U24

+ Added BossMenu and BossShop commands
+ Worked BossDropTable, Edit, Items, Menu, Skills command
+ Started work on the GUI system.
This commit is contained in:
AMinecraftDev 2018-10-10 21:22:06 +08:00
parent 5893cfc0b4
commit f1d94b52ea
28 changed files with 788 additions and 120 deletions

View File

@ -1,67 +1,3 @@
MainPanel:
name: '&cPlease choose one...'
slots: 9
Items:
'1':
type: '383:54'
name: '&6&lCustom Bosses'
lore:
- '&eLeft Click »'
- '&fEdit any of the already created'
- '&fcustom bosses.'
- '&7'
- '&eRight Click »'
- '&fCreate a new custom boss from'
- '&fscratch.'
Button: Bosses
'3':
type: 12
name: '&6&lAuto Spawns'
lore:
- '&eLeft Click »'
- '&fEdit any of the already created'
- '&fauto spawns.'
- '&7'
- '&eRight Click »'
- '&fCreate a new auto spawn from'
- '&fscratch.'
Button: AutoSpawns
'5':
type: 101
name: '&6&lDrop Tables'
lore:
- '&eLeft Click »'
- '&fEdit any of the already created'
- '&fdrop tables.'
- '&7'
- '&eRight Click »'
- '&fCreate a new drop table from'
- '&fscratch.'
Button: DropTables
'7':
type: 50
name: '&6&lCustom Items'
lore:
- '&eLeft Click »'
- '&fEdit any of the already created'
- '&fcustom items.'
- '&7'
- '&eRight Click »'
- '&fCreate a new custom item from'
- '&fan item in your inventory.'
Button: CustomItems
'9':
type: 101
name: '&6&lCustom Skills'
lore:
- '&eLeft Click »'
- '&fEdit any of the already created'
- '&fcustom skills.'
- '&7'
- '&eRight Click »'
- '&fCreate a new custom skill from'
- '&fscratch.'
Button: CustomSkills
MainPanel:
name: '&b&l{boss} Editor'
slots: 45

View File

@ -3,6 +3,4 @@ Hooks:
Factions: false
StackMob: false
WorldEdit: true
WorldGuard: true
Menu:
enabledBlock: EMERALD_BLOCK
WorldGuard: true

View File

@ -12,14 +12,80 @@
# Buttons: # buttons section #
# BackButton: 9 # back button slot #
# ExitButton: 9 # exit button slot #
EditorList:
name: '&6CustomBosses &eEditor'
MainMenu:
name: '&6&lCustomBosses'
slots: 18
Settings:
emptySpaceFiller: true
EmptySpaceFiller:
type: WHITE_STAINED_GLASS_PANE
name: '&7'
Items:
'2':
type: ZOMBIE_SPAWN_EGG
name: '&6&lCustomBosses'
lore:
- '&eLeft Click »'
- '&7Edit any of the already created'
- '&7custom bosses.'
- '&7'
- '&eRight Click »'
- '&7Create a new custom boss from'
- '&7scratch.'
Button: CustomBosses
'5':
type: DIAMOND
name: '&6&lCustom Items'
lore:
- '&eLeft Click »'
- '&7Edit any of the already created'
- '&7custom items.'
- '&7'
- '&eRight Click »'
- '&7Create a new custom item from'
- '&7an item in your inventory.'
Button: CustomItems
'8':
type: CLOCK
name: '&6&lAutoSpawns'
lore:
- '&eLeft Click »'
- '&7Edit any of the already created'
- '&7auto spawns.'
- '&7'
- '&eRight Click »'
- '&7Create a new auto spawn from'
- '&7scratch.'
Button: AutoSpawns
'12':
type: OAK_PRESSURE_PLATE
name: '&6&lDrop Tables'
lore:
- '&eLeft Click »'
- '&7Edit any of the already created'
- '&7drop tables.'
- '&7'
- '&eRight Click »'
- '&7Create a new drop table from'
- '&7scratch.'
Button: DropTables
'16':
type: BLAZE_POWDER
name: '&6&lCustom Skills'
lore:
- '&eLeft Click »'
- '&fEdit any of the already created'
- '&fcustom skills.'
- '&7'
- '&eRight Click »'
- '&fCreate a new custom skill from'
- '&fscratch.'
Button: CustomSkills
ListPanel:
name: '{panelName}'
slots: 54
Settings:
backButton: true
fillTo: 45
Buttons:
backButton: 50
Items:
'46':
type: GLASS_PANE

View File

@ -5,8 +5,10 @@ import net.aminecraftdev.custombosses.api.BossAPI;
import net.aminecraftdev.custombosses.commands.BossCmd;
import net.aminecraftdev.custombosses.container.BossEntityContainer;
import net.aminecraftdev.custombosses.file.BossesFileHandler;
import net.aminecraftdev.custombosses.file.EditorFileHandler;
import net.aminecraftdev.custombosses.file.LangFileHandler;
import net.aminecraftdev.custombosses.managers.BossCommandManager;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.managers.DebugManager;
import net.aminecraftdev.custombosses.managers.files.BossItemFileManager;
import net.aminecraftdev.custombosses.managers.BossMechanicManager;
@ -14,6 +16,7 @@ import net.aminecraftdev.custombosses.managers.files.BossesFileManager;
import net.aminecraftdev.custombosses.utils.IReloadable;
import net.aminecraftdev.custombosses.utils.Message;
import net.aminecraftdev.custombosses.utils.command.SubCommandService;
import net.aminecraftdev.custombosses.utils.file.YmlFileHandler;
import org.bstats.bukkit.Metrics;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
@ -30,10 +33,11 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
@Getter private BossCommandManager bossCommandManager;
@Getter private BossItemFileManager itemStackManager;
@Getter private BossesFileManager bossesFileManager;
@Getter private BossPanelManager bossPanelManager;
@Getter private DebugManager debugManager;
@Getter private LangFileHandler langFileHandler;
@Getter private FileConfiguration lang;
@Getter private YmlFileHandler langFileHandler, editorFileHandler;
@Getter private FileConfiguration lang, editor;
@Override
public void onEnable() {
@ -47,6 +51,7 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
beginMs = System.currentTimeMillis();
this.debugManager = new DebugManager();
this.bossPanelManager = new BossPanelManager(this);
this.bossEntityContainer = new BossEntityContainer();
this.bossMechanicManager = new BossMechanicManager(this);
@ -58,7 +63,14 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
System.out.println("File Handlers and File Managers loaded (took " + (System.currentTimeMillis() - beginMs) + "ms)");
beginMs = System.currentTimeMillis();
createFiles();
System.out.println("All default YML files have been created (took " + (System.currentTimeMillis() - beginMs) + "ms)");
beginMs = System.currentTimeMillis();
this.bossCommandManager = new BossCommandManager(new BossCmd(), this);
this.bossPanelManager.load();
this.bossCommandManager.load();
System.out.println("All commands and listeners loaded (took " + (System.currentTimeMillis() - beginMs) + "ms)");
@ -77,9 +89,26 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
this.bossMechanicManager.load();
this.lang = this.langFileHandler.loadFile();
this.editor = this.editorFileHandler.loadFile();
this.bossPanelManager.reload();
Message.setFile(getLang());
}
private void loadFileManagersAndHandlers() {
this.itemStackManager = new BossItemFileManager(this);
this.bossesFileManager = new BossesFileManager(this);
this.langFileHandler = new LangFileHandler(this);
this.editorFileHandler = new EditorFileHandler(this);
}
private void createFiles() {
this.editorFileHandler.createFile();
this.langFileHandler.createFile();
}
private void saveMessagesToFile() {
FileConfiguration lang = getLang();
@ -91,11 +120,4 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
this.langFileHandler.saveFile(lang);
}
private void loadFileManagersAndHandlers() {
this.itemStackManager = new BossItemFileManager(this);
this.bossesFileManager = new BossesFileManager(this);
this.langFileHandler = new LangFileHandler(this);
}
}

View File

@ -1,23 +1,41 @@
package net.aminecraftdev.custombosses.commands.boss;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.utils.Message;
import net.aminecraftdev.custombosses.utils.Permission;
import net.aminecraftdev.custombosses.utils.command.SubCommand;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 04-Oct-18
*
* TODO
*/
public class BossDropTableCmd extends SubCommand {
public BossDropTableCmd() {
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);
}
}

View File

@ -1,23 +1,41 @@
package net.aminecraftdev.custombosses.commands.boss;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.utils.Message;
import net.aminecraftdev.custombosses.utils.Permission;
import net.aminecraftdev.custombosses.utils.command.SubCommand;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 02-Oct-18
*
* TODO
*/
public class BossEditCmd extends SubCommand {
public BossEditCmd() {
private BossPanelManager bossPanelManager;
public BossEditCmd(BossPanelManager bossPanelManager) {
super("edit");
this.bossPanelManager = bossPanelManager;
}
@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;
}
Player player = (Player) sender;
this.bossPanelManager.getBosses().openFor(player);
}
}

View File

@ -1,7 +1,11 @@
package net.aminecraftdev.custombosses.commands.boss;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.utils.Message;
import net.aminecraftdev.custombosses.utils.Permission;
import net.aminecraftdev.custombosses.utils.command.SubCommand;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
@ -10,12 +14,28 @@ import org.bukkit.command.CommandSender;
*/
public class BossItemsCmd extends SubCommand {
public BossItemsCmd() {
super("items", "item");
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);
}
}

View File

@ -0,0 +1,41 @@
package net.aminecraftdev.custombosses.commands.boss;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.utils.Message;
import net.aminecraftdev.custombosses.utils.Permission;
import net.aminecraftdev.custombosses.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);
}
}

View File

@ -0,0 +1,23 @@
package net.aminecraftdev.custombosses.commands.boss;
import net.aminecraftdev.custombosses.utils.command.SubCommand;
import org.bukkit.command.CommandSender;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 10-Oct-18
*
* TODO
*/
public class BossShopCmd extends SubCommand {
public BossShopCmd() {
super("shop", "buy", "store");
}
@Override
public void execute(CommandSender sender, String[] args) {
}
}

View File

@ -1,7 +1,11 @@
package net.aminecraftdev.custombosses.commands.boss;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.utils.Message;
import net.aminecraftdev.custombosses.utils.Permission;
import net.aminecraftdev.custombosses.utils.command.SubCommand;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
@ -10,12 +14,28 @@ import org.bukkit.command.CommandSender;
*/
public class BossSkillsCmd extends SubCommand {
public BossSkillsCmd() {
super("skills");
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);
}
}

View File

@ -0,0 +1,19 @@
package net.aminecraftdev.custombosses.file;
import net.aminecraftdev.custombosses.utils.file.YmlFileHandler;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 10-Oct-18
*/
public class EditorFileHandler extends YmlFileHandler {
public EditorFileHandler(JavaPlugin javaPlugin) {
super(javaPlugin, true, new File(javaPlugin.getDataFolder(), "editor.yml"));
}
}

View File

@ -30,17 +30,19 @@ public class BossCommandManager implements ILoadable {
}
this.commandService.registerSubCommand(new BossCreateCmd(this.customBosses.getBossEntityContainer()));
this.commandService.registerSubCommand(new BossDebugCmd(this.customBosses.getBossesFileManager()));
this.commandService.registerSubCommand(new BossDropTableCmd());
this.commandService.registerSubCommand(new BossEditCmd());
this.commandService.registerSubCommand(new BossDebugCmd(this.customBosses.getDebugManager()));
this.commandService.registerSubCommand(new BossDropTableCmd(this.customBosses.getBossPanelManager()));
this.commandService.registerSubCommand(new BossEditCmd(this.customBosses.getBossPanelManager()));
this.commandService.registerSubCommand(new BossHelpCmd());
this.commandService.registerSubCommand(new BossInfoCmd());
this.commandService.registerSubCommand(new BossItemsCmd());
this.commandService.registerSubCommand(new BossItemsCmd(this.customBosses.getBossPanelManager()));
this.commandService.registerSubCommand(new BossKillAllCmd());
this.commandService.registerSubCommand(new BossListCmd());
this.commandService.registerSubCommand(new BossMenuCmd(this.customBosses.getBossPanelManager()));
this.commandService.registerSubCommand(new BossNearbyCmd());
this.commandService.registerSubCommand(new BossReloadCmd(this.customBosses));
this.commandService.registerSubCommand(new BossSkillsCmd());
this.commandService.registerSubCommand(new BossShopCmd());
this.commandService.registerSubCommand(new BossSkillsCmd(this.customBosses.getBossPanelManager()));
this.commandService.registerSubCommand(new BossSpawnCmd());
this.commandService.registerSubCommand(new BossTimeCmd());

View File

@ -0,0 +1,159 @@
package net.aminecraftdev.custombosses.managers;
import lombok.Getter;
import net.aminecraftdev.custombosses.CustomBosses;
import net.aminecraftdev.custombosses.panel.*;
import net.aminecraftdev.custombosses.utils.ILoadable;
import net.aminecraftdev.custombosses.utils.IReloadable;
import net.aminecraftdev.custombosses.utils.panel.base.IPanelHandler;
import net.aminecraftdev.custombosses.utils.panel.builder.PanelBuilder;
import java.util.HashMap;
import java.util.Map;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 10-Oct-18
*/
public class BossPanelManager implements ILoadable, IReloadable {
@Getter private IPanelHandler mainMenu, customItems, bosses, autoSpawns, dropTables, customSkills;
private final String customItemsTitle = "&6&lCustomBosses &e&lItems", autoSpawnsTitle = "&6&lCustomBosses &e&lAutoSpawns",
customBossesTitle = "&6&lCustomBosses &e&lBosses", customSkillsTitle = "&6&lCustomBosses &e&lSkills",
dropTableTitle = "&6&lCustomBosses &e&lDropTable";
private final CustomBosses customBosses;
public BossPanelManager(CustomBosses customBosses) {
this.customBosses = customBosses;
}
@Override
public void load() {
loadMainMenu();
loadAutoSpawnsMenu();
loadCustomBossesMenu();
loadCustomItemsMenu();
loadCustomSkillsMenu();
loadDropTableMenu();
}
@Override
public void reload() {
reloadMainMenu();
reloadAutoSpawnsMenu();
reloadCustomBosses();
reloadCustomItems();
reloadCustomSkills();
reloadDropTable();
}
//---------------------------------------------
//
// M A I N M E N U P A N E L
//
//---------------------------------------------
private void loadMainMenu() {
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("MainMenu"));
this.mainMenu = new MainMenuPanel(this, panelBuilder);
}
private void reloadMainMenu() {
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("MainMenu"));
this.mainMenu.initializePanel(panelBuilder);
}
//---------------------------------------------
//
// A U T O S P A W N S P A N E L
//
//---------------------------------------------
private void loadAutoSpawnsMenu() {
this.autoSpawns = new AutoSpawnsPanel(this, getListMenu(this.autoSpawnsTitle));
}
private void reloadAutoSpawnsMenu() {
this.autoSpawns.initializePanel(getListMenu(this.autoSpawnsTitle));
}
//---------------------------------------------
//
// C U S T O M B O S S E S P A N E L
//
//---------------------------------------------
private void loadCustomBossesMenu() {
this.bosses = new CustomBossesPanel(this, getListMenu(this.customBossesTitle));
}
private void reloadCustomBosses() {
this.bosses.initializePanel(getListMenu(this.customBossesTitle));
}
//---------------------------------------------
//
// C U S T O M S K I L L S P A N E L
//
//---------------------------------------------
private void loadCustomSkillsMenu() {
this.customSkills = new CustomSkillsPanel(this, getListMenu(this.customSkillsTitle));
}
private void reloadCustomSkills() {
this.customSkills.initializePanel(getListMenu(this.customSkillsTitle));
}
//---------------------------------------------
//
// D R O P T A B L E P A N E L
//
//---------------------------------------------
private void loadDropTableMenu() {
this.dropTables = new DropTablePanel(this, getListMenu(this.dropTableTitle));
}
private void reloadDropTable() {
this.dropTables.initializePanel(getListMenu(this.dropTableTitle));
}
//---------------------------------------------
//
// C U S T O M I T E M S P A N E L
//
//---------------------------------------------
private void loadCustomItemsMenu() {
this.customItems = new CustomItemsPanel(this, getListMenu(this.customItemsTitle));
}
private void reloadCustomItems() {
this.customItems.initializePanel(getListMenu(this.customItemsTitle));
}
//---------------------------------------------
//
// G E N E R A L L I S T P A N E L
//
//---------------------------------------------
private PanelBuilder getListMenu(String name) {
Map<String, String> replaceMap = new HashMap<>();
replaceMap.put("{panelName}", name);
return new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("ListPanel"), replaceMap);
}
}

View File

@ -0,0 +1,24 @@
package net.aminecraftdev.custombosses.panel;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.utils.panel.base.PanelHandler;
import net.aminecraftdev.custombosses.utils.panel.builder.PanelBuilder;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 10-Oct-18
*
* TODO
*/
public class AutoSpawnsPanel extends PanelHandler {
public AutoSpawnsPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
super(bossPanelManager, panelBuilder);
}
@Override
public void fillPanel() {
this.panel.setParentPanel(this.bossPanelManager.getMainMenu().getPanel());
}
}

View File

@ -0,0 +1,24 @@
package net.aminecraftdev.custombosses.panel;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.utils.panel.base.PanelHandler;
import net.aminecraftdev.custombosses.utils.panel.builder.PanelBuilder;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 10-Oct-18
*
* TODO
*/
public class CustomBossesPanel extends PanelHandler {
public CustomBossesPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
super(bossPanelManager, panelBuilder);
}
@Override
public void fillPanel() {
this.panel.setParentPanel(this.bossPanelManager.getMainMenu().getPanel());
}
}

View File

@ -0,0 +1,24 @@
package net.aminecraftdev.custombosses.panel;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.utils.panel.base.PanelHandler;
import net.aminecraftdev.custombosses.utils.panel.builder.PanelBuilder;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 10-Oct-18
*
* TODO
*/
public class CustomItemsPanel extends PanelHandler {
public CustomItemsPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
super(bossPanelManager, panelBuilder);
}
@Override
public void fillPanel() {
this.panel.setParentPanel(this.bossPanelManager.getMainMenu().getPanel());
}
}

View File

@ -0,0 +1,24 @@
package net.aminecraftdev.custombosses.panel;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.utils.panel.base.PanelHandler;
import net.aminecraftdev.custombosses.utils.panel.builder.PanelBuilder;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 10-Oct-18
*
* TODO
*/
public class CustomSkillsPanel extends PanelHandler {
public CustomSkillsPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
super(bossPanelManager, panelBuilder);
}
@Override
public void fillPanel() {
this.panel.setParentPanel(this.bossPanelManager.getMainMenu().getPanel());
}
}

View File

@ -0,0 +1,24 @@
package net.aminecraftdev.custombosses.panel;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.utils.panel.base.PanelHandler;
import net.aminecraftdev.custombosses.utils.panel.builder.PanelBuilder;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 10-Oct-18
*
* TODO
*/
public class DropTablePanel extends PanelHandler {
public DropTablePanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
super(bossPanelManager, panelBuilder);
}
@Override
public void fillPanel() {
this.panel.setParentPanel(this.bossPanelManager.getMainMenu().getPanel());
}
}

View File

@ -1,9 +0,0 @@
package net.aminecraftdev.custombosses.panel;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 18-Jul-18
*/
public class MainBossPanel {
}

View File

@ -0,0 +1,36 @@
package net.aminecraftdev.custombosses.panel;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.utils.panel.base.PanelHandler;
import net.aminecraftdev.custombosses.utils.panel.builder.PanelBuilder;
import net.aminecraftdev.custombosses.utils.panel.builder.PanelBuilderCounter;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 10-Oct-18
*/
public class MainMenuPanel extends PanelHandler {
public MainMenuPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
super(bossPanelManager, panelBuilder);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
PanelBuilderCounter panelBuilderCounter = panelBuilder.getPanelBuilderCounter();
panelBuilderCounter
.addSlotCounter("CustomBosses", event -> this.bossPanelManager.getBosses().openFor((Player) event.getWhoClicked()))
.addSlotCounter("CustomItems", event -> this.bossPanelManager.getCustomItems().openFor((Player) event.getWhoClicked()))
.addSlotCounter("AutoSpawns", event -> this.bossPanelManager.getAutoSpawns().openFor((Player) event.getWhoClicked()))
.addSlotCounter("DropTables", event -> this.bossPanelManager.getDropTables().openFor((Player) event.getWhoClicked()))
.addSlotCounter("CustomSkills", event -> this.bossPanelManager.getCustomSkills().openFor((Player) event.getWhoClicked()));
this.panel = panelBuilder.getPanel()
.setCancelClick(true)
.setDestroyWhenDone(false)
.setCancelLowerClick(true);
}
}

View File

@ -0,0 +1,12 @@
package net.aminecraftdev.custombosses.utils;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 12-Aug-18
*/
public interface ICloneable<T> {
T clone();
}

View File

@ -28,6 +28,10 @@ public enum Message {
Boss_Debug_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_Debug_Toggled("&e&lCustomBosses &8» &7You have toggled debug mode for &fCustomBosses &7to {0}."),
Boss_DropTable_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_Edit_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_Help_Page1(
"&8&m----*--------&6&l[ &e&lBoss Help &7(Page 1) &6&l]&8&m--------*----\n" +
"&e/boss help (page) &8» &7Displays boss commands.\n" +
@ -50,8 +54,14 @@ public enum Message {
"&7\n" +
"&8&m----*-----------------------------------*----"),
Boss_Items_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_Reload_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_Reload_Successful("&e&lCustomBosses &8» &7All boss data has been reloaded. The process took &f{0}ms&7.");
Boss_Reload_Successful("&e&lCustomBosses &8» &7All boss data has been reloaded. The process took &f{0}ms&7."),
Boss_Skills_NoPermission("&c&l(!) &cYou do not have access to this command.");
private static FileConfiguration LANG;

View File

@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
*/
public enum Permission {
admin("boss.admin"),
create("boss.create"),
debug("boss.debug"),
reload("boss.reload");

View File

@ -1,12 +1,16 @@
package net.aminecraftdev.custombosses.utils.panel;
import lombok.Getter;
import net.aminecraftdev.custombosses.utils.ICloneable;
import net.aminecraftdev.custombosses.utils.StringUtils;
import net.aminecraftdev.custombosses.utils.itemstack.ItemStackConverter;
import net.aminecraftdev.custombosses.utils.itemstack.holder.ItemStackHolder;
import net.aminecraftdev.custombosses.utils.panel.base.ClickAction;
import net.aminecraftdev.custombosses.utils.panel.base.PageAction;
import net.aminecraftdev.custombosses.utils.panel.base.PanelCloseAction;
import net.aminecraftdev.custombosses.utils.panel.builder.PanelBuilderSettings;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -25,7 +29,7 @@ import java.util.*;
* @version 2.0.0
* @since 18-Jul-2018
*/
public class Panel implements Listener {
public class Panel implements Listener, ICloneable<Panel> {
//--------------------------------------------------
//
@ -33,6 +37,7 @@ public class Panel implements Listener {
//
//--------------------------------------------------
@Getter private static final ItemStackConverter ITEM_STACK_CONVERTER = new ItemStackConverter();
@Getter private static final List<Panel> PANELS = new ArrayList<>();
private static JavaPlugin PLUGIN;
@ -104,6 +109,8 @@ public class Panel implements Listener {
this.pageData.putAll(pageData);
this.panelBuilderSettings = panelBuilderSettings;
fillEmptySpace();
PANELS.add(this);
}
@ -337,6 +344,39 @@ public class Panel implements Listener {
return this;
}
/**
* Used to set the parent panel for this Panel, which
* will be used if the Back Button is set up for this
* panel.
*
* @param parentPanel - the parent Panel
* @return the current Panel
*/
public Panel setParentPanel(Panel parentPanel) {
if(!this.panelBuilderSettings.isBackButton()) return this;
int slot = this.panelBuilderSettings.getBackButtonSlot() - 1;
setOnClick(slot, event -> parentPanel.openFor((Player) event.getWhoClicked()));
return this;
}
public Panel setExitButton() {
if(!this.panelBuilderSettings.isExitButton()) return this;
int slot = this.panelBuilderSettings.getExitButtonSlot();
setOnClick(slot, event -> event.getWhoClicked().closeInventory());
return this;
}
//--------------------------------------------------
//
// O T H E R P A N E L M E T H O D S
//
//--------------------------------------------------
/**
* Used to destroy a panel, no matter how many people
* are in it or what's happening in it.
@ -365,6 +405,55 @@ public class Panel implements Listener {
InventoryCloseEvent.getHandlerList().unregister(this);
}
/**
* Used to fill the empty spaces in the panel with the specified
* EmptySpaceFiller item if it's set up in the config.
*/
public void fillEmptySpace() {
ItemStackHolder itemStackHolder = this.panelBuilderSettings.getEmptySpaceFillerItem();
if(itemStackHolder == null) return;
ItemStack itemStack = ITEM_STACK_CONVERTER.from(itemStackHolder);
if(itemStack == null) return;
for(int i = 0; i < getInventory().getSize(); i++) {
ItemStack itemAtSlot = getInventory().getItem(i);
if(itemAtSlot == null || itemAtSlot.getType() == Material.AIR) {
getInventory().setItem(i, itemStack);
}
}
}
@Override
public Panel clone() {
Panel panel = new Panel(this.inventory.getTitle(), this.inventory.getSize());
panel.targettedSlotActions.putAll(this.targettedSlotActions);
panel.allSlotActions.addAll(this.allSlotActions);
panel.currentPageContainer.putAll(this.currentPageContainer);
panel.cancelClick = this.cancelClick;
panel.destroyWhenDone = this.destroyWhenDone;
panel.cancelLowerClick = this.cancelLowerClick;
panel.panelBuilderSettings = this.panelBuilderSettings;
panel.clickSound = this.clickSound;
panel.onPageChange = this.onPageChange;
panel.panelClose = this.panelClose;
for(int i = 0; i < this.inventory.getSize(); i++) {
ItemStack itemStack = this.inventory.getItem(i);
if(itemStack != null) {
panel.inventory.setItem(i, itemStack);
}
}
return panel;
}
//--------------------------------------------------
//
// P A N E L S T A T I C M E T H O D
@ -374,5 +463,4 @@ public class Panel implements Listener {
public static void setPlugin(JavaPlugin javaPlugin) {
PLUGIN = javaPlugin;
}
}

View File

@ -0,0 +1,22 @@
package net.aminecraftdev.custombosses.utils.panel.base;
import net.aminecraftdev.custombosses.utils.panel.Panel;
import net.aminecraftdev.custombosses.utils.panel.builder.PanelBuilder;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 10-Oct-18
*/
public interface IPanelHandler {
Panel getPanel();
void initializePanel(PanelBuilder panelBuilder);
void fillPanel();
void openFor(Player player);
}

View File

@ -0,0 +1,45 @@
package net.aminecraftdev.custombosses.utils.panel.base;
import lombok.Getter;
import net.aminecraftdev.custombosses.managers.BossPanelManager;
import net.aminecraftdev.custombosses.utils.panel.Panel;
import net.aminecraftdev.custombosses.utils.panel.builder.PanelBuilder;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 10-Oct-18
*/
public class PanelHandler implements IPanelHandler {
protected final BossPanelManager bossPanelManager;
@Getter protected Panel panel;
public PanelHandler(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
this.bossPanelManager = bossPanelManager;
initializePanel(panelBuilder);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
this.panel = panelBuilder.getPanel()
.setDestroyWhenDone(false)
.setCancelClick(true)
.setCancelLowerClick(true);
fillPanel();
}
@Override
public void fillPanel() {
}
@Override
public void openFor(Player player) {
this.panel.openFor(player);
}
}

View File

@ -93,13 +93,12 @@ public class PanelBuilder {
if(innerSection.contains("NextPage") && innerSection.getBoolean("NextPage")) this.panelBuilderCounter.addPageData(slot, 1);
if(innerSection.contains("PreviousPage") && innerSection.getBoolean("PreviousPage")) this.panelBuilderCounter.addPageData(slot, -1);
for(String identifier : slotsWith.keySet()) {
if(innerSection.contains(identifier) && innerSection.getBoolean(identifier)) {
Set<Integer> current = slotsWith.get(identifier);
if(innerSection.contains("Button") && slotsWith.containsKey(innerSection.getString("Button"))) {
String identifier = innerSection.getString("Button");
Set<Integer> current = slotsWith.get(identifier);
current.add(slot);
this.panelBuilderCounter.getSlotsWithCounter().put(identifier, current);
}
current.add(slot);
this.panelBuilderCounter.getSlotsWithCounter().put(identifier, current);
}
for(String identifier : specialSlotsWith.keySet()) {

View File

@ -18,13 +18,15 @@ public class PanelBuilderSettings {
public PanelBuilderSettings(ConfigurationSection configurationSection) {
ItemStackHolderConverter itemStackHolderConverter = new ItemStackHolderConverter();
ConfigurationSection settingsSection = configurationSection.getConfigurationSection("Settings");
ConfigurationSection buttonsSection = configurationSection.getConfigurationSection("Buttons");
this.emptySpaceFiller = configurationSection.getBoolean("Settings.emptySpaceFiller", false);
this.backButton = configurationSection.getBoolean("Settings.backButton", false);
this.exitButton = configurationSection.getBoolean("Settings.exitButton", false);
this.fillTo = configurationSection.getInt("Settings.fillTo", 0);
this.backButtonSlot = configurationSection.getInt("Buttons.backButton", -1);
this.exitButtonSlot = configurationSection.getInt("Buttons.exitButton", -1);
this.emptySpaceFiller = settingsSection != null && settingsSection.getBoolean("emptySpaceFiller", false);
this.backButton = settingsSection != null && settingsSection.getBoolean("backButton", false);
this.exitButton = settingsSection != null && settingsSection.getBoolean("exitButton", false);
this.fillTo = settingsSection == null? 0 : settingsSection.getInt("fillTo", 0);
this.backButtonSlot = buttonsSection == null? -1 : buttonsSection.getInt("backButton", -1);
this.exitButtonSlot = buttonsSection == null? -1 : buttonsSection.getInt("exitButton", -1);
this.emptySpaceFillerItem = itemStackHolderConverter.to(configurationSection.getConfigurationSection("EmptySpaceFiller"));
}