Package net.minecraftforge.common.ticket
Class SimpleTicket<T>
- java.lang.Object
-
- net.minecraftforge.common.ticket.SimpleTicket<T>
-
- Type Parameters:
T
- The type that will be used to check if your ticket matches
- Direct Known Subclasses:
AABBTicket
public abstract class SimpleTicket<T> extends java.lang.Object
Common class for a simple ticket based system.
-
-
Field Summary
Fields Modifier and Type Field Description private ITicketManager<T>[]
dummyManagers
protected boolean
isValid
private ITicketManager<T>
masterManager
-
Constructor Summary
Constructors Constructor Description SimpleTicket()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
forEachManager(java.util.function.Consumer<ITicketManager<T>> consumer)
protected ITicketManager<T>[]
getDummyManagers()
protected ITicketManager<T>
getMasterManager()
void
invalidate()
Removes the ticket from the managing system.boolean
isValid()
Checks if your ticket is still registered in the system.abstract boolean
matches(T toMatch)
void
setManager(ITicketManager<T> masterManager, ITicketManager<T>... dummyManagers)
Internal method that sets the collection from the managing system.boolean
unload(ITicketManager<T> unloadingManager)
Called by the managing system when a ticket wishes to unload all of it's tickets, e.g.void
validate()
Re-adds your ticket to the system.
-
-
-
Field Detail
-
masterManager
@Nullable private ITicketManager<T> masterManager
-
dummyManagers
private ITicketManager<T>[] dummyManagers
-
isValid
protected boolean isValid
-
-
Method Detail
-
setManager
@SafeVarargs public final void setManager(@Nonnull ITicketManager<T> masterManager, @Nonnull ITicketManager<T>... dummyManagers)
Internal method that sets the collection from the managing system.
Should not be called if you just want to register a ticket to a system like theFarmlandWaterManager
-
isValid
public boolean isValid()
Checks if your ticket is still registered in the system.
-
invalidate
public void invalidate()
Removes the ticket from the managing system. After this call, any calls toisValid()
should return false unless it is registered again usingvalidate()
-
unload
public boolean unload(ITicketManager<T> unloadingManager)
Called by the managing system when a ticket wishes to unload all of it's tickets, e.g. on chunk unload
The ticket must not remove itself from the manager that is calling the unload! The ticket must ensure that it removes itself from all of it's dummies when returning true- Parameters:
unloadingManager
- The manager that is unloading this ticket- Returns:
- true if this ticket can be removed, false if not.
-
validate
public void validate()
Re-adds your ticket to the system.
-
matches
public abstract boolean matches(T toMatch)
-
forEachManager
protected final void forEachManager(java.util.function.Consumer<ITicketManager<T>> consumer)
-
getMasterManager
protected final ITicketManager<T> getMasterManager()
-
getDummyManagers
protected final ITicketManager<T>[] getDummyManagers()
-
-