Folia scheduler and owned region API

Pulling Folia API to Paper is primarily intended for plugins
that want to target both Paper and Folia without unnecessary
compatibility layers.

Add both a location based scheduler, an entity based scheduler,
and a global region scheduler.

Owned region API may be useful for plugins which want to perform
operations over large areas outside of the buffer zone provided
by the regionaliser, as it is not guaranteed that anything
outside of the buffer zone is owned. Then, the plugins may use
the schedulers depending on the result of the ownership check.
This commit is contained in:
Spottedleaf
2023-06-17 11:52:52 +02:00
parent 31871f6b40
commit a13bff4a5f
11 changed files with 1374 additions and 135 deletions

View File

@@ -71,6 +71,15 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
private EntityDamageEvent lastDamageEvent;
private final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftEntity.DATA_TYPE_REGISTRY);
protected net.kyori.adventure.pointer.Pointers adventure$pointers; // Paper - implement pointers
// Paper start - Folia shedulers
public final io.papermc.paper.threadedregions.EntityScheduler taskScheduler = new io.papermc.paper.threadedregions.EntityScheduler(this);
private final io.papermc.paper.threadedregions.scheduler.FoliaEntityScheduler apiScheduler = new io.papermc.paper.threadedregions.scheduler.FoliaEntityScheduler(this);
@Override
public final io.papermc.paper.threadedregions.scheduler.EntityScheduler getScheduler() {
return this.apiScheduler;
};
// Paper end - Folia schedulers
public CraftEntity(final CraftServer server, final Entity entity) {
this.server = server;
@@ -487,6 +496,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return this.entity;
}
// Paper start
public Entity getHandleRaw() {
return this.entity;
}
// Paper end
@Override
public final EntityType getType() {
return this.entityType;