Skip to content

Commit

Permalink
Feature/menus rework (#860)
Browse files Browse the repository at this point in the history
* Implemented new menu system based on button objects and more OOP style

* Moved MenuBankLogs to the new menu system

* Fix loadGUI not loading the correct menu file

* Removed unused code from MenuBankLogs

* Changed loadGUI to loadMenu

* Moved MenuCoops to the new system

* Fixed coops button not having the proper type

* Removed the identifier

* Moved MenuCounts to the new system

* Moved MenuGlobalWarps to the new system

* Cleaned code

* Changed modifyButtonItem to work on ItemStacks and not ItemBuilders

* Rename targetPlayer in button object to a better indicative name

* Updated methods for better menus customizations

* Converted MenuBiomes to the new system

* Fixed incorrect file name

* Fix general errors

* Changed patterns to work with button builders instead of button instances

* Moved MenuBorderColor to the new system

* Moved MenuConfirmBan to the new system

* Moved MenuConfirmDisband to the new system

* Moved MenuConfirmKick to the new system

* Moved MenuConfirmLeave to the new system

* Moved MenuControlPanel to the new system

* Fix compilation errors

* Move MenuIslandRate to the new system

* Move MenuIslandRatings to the new system

* Fix compilation issues

* Moved MemberManageButton to new system

* Moved MenuMemberRole to the new system

* Moved MenuMembers to the new system

* Changed menu buttons to get as a parameter an instance of the menu they associated with instead of the abstract SuperiorMenu object

* Moved MenuMissions to the new system

* Moved MenuMissionsCategory to the new system

* Fix compilation errors with FileUtils#loadMenu

* Moved MenuPlayerLanguage to the new system

* Changed parameters of button methods to get an instance of the menu instead of viewer and target

* Moved MenuIslandFlags to the new system

* Moved MenuUniqueVisitors to the new system

* Moved MenuUpgrades to the new system

* Moved MenuValues to the new system

* Moved MenuVisitors to the new system

* Moved MenuWarpCategories to the new system

* Moved MenuWarpCategoryIconEdit to the new system

* Moved MenuWarpCategoryManage to the new system

* Moved MenuWarpIconEdit to the new system

* Fixed incorrect field names

* Fixed incorrect parameter given to updateObject

* Added getButtons to pattern builders

* Added getButtons to patterns

* Moved MenuWarps to the new system

* Fixed MissionsModule not working with the new menus system

* Fixed PagedSuperiorMenu giving incorrect parameters to buttons

* Moved MenuIslandBank to the new system

* Fix missing field name

* Moved MenuIslandChest to the new system

* Moved MenuIslandPrivileges to the new system

* Moved MenuIslandCreation to the new system

* Moved MenuTopIslands to the new system

* Fixed errors with method calls for deposit & withdraw methods

* Moved MenuWarpManage to the new system

* Moved SuperiorMenuSettings to the new system

* Moved SuperiorMenuCustom to the new system

* Moved all internal menus to their own package

* Fixed null issues with mapButton methods

* Fixed incorrect menu file names

* Fixed incorrect detection of biome field

* Fixed empty dummy button can be null

* Fixed potential null issue with setting island warp icon

* Fixed menuPattern being null

* Fixed no-access-item not initialized correctly

* Fixed null-issues with bonusWorth and bonusLevel for island-creation

* Fixed null issues with ItemBuilder for null items

* Fixed menus not loading items

* Fixed incorrect detection of object indexes

* Fixed detection of button's indexes

* Fixed incorrect detection of disabled-settings items

* Fixed upgrade buttons not checking for island's upgrade level

* Fixed detection of default warp icon

* Fixed icon-lore edit not closing the menu for the player

* Fixed detection of rows size for MenuWarpCategories

* Changed MenuWarpCategories to non-paged menu due to warp categories can have custom slots

* Fixed NPE when the permissions section is invalid

* Fixed NPE when the items section is invalid

* Added detection for issues with yaml-foramtting issues

* Added hard-coded limits for patterns

* Fix menu accepting null-items when they shouldn't

* Optimized a bit creation of menus

* Cleaned code

* Merged dev branch

* Merged `dev` changes

* Merged dev

* Deleted unused files

* Cleaned code a bit
  • Loading branch information
OmerBenGera committed Jan 21, 2022
1 parent 3ddd587 commit 7749d44
Show file tree
Hide file tree
Showing 123 changed files with 7,544 additions and 4,546 deletions.
@@ -1,11 +1,14 @@
package com.bgsoftware.superiorskyblock.api.menu;

import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
import org.bukkit.inventory.InventoryHolder;

import javax.annotation.Nullable;

public interface ISuperiorMenu extends InventoryHolder {

SuperiorPlayer getInventoryViewer();

void setPreviousMove(boolean previousMove);

void cloneAndOpen(@Nullable ISuperiorMenu previousMenu);
Expand Down
Expand Up @@ -8,7 +8,7 @@
import com.bgsoftware.superiorskyblock.api.missions.Mission;
import com.bgsoftware.superiorskyblock.api.upgrades.Upgrade;
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
import com.bgsoftware.superiorskyblock.menu.SuperiorMenuCustom;
import com.bgsoftware.superiorskyblock.menu.impl.internal.SuperiorMenuCustom;
import com.bgsoftware.superiorskyblock.utils.entities.EntityUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
Expand Down
Expand Up @@ -5,7 +5,7 @@
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
import com.bgsoftware.superiorskyblock.commands.CommandTabCompletes;
import com.bgsoftware.superiorskyblock.commands.IAdminPlayerCommand;
import com.bgsoftware.superiorskyblock.menu.SuperiorMenuCustom;
import com.bgsoftware.superiorskyblock.menu.impl.internal.SuperiorMenuCustom;
import org.bukkit.command.CommandSender;

import java.util.ArrayList;
Expand Down
Expand Up @@ -3,7 +3,7 @@
import com.bgsoftware.superiorskyblock.lang.Message;
import com.bgsoftware.superiorskyblock.SuperiorSkyblockPlugin;
import com.bgsoftware.superiorskyblock.commands.ISuperiorCommand;
import com.bgsoftware.superiorskyblock.menu.SuperiorMenuSettings;
import com.bgsoftware.superiorskyblock.menu.impl.internal.SuperiorMenuSettings;
import org.bukkit.command.CommandSender;

import java.util.ArrayList;
Expand Down
Expand Up @@ -13,9 +13,9 @@
import com.bgsoftware.superiorskyblock.api.missions.MissionCategory;
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
import com.bgsoftware.superiorskyblock.handler.HandlerLoadException;
import com.bgsoftware.superiorskyblock.menu.SuperiorMenuBlank;
import com.bgsoftware.superiorskyblock.menu.SuperiorMenuCustom;
import com.bgsoftware.superiorskyblock.menu.SuperiorMenuSettings;
import com.bgsoftware.superiorskyblock.menu.impl.internal.SuperiorMenuBlank;
import com.bgsoftware.superiorskyblock.menu.impl.internal.SuperiorMenuCustom;
import com.bgsoftware.superiorskyblock.menu.impl.internal.SuperiorMenuSettings;
import com.bgsoftware.superiorskyblock.menu.impl.MenuBankLogs;
import com.bgsoftware.superiorskyblock.menu.impl.MenuBiomes;
import com.bgsoftware.superiorskyblock.menu.impl.MenuBorderColor;
Expand All @@ -37,9 +37,9 @@
import com.bgsoftware.superiorskyblock.menu.impl.MenuMembers;
import com.bgsoftware.superiorskyblock.menu.impl.MenuMissions;
import com.bgsoftware.superiorskyblock.menu.impl.MenuMissionsCategory;
import com.bgsoftware.superiorskyblock.menu.impl.MenuPermissions;
import com.bgsoftware.superiorskyblock.menu.impl.MenuIslandPrivileges;
import com.bgsoftware.superiorskyblock.menu.impl.MenuPlayerLanguage;
import com.bgsoftware.superiorskyblock.menu.impl.MenuSettings;
import com.bgsoftware.superiorskyblock.menu.impl.MenuIslandFlags;
import com.bgsoftware.superiorskyblock.menu.impl.MenuTopIslands;
import com.bgsoftware.superiorskyblock.menu.impl.MenuUniqueVisitors;
import com.bgsoftware.superiorskyblock.menu.impl.MenuUpgrades;
Expand Down Expand Up @@ -104,9 +104,9 @@ public void initializeMenus() {
handleExceptions(MenuMembers::init);
handleExceptions(MenuMissions::init);
handleExceptions(MenuMissionsCategory::init);
handleExceptions(MenuPermissions::init);
handleExceptions(MenuIslandPrivileges::init);
handleExceptions(MenuPlayerLanguage::init);
handleExceptions(MenuSettings::init);
handleExceptions(MenuIslandFlags::init);
handleExceptions(MenuTopIslands::init);
handleExceptions(MenuUniqueVisitors::init);
handleExceptions(MenuUpgrades::init);
Expand Down Expand Up @@ -356,41 +356,41 @@ public void openPermissions(SuperiorPlayer targetPlayer, @Nullable ISuperiorMenu
Preconditions.checkNotNull(targetPlayer, "targetPlayer parameter cannot be null.");
Preconditions.checkNotNull(targetIsland, "targetIsland parameter cannot be null.");
Preconditions.checkNotNull(permissiblePlayer, "permissiblePlayer parameter cannot be null.");
MenuPermissions.openInventory(targetPlayer, previousMenu, targetIsland, permissiblePlayer);
MenuIslandPrivileges.openInventory(targetPlayer, previousMenu, targetIsland, permissiblePlayer);
}

@Override
public void openPermissions(SuperiorPlayer targetPlayer, @Nullable ISuperiorMenu previousMenu, Island targetIsland, PlayerRole permissibleRole) {
Preconditions.checkNotNull(targetPlayer, "targetPlayer parameter cannot be null.");
Preconditions.checkNotNull(targetIsland, "targetIsland parameter cannot be null.");
Preconditions.checkNotNull(permissibleRole, "permissibleRole parameter cannot be null.");
MenuPermissions.openInventory(targetPlayer, previousMenu, targetIsland, permissibleRole);
MenuIslandPrivileges.openInventory(targetPlayer, previousMenu, targetIsland, permissibleRole);
}

@Override
public void refreshPermissions(Island island) {
Preconditions.checkNotNull(island, "island parameter cannot be null.");
MenuPermissions.refreshMenus(island);
MenuIslandPrivileges.refreshMenus(island);
}

@Override
public void refreshPermissions(Island island, SuperiorPlayer permissiblePlayer) {
Preconditions.checkNotNull(island, "island parameter cannot be null.");
Preconditions.checkNotNull(permissiblePlayer, "permissiblePlayer parameter cannot be null.");
MenuPermissions.refreshMenus(island, permissiblePlayer);
MenuIslandPrivileges.refreshMenus(island, permissiblePlayer);
}

@Override
public void refreshPermissions(Island island, PlayerRole permissibleRole) {
Preconditions.checkNotNull(island, "island parameter cannot be null.");
Preconditions.checkNotNull(permissibleRole, "permissibleRole parameter cannot be null.");
MenuPermissions.refreshMenus(island, permissibleRole);
MenuIslandPrivileges.refreshMenus(island, permissibleRole);
}

@Override
public void updatePermission(IslandPrivilege islandPrivilege) {
Preconditions.checkNotNull(islandPrivilege, "islandPrivilege parameter cannot be null.");
MenuPermissions.updatePermission(islandPrivilege);
MenuIslandPrivileges.updatePermission(islandPrivilege);
}

@Override
Expand All @@ -403,19 +403,19 @@ public void openPlayerLanguage(SuperiorPlayer targetPlayer, @Nullable ISuperiorM
public void openSettings(SuperiorPlayer targetPlayer, @Nullable ISuperiorMenu previousMenu, Island targetIsland) {
Preconditions.checkNotNull(targetPlayer, "targetPlayer parameter cannot be null.");
Preconditions.checkNotNull(targetIsland, "targetIsland parameter cannot be null.");
MenuSettings.openInventory(targetPlayer, previousMenu, targetIsland);
MenuIslandFlags.openInventory(targetPlayer, previousMenu, targetIsland);
}

@Override
public void refreshSettings(Island island) {
Preconditions.checkNotNull(island, "island parameter cannot be null.");
MenuSettings.refreshMenus(island);
MenuIslandFlags.refreshMenus(island);
}

@Override
public void updateSettings(IslandFlag islandFlag) {
Preconditions.checkNotNull(islandFlag, "islandFlag parameter cannot be null.");
MenuSettings.updateSettings(islandFlag);
MenuIslandFlags.updateSettings(islandFlag);
}

@Override
Expand Down
Expand Up @@ -6,8 +6,8 @@
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
import com.bgsoftware.superiorskyblock.key.ConstantKeys;
import com.bgsoftware.superiorskyblock.key.Key;
import com.bgsoftware.superiorskyblock.menu.impl.internal.StackedBlocksDepositMenu;
import com.bgsoftware.superiorskyblock.lang.Message;
import com.bgsoftware.superiorskyblock.menu.StackedBlocksDepositMenu;
import com.bgsoftware.superiorskyblock.threads.Executor;
import com.bgsoftware.superiorskyblock.utils.LocationUtils;
import com.bgsoftware.superiorskyblock.utils.ServerVersion;
Expand Down
@@ -1,7 +1,7 @@
package com.bgsoftware.superiorskyblock.listeners;

import com.bgsoftware.superiorskyblock.SuperiorSkyblockPlugin;
import com.bgsoftware.superiorskyblock.menu.StackedBlocksDepositMenu;
import com.bgsoftware.superiorskyblock.menu.impl.internal.StackedBlocksDepositMenu;
import com.bgsoftware.superiorskyblock.menu.SuperiorMenu;
import com.bgsoftware.superiorskyblock.threads.Executor;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -63,7 +63,7 @@ public void onMenuClick(InventoryClickEvent e) {
e.setCancelled(true);

if (e.getClickedInventory().equals(e.getView().getTopInventory()))
((SuperiorMenu) inventoryHolder).onClick(e);
((SuperiorMenu) inventoryHolder).onClick(plugin, e);
} else if (inventoryHolder instanceof StackedBlocksDepositMenu) {
((StackedBlocksDepositMenu) inventoryHolder).onInteract(e);
}
Expand All @@ -77,7 +77,7 @@ public void onMenuClose(InventoryCloseEvent e) {
return;

if (inventoryHolder instanceof SuperiorMenu) {
((SuperiorMenu) inventoryHolder).closeInventory(plugin.getPlayers().getSuperiorPlayer(e.getPlayer()));
((SuperiorMenu) inventoryHolder).closeInventory(plugin, plugin.getPlayers().getSuperiorPlayer(e.getPlayer()));
} else if (inventoryHolder instanceof StackedBlocksDepositMenu) {
((StackedBlocksDepositMenu) inventoryHolder).onClose(e);
}
Expand Down

This file was deleted.

0 comments on commit 7749d44

Please sign in to comment.