Class RyseInventory.Builder
java.lang.Object
io.github.rysefoxx.inventory.plugin.pagination.RyseInventory.Builder
- Enclosing class:
RyseInventory
Builder to create an inventory.
-
Method Summary
Modifier and TypeMethodDescription@NotNull RyseInventory.Builderanimation(@NotNull SlideAnimation animation) Based on this animation, the items can appear animated when opening the inventory.@NotNull RyseInventorybuild(@NotNull org.bukkit.plugin.Plugin plugin) Builds the RyseInventory@NotNull RyseInventorybuild(@NotNull org.bukkit.plugin.Plugin plugin, @Nullable InventoryManager defaultManager) Builds the RyseInventory@NotNull RyseInventory.BuilderWhen the inventory is opened, the inventory is emptied and saved.@NotNull RyseInventory.Builderclose(CloseReason @NotNull ... reasons) Here you can set possible reasons to automatically close the inventory when the reason takes place.@NotNull RyseInventory.BuildercloseAfter(int time, @Nullable TimeSetting setting) With this method you can automatically set when to close the inventory.@NotNull RyseInventory.Builderdelay(int time, @Nullable TimeSetting setting) Adjusts the delay of the scheduler.@NotNull RyseInventory.BuilderThis function disables the update task.@NotNull RyseInventory.BuilderenableAction(@NotNull BooleanSupplier condition, Action @NotNull ... actions) This allows to get more control over the InventoryAction.@NotNull RyseInventory.BuilderenableAction(Action @NotNull ... actions) This allows to get more control over the InventoryAction.fixedPageSize(int page) Sets a page number.@NotNull RyseInventory.Builderidentifier(@NotNull Object identifier) Gives the inventory an identification@NotNull RyseInventory.BuilderignoreClickEvent(DisabledInventoryClick @NotNull ... clicks) Set what should be ignored in the InventoryClickEvent.@NotNull RyseInventory.BuilderignoredSlot(int slot, @NotNull Consumer<org.bukkit.event.inventory.InventoryClickEvent> event) In this slot items can be taken or added by the player.@NotNull RyseInventory.BuilderignoredSlot(@NotNull BooleanSupplier condition, int slot, @NotNull Consumer<org.bukkit.event.inventory.InventoryClickEvent> event) In this slot items can be taken or added by the player.@NotNull RyseInventory.BuilderignoredSlots(int @NotNull ... slots) In all these slots items can be put in or removed by the user.@NotNull RyseInventory.BuilderignoredSlots(@NotNull BooleanSupplier condition, int... slots) In all these slots items can be put in or removed by the user.@NotNull RyseInventory.BuilderignoredSlots(@NotNull BooleanSupplier condition, @NotNull List<Integer> slots, @NotNull Consumer<org.bukkit.event.inventory.InventoryClickEvent> event) In all these slots items can be taken or added by the player.@NotNull RyseInventory.BuilderignoredSlots(@NotNull List<Integer> slots, @NotNull Consumer<org.bukkit.event.inventory.InventoryClickEvent> event) In all these slots items can be taken or added by the player.@NotNull RyseInventory.BuilderignoreEvents(DisabledEvents @NotNull ... events) Disables events according to wishes.@NotNull RyseInventory.BuilderIf this method is called, all items that the player can set himself will not be saved.@NotNull RyseInventory.Builder@NotNull RyseInventory.Builderlistener(@NotNull EventCreator<? extends org.bukkit.event.Event> event) Adds its own event to the inventory.@NotNull RyseInventory.BuilderloadDelay(int time, @Nullable TimeSetting setting) With this method, the content of the inventory is loaded later.@NotNull RyseInventory.BuilderloadTitle(int time, @Nullable TimeSetting setting) With this method the title will be loaded later.@NotNull RyseInventory.Builder@NotNull RyseInventory.BuilderopenDelay(int time, @Nullable TimeSetting setting) Adjusts the delay before the inventory is opened.@NotNull RyseInventory.Builderoptions(InventoryOptions @NotNull ... options) Settings to help ensure that the player is not disturbed while he has the inventory open.@NotNull RyseInventory.Builderperiod(int time, @Nullable TimeSetting setting) Adjusts the period of the scheduler.Save the inventory permanently in a list.@NotNull RyseInventory.BuilderThis method can be used to prevent the player from closing the inventory.@NotNull RyseInventory.BuilderThe method can be used so that data is not transferred to the next page as well.@NotNull RyseInventory.Builderprovider(@NotNull InventoryProvider provider) The provider to fill the inventory with content.@NotNull RyseInventory.Builderrows(int rows) If you do not have a size but a row, you can also create an inventory by doing this.@NotNull RyseInventory.BuilderAdd to a page the rows you want.@NotNull RyseInventory.BuilderAdd to a page the rows you want.@NotNull RyseInventory.Buildersize(int size) @NotNull RyseInventory.BuilderAssigns a fixed title to the inventory@NotNull RyseInventory.Buildertitle(@NotNull net.kyori.adventure.text.Component title) Assigns a fixed title to the inventory@NotNull RyseInventory.BuildertitleHolder(@NotNull String title) Adds a temporary title to the inventory.@NotNull RyseInventory.BuildertitleHolder(@NotNull net.kyori.adventure.text.Component title) Adds a temporary title to the inventory.@NotNull RyseInventory.Buildertype(@NotNull InventoryOpenerType type) Modifies the inventory type.
-
Method Details
-
newInstance
-
keepOriginal
-
disableUpdateTask
This function disables the update task.- Returns:
- A Builder object.
-
permanentCache
Save the inventory permanently in a list. As a result, you can always get this inventory through theInventoryManager.getInventory(Object)method. Of course, the inventory must be given an ID by theidentifier(Object)method- Returns:
- A Builder object.
-
ignoredSlot
@NotNull public @NotNull RyseInventory.Builder ignoredSlot(@Nonnegative int slot, @NotNull @NotNull Consumer<org.bukkit.event.inventory.InventoryClickEvent> event) In this slot items can be taken or added by the player. However, you can now add your own logic.- Parameters:
slot- The slotevent- Your event with your own logic when the item is clicked.- Returns:
- The Inventory Builder to set additional options.
-
ignoredSlot
@NotNull public @NotNull RyseInventory.Builder ignoredSlot(@NotNull @NotNull BooleanSupplier condition, @Nonnegative int slot, @NotNull @NotNull Consumer<org.bukkit.event.inventory.InventoryClickEvent> event) In this slot items can be taken or added by the player. However, you can now add your own logic.- Parameters:
condition- The condition must return true for the slots to be ignored.slot- The slotevent- Your event with your own logic when the item is clicked.- Returns:
- The Inventory Builder to set additional options.
-
ignoredSlots
@NotNull public @NotNull RyseInventory.Builder ignoredSlots(@NotNull @NotNull List<Integer> slots, @NotNull @NotNull Consumer<org.bukkit.event.inventory.InventoryClickEvent> event) In all these slots items can be taken or added by the player. However, you can now add your own logic.- Parameters:
slots- The slotsevent- Your event with your own logic when the item is clicked.- Returns:
- The Inventory Builder to set additional options.
-
ignoredSlots
@NotNull public @NotNull RyseInventory.Builder ignoredSlots(@NotNull @NotNull BooleanSupplier condition, @NotNull @NotNull List<Integer> slots, @NotNull @NotNull Consumer<org.bukkit.event.inventory.InventoryClickEvent> event) In all these slots items can be taken or added by the player. However, you can now add your own logic.- Parameters:
condition- The condition must return true for the slots to be ignored.slots- The slotsevent- Your event with your own logic when the item is clicked.- Returns:
- The Inventory Builder to set additional options.
-
ignoredSlots
In all these slots items can be put in or removed by the user.- Parameters:
slots- The slots- Returns:
- The Inventory Builder to set additional options.
-
ignoredSlots
@NotNull public @NotNull RyseInventory.Builder ignoredSlots(@NotNull @NotNull BooleanSupplier condition, int... slots) In all these slots items can be put in or removed by the user.- Parameters:
slots- The slotscondition- The condition must return true for the slots to be ignored.- Returns:
- The Inventory Builder to set additional options.
-
options
Settings to help ensure that the player is not disturbed while he has the inventory open.- Parameters:
options- All setting options for the inventory- Returns:
- The Inventory Builder to set additional options.
-
closeAfter
@NotNull public @NotNull RyseInventory.Builder closeAfter(@Nonnegative int time, @Nullable @Nullable TimeSetting setting) With this method you can automatically set when to close the inventory.- Parameters:
time- Timesetting- Set your own time type.- Returns:
- The Inventory Builder to set additional options.
-
close
Here you can set possible reasons to automatically close the inventory when the reason takes place.- Parameters:
reasons- The reason to close the inventory.- Returns:
- The Inventory Builder to set additional options.
-
loadDelay
@NotNull public @NotNull RyseInventory.Builder loadDelay(@Nonnegative int time, @Nullable @Nullable TimeSetting setting) With this method, the content of the inventory is loaded later.- Parameters:
time- Timesetting- Set your own time type.- Returns:
- The Inventory Builder to set additional options.
-
loadTitle
@NotNull public @NotNull RyseInventory.Builder loadTitle(@Nonnegative int time, @Nullable @Nullable TimeSetting setting) With this method the title will be loaded later.- Parameters:
time- Timesetting- Set your own time type.- Returns:
- The Inventory Builder to set additional options.
-
type
Modifies the inventory type.- Parameters:
type- What type of inventory should it be.- Returns:
- The Inventory Builder to set additional options.
By default, the type is CHEST
-
enableAction
@NotNull public @NotNull RyseInventory.Builder enableAction(@NotNull @NotNull BooleanSupplier condition, Action @NotNull ... actions) This allows to get more control over the InventoryAction. E.g. you can say that DOUBLE_CLICK as well as MOVE_TO_OTHER_INVENTORY should be activated and thereby the InventoryClickEvent is not canceled.- Parameters:
actions- The actionscondition- The condition must return true for the action to be activated.- Returns:
- The Inventory Builder to set additional options.
-
enableAction
This allows to get more control over the InventoryAction. E.g. you can say that DOUBLE_CLICK as well as MOVE_TO_OTHER_INVENTORY should be activated and thereby the InventoryClickEvent is not canceled.- Parameters:
actions- The actions- Returns:
- The Inventory Builder to set additional options.
-
clearAndSafe
When the inventory is opened, the inventory is emptied and saved. When closing the inventory, the inventory will be reloaded.- Returns:
- The Inventory Builder to set additional options.
By default, the inventory is not emptied and saved.
-
size
@NotNull public @NotNull RyseInventory.Builder size(@Nonnegative int size) throws IllegalArgumentException - Parameters:
size- The inventory size- Returns:
- The Inventory Builder to set additional options.
- Throws:
IllegalArgumentException- if size is smaller than 9 or larger than 54.
-
identifier
Gives the inventory an identification- Parameters:
identifier- The ID through which you can get the inventory- Returns:
- The Inventory Builder to set additional options.
-
provider
@NotNull public @NotNull RyseInventory.Builder provider(@NotNull @NotNull InventoryProvider provider) The provider to fill the inventory with content.- Parameters:
provider- Implement with new InventoryProvider()- Returns:
- The Inventory Builder to set additional options.
-
preventClose
This method can be used to prevent the player from closing the inventory.- Returns:
- The Inventory Builder to set additional options.
The inventory is always closable by default.
-
preventTransferData
The method can be used so that data is not transferred to the next page as well.- Returns:
- The Inventory Builder to set additional options.
The data is always transferred by default.
-
ignoreManualItems
If this method is called, all items that the player can set himself will not be saved.- Returns:
- The Inventory Builder to set additional options.
-
delay
@NotNull public @NotNull RyseInventory.Builder delay(@Nonnegative int time, @Nullable @Nullable TimeSetting setting) Adjusts the delay of the scheduler.- Parameters:
time- Timesetting- Set your own time type.- Returns:
- The Inventory Builder to set additional options.
-
openDelay
@NotNull public @NotNull RyseInventory.Builder openDelay(@Nonnegative int time, @Nullable @Nullable TimeSetting setting) Adjusts the delay before the inventory is opened.- Parameters:
time- Timesetting- Set your own time type.- Returns:
- The Inventory Builder to set additional options.
-
period
@NotNull public @NotNull RyseInventory.Builder period(@Nonnegative int time, @Nullable @Nullable TimeSetting setting) Adjusts the period of the scheduler.- Parameters:
time- Timesetting- Set your own time type.- Returns:
- The Inventory Builder to set additional options.
-
rows
@NotNull public @NotNull RyseInventory.Builder rows(@Nonnegative int rows) throws IllegalArgumentException If you do not have a size but a row, you can also create an inventory by doing this. This number of rows is used for each page.- Parameters:
rows- The row- Returns:
- The Inventory Builder to set additional options.
- Throws:
IllegalArgumentException- if rows greater than 6If you had to create an inventory with 1 row, do not pass 0 but 1. Also applies to multiple rows.
If this method is used, the methodrows(Page)is ignored.
-
rows
Add to a page the rows you want.- Parameters:
page- The page- Returns:
- The Inventory Builder to set additional options.
-
rows
Add to a page the rows you want.- Parameters:
pages- The pages- Returns:
- The Inventory Builder to set additional options.
-
title
Assigns a fixed title to the inventory- Parameters:
title- The title- Returns:
- The Inventory Builder to set additional options.
The title can also be changed later when the inventory is open.
-
title
@NotNull public @NotNull RyseInventory.Builder title(@NotNull @NotNull net.kyori.adventure.text.Component title) Assigns a fixed title to the inventory- Parameters:
title- The title- Returns:
- The Inventory Builder to set additional options.
The title can also be changed later when the inventory is open.
-
animation
@NotNull public @NotNull RyseInventory.Builder animation(@NotNull @NotNull SlideAnimation animation) Based on this animation, the items can appear animated when opening the inventory.- Parameters:
animation-SlideAnimation.builder(Plugin)- Returns:
- The Inventory Builder to set additional options.
-
titleHolder
Adds a temporary title to the inventory.- Parameters:
title- The temp title- Returns:
- The Inventory Builder to set additional options.
This title is used when the
loadTitle(int, TimeSetting)method is used.
-
titleHolder
@NotNull public @NotNull RyseInventory.Builder titleHolder(@NotNull @NotNull net.kyori.adventure.text.Component title) Adds a temporary title to the inventory.- Parameters:
title- The temp title- Returns:
- The Inventory Builder to set additional options.
This title is used when the
loadTitle(int, TimeSetting)method is used.
-
listener
@NotNull public @NotNull RyseInventory.Builder listener(@NotNull @NotNull EventCreator<? extends org.bukkit.event.Event> event) Adds its own event to the inventory.- Parameters:
event- What kind of event- Returns:
- The Inventory Builder to set additional options.
-
ignoreClickEvent
@NotNull public @NotNull RyseInventory.Builder ignoreClickEvent(DisabledInventoryClick @NotNull ... clicks) Set what should be ignored in the InventoryClickEvent.- Parameters:
clicks- What should be ignored- Returns:
- The Inventory Builder to set additional options.
-
ignoreEvents
Disables events according to wishes.- Parameters:
events- The events- Returns:
- The Inventory Builder to set additional options.
-
fixedPageSize
Sets a page number. These pages can be opened at any time independently of the item.- Parameters:
page- The page number- Returns:
- The Inventory Builder to set additional options.
-
build
@NotNull public @NotNull RyseInventory build(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @Nullable @Nullable InventoryManager defaultManager) throws IllegalStateException Builds the RyseInventory- Parameters:
plugin- Instance to your main class.defaultManager- The default manager if the player does not have a custom manager.- Returns:
- the RyseInventory
- Throws:
IllegalStateException- if manager is null or if the provider is null
-
build
@NotNull public @NotNull RyseInventory build(@NotNull @NotNull org.bukkit.plugin.Plugin plugin) throws IllegalStateException Builds the RyseInventory- Parameters:
plugin- Instance to your main class.- Returns:
- the RyseInventory
- Throws:
IllegalStateException- if manager is null or if the provider is null
-