This repository was archived by the owner on Dec 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathPaperEnvironment.java
63 lines (55 loc) · 2.51 KB
/
PaperEnvironment.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package io.papermc.lib.environments;
import io.papermc.lib.features.asyncchunks.AsyncChunksPaper_13;
import io.papermc.lib.features.asyncchunks.AsyncChunksPaper_15;
import io.papermc.lib.features.asyncchunks.AsyncChunksPaper_9_12;
import io.papermc.lib.features.asyncteleport.AsyncTeleportPaper;
import io.papermc.lib.features.asyncteleport.AsyncTeleportPaper_13;
import io.papermc.lib.features.bedspawnlocation.BedSpawnLocationPaper;
import io.papermc.lib.features.blockstatesnapshot.BlockStateSnapshotOptionalSnapshots;
import io.papermc.lib.features.chunkisgenerated.ChunkIsGeneratedApiExists;
import io.papermc.lib.features.offlineplayers.GetOfflinePlayerPaper;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.HumanEntity;
public class PaperEnvironment extends SpigotEnvironment {
public PaperEnvironment() {
super();
if (isVersion(13, 1)) {
asyncChunksHandler = new AsyncChunksPaper_13();
asyncTeleportHandler = new AsyncTeleportPaper_13();
} else if (isVersion(9) && !isVersion(13)) {
asyncChunksHandler = new AsyncChunksPaper_9_12();
asyncTeleportHandler = new AsyncTeleportPaper();
}
if (isVersion(12)) {
// Paper added this API in 1.12 with same signature spigot did in 1.13
isGeneratedHandler = new ChunkIsGeneratedApiExists();
blockStateSnapshotHandler = new BlockStateSnapshotOptionalSnapshots();
}
if (isVersion(15, 2)) {
try {
// Try for new Urgent API in 1.15.2+, Teleport will automatically benefit from this
World.class.getDeclaredMethod("getChunkAtAsyncUrgently", Location.class);
asyncChunksHandler = new AsyncChunksPaper_15();
HumanEntity.class.getDeclaredMethod("getPotentialBedLocation");
bedSpawnLocationHandler = new BedSpawnLocationPaper();
} catch (NoSuchMethodException ignored) {}
}
if (isVersion(16, 4)) {
try {
// Check for the new "getOfflinePlayerIfCached" method which was added in Paper API 1.16.4+
Server.class.getDeclaredMethod("getOfflinePlayerIfCached", String.class);
getOfflinePlayerHandler = new GetOfflinePlayerPaper();
} catch(NoSuchMethodException ignored) {}
}
}
@Override
public String getName() {
return "Paper";
}
@Override
public boolean isPaper() {
return true;
}
}