From 305664e9ea3d1328025fef2f995ca646d3e9e10b Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 29 Mar 2022 12:29:19 +0200 Subject: [PATCH] Fix build --- .../bausystem/utils/NMSWrapper15.java | 12 +++++ .../bausystem/utils/NMSWrapper18.java | 12 +++++ BauSystem_Main/build.gradle | 5 +- .../features/observer/ObserverTracer.java | 5 +- .../features/other/NoClipCommand.java | 4 +- .../slaves/laufbau/BlockBoundingBox.java | 2 +- .../boundingboxes/WallBoundingBox.java | 46 +++++++++++++++++++ .../features/tpslimit/FreezeUtils.java | 10 ++-- .../tracer/show/mode/ParticleShowMode.java | 4 +- .../bausystem/features/world/SignEdit.java | 2 +- .../steamwar/bausystem/utils/NMSWrapper.java | 4 ++ 11 files changed, 92 insertions(+), 14 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java index 651010b7..a5d430b5 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java @@ -32,6 +32,7 @@ import de.steamwar.bausystem.entities.WarpEntity15; import net.minecraft.server.v1_15_R1.*; import org.bukkit.Bukkit; import org.bukkit.GameMode; +import org.bukkit.Particle; import org.bukkit.World; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; @@ -91,6 +92,17 @@ public class NMSWrapper15 implements NMSWrapper.INMSWrapper { gameStateChangeReason.set(packet, 3); } + @Override + public void setPlayerBuildAbilities(Player player) { + ((CraftPlayer) player).getHandle().abilities.mayBuild = true; + ((CraftPlayer) player).getHandle().abilities.canInstantlyBuild = true; + } + + @Override + public Particle tntPositionParticle() { + return Particle.BARRIER; + } + private static final int threshold = 2048; @Override public boolean checkItemStack(ItemStack item) { diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java index 7d99946a..10b01d26 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java @@ -44,6 +44,7 @@ import net.minecraft.world.level.EnumGamemode; import net.minecraft.world.phys.Vec3D; import org.bukkit.Bukkit; import org.bukkit.GameMode; +import org.bukkit.Particle; import org.bukkit.World; import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; @@ -103,6 +104,17 @@ public class NMSWrapper18 implements NMSWrapper.INMSWrapper { gameStateChangeReason.set(packet, PacketPlayOutGameStateChange.d); } + @Override + public void setPlayerBuildAbilities(Player player) { + ((CraftPlayer) player).getHandle().fr().d = true; + ((CraftPlayer) player).getHandle().fr().e = true; + } + + @Override + public Particle tntPositionParticle() { + return Particle.BLOCK_MARKER; + } + private static final int threshold = 2048; @Override public boolean checkItemStack(ItemStack item) { diff --git a/BauSystem_Main/build.gradle b/BauSystem_Main/build.gradle index 5027460c..2b8f7a6e 100644 --- a/BauSystem_Main/build.gradle +++ b/BauSystem_Main/build.gradle @@ -56,7 +56,10 @@ dependencies { annotationProcessor 'org.atteo.classindex:classindex:3.11' testAnnotationProcessor 'org.atteo.classindex:classindex:3.11' - compileOnly files("${projectDir}/../lib/Spigot-1.15.jar") + compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT' + compileOnly files("${projectDir}/../lib/Spigot-1.18.jar") + compileOnly 'com.mojang:authlib:1.5.25' + compileOnly 'io.netty:netty-all:4.1.68.Final' compileOnly files("${projectDir}/../lib/WorldEdit-1.15.jar") compileOnly files("${projectDir}/../lib/SpigotCore.jar") } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java index a5b0bb4c..9f641e65 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracer.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.observer; +import com.comphenix.tinyprotocol.Reflection; import de.steamwar.bausystem.region.Point; import org.bukkit.Location; import org.bukkit.Material; @@ -29,7 +30,6 @@ import org.bukkit.block.data.Bisected; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.type.Observer; import org.bukkit.block.data.type.*; -import org.bukkit.craftbukkit.v1_15_R1.block.impl.CraftPoweredRail; import org.bukkit.entity.Player; import java.util.*; @@ -170,6 +170,7 @@ public class ObserverTracer { } } + private static final Class craftPoweredRail = Reflection.getClass("{obc}.block.impl.CraftPoweredRail"); private boolean checkAllowed(Block block, BlockData blockData) { if (checkMaterial(block)) return true; if (block.getType() == Material.BELL) { @@ -178,7 +179,7 @@ public class ObserverTracer { return blockData instanceof Door || blockData instanceof Gate - || blockData instanceof CraftPoweredRail + || craftPoweredRail.isInstance(blockData) || blockData instanceof TrapDoor || blockData instanceof GlassPane; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java index b5082dd8..d61df74e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java @@ -32,7 +32,6 @@ import de.steamwar.command.SWCommand; import de.steamwar.core.Core; import lombok.Getter; import org.bukkit.GameMode; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -106,8 +105,7 @@ public class NoClipCommand extends SWCommand implements Listener { player.setGameMode(GameMode.CREATIVE); } else { player.setGameMode(GameMode.SPECTATOR); - ((CraftPlayer) player).getHandle().abilities.mayBuild = true; - ((CraftPlayer) player).getHandle().abilities.canInstantlyBuild = true; + NMSWrapper.impl.setPlayerBuildAbilities(player); Object gameStateChangeObject = Reflection.newInstance(gameStateChange); NMSWrapper.impl.setGameStateChangeReason(gameStateChangeObject); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java index c4ccdefe..6c1257ad 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java @@ -86,7 +86,7 @@ public class BlockBoundingBox { addPixel(Material.AIR.createBlockData(), 0, 0, 0, 0, 0, 0, null); addPixel(Material.END_STONE.createBlockData(), 0, 0, 0, 16, 16, 16, null); - addPixel(Material.GRASS_PATH.createBlockData(), 0, 0, 0, 16, 15, 16, createItem("LAUFBAU_BLOCK_GRASS_PATH", Material.GRASS_PATH)); + addPixel(SWItem.getMaterial("GRASS_PATH").createBlockData(), 0, 0, 0, 16, 15, 16, createItem("LAUFBAU_BLOCK_GRASS_PATH", SWItem.getMaterial("GRASS_PATH"))); addPixel(Material.SOUL_SAND.createBlockData(), 0, 0, 0, 16, 14, 16, createItem("LAUFBAU_BLOCK_SOUL_SAND", Material.SOUL_SAND)); Cocoa cocoaNorth = (Cocoa) Material.COCOA.createBlockData(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java index a0bb9a0b..8f42dd98 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java @@ -24,9 +24,11 @@ import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.bausystem.linkage.Enable; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.core.Core; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.type.Fence; +import org.bukkit.block.data.type.Wall; import java.util.ArrayList; import java.util.List; @@ -39,6 +41,50 @@ public class WallBoundingBox implements Enable { @Override public void enable() { + if (Core.getVersion() > 15) { + v18(); + } else { + v15(); + } + } + + private void v18() { + for (int nx = 0; nx < 2; nx++) { + for (int nz = 0; nz < 2; nz++) { + for (int px = 0; px < 2; px++) { + for (int pz = 0; pz < 2; pz++) { + Wall fence = (Wall) Material.END_STONE_BRICK_WALL.createBlockData(); + List lore = new ArrayList<>(); + List cuboidList = new ArrayList<>(); + cuboidList.add(pixelCuboid(4, 0, 4, 8, 24, 8)); + if (nz == 1) { + lore.add("LAUFBAU_CONNECTION_NORTH"); + fence.setHeight(BlockFace.NORTH, Wall.Height.LOW); + cuboidList.add(pixelCuboid(5, 0, 0, 6, 24, 4)); + } + if (pz == 1) { + lore.add("LAUFBAU_CONNECTION_SOUTH"); + fence.setHeight(BlockFace.SOUTH, Wall.Height.LOW); + cuboidList.add(pixelCuboid(5, 0, 12, 6, 24, 4)); + } + if (nx == 1) { + lore.add("LAUFBAU_CONNECTION_WEST"); + fence.setHeight(BlockFace.WEST, Wall.Height.LOW); + cuboidList.add(pixelCuboid(0, 0, 5, 4, 24, 6)); + } + if (px == 1) { + lore.add("LAUFBAU_CONNECTION_EAST"); + fence.setHeight(BlockFace.EAST, Wall.Height.LOW); + cuboidList.add(pixelCuboid(12, 0, 5, 4, 24, 6)); + } + new BlockBoundingBox(fence, cuboidList, createItem("LAUFBAU_BLOCK_END_STONE_BRICK_WALL", Material.END_STONE_BRICK_WALL, lore.toArray(new String[0]))); + } + } + } + } + } + + private void v15() { for (int nx = 0; nx < 2; nx++) { for (int nz = 0; nz < 2; nz++) { for (int px = 0; px < 2; px++) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/FreezeUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/FreezeUtils.java index e0d5804d..18679323 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/FreezeUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/FreezeUtils.java @@ -19,12 +19,11 @@ package de.steamwar.bausystem.features.tpslimit; +import com.comphenix.tinyprotocol.Reflection; import lombok.Getter; import lombok.experimental.UtilityClass; -import net.minecraft.server.v1_15_R1.WorldServer; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; import yapion.utils.ReflectionsUtils; import java.lang.reflect.Field; @@ -35,13 +34,16 @@ public class FreezeUtils { private static final Field field; public static final boolean freezeEnabled; + private static final Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle", null); + @Getter private static boolean frozen = false; private static final World world; static { - field = ReflectionsUtils.getField(WorldServer.class, "freezed"); + + field = ReflectionsUtils.getField(Reflection.getClass("{nms.server.level}.WorldServer"), "freezed"); if (field != null) field.setAccessible(true); freezeEnabled = field != null; world = Bukkit.getWorlds().get(0); @@ -62,7 +64,7 @@ public class FreezeUtils { private void setFreeze(World world, boolean state) { if (freezeEnabled) { try { - field.set(((CraftWorld) world).getHandle(), state); + field.set(getWorldHandle.invoke(world), state); frozen = state; } catch (IllegalAccessException e) { // Ignored; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/ParticleShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/ParticleShowMode.java index 1d64acfd..d897b45c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/ParticleShowMode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/ParticleShowMode.java @@ -23,8 +23,8 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tracer.TNTPosition; import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; import de.steamwar.bausystem.shared.ShowMode; +import de.steamwar.bausystem.utils.NMSWrapper; import org.bukkit.Bukkit; -import org.bukkit.Particle; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; import org.bukkit.util.Vector; @@ -57,7 +57,7 @@ public class ParticleShowMode implements ShowMode { positionSet.add(position.getLocation()); if (bukkitTask == null) { bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { - positionSet.forEach(p -> player.spawnParticle(Particle.BARRIER, p.toLocation(player.getWorld()), 1, 0, 0, 0, 0)); + positionSet.forEach(p -> player.spawnParticle(NMSWrapper.impl.tntPositionParticle(), p.toLocation(player.getWorld()), 1, 0, 0, 0, 0)); }, 40L, 40L); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java index e7431347..e59c870e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java @@ -40,7 +40,7 @@ import org.bukkit.event.player.PlayerInteractEvent; public class SignEdit implements Listener { private static final Class blockPosition = Reflection.getClass("{nms.core}.BlockPosition"); - private static final Class craftBlock = Reflection.getClass("{obc}.CraftBlock"); + private static final Class craftBlock = Reflection.getClass("{obc}.block.CraftBlock"); private static final Class craftWorld = Reflection.getClass("{obc}.CraftWorld"); private static final Class generatorAccess = Reflection.getClass("{nms.world.level}.GeneratorAccess"); private static final Reflection.MethodInvoker getPosition = Reflection.getTypedMethod(craftBlock, "getPosition", blockPosition); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java index fda7a934..00dd5294 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java @@ -26,6 +26,7 @@ import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; import de.steamwar.bausystem.features.warp.AbstractWarpEntity; import de.steamwar.core.VersionDependent; import org.bukkit.GameMode; +import org.bukkit.Particle; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -46,6 +47,9 @@ public class NMSWrapper { void sendTickPackets(); void setGameStateChangeReason(Object packet); + void setPlayerBuildAbilities(Player player); + + Particle tntPositionParticle(); boolean checkItemStack(ItemStack item);