|
24 | 24 | package com.georgev22.particle.utils; |
25 | 25 |
|
26 | 26 | import com.georgev22.particle.ParticleConstants; |
27 | | -import org.bukkit.Bukkit; |
28 | 27 | import org.bukkit.Location; |
29 | 28 | import org.bukkit.entity.Entity; |
30 | 29 | import org.bukkit.entity.Player; |
@@ -95,11 +94,13 @@ public final class ReflectionUtils { |
95 | 94 | private static Plugin plugin; |
96 | 95 |
|
97 | 96 | static { |
98 | | - String serverPath = Bukkit.getServer().getClass().getPackage().getName(); |
99 | | - String version = serverPath.substring(serverPath.lastIndexOf(".") + 1); |
100 | 97 | MINECRAFT_VERSION = MinecraftVersion.getCurrentVersion(); |
| 98 | + String version = MinecraftVersion.getCurrentVersionNameVtoLowerCase(); |
101 | 99 | NET_MINECRAFT_SERVER_PACKAGE_PATH = "net.minecraft" + (MINECRAFT_VERSION.isBelow(MinecraftVersion.V1_17_R1) ? ".server." + version : ""); |
102 | | - CRAFT_BUKKIT_PACKAGE_PATH = MINECRAFT_VERSION.isAbove(MinecraftVersion.V1_20_R3) ? "org.bukkit.craftbukkit" : "org.bukkit.craftbukkit." + version; |
| 100 | + CRAFT_BUKKIT_PACKAGE_PATH = |
| 101 | + MINECRAFT_VERSION.isAbove(MinecraftVersion.V1_20_R3) && isPaper() |
| 102 | + ? "org.bukkit.craftbukkit" |
| 103 | + : "org.bukkit.craftbukkit." + version; |
103 | 104 | plugin = readDeclaredField(PLUGIN_CLASS_LOADER_PLUGIN_FIELD, ReflectionUtils.class.getClassLoader()); |
104 | 105 | PLAYER_CONNECTION_CACHE = new PlayerConnectionCache(); |
105 | 106 | try { |
@@ -556,4 +557,19 @@ public static InputStream getResourceStreamSafe(String resource) { |
556 | 557 | } |
557 | 558 | } |
558 | 559 |
|
| 560 | + public static boolean isPaper() { |
| 561 | + try { |
| 562 | + Class.forName("com.destroystokyo.paper.PaperConfig"); |
| 563 | + return true; |
| 564 | + } catch (ClassNotFoundException ignored) { |
| 565 | + } |
| 566 | + try { |
| 567 | + Class.forName("io.papermc.paper.configuration.Configuration"); |
| 568 | + return true; |
| 569 | + } catch (ClassNotFoundException ignored) { |
| 570 | + } |
| 571 | + |
| 572 | + return false; |
| 573 | + } |
| 574 | + |
559 | 575 | } |
0 commit comments