Class ContainerSpec.Builder
java.lang.Object
com.ultikits.ultitools.ui.ContainerSpec.Builder
- Enclosing class:
ContainerSpec
Reusable builder. The last initial/baseline selection wins.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<org.bukkit.inventory.ItemStack> private Durationprivate @Nullable UUIDprivate @Nullable Dispositionprivate booleanprivate List<org.bukkit.inventory.ItemStack> private final ContainerKindprivate Consumer<ContainerChange> private TransferPolicyprivate final intprivate @Nullable ContainerStoreprivate @Nullable UndeliveredHandler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionInitial contents that are the baseline (for example read from storage); not owed to anyone.build()commitTimeout(Duration timeout) Default 30 s; positive, at most 10 minutes.disposition(Disposition disposition) Required for storage; rejected for template.private List<org.bukkit.inventory.ItemStack> endWhenUnviewed(boolean end) Default true: the container ends as soon as no session shows it any more, whatever the reason: the last showing session closes (in that session's close step, after its screen closes and before its result completes), orGridSession.update(Grid)gives every showing session a snapshot that no longer binds it.Initial contents, counted as put in bycontributor(the RETURN disposition gives them back to them).onChange(Consumer<ContainerChange> listener) Called after each applied transfer, on the container's thread; exceptions are logged and swallowed.policy(TransferPolicy policy) DefaultTransferPolicy.allowAll().private List<org.bukkit.inventory.ItemStack> store(ContainerStore store) Required when the disposition is COMMIT; rejected otherwise.undelivered(UndeliveredHandler handler) Required for storage (items owed to a player who cannot receive them).private voidvalidate()private voidprivate void
-
Field Details
-
kind
-
size
private final int size -
policy
-
disposition
-
store
-
commitTimeout
-
undelivered
-
endWhenUnviewed
private boolean endWhenUnviewed -
onChange
-
contributor
-
initial
-
baseline
-
-
Constructor Details
-
Builder
-
-
Method Details
-
emptyContents
-
policy
DefaultTransferPolicy.allowAll(). -
disposition
Required for storage; rejected for template. -
store
Required when the disposition is COMMIT; rejected otherwise. EnablesSlotContainer.commit(). -
commitTimeout
Default 30 s; positive, at most 10 minutes. A store answer later than this counts as Unknown. -
undelivered
Required for storage (items owed to a player who cannot receive them). -
endWhenUnviewed
Default true: the container ends as soon as no session shows it any more, whatever the reason: the last showing session closes (in that session's close step, after its screen closes and before its result completes), orGridSession.update(Grid)gives every showing session a snapshot that no longer binds it. Showing another grid that binds the same container hands it over without ending it; paging within the same container never ends it. Opening any intent that does not bind it (a Confirm, a Form, another grid) for its last viewer ends it, so a module that opens sub-screens over a container and comes back builds it withendWhenUnviewed(false)and callsSlotContainer.end()orSlotContainer.drain()itself. A container that was never shown does not end this way. -
onChange
Called after each applied transfer, on the container's thread; exceptions are logged and swallowed. -
initial
public ContainerSpec.Builder initial(UUID contributor, List<org.bukkit.inventory.ItemStack> contents) Initial contents, counted as put in bycontributor(the RETURN disposition gives them back to them). Storage only: a template rejects it atbuild(). -
baseline
Initial contents that are the baseline (for example read from storage); not owed to anyone. -
sizedCopy
-
validate
private void validate() -
validateTemplate
private void validateTemplate() -
validateStorage
private void validateStorage() -
build
- Throws:
IllegalArgumentException- on a missing required or a forbidden attribute: storage without a disposition or an undelivered handler, COMMIT without a store, a store with any other disposition, or a template with a disposition, a store, an undelivered handler or contributed initial contents
-