Skip to content

Commit

Permalink
Changed ServerVersion as 1.20.6+ removed package nms
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigerpanzer02 committed Jul 12, 2024
1 parent 9b6d97d commit 7e7a718
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repositories {
}

dependencies {
implementation("plugily.projects:MiniGamesBox-Classic:1.3.12") { isTransitive = false }
implementation("plugily.projects:MiniGamesBox-Classic:1.3.13") { isTransitive = false }
compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("net.citizensnpcs:citizensapi:2.0.31-SNAPSHOT")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void onNPCClick(PlugilyPlayerInteractEntityEvent event) {
if(playerPlot != null) {

// Prevent "Legacy material support initialisation"
playerPlot.changeFloor(material, ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_12_R1) ? hand.getData().getData() : 0);
playerPlot.changeFloor(material, ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_12) ? hand.getData().getData() : 0);
new MessageBuilder("MENU_OPTION_CONTENT_FLOOR_CHANGED").asKey().player(event.getPlayer()).sendPlayer();
}
}
Expand Down Expand Up @@ -340,7 +340,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
plot.addEntity();
event.setCancelled(false);

if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) {
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9)) {
event.getEntity().setAI(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public boolean additionalValidatorChecks(ConfigurationSection section, PluginAre
World minWorld = minPoint.getWorld();

if(minWorld != null) {
Biome biome = ServerVersion.Version.isCurrentHigher(ServerVersion.Version.v1_15_R1) ?
Biome biome = ServerVersion.Version.isCurrentHigher(ServerVersion.Version.v1_15) ?
minWorld.getBiome(minPoint.getBlockX(), minPoint.getBlockY(), minPoint.getBlockZ())
: minWorld.getBiome(minPoint.getBlockX(), minPoint.getBlockZ());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void resetPlot() {
}

for(Chunk chunk : cuboid.chunkList()) {
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_15_R1)) {
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_15)) {
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
continue;
}
Expand All @@ -235,7 +235,7 @@ public void resetPlot() {
changeFloor(defaultFloor.parseMaterial());

if(centerWorld != null) {
if(ServerVersion.Version.isCurrentHigher(ServerVersion.Version.v1_15_R1)) {
if(ServerVersion.Version.isCurrentHigher(ServerVersion.Version.v1_15)) {
Location min = cuboid.getMinPoint();
Location max = cuboid.getMaxPoint();

Expand Down Expand Up @@ -307,7 +307,7 @@ public void changeFloor(Material material, byte data) {
Block block = maxWorld.getBlockAt(x, y, z);
block.setType(material);

if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_12_R1)) {
if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_12)) {
try {
Block.class.getMethod("setData", byte.class).invoke(block, data);
} catch(Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public ItemStack buildBanner() {
ItemStack item = XMaterial.WHITE_BANNER.parseItem();
BannerMeta meta = (BannerMeta) item.getItemMeta();

if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_12_R1)) {
if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_12)) {
meta.setBaseColor(color);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void prepareBaseStageGui() {
for(DyeColor color : DyeColor.values()) {
ItemStack item;

if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_12_R1)) {
if(ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_12)) {
item = XMaterial.WHITE_BANNER.parseItem();
BannerMeta meta = (BannerMeta) item.getItemMeta();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void onClick(InventoryClickEvent event) {
}

for(Chunk chunk : plot.getCuboid().chunkList()) {
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_15_R1)) {
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_15)) {
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public class ChunkManager {
private static Constructor<?> mapChunkConstructor;

static {
if (ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_18_R1)) {
if (ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_18)) {
packetPlayOutMapChunk = PacketUtils.classByName("net.minecraft.network.protocol.game", "PacketPlayOutMapChunk");
chunkClass = PacketUtils.classByName("net.minecraft.world.level.chunk", "Chunk");

if (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_17_R1)) {
if (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_17)) {
try {
mapChunkConstructor = packetPlayOutMapChunk.getConstructor(PacketUtils.classByName("net.minecraft.world.level.chunk", "LevelChunk"));
} catch (NoSuchMethodException e) {
Expand All @@ -58,26 +58,26 @@ public class ChunkManager {
}

public static void sendMapChunk(Player player, Chunk chunk) {
if (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_18_R1)) {
if (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_18)) {
return; // Should just use World#refreshChunk instead
}

try {
Method chunkHandleMethod = chunk.getClass().getMethod("getHandle");
if (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_17_R1)) {
if (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_17)) {
PacketUtils.sendPacket(player, mapChunkConstructor.newInstance(chunkHandleMethod.invoke(chunk)));
return;
}

if (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16_R1)) {
if (ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16)) {
if (mapChunkConstructor == null)
mapChunkConstructor = packetPlayOutMapChunk.getConstructor(chunkClass, int.class, boolean.class);

PacketUtils.sendPacket(player, mapChunkConstructor.newInstance(chunkHandleMethod.invoke(chunk), 65535, false));
return;
}

if (ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_10_R2)) {
if (ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_10)) {
if (mapChunkConstructor == null)
mapChunkConstructor = packetPlayOutMapChunk.getConstructor(chunkClass, boolean.class, int.class);

Expand Down

0 comments on commit 7e7a718

Please sign in to comment.