+ Fixed issue where aSkyblock Hook wasn't set up
+ Fixed issue with AddItem Panels not re-directing to the previous panel
This commit is contained in:
Charles 2019-01-28 00:33:59 +08:00
parent 713f79552c
commit 8fd00c1d38
13 changed files with 142 additions and 14 deletions

View File

@ -6,7 +6,7 @@ import com.songoda.epicbosses.utils.IASkyblockHelper;
import com.songoda.epicbosses.utils.IFactionHelper;
import com.songoda.epicbosses.utils.IReloadable;
import com.songoda.epicbosses.utils.IWorldGuardHelper;
import com.songoda.epicbosses.utils.askyblock.ASkyblockHelper;
import com.songoda.epicbosses.utils.dependencies.ASkyblockHelper;
import utils.factions.FactionsM;
import utils.factions.FactionsOne;
import utils.factions.FactionsUUID;
@ -61,6 +61,7 @@ public class BossHookManager implements IReloadable {
setupFactions();
setupWorldGuard();
setupAskyblock();
}
private void setupAskyblock() {

View File

@ -10,6 +10,7 @@ import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.EquipmentElement;
import com.songoda.epicbosses.entity.elements.HandsElement;
import com.songoda.epicbosses.panel.additems.CustomItemsAddItemsParentPanelHandler;
import com.songoda.epicbosses.panel.autospawns.*;
import com.songoda.epicbosses.panel.bosses.*;
import com.songoda.epicbosses.panel.bosses.commands.OnDeathCommandEditor;
@ -76,7 +77,6 @@ import com.songoda.epicbosses.utils.IReloadable;
import com.songoda.epicbosses.utils.StringUtils;
import com.songoda.epicbosses.utils.panel.base.IPanelHandler;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.Collection;
@ -95,7 +95,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
BOOTS_EDITOR_PATH = "BootsEditorPanel", MAIN_HAND_EDITOR_PATH = "MainHandEditorPanel", OFF_HAND_EDITOR_PATH = "OffHandEditorPanel";
@Getter private IPanelHandler mainMenu, customItems, bosses, autoSpawns, dropTables, customSkills, shopPanel;
@Getter private IPanelHandler addItemsMenu;
@Getter private IPanelHandler customItemAddItemsMenu;
@Getter private ISubVariablePanelHandler<BossEntity, EntityStatsElement> equipmentEditMenu, helmetEditorMenu, chestplateEditorMenu, leggingsEditorMenu, bootsEditorMenu;
@Getter private ISubVariablePanelHandler<BossEntity, EntityStatsElement> weaponEditMenu, offHandEditorMenu, mainHandEditorMenu;
@ -133,6 +133,7 @@ public class BossPanelManager implements ILoadable, IReloadable {
@Getter private IVariablePanelHandler<AutoSpawn> mainAutoSpawnEditPanel, autoSpawnEntitiesEditPanel, autoSpawnSpecialSettingsEditorPanel, autoSpawnTypeEditorPanel, autoSpawnCustomSettingsEditorPanel,
autoSpawnMessageEditorPanel;
@Getter private PanelBuilder addItemsBuilder;
private final CustomBosses customBosses;
public BossPanelManager(CustomBosses customBosses) {
@ -804,13 +805,15 @@ public class BossPanelManager implements ILoadable, IReloadable {
private void loadAddItemsMenu() {
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("AddItemsMenu"));
this.addItemsMenu = new AddItemsPanel(this, panelBuilder, this.customBosses);
this.addItemsBuilder = panelBuilder.cloneBuilder();
this.customItemAddItemsMenu = new AddItemsPanel(this, panelBuilder.cloneBuilder(), this.customBosses, new CustomItemsAddItemsParentPanelHandler(this));
}
private void reloadAddItemsMenu() {
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("AddItemsMenu"));
this.addItemsMenu.initializePanel(panelBuilder);
this.addItemsBuilder = this.addItemsBuilder.cloneBuilder();
this.customItemAddItemsMenu.initializePanel(panelBuilder.cloneBuilder());
}
//---------------------------------------------

View File

@ -3,6 +3,7 @@ package com.songoda.epicbosses.panel;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.managers.files.ItemsFileManager;
import com.songoda.epicbosses.panel.additems.interfaces.IParentPanelHandler;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.ServerUtils;
import com.songoda.epicbosses.utils.panel.Panel;
@ -26,12 +27,14 @@ import java.util.UUID;
public class AddItemsPanel extends PanelHandler {
private Map<UUID, ItemStack> storedItemStacks = new HashMap<>();
private IParentPanelHandler parentPanelHandler;
private ItemsFileManager itemsFileManager;
public AddItemsPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin) {
public AddItemsPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder, CustomBosses plugin, IParentPanelHandler parentPanelHandler) {
super(bossPanelManager, panelBuilder);
this.itemsFileManager = plugin.getItemStackManager();
this.parentPanelHandler = parentPanelHandler;
}
@Override
@ -82,6 +85,10 @@ public class AddItemsPanel extends PanelHandler {
panel.openFor(player);
}
private void openParentPanel(Player player) {
this.parentPanelHandler.openParentPanel(player);
}
private ClickAction getSelectedSlotAction(PanelBuilderCounter panelBuilderCounter, Panel panel) {
return event -> {
int rawSlot = event.getRawSlot();
@ -115,7 +122,8 @@ public class AddItemsPanel extends PanelHandler {
this.storedItemStacks.remove(uuid);
}
this.bossPanelManager.getCustomItems().openFor(player);
openParentPanel(player);
// this.bossPanelManager.getCustomItems().openFor(player);
};
}
@ -133,7 +141,8 @@ public class AddItemsPanel extends PanelHandler {
this.storedItemStacks.remove(uuid);
}
this.bossPanelManager.getCustomItems().openFor(player);
openParentPanel(player);
// this.bossPanelManager.getCustomItems().openFor(player);
};
}
}

View File

@ -48,7 +48,7 @@ public class CustomItemsPanel extends MainListPanelHandler {
}));
loadPage(panel, 0, currentItemStacks, entryList);
panel.getPanelBuilderCounter().getSlotsWith("AddNew").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getAddItemsMenu().openFor((Player) event.getWhoClicked())));
panel.getPanelBuilderCounter().getSlotsWith("AddNew").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getCustomItemAddItemsMenu().openFor((Player) event.getWhoClicked())));
}
private void loadPage(Panel panel, int requestedPage, Map<String, ItemStackHolder> currentItemStacks, List<String> entryList) {

View File

@ -69,7 +69,7 @@ public class MainMenuPanel extends PanelHandler {
if(event.getClick() == ClickType.LEFT || event.getClick() == ClickType.SHIFT_LEFT) {
this.bossPanelManager.getCustomItems().openFor(player);
} else if(event.getClick() == ClickType.RIGHT || event.getClick() == ClickType.SHIFT_RIGHT) {
this.bossPanelManager.getAddItemsMenu().openFor(player);
this.bossPanelManager.getCustomItemAddItemsMenu().openFor(player);
}
};
}

View File

@ -0,0 +1,24 @@
package com.songoda.epicbosses.panel.additems;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.panel.additems.interfaces.IParentPanelHandler;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 27-Jan-19
*/
public class CustomItemsAddItemsParentPanelHandler implements IParentPanelHandler {
private BossPanelManager bossPanelManager;
public CustomItemsAddItemsParentPanelHandler(BossPanelManager bossPanelManager) {
this.bossPanelManager = bossPanelManager;
}
@Override
public void openParentPanel(Player player) {
this.bossPanelManager.getCustomItems().openFor(player);
}
}

View File

@ -0,0 +1,30 @@
package com.songoda.epicbosses.panel.additems;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.panel.additems.interfaces.IParentPanelHandler;
import com.songoda.epicbosses.utils.panel.base.ISubVariablePanelHandler;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 27-Jan-19
*/
public class ItemStackSubListParentPanelHandler implements IParentPanelHandler {
private ISubVariablePanelHandler<BossEntity, EntityStatsElement> panelHandler;
private EntityStatsElement entityStatsElement;
private BossEntity bossEntity;
public ItemStackSubListParentPanelHandler(BossEntity bossEntity, EntityStatsElement entityStatsElement, ISubVariablePanelHandler<BossEntity, EntityStatsElement> panelHandler) {
this.entityStatsElement = entityStatsElement;
this.panelHandler = panelHandler;
this.bossEntity = bossEntity;
}
@Override
public void openParentPanel(Player player) {
this.panelHandler.openFor(player, this.bossEntity, this.entityStatsElement);
}
}

View File

@ -0,0 +1,27 @@
package com.songoda.epicbosses.panel.additems;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.panel.additems.interfaces.IParentPanelHandler;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 27-Jan-19
*/
public class SpawnItemAddItemsParentPanelHandler implements IParentPanelHandler {
private BossPanelManager bossPanelManager;
private BossEntity bossEntity;
public SpawnItemAddItemsParentPanelHandler(BossPanelManager bossPanelManager, BossEntity bossEntity) {
this.bossPanelManager = bossPanelManager;
this.bossEntity = bossEntity;
}
@Override
public void openParentPanel(Player player) {
this.bossPanelManager.getSpawnItemEditMenu().openFor(player, this.bossEntity);
}
}

View File

@ -0,0 +1,14 @@
package com.songoda.epicbosses.panel.additems.interfaces;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 27-Jan-19
*/
public interface IParentPanelHandler {
void openParentPanel(Player player);
}

View File

@ -6,6 +6,9 @@ import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.managers.files.BossesFileManager;
import com.songoda.epicbosses.managers.files.ItemsFileManager;
import com.songoda.epicbosses.panel.AddItemsPanel;
import com.songoda.epicbosses.panel.additems.interfaces.IParentPanelHandler;
import com.songoda.epicbosses.panel.additems.SpawnItemAddItemsParentPanelHandler;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.ObjectUtils;
import com.songoda.epicbosses.utils.ServerUtils;
@ -72,7 +75,7 @@ public class SpawnItemEditorPanel extends VariablePanelHandler<BossEntity> {
.setParentPanelHandler(this.bossPanelManager.getMainBossEditMenu(), bossEntity);
ServerUtils.get().runTaskAsync(() -> {
panelBuilderCounter.getSlotsWith("AddNew").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getAddItemsMenu().openFor(player)));
panelBuilderCounter.getSlotsWith("AddNew").forEach(slot -> panel.setOnClick(slot, event -> openAddItemsPanel(player, bossEntity)));
panelBuilderCounter.getSlotsWith("Remove").forEach(slot -> panel.setOnClick(slot, event -> {
if(!bossEntity.isEditing()) {
Message.Boss_Edit_CannotBeModified.msg(event.getWhoClicked());
@ -96,6 +99,13 @@ public class SpawnItemEditorPanel extends VariablePanelHandler<BossEntity> {
}
private void openAddItemsPanel(Player player, BossEntity bossEntity) {
IParentPanelHandler parentPanelHandler = new SpawnItemAddItemsParentPanelHandler(this.bossPanelManager, bossEntity);
AddItemsPanel addItemsPanel = new AddItemsPanel(this.bossPanelManager, this.bossPanelManager.getAddItemsBuilder().cloneBuilder(), this.plugin, parentPanelHandler);
addItemsPanel.openFor(player);
}
private void loadPage(Panel panel, int requestedPage, Map<String, ItemStackHolder> filteredMap, List<String> entryList, BossEntity bossEntity) {
String current = ObjectUtils.getValue(bossEntity.getSpawnItem(), "");

View File

@ -7,6 +7,9 @@ import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.managers.files.BossesFileManager;
import com.songoda.epicbosses.managers.files.ItemsFileManager;
import com.songoda.epicbosses.panel.AddItemsPanel;
import com.songoda.epicbosses.panel.additems.ItemStackSubListParentPanelHandler;
import com.songoda.epicbosses.panel.additems.interfaces.IParentPanelHandler;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.ServerUtils;
import com.songoda.epicbosses.utils.itemstack.ItemStackConverter;
@ -89,7 +92,7 @@ public abstract class ItemStackSubListPanelHandler extends SubVariablePanelHandl
PanelBuilderCounter panelBuilderCounter = panel.getPanelBuilderCounter();
ServerUtils.get().runTaskAsync(() -> {
panelBuilderCounter.getSlotsWith("AddNew").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getAddItemsMenu().openFor(player)));
panelBuilderCounter.getSlotsWith("AddNew").forEach(slot -> panel.setOnClick(slot, event -> openAddItemsPanel(player, bossEntity, entityStatsElement)));
panelBuilderCounter.getSlotsWith("Remove").forEach(slot -> panel.setOnClick(slot, event -> {
if(!bossEntity.isEditing()) {
Message.Boss_Edit_CannotBeModified.msg(event.getWhoClicked());
@ -113,6 +116,13 @@ public abstract class ItemStackSubListPanelHandler extends SubVariablePanelHandl
}
private void openAddItemsPanel(Player player, BossEntity bossEntity, EntityStatsElement entityStatsElement) {
IParentPanelHandler parentPanelHandler = new ItemStackSubListParentPanelHandler(bossEntity, entityStatsElement, getParentHolder());
AddItemsPanel addItemsPanel = new AddItemsPanel(this.bossPanelManager, this.bossPanelManager.getAddItemsBuilder().cloneBuilder(), this.plugin, parentPanelHandler);
addItemsPanel.openFor(player);
}
private void loadPage(Panel panel, int requestedPage, Map<String, ItemStackHolder> filteredMap, List<String> entryList, BossEntity bossEntity, EntityStatsElement entityStatsElement) {
String current = getCurrent(entityStatsElement);

View File

@ -1,4 +1,4 @@
package com.songoda.epicbosses.utils.askyblock;
package com.songoda.epicbosses.utils.dependencies;
import com.wasteofplastic.askyblock.ASkyBlock;
import com.wasteofplastic.askyblock.Island;

View File

@ -19,7 +19,7 @@
</modules>
<properties>
<plugin.version>1.0.3-U1</plugin.version>
<plugin.version>1.0.3-U2</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>