mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-29 23:17:59 +02:00
Improve Tickable interface
This commit is contained in:
parent
3ecace5bd6
commit
28be690937
@ -1,7 +1,54 @@
|
||||
package net.minestom.server;
|
||||
|
||||
import net.minestom.server.utils.time.UpdateOption;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Represents an element which is ticked at a regular interval.
|
||||
* <p>
|
||||
* Each tickable element can also be a container for multiple elements using {@link #getTickableElements()}.
|
||||
*/
|
||||
public interface Tickable {
|
||||
|
||||
/**
|
||||
* Ticks this element if {@link #getTickRate()} allows it.
|
||||
* <p>
|
||||
* Will execute this same method for every elements inside {@link #getTickableElements()}.
|
||||
*
|
||||
* @param time the time of the tick in milliseconds
|
||||
*/
|
||||
void tick(long time);
|
||||
|
||||
/**
|
||||
* Gets all the tickable elements linked to this.
|
||||
*
|
||||
* @return a modifiable {@link Collection} containing the linked tickable elements
|
||||
*/
|
||||
@NotNull
|
||||
Collection<Tickable> getTickableElements();
|
||||
|
||||
/**
|
||||
* Gets the current tick rate of this element
|
||||
*
|
||||
* @return the current tick rate
|
||||
*/
|
||||
@NotNull
|
||||
UpdateOption getTickRate();
|
||||
|
||||
/**
|
||||
* Changes the tick rate of this element.
|
||||
*
|
||||
* @param updateOption the new tick rate
|
||||
*/
|
||||
void setTickRate(@NotNull UpdateOption updateOption);
|
||||
|
||||
/**
|
||||
* Gets the last time this element has been ticked.
|
||||
*
|
||||
* @return the last tick time in milliseconds
|
||||
*/
|
||||
long getLastTickTime();
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user