forked from Slimefun/Slimefun4
-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(universal): fill universal menu api
- Loading branch information
1 parent
a0b4a96
commit 0fdd70c
Showing
8 changed files
with
97 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/me/mrCookieSlime/Slimefun/api/inventory/UniversalMenuPreset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package me.mrCookieSlime.Slimefun.api.inventory; | ||
|
||
import javax.annotation.Nonnull; | ||
import org.bukkit.block.Block; | ||
|
||
public abstract class UniversalMenuPreset extends BlockMenuPreset { | ||
/** | ||
* Creates a new ChestMenu with the specified | ||
* Title | ||
* | ||
* @param title The title of the Menu | ||
*/ | ||
public UniversalMenuPreset(@Nonnull String id, @Nonnull String title) { | ||
super(id, title); | ||
} | ||
|
||
public void newInstance(@Nonnull UniversalChestMenu menu, @Nonnull Block b) { | ||
// This method can optionally be overridden by implementations | ||
} | ||
|
||
protected void clone(@Nonnull DirtyChestMenu menu, @Nonnull Block block) { | ||
menu.setPlayerInventoryClickable(true); | ||
|
||
for (int slot : occupiedSlots) { | ||
menu.addItem(slot, getItemInSlot(slot)); | ||
} | ||
|
||
if (size > -1) { | ||
menu.addItem(size - 1, null); | ||
} | ||
|
||
if (menu instanceof UniversalChestMenu universalChestMenu) { | ||
newInstance(universalChestMenu, block); | ||
} | ||
|
||
for (int slot = 0; slot < 54; slot++) { | ||
if (getMenuClickHandler(slot) != null) { | ||
menu.addMenuClickHandler(slot, getMenuClickHandler(slot)); | ||
} | ||
} | ||
|
||
menu.addMenuOpeningHandler(getMenuOpeningHandler()); | ||
menu.addMenuCloseHandler(getMenuCloseHandler()); | ||
} | ||
} |