diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java index 91a9d650..a4e32c8b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java @@ -155,7 +155,6 @@ public class FreezeListener implements Listener, ScoreboardElement { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent e) { - if (Core.getVersion() < 19) return; if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return; if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { e.setCancelled(true); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/StorageLib.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/StorageLib.java index 04cde3f0..03e2cc41 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/StorageLib.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/StorageLib.java @@ -56,7 +56,6 @@ public class StorageLib implements LuaLib, Enable, Disable { @Override public void enable() { - if (Core.getVersion() <= 15) return; if (!storageDirectory.exists()) storageDirectory.mkdirs(); try { @@ -132,7 +131,6 @@ public class StorageLib implements LuaLib, Enable, Disable { @Override public void disable() { - if (Core.getVersion() <= 15) return; if (!storageDirectory.exists()) storageDirectory.mkdirs(); try { FileWriter fileWriter = new FileWriter(new File(storageDirectory, "global.json")); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorObserverPhaseSettingsGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorObserverPhaseSettingsGui.java index 16f036b0..2dd660bb 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorObserverPhaseSettingsGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorObserverPhaseSettingsGui.java @@ -26,7 +26,6 @@ import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement; import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; -import de.steamwar.core.Core; import de.steamwar.data.CMDs; import de.steamwar.inventory.SWItem; import org.bukkit.Material; @@ -128,15 +127,14 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); }).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED)); - Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR"); - SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> { + SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : Material.RECOVERY_COMPASS, "§eActivation Order§8:§7 " + order, clickType -> { new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> { if (integer < -SimulatorPhase.ORDER_LIMIT) return false; if (integer > SimulatorPhase.ORDER_LIMIT) return false; observer.setOrder(integer); SimulatorWatcher.update(simulator); return true; - }, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open(); + }, this).setItem(order >= 0 ? Material.COMPASS : Material.RECOVERY_COMPASS).open(); }); orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30))); inventory.setItem(22, orderItem); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java index cf7726bd..cf2c6aba 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java @@ -26,7 +26,6 @@ import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement; import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; -import de.steamwar.core.Core; import de.steamwar.data.CMDs; import de.steamwar.inventory.SWItem; import org.bukkit.Material; @@ -154,15 +153,14 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); }).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED)); - Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR"); - SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> { + SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : Material.RECOVERY_COMPASS, "§eActivation Order§8:§7 " + order, clickType -> { new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> { if (integer < -SimulatorPhase.ORDER_LIMIT) return false; if (integer > SimulatorPhase.ORDER_LIMIT) return false; redstone.setOrder(integer); SimulatorWatcher.update(simulator); return true; - }, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open(); + }, this).setItem(order >= 0 ? Material.COMPASS : Material.RECOVERY_COMPASS).open(); }); orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30))); inventory.setItem(22, orderItem); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTGui.java index 08d3628d..66367e83 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTGui.java @@ -102,16 +102,14 @@ public class SimulatorTNTGui extends SimulatorScrollGui { tnt.setDisabled(!tnt.isDisabled()); SimulatorWatcher.update(simulator); }).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED)); - if (Core.getVersion() > 19) { - inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> { - new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> { - if (depthLimit <= 0) return false; - simulator.setStabGenerator(new SimulatorStabGenerator(Region.getRegion(player.getLocation()), simulator, tnt, depthLimit)); - SimulatorWatcher.update(simulator); - return true; - }, null).open(); - }).setCustomModelData(CMDs.Simulator.CREATE_STAB)); - } + inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> { + new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> { + if (depthLimit <= 0) return false; + simulator.setStabGenerator(new SimulatorStabGenerator(Region.getRegion(player.getLocation()), simulator, tnt, depthLimit)); + SimulatorWatcher.update(simulator); + return true; + }, null).open(); + }).setCustomModelData(CMDs.Simulator.CREATE_STAB)); inventory.setItem(50, new SWItem(Material.CHEST, parent.getElements().size() == 1 ? "§eMake Group" : "§eAdd another TNT to Group", clickType -> { TNTElement tntElement = new TNTElement(tnt.getPosition().clone()); tntElement.add(new TNTPhase()); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTPhaseSettingsGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTPhaseSettingsGui.java index e66449fb..cc60da86 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTPhaseSettingsGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTPhaseSettingsGui.java @@ -26,7 +26,6 @@ import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement; import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; -import de.steamwar.core.Core; import de.steamwar.data.CMDs; import de.steamwar.inventory.SWItem; import org.bukkit.Material; @@ -159,15 +158,14 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); }).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED)); - Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR"); - SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eCalculation Order§8:§7 " + order, clickType -> { + SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : Material.RECOVERY_COMPASS, "§eCalculation Order§8:§7 " + order, clickType -> { new SimulatorAnvilGui<>(player, "Calculation Order", order + "", Integer::parseInt, integer -> { if (integer < -SimulatorPhase.ORDER_LIMIT) return false; if (integer > SimulatorPhase.ORDER_LIMIT) return false; tnt.setOrder(integer); SimulatorWatcher.update(simulator); return true; - }, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open(); + }, this).setItem(order >= 0 ? Material.COMPASS : Material.RECOVERY_COMPASS).open(); }); orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30))); inventory.setItem(22, orderItem); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java index 90b88f6c..4f1ef8ff 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/base/SimulatorBaseGui.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.simulator.gui.base; import de.steamwar.bausystem.features.simulator.SimulatorWatcher; import de.steamwar.bausystem.features.simulator.data.Simulator; -import de.steamwar.core.Core; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import org.bukkit.Bukkit; @@ -47,10 +46,7 @@ public abstract class SimulatorBaseGui { public final void open() { if (!shouldOpen()) return; - String newTitle = title(); - String originalTitle = player.getOpenInventory().getTitle(); - - if (inv != null && (Core.getVersion() > 19 || newTitle.equals(originalTitle))) { + if (inv != null) { // TODO: Flickering is better but not gone! for (int i = 9; i < size - 9; i++) { inv.setItem(i, null); @@ -60,9 +56,7 @@ public abstract class SimulatorBaseGui { inventory.open(); SimulatorWatcher.watch(player, simulator, this::open); } - if (Core.getVersion() > 19) { - player.getOpenInventory().setTitle(title()); - } + player.getOpenInventory().setTitle(title()); if (simulator != null && simulator.getStabGenerator() != null) { populateStabGenerator(); } else { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java index ee9d48f4..70c2d567 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java @@ -235,19 +235,17 @@ public class BlockBoundingBox { endRodEastWest.setFacing(BlockFace.EAST); addPixel(endRodEastWest, 0, 6, 6, 16, 4, 4, createItem("LAUFBAU_BLOCK_END_ROD", Material.END_ROD, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST")); - if (Core.getVersion() >= 19) { - Directional lightningRodBottomTop = (Directional) Material.LIGHTNING_ROD.createBlockData(); - lightningRodBottomTop.setFacing(BlockFace.UP); - addPixel(lightningRodBottomTop, 6, 0, 6, 4, 16, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_UP", "LAUFBAU_FACING_DOWN")); + Directional lightningRodBottomTop = (Directional) Material.LIGHTNING_ROD.createBlockData(); + lightningRodBottomTop.setFacing(BlockFace.UP); + addPixel(lightningRodBottomTop, 6, 0, 6, 4, 16, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_UP", "LAUFBAU_FACING_DOWN")); - Directional lightningRodNorthSouth = (Directional) Material.LIGHTNING_ROD.createBlockData(); - lightningRodNorthSouth.setFacing(BlockFace.NORTH); - addPixel(lightningRodNorthSouth, 6, 6, 0, 4, 4, 16, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH")); + Directional lightningRodNorthSouth = (Directional) Material.LIGHTNING_ROD.createBlockData(); + lightningRodNorthSouth.setFacing(BlockFace.NORTH); + addPixel(lightningRodNorthSouth, 6, 6, 0, 4, 4, 16, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_NORTH", "LAUFBAU_FACING_SOUTH")); - Directional lightningRodEastWest = (Directional) Material.LIGHTNING_ROD.createBlockData(); - lightningRodEastWest.setFacing(BlockFace.EAST); - addPixel(lightningRodEastWest, 0, 6, 6, 16, 4, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST")); - } + Directional lightningRodEastWest = (Directional) Material.LIGHTNING_ROD.createBlockData(); + lightningRodEastWest.setFacing(BlockFace.EAST); + addPixel(lightningRodEastWest, 0, 6, 6, 16, 4, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_EAST", "LAUFBAU_FACING_WEST")); Waterlogged conduit = (Waterlogged) Material.CONDUIT.createBlockData(); conduit.setWaterlogged(false); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java index f5ccb209..dffe873d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java @@ -22,11 +22,9 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.core.Core; import de.steamwar.linkage.Linked; 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; @@ -40,11 +38,7 @@ public class WallBoundingBox implements BoundingBoxLoader { @Override public void load() { - if (Core.getVersion() > 15) { - v18(); - } else { - v15(); - } + v18(); } private void v18() { @@ -82,40 +76,4 @@ public class WallBoundingBox implements BoundingBoxLoader { } } } - - private void v15() { - 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++) { - Fence fence = (Fence) 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.setFace(BlockFace.NORTH, true); - cuboidList.add(pixelCuboid(5, 0, 0, 6, 24, 4)); - } - if (pz == 1) { - lore.add("LAUFBAU_CONNECTION_SOUTH"); - fence.setFace(BlockFace.SOUTH, true); - cuboidList.add(pixelCuboid(5, 0, 12, 6, 24, 4)); - } - if (nx == 1) { - lore.add("LAUFBAU_CONNECTION_WEST"); - fence.setFace(BlockFace.WEST, true); - cuboidList.add(pixelCuboid(0, 0, 5, 4, 24, 6)); - } - if (px == 1) { - lore.add("LAUFBAU_CONNECTION_EAST"); - fence.setFace(BlockFace.EAST, true); - 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]))); - } - } - } - } - } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java index f6ce114c..aa8718c4 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java @@ -25,7 +25,6 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import de.steamwar.bausystem.utils.WorldEditUtils; -import de.steamwar.core.Core; import lombok.Getter; import lombok.SneakyThrows; import org.bukkit.Location; @@ -57,9 +56,8 @@ public class Panzern { private BaseBlock blockType; private BaseBlock slabType; - private static final BaseBlock jukeboxType = (Core.getVersion() > 19 ? BlockTypes.get("lodestone"): BlockTypes.get("jukebox")).getDefaultState().toBaseBlock(); + private static final BaseBlock jukeboxType = BlockTypes.get("lodestone").getDefaultState().toBaseBlock(); private static final BaseBlock cobwebType = BlockTypes.COBWEB.getDefaultState().toBaseBlock(); - private static final BaseBlock airType = BlockTypes.AIR.getDefaultState().toBaseBlock(); @Getter private EditSession editSession; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java index 48c55e3b..07ac31a3 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java @@ -23,7 +23,6 @@ import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.configplayer.Config; -import de.steamwar.core.Core; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket; @@ -150,7 +149,7 @@ public class SmartPlaceListener implements Listener { if (!Permission.BUILD.hasPermission(event.getPlayer())) return; if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return; if (!SMART_PLACING.contains(event.getPlayer())) { - if (Core.getVersion() >= 20 && CONTAINERS.contains(event.getBlockAgainst().getType())) { + if (CONTAINERS.contains(event.getBlockAgainst().getType())) { SoundGroup soundGroup = event.getBlockPlaced().getBlockData().getSoundGroup(); event.getPlayer().playSound(event.getBlockPlaced().getLocation(), soundGroup.getPlaceSound(), soundGroup.getVolume() * 0.8F, soundGroup.getPitch() * 0.8F); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java index 9eafc09b..a9b36c50 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java @@ -31,7 +31,6 @@ import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; import de.steamwar.bausystem.utils.bossbar.BossBarService; import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; -import de.steamwar.core.Core; import de.steamwar.core.TPSWatcher; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWItem; @@ -59,16 +58,12 @@ public class TPSSystem implements Listener { } new TPSLimitCommand(); new TickLimitCommand(); - if (Core.getVersion() >= 15) { - new TPSWarpCommand(); - new TickWarpCommand(); - if (TickManager.impl.canFreeze()) { - new TickWarpingCommand(); - } - } - if (Core.getVersion() >= 21) { - new Tick21Command(); + new TPSWarpCommand(); + new TickWarpCommand(); + if (TickManager.impl.canFreeze()) { + new TickWarpingCommand(); } + new Tick21Command(); new TPSDefaultCommand(); new TickDefaultCommand(); new TPSBaseCommand(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java index 53ac62fb..cb5cb89d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java @@ -20,7 +20,6 @@ package de.steamwar.bausystem.features.tracer; import de.steamwar.bausystem.region.Region; -import de.steamwar.core.Core; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; @@ -100,11 +99,7 @@ public class TNTPoint { List history, List destroyedBlocks) { this.tntId = tntId; this.explosion = explosion; - if (Core.getVersion() > 15) { - this.inWater = tnt.isInWater(); - } else { - this.inWater = false; - } + this.inWater = tnt.isInWater(); this.afterFirstExplosion = afterFirstExplosion; this.ticksSinceStart = ticksSinceStart; fuse = tnt.getFuseTicks(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java index f57ff726..c661ccb4 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java @@ -20,7 +20,6 @@ package de.steamwar.bausystem.features.warp; import de.steamwar.bausystem.region.Region; -import de.steamwar.core.Core; import de.steamwar.core.SWPlayer; import de.steamwar.entity.RArmorStand; import de.steamwar.entity.REntityServer; @@ -113,7 +112,7 @@ public class WarpListener implements Listener { vector.setY(0); Vector position = p.getLocation().toVector().clone().add(vector.normalize().multiply(5)); - position.setY(p.getLocation().getY() - (Core.getVersion() >= 20 ? 0 : 1)); + position.setY(p.getLocation().getY()); if ((position.getX() - current.getX()) * (position.getX() - current.getX()) + (position.getZ() - current.getZ()) * (position.getZ() - current.getZ()) < 0.1) { name = "§a§l" + name; diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegionData.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegionData.java index 9906a6e4..065e2e20 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegionData.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedGlobalRegionData.java @@ -25,7 +25,6 @@ import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.ProtectMode; import de.steamwar.bausystem.region.flags.TNTMode; -import de.steamwar.core.Core; import lombok.NonNull; import yapion.hierarchy.types.YAPIONObject; @@ -47,7 +46,7 @@ public class FixedGlobalRegionData extends RegionData { if (flag.oneOf(Flag.COLOR, Flag.PROTECT)) { return RegionFlagPolicy.READ_ONLY; } - if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) { + if (flag.oneOf(Flag.ITEMS)) { return RegionFlagPolicy.WRITABLE; } if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE)) { diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegionData.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegionData.java index b42b15e7..c2de7042 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegionData.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegionData.java @@ -22,7 +22,6 @@ package de.steamwar.bausystem.region.fixed; import de.steamwar.bausystem.region.RegionData; import de.steamwar.bausystem.region.RegionFlagPolicy; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.core.Core; import lombok.NonNull; import yapion.hierarchy.types.YAPIONObject; @@ -37,7 +36,7 @@ public class FixedRegionData extends RegionData { if (flag.oneOf(Flag.COLOR, Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROTECT, Flag.NO_GRAVITY, Flag.CHANGED, Flag.WATER_DESTROY)) { return RegionFlagPolicy.WRITABLE; } - if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) { + if (flag.oneOf(Flag.ITEMS)) { return RegionFlagPolicy.WRITABLE; } if (flag.oneOf(Flag.TESTBLOCK)) { diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java index 37ae0b7a..4a2db53d 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java +++ b/CommonCore/Linkage/src/de/steamwar/linkage/AbstractLinker.java @@ -71,9 +71,6 @@ public abstract class AbstractLinker { try { classes.forEach(clazz -> { - MinVersion minVersion = clazz.getAnnotation(MinVersion.class); - MaxVersion maxVersion = clazz.getAnnotation(MaxVersion.class); - if (!versionCheck(clazz, minVersion, maxVersion)) return; EventMode eventMode = clazz.getAnnotation(EventMode.class); if (!eventModeCheck(clazz, eventMode)) return; PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class); @@ -135,13 +132,6 @@ public abstract class AbstractLinker { instances.put(instance.getClass(), instance); } - /** - * @return {@code true} if the clazz passes the checks {@code false} otherwise - */ - protected boolean versionCheck(@NonNull Class clazz, MinVersion minVersion, MaxVersion maxVersion) { - return true; - } - /** * @return {@code true} if the clazz passes the checks {@code false} otherwise */ diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/MaxVersion.java b/CommonCore/Linkage/src/de/steamwar/linkage/MaxVersion.java index eba760d4..ecd347a4 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/MaxVersion.java +++ b/CommonCore/Linkage/src/de/steamwar/linkage/MaxVersion.java @@ -26,6 +26,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) +@Deprecated public @interface MaxVersion { int value(); } diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java b/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java index e87bd05b..e0bc39f5 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java +++ b/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java @@ -26,6 +26,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) +@Deprecated public @interface MinVersion { int value(); } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index 011d36f6..40dd8b34 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -98,13 +98,7 @@ public class FightSystem extends JavaPlugin { new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener()); new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f)); new OneShotStateDependent(ArenaMode.Test, FightState.All, WorldEditRendererCUIEditor::new); - if (Core.getVersion() >= 19) { - try { - Bukkit.getWorlds().get(0).setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(Config.mode)); - } catch (Exception e) { - // Ignore if failed! - } - } + Config.world.setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(Config.mode)); techHider = new TechHiderWrapper(); hullHider = new HullHider(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java index 1ed59d98..9f8383cf 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/ai/AIManager.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem.ai; -import de.steamwar.Reflection; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.FightTeam; @@ -30,28 +29,30 @@ import org.bukkit.Material; import java.util.Arrays; import java.util.List; import java.util.function.BooleanSupplier; +import java.util.function.Function; import java.util.stream.Collectors; @AllArgsConstructor public class AIManager { private static final List AIs = Arrays.asList( - new AIManager(DummyAI.class, Material.STONE, () -> ArenaMode.Test.contains(Config.mode)) + new AIManager("DummyAI", DummyAI::new, Material.STONE, () -> ArenaMode.Test.contains(Config.mode)) ); public static List availableAIs() { return AIs.stream().filter(manager -> manager.available.getAsBoolean()).collect(Collectors.toList()); } - private final Class aiClass; + private final String name; + private final Function constructor; @Getter private final Material icon; private final BooleanSupplier available; public String name() { - return aiClass.getSimpleName(); + return name; } public void join(FightTeam team) { - Reflection.getConstructor(aiClass, FightTeam.class).invoke(team); + constructor.apply(team); } } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java index 7119173e..5e4ecc45 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem.commands; -import de.steamwar.Reflection; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; @@ -33,15 +32,14 @@ import lombok.experimental.UtilityClass; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; import org.bukkit.command.Command; -import org.bukkit.command.SimpleCommandMap; +import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Player; @UtilityClass public class Commands { - private static final Reflection.Field commandMap = Reflection.getField("org.bukkit.craftbukkit.CraftServer", "commandMap", SimpleCommandMap.class); public static void injectCommand(Command cmd) { - commandMap.get(Bukkit.getServer()).register("FightSystem", cmd); + ((CraftServer) Bukkit.getServer()).getCommandMap().register("FightSystem", cmd); } private static void errNoTeam(Player p){ diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java index 8d983b56..fc455d74 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem.fight; -import de.steamwar.core.Core; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.record.GlobalRecorder; @@ -84,10 +83,7 @@ public class Fight { public static void playSound(Sound sound, float volume, float pitch) { GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch); //volume: max. 100, pitch: max. 2 - if(Core.getVersion() >= 18) - Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player, sound, volume, pitch)); - else - Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch)); + Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player, sound, volume, pitch)); } public static FightTeam getTeamByName(String name) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java index afc735a2..92c70ba7 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKitListener.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem.fight; -import de.steamwar.core.Core; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.states.FightState; @@ -51,7 +50,7 @@ public class HotbarKitListener implements Listener { @EventHandler public void handlePlayerInteract(PlayerInteractEvent event) { - if (event.getAction() == Action.PHYSICAL || (Core.getVersion() > 8 && event.getHand() != EquipmentSlot.HAND)) + if (event.getAction() == Action.PHYSICAL || event.getHand() != EquipmentSlot.HAND) return; Player player = event.getPlayer(); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java index 19d2db5f..29ef298f 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java @@ -25,6 +25,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.utils.WorldOfColorWrapper; import de.steamwar.linkage.Linked; +import net.minecraft.world.entity.projectile.AbstractArrow; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -43,9 +44,8 @@ public class ArrowStopper { new StateDependentTask(Config.GameModeConfig.Techhider.Active, FightState.Running, this::run, 1, 1); } - private static final Class entityArrow = Reflection.getClass("net.minecraft.world.entity.projectile.AbstractArrow"); private void run() { - Recording.iterateOverEntities(entityArrow::isInstance, entity -> { + Recording.iterateOverEntities(AbstractArrow.class::isInstance, entity -> { Projectile arrow = (Projectile) entity; if (invalidEntity(arrow)) return; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java index 009a9bd4..540577ab 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java @@ -20,11 +20,10 @@ package de.steamwar.fightsystem.listener; import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.Reflection; -import de.steamwar.core.Core; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import de.steamwar.linkage.Linked; +import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket; import org.bukkit.entity.Player; import java.io.*; @@ -44,8 +43,7 @@ public class ClickAnalyzer { public ClickAnalyzer() { TinyProtocol.instance.addFilter(Recording.blockPlacePacket, this::onBlockPlace); - if(Core.getVersion() > 8) - TinyProtocol.instance.addFilter(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket"), this::onBlockPlace); + TinyProtocol.instance.addFilter(ServerboundUseItemOnPacket.class, this::onBlockPlace); } public Object onBlockPlace(Player player, Object packet) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java index 1f23312b..2a7fdcae 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java @@ -40,6 +40,9 @@ import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import de.steamwar.fightsystem.utils.FlatteningWrapper; import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.linkage.Linked; +import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; +import net.minecraft.network.protocol.game.ServerboundUseItemPacket; +import net.minecraft.world.entity.item.PrimedTnt; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -79,10 +82,9 @@ public class Recording implements Listener { return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE; } - public static final Class primedTnt = Reflection.getClass("net.minecraft.world.entity.item.PrimedTnt"); - private static final Reflection.Method getBukkitEntity = Reflection.getTypedMethod(Reflection.getClass("net.minecraft.world.entity.Entity"), "getBukkitEntity", null); + public static final Class primedTnt = PrimedTnt.class; public static void iterateOverEntities(Predicate filter, Consumer consumer) { - CraftbukkitWrapper.impl.entityIterator().filter(filter).map(entity -> (Entity) getBukkitEntity.invoke(entity)).forEach(consumer); + CraftbukkitWrapper.impl.entityIterator().filter(filter).map(net.minecraft.world.entity.Entity::getBukkitEntity).forEach(consumer); } public Recording() { @@ -131,7 +133,7 @@ public class Recording implements Listener { GlobalRecorder.getInstance().entitySpeed(entity); } - private static final Class blockDigPacket = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundPlayerActionPacket"); + private static final Class blockDigPacket = ServerboundPlayerActionPacket.class; private static final Class playerDigType = blockDigPacket.getDeclaredClasses()[0]; private static final Reflection.Field blockDigType = Reflection.getField(blockDigPacket, playerDigType, 0); private static final Object releaseUseItem = playerDigType.getEnumConstants()[5]; @@ -141,7 +143,7 @@ public class Recording implements Listener { return packet; } - public static final Class blockPlacePacket = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemPacket"); + public static final Class blockPlacePacket = ServerboundUseItemPacket.class; private Object blockPlace(Player p, Object packet) { boolean mainHand = BountifulWrapper.impl.mainHand(packet); if(!isNotSent(p) && BountifulWrapper.impl.bowInHand(mainHand, p)) diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java index db865f19..a91de770 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java @@ -21,7 +21,6 @@ package de.steamwar.fightsystem.utils; import com.comphenix.tinyprotocol.TinyProtocol; import com.mojang.authlib.GameProfile; -import de.steamwar.Reflection; import de.steamwar.core.ProtocolWrapper; import de.steamwar.fightsystem.FightSystem; import net.minecraft.core.BlockPos; @@ -38,13 +37,6 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; public class BlockIdWrapper { - public static final Class worldServer = Reflection.getClass("net.minecraft.server.level.ServerLevel"); - public static final Reflection.Method getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle", worldServer); - - public static final Class craftPlayer = Reflection.getClass("org.bukkit.craftbukkit.entity.CraftPlayer"); - public static final Class entityPlayer = Reflection.getClass("net.minecraft.server.level.ServerPlayer"); - public static final Reflection.Method getPlayer = Reflection.getTypedMethod(craftPlayer, "getHandle", entityPlayer); - public static final BlockIdWrapper impl = new BlockIdWrapper(); public Material idToMaterial(int blockState) { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java index ac31b2ac..2723f23d 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.listener.Recording; import de.steamwar.fightsystem.record.GlobalRecorder; +import net.minecraft.world.InteractionHand; import org.bukkit.*; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeInstance; @@ -44,7 +45,7 @@ import java.util.Map; public class BountifulWrapper { public static final BountifulWrapper impl = new BountifulWrapper(); - private static final Class enumHand = Reflection.getClass("net.minecraft.world.InteractionHand"); + private static final Class enumHand = InteractionHand.class; private static final Object mainHand = enumHand.getEnumConstants()[0]; private static final Reflection.Field blockPlaceHand = Reflection.getField(Recording.blockPlacePacket, enumHand, 0); diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java index c42faa24..6a4518c8 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java @@ -19,17 +19,14 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.Reflection; import de.steamwar.fightsystem.Config; import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; -import net.minecraft.world.level.entity.LevelEntityGetter; -import org.bukkit.Chunk; import org.bukkit.GameRule; import org.bukkit.World; import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.entity.Entity; import java.util.HashSet; @@ -40,26 +37,16 @@ import java.util.stream.StreamSupport; public class CraftbukkitWrapper { public static final CraftbukkitWrapper impl = new CraftbukkitWrapper(); - private static final Reflection.Method getWorld = Reflection.getMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle"); - private static final Reflection.Method getChunk = Reflection.getTypedMethod(ServerLevel.class, null, LevelChunk.class, int.class, int.class); - private static final Reflection.Method getChunkSections = Reflection.getTypedMethod(LevelChunk.class, null, LevelChunkSection[].class); - private LevelChunkSection[] getChunkSections(World world, int x, int z) { - return (LevelChunkSection[]) getChunkSections.invoke(getChunk.invoke(getWorld.invoke(world), x, z)); - } - - private static final Reflection.Method getEntity = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.entity.CraftEntity"), "getHandle", net.minecraft.world.entity.Entity.class); protected net.minecraft.world.entity.Entity getEntity(Entity e) { - return (net.minecraft.world.entity.Entity) getEntity.invoke(e); + return ((CraftEntity) e).getHandle(); } public float headRotation(Entity e) { return getEntity(e).getYHeadRot(); } - private static final Reflection.Method getWorldEntities = Reflection.getTypedMethod(ServerLevel.class, null, LevelEntityGetter.class); - private static final Reflection.Method getIterable = Reflection.getTypedMethod(LevelEntityGetter.class, null, Iterable.class); - public Stream entityIterator() { - return StreamSupport.stream(((Iterable) getIterable.invoke(getWorldEntities.invoke(getWorld.invoke(Config.world)))).spliterator(), false); + public Stream entityIterator() { + return StreamSupport.stream(((CraftWorld) Config.world).getHandle().getEntities().getAll().spliterator(), false); } public void setupGamerule() { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHider.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHider.java index e7c505a3..29751f50 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHider.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHider.java @@ -21,7 +21,6 @@ package de.steamwar.fightsystem.utils; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.Reflection; -import de.steamwar.core.Core; import de.steamwar.entity.REntity; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.fight.Fight; @@ -34,6 +33,11 @@ import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.techhider.TechHider; import lombok.Getter; +import net.minecraft.core.Vec3i; +import net.minecraft.network.protocol.game.ClientboundExplodePacket; +import net.minecraft.network.protocol.game.ClientboundLevelEventPacket; +import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket; +import net.minecraft.network.protocol.game.ClientboundSoundPacket; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -61,7 +65,7 @@ public class HullHider implements Listener { private final Hull[] hulls; private final Map, BiFunction> packetHiders = new HashMap<>(); - private static final Class packetPlayOutExplosion = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundExplodePacket"); + private static final Class packetPlayOutExplosion = ClientboundExplodePacket.class; public HullHider() { if(!TechHiderWrapper.ENABLED) { hulls = new Hull[0]; @@ -73,10 +77,8 @@ public class HullHider implements Listener { packetHiders.put(packetPlayOutWorldEvent, this::worldEventHider); packetHiders.put(packetPlayOutExplosion, this::explosionHider); - posHiderGenerator("net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket", Core.getVersion() >= 18 ? double.class : float.class, 1.0); - posHiderGenerator("net.minecraft.network.protocol.game.ClientboundSoundPacket", int.class, 8.0); - if(Core.getVersion() >= 9 && Core.getVersion() < 18) - posHiderGenerator("net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect", int.class, 8.0); + posHiderGenerator(ClientboundLevelParticlesPacket.class, double.class, 1.0); + posHiderGenerator(ClientboundSoundPacket.class, int.class, 8.0); new StateDependentListener(TechHiderWrapper.ENABLED, FightState.Schem, this); new StateDependent(TechHiderWrapper.ENABLED, FightState.Schem) { @@ -200,9 +202,9 @@ public class HullHider implements Listener { } - private static final Class packetPlayOutWorldEvent = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundLevelEventPacket"); + private static final Class packetPlayOutWorldEvent = ClientboundLevelEventPacket.class; private static final Reflection.Field worldEventPosition = Reflection.getField(packetPlayOutWorldEvent, TechHider.blockPosition, 0); - public static final Reflection.Field blockPositionY = Reflection.getField("net.minecraft.core.Vec3i", int.class, 1); + public static final Reflection.Field blockPositionY = Reflection.getField(Vec3i.class, int.class, 1); private Object worldEventHider(Player player, Object packet) { Object baseBlock = worldEventPosition.get(packet); return packetHider(player, packet, new Location(Config.world, TechHider.blockPositionX.get(baseBlock), blockPositionY.get(baseBlock), TechHider.blockPositionZ.get(baseBlock))); @@ -212,8 +214,7 @@ public class HullHider implements Listener { return ReflectionWrapper.impl.explosionHider(player, packet, this::packetHider); } - private void posHiderGenerator(String typeName, Class posType, double factor) { - Class type = Reflection.getClass(typeName); + private void posHiderGenerator(Class type, Class posType, double factor) { Function location = posPacketToLocation(type, posType, factor); packetHiders.put(type, (player, packet) -> packetHider(player, packet, location.apply(packet))); } diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHiderWrapper.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHiderWrapper.java index 061e3877..378c3efc 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHiderWrapper.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/utils/HullHiderWrapper.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.Reflection; import de.steamwar.fightsystem.Config; import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap; import net.minecraft.core.BlockPos; @@ -27,18 +26,18 @@ import net.minecraft.core.SectionPos; import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket; import net.minecraft.world.level.block.state.BlockState; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import java.util.List; public class HullHiderWrapper { public static final HullHiderWrapper impl = new HullHiderWrapper(); - private static final Reflection.Method getState = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.block.data.CraftBlockData"), "getState", BlockState.class); public Object generateBlockChangePacket(List changes) { Object[] blockdata = new Object[changes.size()]; for(int i = 0; i < blockdata.length; i++) { Hull.IntVector change = changes.get(i); - blockdata[i] = getState.invoke(Config.world.getBlockData(change.getX(), change.getY(), change.getZ())); + blockdata[i] = ((CraftBlockData) Config.world.getBlockData(change.getX(), change.getY(), change.getZ())).getState(); } return generateBlockChangePacket(changes, blockdata); diff --git a/MissileWars/build.gradle.kts b/MissileWars/build.gradle.kts index 16dc6622..c6b757e1 100644 --- a/MissileWars/build.gradle.kts +++ b/MissileWars/build.gradle.kts @@ -33,6 +33,6 @@ dependencies { compileOnly(libs.spigotapi) - compileOnly(libs.nms20) + compileOnly(libs.nms21) compileOnly(libs.fawe21) } diff --git a/MissileWars/src/de/steamwar/misslewars/FightWorld.java b/MissileWars/src/de/steamwar/misslewars/FightWorld.java index 1187d840..501c18a2 100644 --- a/MissileWars/src/de/steamwar/misslewars/FightWorld.java +++ b/MissileWars/src/de/steamwar/misslewars/FightWorld.java @@ -20,15 +20,19 @@ package de.steamwar.misslewars; import de.steamwar.core.CraftbukkitWrapper; -import net.minecraft.world.level.chunk.Chunk; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunkSection; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.WorldCreator; -import org.bukkit.craftbukkit.v1_20_R1.CraftWorld; +import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import java.util.HashSet; +import java.util.Set; import java.util.function.ObjIntConsumer; public class FightWorld { @@ -71,10 +75,14 @@ public class FightWorld { } private static void resetChunk(World world, World backup, int x, int z) { - Chunk chunk = ((CraftWorld) world).getHandle().d(x, z); - Chunk backupChunk = ((CraftWorld) backup).getHandle().d(x, z); - - System.arraycopy(backupChunk.d(), 0, chunk.d(), 0, chunk.d().length); + LevelChunk worldChunk = ((CraftWorld) world).getHandle().getChunk(x, z); + LevelChunk backupChunk = ((CraftWorld) backup).getHandle().getChunk(x, z); + LevelChunkSection[] sections = worldChunk.getSections(); + System.arraycopy(backupChunk.getSections(), 0, sections, 0, sections.length); + Set blocks = new HashSet<>(worldChunk.blockEntities.keySet()); + blocks.stream().filter(key -> !backupChunk.blockEntities.containsKey(key)).forEach(worldChunk::removeBlockEntity); + worldChunk.heightmaps.clear(); + worldChunk.heightmaps.putAll(backupChunk.heightmaps); for(Player p : Bukkit.getOnlinePlayers()) CraftbukkitWrapper.impl.sendChunk(p, x, z); diff --git a/MissileWars/src/de/steamwar/misslewars/slowmo/SlowMoUtils.java b/MissileWars/src/de/steamwar/misslewars/slowmo/SlowMoUtils.java index 4630784d..c5e01cc4 100644 --- a/MissileWars/src/de/steamwar/misslewars/slowmo/SlowMoUtils.java +++ b/MissileWars/src/de/steamwar/misslewars/slowmo/SlowMoUtils.java @@ -19,9 +19,10 @@ package de.steamwar.misslewars.slowmo; -import de.steamwar.Reflection; +import net.minecraft.server.level.ServerLevel; import org.bukkit.Bukkit; import org.bukkit.World; +import org.bukkit.craftbukkit.CraftWorld; import java.lang.reflect.Field; @@ -30,7 +31,6 @@ public class SlowMoUtils { private static final Field field; public static final boolean freezeEnabled; - private static final Reflection.Method getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.CraftWorld"), "getHandle", null); private static boolean frozen = false; private static final World world; @@ -38,7 +38,7 @@ public class SlowMoUtils { static { Field temp; try { - temp = Reflection.getClass("net.minecraft.server.level.ServerLevel").getField("freezed"); + temp = ServerLevel.class.getField("freezed"); } catch (NoSuchFieldException e) { temp = null; } @@ -64,7 +64,7 @@ public class SlowMoUtils { if (freezeEnabled) { if (frozen == state) return; try { - field.set(getWorldHandle.invoke(world), state); + field.set(((CraftWorld) world).getHandle(), state); frozen = state; } catch (IllegalAccessException e) { // Ignored; diff --git a/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java b/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java index dbed2d9a..2e8a2024 100644 --- a/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoChecker.java @@ -127,7 +127,7 @@ public class AutoChecker { else if (!itemsInInv.getOrDefault(itemType, EnumSet.noneOf(Material.class)).contains(material)) { result.getForbiddenItems().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); } else if (material == Material.DISPENSER && (itemType == Material.ARROW || itemType == Material.FIRE_CHARGE)) { - counter += Core.getVersion() >= 21 ? item.getInt("count") : item.getByte("Count"); + counter += item.getInt("count"); } if (item.containsKey("tag")) { result.getForbiddenNbt().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); diff --git a/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java b/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java index 0cb6e386..e216282b 100644 --- a/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/autocheck/AutoCheckerResult.java @@ -172,16 +172,14 @@ public class AutoCheckerResult { blockScanResult.getDefunctNbt().forEach(blockVector3 -> { SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DEFUNCT_NBT", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()); }); - if(Core.getVersion() > 12) { - blockScanResult.getDesignBlocks().forEach((material, poss) -> { - if (material == Material.WATER || material == Material.LAVA) return; - if(material.getBlastResistance() > type.Schematic.MaxDesignBlastResistance) { - poss.forEach(pos -> { - SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DESIGN_BLOCK", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos), material.name(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); - }); - } - }); - } + blockScanResult.getDesignBlocks().forEach((material, poss) -> { + if (material == Material.WATER || material == Material.LAVA) return; + if(material.getBlastResistance() > type.Schematic.MaxDesignBlastResistance) { + poss.forEach(pos -> { + SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DESIGN_BLOCK", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos), material.name(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); + }); + } + }); entities.forEach(blockPos -> { SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_ENTITY", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockPos), blockPos.getX(), blockPos.getY(), blockPos.getZ()); }); diff --git a/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java index d07c30dc..b3399344 100644 --- a/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/SchematicCommand.java @@ -35,7 +35,6 @@ import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; -import de.steamwar.core.Core; import de.steamwar.linkage.Linked; import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; @@ -161,10 +160,8 @@ public class SchematicCommand extends SWCommand { NORMAL } - private static final Function getCount = item -> Core.getVersion() >= 21 ? item.getInt("count") : item.getByte("Count"); - private static final BiFunction setCount = (item, count) -> Core.getVersion() >= 21 ? - item.createBuilder().putInt("count", count).build() : - item.createBuilder().putByte("Count", count.byteValue()).build(); + private static final Function getCount = item -> item.getInt("count"); + private static final BiFunction setCount = (item, count) -> item.createBuilder().putInt("count", count).build(); public static Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig type) throws Exception { for (BlockPos blockPos : result.getBlockScanResult().getRecords()) { diff --git a/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java index ecf3c16d..d0134625 100644 --- a/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java +++ b/SchematicSystem/src/de/steamwar/schematicsystem/commands/schematiccommand/parts/CheckPart.java @@ -87,10 +87,6 @@ public class CheckPart extends SWCommand { @Register("fix") public void fixSchematicCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig type) { - if(Core.getVersion() < 15) { - SchematicSystem.MESSAGE.send("COMMAND_FIX_WRONG_VERSION", player); - return; - } Clipboard clipboard; try { clipboard = WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getClipboard().getClipboard(); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/Reflection.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/Reflection.java index 5b5d88d2..3230e84e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/Reflection.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/Reflection.java @@ -206,18 +206,10 @@ public final class Reflection { return getField(target, name, fieldType, 0); } - public static Field getField(String className, String name, Class fieldType) { - return getField(getClass(className), name, fieldType, 0); - } - public static Field getField(Class target, Class fieldType, int index) { return getField(target, null, fieldType, index); } - public static Field getField(String className, Class fieldType, int index) { - return getField(getClass(className), fieldType, index); - } - public static Field getField(Class target, Class fieldType, int index, Class... parameters) { return getField(target, null, fieldType, index, parameters); } @@ -268,14 +260,6 @@ public final class Reflection { } } - public static Method getMethod(String className, String methodName, Class... params) { - return getTypedMethod(getClass(className), methodName, null, params); - } - - public static Method getMethod(Class clazz, String methodName, Class... params) { - return getTypedMethod(clazz, methodName, null, params); - } - public static Method getTypedMethod(Class clazz, String methodName, Class returnType, Class... params) { for (final java.lang.reflect.Method method : clazz.getDeclaredMethods()) { if ((methodName == null || method.getName().equals(methodName)) @@ -306,10 +290,6 @@ public final class Reflection { } } - public static Constructor getConstructor(String className, Class... params) { - return getConstructor(getClass(className), params); - } - public static Constructor getConstructor(Class clazz, Class... params) { for (final java.lang.reflect.Constructor constructor : clazz.getDeclaredConstructors()) { if (Arrays.equals(constructor.getParameterTypes(), params)) { @@ -323,12 +303,8 @@ public final class Reflection { public static Object newInstance(Class clazz) { try { - if (Core.getVersion() > 15) { - return Unsafe.getUnsafe().allocateInstance(clazz); - } else { - return clazz.newInstance(); - } - } catch (InstantiationException | IllegalAccessException e) { + return Unsafe.getUnsafe().allocateInstance(clazz); + } catch (InstantiationException e) { throw new SecurityException("Could not create object", e); } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java index 0ff13595..33f85cdb 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java @@ -22,6 +22,10 @@ package de.steamwar.core; import de.steamwar.Reflection; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; +import net.minecraft.network.syncher.EntityDataAccessor; +import net.minecraft.network.syncher.EntityDataSerializer; +import net.minecraft.network.syncher.EntityDataSerializers; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.entity.PositionMoveRotation; import net.minecraft.world.phys.Vec3; import org.bukkit.Sound; @@ -43,18 +47,14 @@ public class BountifulWrapper { player.spigot().sendMessage(type, msg); } - private static final Class dataWatcherObject = Reflection.getClass("net.minecraft.network.syncher.EntityDataAccessor"); - private static final Class dataWatcherRegistry = Reflection.getClass("net.minecraft.network.syncher.EntityDataSerializers"); - private static final Class dataWatcherSerializer = Reflection.getClass("net.minecraft.network.syncher.EntityDataSerializer"); - private static final Reflection.Constructor dataWatcherObjectConstructor = Reflection.getConstructor(dataWatcherObject, int.class, dataWatcherSerializer); + private static final Class dataWatcherRegistry = EntityDataSerializers.class; + private static final Class dataWatcherSerializer = EntityDataSerializer.class; public Object getDataWatcherObject(int index, Class type) { - return dataWatcherObjectConstructor.invoke(index, Reflection.getField(dataWatcherRegistry, dataWatcherSerializer, 0, type).get(null)); + return new EntityDataAccessor<>(index, (EntityDataSerializer) Reflection.getField(dataWatcherRegistry, dataWatcherSerializer, 0, type).get(null)); } - private static final Class item = Reflection.getClass("net.minecraft.network.syncher.SynchedEntityData$DataItem"); - private static final Reflection.Constructor itemConstructor = Reflection.getConstructor(item, dataWatcherObject, Object.class); public Object getDataWatcherItem(Object dwo, Object value) { - return itemConstructor.invoke(dwo, value); + return new SynchedEntityData.DataItem<>((EntityDataAccessor) dwo, value); } public BountifulWrapper.PositionSetter getPositionSetter(Class packetClass, int fieldOffset) { @@ -92,11 +92,10 @@ public class BountifulWrapper { public BountifulWrapper.PositionSetter getRelMoveSetter(Class packetClass) { - Class type = Core.getVersion() > 12 ? short.class : int.class; - int fieldOffset = Core.getVersion() > 12 ? 0 : 1; - Reflection.Field moveX = Reflection.getField(packetClass, type, 0 + fieldOffset); - Reflection.Field moveY = Reflection.getField(packetClass, type, 1 + fieldOffset); - Reflection.Field moveZ = Reflection.getField(packetClass, type, 2 + fieldOffset); + Class type = short.class; + Reflection.Field moveX = Reflection.getField(packetClass, type, 0); + Reflection.Field moveY = Reflection.getField(packetClass, type, 1); + Reflection.Field moveZ = Reflection.getField(packetClass, type, 2); Reflection.Field moveYaw = Reflection.getField(packetClass, byte.class, 0); Reflection.Field movePitch = Reflection.getField(packetClass, byte.class, 1); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CheckpointUtilsJ9.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CheckpointUtilsJ9.java index 31577e6e..0099d6cf 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CheckpointUtilsJ9.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CheckpointUtilsJ9.java @@ -93,7 +93,6 @@ class CheckpointUtilsJ9 { private static final Reflection.Field channelFutures = Reflection.getField(ServerConnectionListener.class, List.class, 0, ChannelFuture.class); - private static final Reflection.Method bind = Reflection.getMethod(ServerConnectionListener.class, null, InetAddress.class, int.class); private static void freezeInternal(Path path) throws Exception { Bukkit.getPluginManager().callEvent(new CRIUSleepEvent()); @@ -137,11 +136,9 @@ class CheckpointUtilsJ9 { } // Reopen socket - bind.invoke(serverConnection, InetAddress.getLoopbackAddress(), port); - if(Core.getVersion() > 12) { - for(Object future : channels) { - ((ChannelFuture) future).channel().config().setAutoRead(true); - } + serverConnection.startTcpServerListener(InetAddress.getLoopbackAddress(), port); + for(Object future : channels) { + ((ChannelFuture) future).channel().config().setAutoRead(true); } Bukkit.getPluginManager().callEvent(new CRIUWakeupEvent()); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java index e25f9728..02dd64bf 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/Core.java @@ -111,8 +111,7 @@ public class Core extends JavaPlugin { getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new NetworkReceiver()); getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge"); - if (Core.getVersion() != 20) - SteamwarGameProfileRepository.impl.inject(); + SteamwarGameProfileRepository.impl.inject(); TinyProtocol.init(); CheckpointUtils.signalHandler(); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/FlatteningWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/FlatteningWrapper.java index 0befeb68..e08b9a9e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/FlatteningWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/FlatteningWrapper.java @@ -21,9 +21,17 @@ package de.steamwar.core; import com.destroystokyo.paper.profile.PlayerProfile; import de.steamwar.Reflection; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundSetObjectivePacket; -import net.minecraft.network.protocol.game.ClientboundSetScorePacket; -import org.bukkit.*; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Pose; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.World; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -229,14 +237,14 @@ public class FlatteningWrapper { renamedLegacy.put("RECORD_12", Material.MUSIC_DISC_WAIT); } - private static final Reflection.Field scoreboardName = Reflection.getField(ClientboundSetObjectivePacket.class, Reflection.getClass("net.minecraft.network.chat.Component"), 0); + private static final Reflection.Field scoreboardName = Reflection.getField(ClientboundSetObjectivePacket.class, Component.class, 0); public void setScoreboardTitle(Object packet, String title) { scoreboardName.set(packet, ChatWrapper.impl.stringToChatComponent(title)); } - private static final Class scoreActionEnum = Core.getVersion() < 21 ? Reflection.getClass("net.minecraft.server.ServerScoreboard$Method") : null; - private static final Reflection.Field scoreAction = Core.getVersion() < 21 ? Reflection.getField(ClientboundSetScorePacket.class, scoreActionEnum, 0) : null; - private static final Object scoreActionChange = Core.getVersion() < 21 ? scoreActionEnum.getEnumConstants()[0] : null; + private static final Class scoreActionEnum = null; + private static final Reflection.Field scoreAction = null; + private static final Object scoreActionChange = null; public void setScoreAction(Object packet) { scoreAction.set(packet, scoreActionChange); @@ -302,7 +310,7 @@ public class FlatteningWrapper { return head; } - protected static final Class entityPose = Reflection.getClass("net.minecraft.world.entity.Pose"); + protected static final Class entityPose = Pose.class; protected static final Object shooting = entityPose.getEnumConstants()[16]; protected static final Object standing = entityPose.getEnumConstants()[0]; protected static final Object swimming = entityPose.getEnumConstants()[3]; @@ -321,41 +329,22 @@ public class FlatteningWrapper { } } - public void setNamedSpawnPacketDataWatcher(Object packet) { - // field not present - } - public Object formatDisplayName(String displayName) { return displayName != null ? Optional.of(ChatWrapper.impl.stringToChatComponent(displayName)) : Optional.empty(); } - private static final Class registryBlocks = Reflection.getClass("net.minecraft.core.DefaultedRegistry"); - private static final Class entityTypes = Reflection.getClass("net.minecraft.world.entity.EntityType"); - private static final Object entityTypesRegistry = Reflection.getField(Reflection.getClass(Core.getVersion() > 18 ? "net.minecraft.core.registries.BuiltInRegistries" : "net.minecraft.core.IRegistry"), registryBlocks, 0, entityTypes).get(null); - private static final Reflection.Method get = Reflection.getMethod(registryBlocks, null, Reflection.getClass("net.minecraft.resources.ResourceLocation")); - private static final Reflection.Field spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, entityTypes, 0); - private static final Reflection.Field spawnLivingType = Core.getVersion() > 18 ? spawnType : Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1); - private static final Reflection.Method toMinecraft = Reflection.getMethod("org.bukkit.craftbukkit.util.CraftNamespacedKey", "toMinecraft", NamespacedKey.class); - private static final Map types = new HashMap<>(); - static { - types.put(EntityType.ARMOR_STAND, 1); - } + private static final Reflection.Field spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, net.minecraft.world.entity.EntityType.class, 0); public void setSpawnPacketType(Object packet, EntityType type) { - if(type.isAlive()) { - spawnLivingType.set(packet, Core.getVersion() > 18 ? get.invoke(entityTypesRegistry, toMinecraft.invoke(null, type.getKey())) : types.get(type)); - } else { - spawnType.set(packet, get.invoke(entityTypesRegistry, toMinecraft.invoke(null, type.getKey()))); - } + ResourceLocation key = CraftNamespacedKey.toMinecraft(type.getKey()); + spawnType.set(packet, BuiltInRegistries.ENTITY_TYPE.get(key).get().value()); } public int getViewDistance(Player player) { return player.getClientViewDistance(); } - private static final Reflection.Method getHandle = Reflection.getMethod("org.bukkit.craftbukkit.CraftWorld", "getHandle"); - private static final Reflection.Method save = Reflection.getMethod("net.minecraft.server.level.ServerLevel", null, Reflection.getClass("net.minecraft.util.ProgressListener"), boolean.class, boolean.class); public void syncSave(World world) { - save.invoke(getHandle.invoke(world), null, true, false); + ((CraftWorld) world).getHandle().save(null, true, false); } public enum EntityPose { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java index c61bdfaf..d6fdd3f2 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ProtocolWrapper.java @@ -21,7 +21,7 @@ package de.steamwar.core; import com.mojang.authlib.GameProfile; import com.mojang.datafixers.util.Pair; -import de.steamwar.Reflection; +import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket; import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket; import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; @@ -35,16 +35,13 @@ import java.util.EnumSet; public class ProtocolWrapper { - public static final Class itemStack = Reflection.getClass("net.minecraft.world.item.ItemStack"); - public static final Class spawnPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundAddEntityPacket"); - public static final Class spawnLivingPacket = Core.getVersion() > 18 ? ProtocolWrapper.spawnPacket : Reflection.getClass("net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving"); - public static final Class equipmentPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket"); - - public static final Class enumGamemode = Reflection.getClass(Core.getVersion() > 9 ? "net.minecraft.world.level.GameType" : "net.minecraft.WorldSettings$EnumGamemode"); - public static final Reflection.Method getGameModeById = Reflection.getTypedMethod(enumGamemode, null, enumGamemode, int.class); + public static final Class itemStack = ItemStack.class; + public static final Class spawnPacket = ClientboundAddEntityPacket.class; + public static final Class spawnLivingPacket = ProtocolWrapper.spawnPacket; + public static final Class equipmentPacket = ClientboundSetEquipmentPacket.class; // 0: hand, 1: offhand, 2: feet, 3: legs, 4: chest, 5: head - public static final Object[] itemSlots = Core.getVersion() > 8 ? Reflection.getClass("net.minecraft.world.entity.EnumItemSlot").getEnumConstants() : new Integer[]{0, 0, 1, 2, 3, 4}; + public static final EquipmentSlot[] itemSlots = EquipmentSlot.values(); public static final ProtocolWrapper impl = new ProtocolWrapper(); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java index e88b1e82..63aed6a1 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/TPSWatcher.java @@ -19,7 +19,7 @@ package de.steamwar.core; -import de.steamwar.Reflection; +import net.minecraft.server.MinecraftServer; import org.bukkit.Bukkit; public class TPSWatcher { @@ -79,11 +79,8 @@ public class TPSWatcher { } } - private static final Class minecraftServer = Reflection.getClass("net.minecraft.server.MinecraftServer"); - private static final Reflection.Method getServer = Reflection.getTypedMethod(minecraftServer, "getServer", minecraftServer); - private static final Reflection.Field recentTps = Reflection.getField(minecraftServer, "recentTps", double[].class); private static double[] getSpigotTPS() { - return recentTps.get(getServer.invoke(null)); + return MinecraftServer.getServer().recentTps; } private static double round(double d) { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererCUIEditor.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererCUIEditor.java index 0060d29a..00a6d344 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererCUIEditor.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRendererCUIEditor.java @@ -116,9 +116,7 @@ public class WorldEditRendererCUIEditor implements Listener { public WorldEditRendererCUIEditor() { Bukkit.getPluginManager().registerEvents(this, Core.getInstance()); - if (Core.getVersion() >= 20) { - new Command(); - } + new Command(); } private static class Command extends SWCommand { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java index 6e6a8de3..d9edd2c7 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java @@ -25,6 +25,7 @@ import de.steamwar.linkage.Linked; import net.minecraft.network.protocol.game.ClientboundLoginPacket; import net.minecraft.network.protocol.game.CommonPlayerSpawnInfo; import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.Level; @Linked @@ -32,8 +33,8 @@ public class WorldIdentifier { private static ResourceKey resourceKey = null; - private static final Class resourceKeyClass = Reflection.getClass("net.minecraft.resources.ResourceKey"); - private static final Class minecraftKeyClass = Reflection.getClass("net.minecraft.resources.MinecraftKey"); + private static final Class resourceKeyClass = ResourceKey.class; + private static final Class minecraftKeyClass = ResourceLocation.class; private static final Reflection.Constructor resourceKeyConstructor = Reflection.getConstructor(resourceKeyClass, minecraftKeyClass, minecraftKeyClass); private static final Reflection.Constructor minecraftKeyConstructor = Reflection.getConstructor(minecraftKeyClass, String.class, String.class); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java index 40cdb955..0f4e016d 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java @@ -26,6 +26,9 @@ import de.steamwar.linkage.Linked; import de.steamwar.sql.SWException; import de.steamwar.techhider.ProtocolUtils; import de.steamwar.techhider.TechHider; +import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; +import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket; +import net.minecraft.world.phys.BlockHitResult; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -43,9 +46,7 @@ public class AntiNocom implements Listener { public AntiNocom() { TinyProtocol.instance.addFilter(blockDig, this::onDig); - if(Core.getVersion() > 8) { - registerUseItem(); - } + registerUseItem(); } @EventHandler @@ -54,18 +55,13 @@ public class AntiNocom implements Listener { } private void registerUseItem() { - Class useItem = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket"); + Class useItem = ServerboundUseItemOnPacket.class; - Function getPosition; - if(Core.getVersion() > 12) { - Class movingObjectPositionBlock = Reflection.getClass("net.minecraft.world.phys.BlockHitResult"); - Reflection.Field useItemPosition = Reflection.getField(useItem, movingObjectPositionBlock, 0); - Reflection.Field movingBlockPosition = Reflection.getField(movingObjectPositionBlock, TechHider.blockPosition, 0); + Class movingObjectPositionBlock = BlockHitResult.class; + Reflection.Field useItemPosition = Reflection.getField(useItem, movingObjectPositionBlock, 0); + Reflection.Field movingBlockPosition = Reflection.getField(movingObjectPositionBlock, TechHider.blockPosition, 0); - getPosition = (packet) -> movingBlockPosition.get(useItemPosition.get(packet)); - } else { - getPosition = Reflection.getField(useItem, TechHider.blockPosition, 0)::get; - } + Function getPosition = (packet) -> movingBlockPosition.get(useItemPosition.get(packet)); TinyProtocol.instance.addFilter(useItem, (player, packet) -> { Object pos = getPosition.apply(packet); @@ -73,7 +69,7 @@ public class AntiNocom implements Listener { }); } - private static final Class blockDig = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundPlayerActionPacket"); + private static final Class blockDig = ServerboundPlayerActionPacket.class; private static final Reflection.Field digPosition = Reflection.getField(blockDig, TechHider.blockPosition, 0); private Object onDig(Player player, Object packet) { Object pos = digPosition.get(packet); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RArmorStand.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RArmorStand.java index 249d2cda..3fdafe4a 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RArmorStand.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RArmorStand.java @@ -20,7 +20,6 @@ package de.steamwar.entity; import de.steamwar.core.BountifulWrapper; -import de.steamwar.core.Core; import lombok.Getter; import org.bukkit.Location; import org.bukkit.entity.EntityType; @@ -29,26 +28,7 @@ import java.util.function.Consumer; public class RArmorStand extends REntity { - private static int sizeIndex() { - switch(Core.getVersion()) { - case 8: - case 9: - return 10; - case 10: - case 12: - return 11; - case 14: - return 13; - case 15: - return 14; - case 18: - case 19: - default: - return 15; - } - } - - private static final Object sizeWatcher = BountifulWrapper.impl.getDataWatcherObject(sizeIndex(), Byte.class); + private static final Object sizeWatcher = BountifulWrapper.impl.getDataWatcherObject(15, Byte.class); @Getter private final Size size; diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RBlockDisplay.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RBlockDisplay.java index 0058617a..8f87f63c 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RBlockDisplay.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RBlockDisplay.java @@ -19,13 +19,13 @@ package de.steamwar.entity; -import de.steamwar.Reflection; import de.steamwar.core.BountifulWrapper; -import de.steamwar.core.Core; import lombok.Getter; +import net.minecraft.world.level.block.state.BlockState; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.entity.EntityType; import java.util.function.BiConsumer; @@ -58,12 +58,10 @@ public class RBlockDisplay extends RDisplay { sendPacket(updatePacketSink, this::getBlock); } - private static final Class iBlockDataClass = Reflection.getClass("net.minecraft.world.level.block.state.BlockState"); - private static final Reflection.Method getState = Reflection.getTypedMethod(Reflection.getClass("org.bukkit.craftbukkit.block.data.CraftBlockData"), "getState", iBlockDataClass); - private static final Object blockWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 23 : 22, iBlockDataClass); + private static final Object blockWatcher = BountifulWrapper.impl.getDataWatcherObject(23, BlockState.class); private void getBlock(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || !block.getAsString(true).equals(DEFAULT_BLOCK.getAsString(true))) { - packetSink.accept(blockWatcher, getState.invoke(block)); + packetSink.accept(blockWatcher, ((CraftBlockData) block).getState()); } } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RDisplay.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RDisplay.java index 34c3a2eb..727e7b2a 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RDisplay.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RDisplay.java @@ -20,7 +20,6 @@ package de.steamwar.entity; import de.steamwar.core.BountifulWrapper; -import de.steamwar.core.Core; import lombok.Getter; import lombok.NonNull; import org.bukkit.Color; @@ -111,10 +110,10 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getTransformData); } - private static final Object translationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 11 : 10, Vector3f.class); - private static final Object leftRotationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 13 : 12, Quaternionf.class); - private static final Object scaleWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 12 : 11, Vector3f.class); - private static final Object rightRotationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 14 : 13, Quaternionf.class); + private static final Object translationWatcher = BountifulWrapper.impl.getDataWatcherObject(11, Vector3f.class); + private static final Object leftRotationWatcher = BountifulWrapper.impl.getDataWatcherObject(13, Quaternionf.class); + private static final Object scaleWatcher = BountifulWrapper.impl.getDataWatcherObject(12, Vector3f.class); + private static final Object rightRotationWatcher = BountifulWrapper.impl.getDataWatcherObject(14, Quaternionf.class); private void getTransformData(boolean ignoreDefault, BiConsumer dataSink) { if (ignoreDefault || !transform.equals(DEFAULT_TRANSFORM)) { @@ -130,8 +129,8 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getInterpolationDuration); } - private static final Object transformationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 9 : 8, Integer.class); - private static final Object positionOrRotationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 10 : 9, Integer.class); + private static final Object transformationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(9, Integer.class); + private static final Object positionOrRotationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(10, Integer.class); private void getInterpolationDuration(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || interpolationDelay != 0) { @@ -145,7 +144,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getViewRange); } - private static final Object viewRangeWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 17 : 16, Float.class); + private static final Object viewRangeWatcher = BountifulWrapper.impl.getDataWatcherObject(17, Float.class); private void getViewRange(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || viewRange != 1.0F) { @@ -158,7 +157,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getShadowRadius); } - private static final Object shadowRadiusWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 18 : 17, Float.class); + private static final Object shadowRadiusWatcher = BountifulWrapper.impl.getDataWatcherObject(18, Float.class); private void getShadowRadius(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || shadowRadius != 0.0F) { @@ -171,7 +170,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getShadowStrength); } - private static final Object shadowStrengthWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 19 : 18, Float.class); + private static final Object shadowStrengthWatcher = BountifulWrapper.impl.getDataWatcherObject(19, Float.class); private void getShadowStrength(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || shadowStrength != 1.0F) { @@ -184,7 +183,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getDisplayWidth); } - private static final Object displayWidthWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 20 : 19, Float.class); + private static final Object displayWidthWatcher = BountifulWrapper.impl.getDataWatcherObject(20, Float.class); private void getDisplayWidth(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || displayWidth != 0.0F) { @@ -197,7 +196,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getDisplayHeight); } - private static final Object displayHeightWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 21 : 20, Float.class); + private static final Object displayHeightWatcher = BountifulWrapper.impl.getDataWatcherObject(21, Float.class); private void getDisplayHeight(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || displayHeight != 0.0F) { @@ -210,7 +209,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getInterpolationDelay); } - private static final Object interpolationDelayWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 8 : 7, Integer.class); + private static final Object interpolationDelayWatcher = BountifulWrapper.impl.getDataWatcherObject(8, Integer.class); private void getInterpolationDelay(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || interpolationDelay != 0) { @@ -223,7 +222,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getBillboard); } - private static final Object billboardWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 15 : 14, Byte.class); + private static final Object billboardWatcher = BountifulWrapper.impl.getDataWatcherObject(15, Byte.class); private void getBillboard(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || billboard != Display.Billboard.FIXED) { @@ -236,7 +235,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getGlowColorOverride); } - private static final Object glowColorOverrideWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 22 : 21, Integer.class); + private static final Object glowColorOverrideWatcher = BountifulWrapper.impl.getDataWatcherObject(22, Integer.class); private void getGlowColorOverride(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || glowColorOverride != null) { @@ -249,7 +248,7 @@ public abstract class RDisplay extends REntity { sendPacket(updatePacketSink, this::getBrightness); } - private static final Object brightnessWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 16 : 15, Integer.class); + private static final Object brightnessWatcher = BountifulWrapper.impl.getDataWatcherObject(16, Integer.class); private void getBrightness(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || brightness != null) { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java index 9962878e..95ce73b0 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java @@ -20,11 +20,16 @@ package de.steamwar.entity; import de.steamwar.Reflection; -import de.steamwar.core.*; +import de.steamwar.core.BountifulWrapper; +import de.steamwar.core.ChatWrapper; +import de.steamwar.core.FlatteningWrapper; +import de.steamwar.core.ProtocolWrapper; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import lombok.Getter; +import net.minecraft.network.protocol.game.*; import org.bukkit.Location; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.EntityType; import org.bukkit.inventory.ItemStack; @@ -35,9 +40,9 @@ import java.util.function.Function; public class REntity { private static final Object entityStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(0, Byte.class); - private static final Object sneakingDataWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 6 : 0, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass()); - private static final Object bowDrawnWatcher = Core.getVersion() >= 21 ? BountifulWrapper.impl.getDataWatcherObject(6, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass()) : BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 7 : 6, Byte.class); - private static final Object nameWatcher = BountifulWrapper.impl.getDataWatcherObject(2, Core.getVersion() > 12 ? Optional.class : String.class); // Optional + private static final Object sneakingDataWatcher = BountifulWrapper.impl.getDataWatcherObject(6, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass()); + private static final Object bowDrawnWatcher = BountifulWrapper.impl.getDataWatcherObject(6, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass()); + private static final Object nameWatcher = BountifulWrapper.impl.getDataWatcherObject(2, Optional.class); // Optional private static final Object nameVisibleWatcher = BountifulWrapper.impl.getDataWatcherObject(3, Boolean.class); private static final Object noGravityDataWatcher = BountifulWrapper.impl.getDataWatcherObject(5,Boolean.class); @@ -126,7 +131,7 @@ public class REntity { move(location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw(), rotToByte(location.getYaw())); } - private static final double MAX_REL_MOVE = Core.getVersion() > 8 ? 8.0 : 4.0; + private static final double MAX_REL_MOVE = 8.0; public void move(double locX, double locY, double locZ, float pitch, float yaw, byte headYaw) { server.preEntityMove(this, locX, locZ); @@ -160,9 +165,9 @@ public class REntity { server.postEntityMove(this, fromX, fromZ); } - private static final Class animationPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundAnimatePacket"); - private static final Reflection.Field animationEntity = Reflection.getField(animationPacket, int.class, Core.getVersion() > 15 ? (Core.getVersion() > 19 ? 5 : 6) : 0); - private static final Reflection.Field animationAnimation = Reflection.getField(animationPacket, int.class, Core.getVersion() > 15 ? (Core.getVersion() > 19 ? 6 : 7) : 1); + private static final Class animationPacket = ClientboundAnimatePacket.class; + private static final Reflection.Field animationEntity = Reflection.getField(animationPacket, int.class, 5); + private static final Reflection.Field animationAnimation = Reflection.getField(animationPacket, int.class, 6); public void showAnimation(byte animation) { Object packet = Reflection.newInstance(animationPacket); animationEntity.set(packet, entityId); @@ -170,7 +175,7 @@ public class REntity { server.updateEntity(this, packet); } - private static final Class velocityPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket"); + private static final Class velocityPacket = ClientboundSetEntityMotionPacket.class; private static final Reflection.Field velocityEntity = Reflection.getField(velocityPacket, int.class, 0); private static final Reflection.Field velocityX = Reflection.getField(velocityPacket, int.class, 1); private static final Reflection.Field velocityY = Reflection.getField(velocityPacket, int.class, 2); @@ -184,7 +189,7 @@ public class REntity { server.updateEntity(this, packet); } - private static final Class statusPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundEntityEventPacket"); + private static final Class statusPacket = ClientboundEntityEventPacket.class; private static final Reflection.Field statusEntity = Reflection.getField(statusPacket, int.class, 0); private static final Reflection.Field statusStatus = Reflection.getField(statusPacket, byte.class, 0); public void showDamage() { @@ -196,11 +201,7 @@ public class REntity { public void setPose(FlatteningWrapper.EntityPose pose) { this.pose = pose; - if(Core.getVersion() > 12) { - server.updateEntity(this, getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(pose))); - } else { - server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus())); - } + server.updateEntity(this, getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(pose))); } public void setOnFire(boolean perma) { @@ -219,13 +220,7 @@ public class REntity { public void setBowDrawn(boolean drawn, boolean offHand) { bowDrawn = drawn; - if (Core.getVersion() >= 21) { - server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.SHOOTING))); - } else if(Core.getVersion() > 8){ - server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0)))); - }else{ - server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus())); - } + server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.SHOOTING))); } public void setDisplayName(String displayName) { @@ -247,55 +242,22 @@ public class REntity { public void setNoGravity(boolean noGravity) { this.noGravity = noGravity; - if(Core.getVersion() > 8) - server.updateEntity(this,getDataWatcherPacket(noGravityDataWatcher,noGravity)); + server.updateEntity(this,getDataWatcherPacket(noGravityDataWatcher,noGravity)); } public void setGlowing(boolean glowing) { this.isGlowing = glowing; - if(Core.getVersion() > 8) { - server.updateEntity(this,getDataWatcherPacket(entityStatusWatcher,getEntityStatus())); - } + server.updateEntity(this,getDataWatcherPacket(entityStatusWatcher,getEntityStatus())); } public boolean isGlowing() { return isGlowing; } - private static int spawnPacketOffset() { - switch (Core.getVersion()) { - case 8: - case 18: - return 1; - case 9: - case 10: - case 12: - case 14: - case 15: - return 0; - case 19: - default: - return 2; - } - } - private static final Function spawnPacketGenerator = entitySpawnPacketGenerator(ProtocolWrapper.spawnPacket, spawnPacketOffset()); - private static int objectDataOffset() { - switch (Core.getVersion()) { - case 8: - return 9; - case 9: - case 14: - case 12: - case 10: - case 15: - case 18: - return 6; - case 19: - default: - return 4; - } - } - private static final Reflection.Field additionalData = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, objectDataOffset()); + private static final Function spawnPacketGenerator = entitySpawnPacketGenerator(ProtocolWrapper.spawnPacket, 2); + + private static final Reflection.Field additionalData = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, 4); + private Object spawnPacketGenerator() { Object packet = spawnPacketGenerator.apply(this); additionalData.set(packet, objectData); @@ -306,7 +268,7 @@ public class REntity { // empty for regular entity } - private static final Function livingSpawnPacketGenerator = Core.getVersion() >= 19 ? REntity::spawnPacketGenerator : entitySpawnPacketGenerator(ProtocolWrapper.spawnLivingPacket, Core.getVersion() == 8 ? 2 : 0); + private static final Function livingSpawnPacketGenerator = REntity::spawnPacketGenerator; void spawn(Consumer packetSink) { if(entityType.isAlive()) { packetSink.accept(livingSpawnPacketGenerator.apply(this)); @@ -322,7 +284,7 @@ public class REntity { packetSink.accept(getHeadRotationPacket()); } - if(Core.getVersion() > 12 && pose != FlatteningWrapper.EntityPose.NORMAL) { + if(pose != FlatteningWrapper.EntityPose.NORMAL) { packetSink.accept(getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(pose))); } @@ -335,8 +297,9 @@ public class REntity { packetSink.accept(getDataWatcherPacket(nameWatcher, FlatteningWrapper.impl.formatDisplayName(displayName), nameVisibleWatcher, true)); } - if(Core.getVersion() > 8 && noGravity) + if(noGravity) { packetSink.accept(getDataWatcherPacket(noGravityDataWatcher, true)); + } } void tick() { @@ -348,17 +311,11 @@ public class REntity { } } - private static final Class destroyPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket"); - private static final Reflection.Field destroyEntities; - static { - if(Core.getVersion() > 15) - destroyEntities = Reflection.getField(destroyPacket, IntList.class, 0); - else - destroyEntities = Reflection.getField(destroyPacket, int[].class, 0); - } + private static final Class destroyPacket = ClientboundRemoveEntitiesPacket.class; + private static final Reflection.Field destroyEntities = Reflection.getField(destroyPacket, IntList.class, 0); void despawn(Consumer packetSink){ Object packet = Reflection.newInstance(destroyPacket); - destroyEntities.set(packet, Core.getVersion() > 15 ? new IntArrayList(new int[]{entityId}) : new int[]{entityId}); + destroyEntities.set(packet, new IntArrayList(new int[]{entityId})); packetSink.accept(packet); } @@ -381,11 +338,9 @@ public class REntity { status |= 1; if(pose == FlatteningWrapper.EntityPose.SNEAKING) status |= 2; - if(Core.getVersion() == 8 && bowDrawn) - status |= 0x10; if(invisible) status |= 0x20; - if(Core.getVersion() > 8 && isGlowing) + if(isGlowing) status |= 0x40; return status; @@ -395,26 +350,19 @@ public class REntity { return ChatWrapper.impl.getDataWatcherPacket(entityId, dataWatcherKeyValues); } - public static final Class teleportPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket"); + public static final Class teleportPacket = ClientboundTeleportEntityPacket.class; public static final Reflection.Field teleportEntity = Reflection.getField(teleportPacket, int.class, 0); - public static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0); + public static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, 0); private Object getTeleportPacket(){ - if (Core.getVersion() >= 21) { - return PacketConstructor.impl.teleportPacket(entityId, x, y, z, pitch, yaw); - } - - Object packet = Reflection.newInstance(teleportPacket); - teleportEntity.set(packet, entityId); - teleportPosition.set(packet, x, y, z, pitch, yaw); - return packet; + return PacketConstructor.impl.teleportPacket(entityId, x, y, z, pitch, yaw); } - private static final Class entityPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundMoveEntityPacket"); + private static final Class entityPacket = ClientboundMoveEntityPacket.class; private static final Reflection.Field moveEntityId = Reflection.getField(entityPacket, int.class, 0); private static final BountifulWrapper.PositionSetter movePosition = BountifulWrapper.impl.getRelMoveSetter(entityPacket); - private static final Class lookPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$Rot"); - private static final Class movePacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$Pos"); - private static final Class moveLookPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundMoveEntityPacket$PosRot"); + private static final Class lookPacket = ClientboundMoveEntityPacket.Rot.class; + private static final Class movePacket = ClientboundMoveEntityPacket.Pos.class; + private static final Class moveLookPacket = ClientboundMoveEntityPacket.PosRot.class; private Object getMoveLookPacket(double diffX, double diffY, double diffZ, boolean rotEq) { Class clazz; if(diffX == 0 && diffY == 0 && diffZ == 0) { @@ -434,7 +382,7 @@ public class REntity { return packet; } - private static final Class headRotationPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundRotateHeadPacket"); + private static final Class headRotationPacket = ClientboundRotateHeadPacket.class; private static final Reflection.Field headRotationEntity = Reflection.getField(headRotationPacket, int.class, 0); private static final Reflection.Field headRotationYaw = Reflection.getField(headRotationPacket, byte.class, 0); private Object getHeadRotationPacket(){ @@ -447,13 +395,11 @@ public class REntity { private static final Reflection.Field equipmentEntity = Reflection.getField(ProtocolWrapper.equipmentPacket, int.class, 0); private static final Reflection.Field equipmentSlots = Reflection.getField(ProtocolWrapper.equipmentPacket, List.class, 0); - private static final Class craftItemStack = Reflection.getClass("org.bukkit.craftbukkit.inventory.CraftItemStack"); - protected static final Reflection.Method asNMSCopy = Reflection.getTypedMethod(REntity.craftItemStack, "asNMSCopy", ProtocolWrapper.itemStack, ItemStack.class); protected Object getEquipmentPacket(Object slot, ItemStack stack){ Object packet = Reflection.newInstance(ProtocolWrapper.equipmentPacket); equipmentEntity.set(packet, entityId); equipmentSlots.set(packet, new ArrayList<>()); - ProtocolWrapper.impl.setEquipmentPacketStack(packet, slot, asNMSCopy.invoke(null, stack)); + ProtocolWrapper.impl.setEquipmentPacketStack(packet, slot, CraftItemStack.asNMSCopy(stack)); return packet; } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntityServer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntityServer.java index 3ba28d38..33d36170 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntityServer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntityServer.java @@ -19,10 +19,11 @@ package de.steamwar.entity; -import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; +import de.steamwar.Reflection; import de.steamwar.core.Core; import de.steamwar.core.FlatteningWrapper; +import net.minecraft.network.protocol.game.ServerboundInteractPacket; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -47,19 +48,15 @@ public class REntityServer implements Listener { private static final HashSet emptyEntities = new HashSet<>(0); private static final HashSet emptyPlayers = new HashSet<>(0); - private static final Class useEntity = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundInteractPacket"); + private static final Class useEntity = ServerboundInteractPacket.class; private static final Reflection.Field useEntityTarget = Reflection.getField(useEntity, int.class, 0); private static final Class useEntityEnumAction = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundInteractPacket$Action"); private static final Reflection.Field useEntityAction = Reflection.getField(useEntity, useEntityEnumAction, 0); private static final Function getEntityAction; static { - if(Core.getVersion() > 15) { - Class useEntityEnumActionType = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundInteractPacket$ActionType"); - Reflection.Method useEntityGetAction = Reflection.getTypedMethod(useEntityEnumAction, null, useEntityEnumActionType); - getEntityAction = value -> ((Enum) useEntityGetAction.invoke(value)).ordinal(); - } else { - getEntityAction = value -> ((Enum) value).ordinal(); - } + Class useEntityEnumActionType = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundInteractPacket$ActionType"); + Reflection.Method useEntityGetAction = Reflection.getTypedMethod(useEntityEnumAction, null, useEntityEnumActionType); + getEntityAction = value -> ((Enum) useEntityGetAction.invoke(value)).ordinal(); } private final ConcurrentHashMap entityMap = new ConcurrentHashMap<>(); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RFallingBlockEntity.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RFallingBlockEntity.java index 92d19f90..293ce520 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RFallingBlockEntity.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RFallingBlockEntity.java @@ -19,7 +19,6 @@ package de.steamwar.entity; -import de.steamwar.core.Core; import de.steamwar.techhider.BlockIds; import lombok.Getter; import org.bukkit.Location; @@ -32,7 +31,7 @@ public class RFallingBlockEntity extends REntity{ private final Material material; public RFallingBlockEntity(REntityServer server, Location location, Material material) { - super(server, EntityType.FALLING_BLOCK, location, BlockIds.impl.materialToId(material) >> (Core.getVersion() <= 12 ? 4 : 0)); + super(server, EntityType.FALLING_BLOCK, location, BlockIds.impl.materialToId(material)); this.material = material; server.addEntity(this); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RItemDisplay.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RItemDisplay.java index 894ba21c..1d78cb8d 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RItemDisplay.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RItemDisplay.java @@ -20,11 +20,11 @@ package de.steamwar.entity; import de.steamwar.core.BountifulWrapper; -import de.steamwar.core.Core; import de.steamwar.core.ProtocolWrapper; import lombok.Getter; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.EntityType; import org.bukkit.entity.ItemDisplay; import org.bukkit.inventory.ItemStack; @@ -61,14 +61,14 @@ public class RItemDisplay extends RDisplay { sendPacket(updatePacketSink, this::getItemStack); } - private static final Object itemStackWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 23 : 22, ProtocolWrapper.itemStack); + private static final Object itemStackWatcher = BountifulWrapper.impl.getDataWatcherObject(23, ProtocolWrapper.itemStack); private void getItemStack(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || !itemStack.equals(DEFAULT_ITEM_STACK)) { - packetSink.accept(itemStackWatcher, asNMSCopy.invoke(null, itemStack)); + packetSink.accept(itemStackWatcher, CraftItemStack.asNMSCopy(itemStack)); } } - private static final Object itemDisplayTransformWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 24 : 23, Byte.class); + private static final Object itemDisplayTransformWatcher = BountifulWrapper.impl.getDataWatcherObject(24, Byte.class); public void setItemDisplayTransform(ItemDisplay.ItemDisplayTransform itemDisplayTransform) { this.itemDisplayTransform = itemDisplayTransform; sendPacket(updatePacketSink, this::getItemDisplayTransform); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java index 9883cdde..6f7ce6b5 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RPlayer.java @@ -21,8 +21,9 @@ package de.steamwar.entity; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; -import de.steamwar.Reflection; -import de.steamwar.core.*; +import de.steamwar.core.BountifulWrapper; +import de.steamwar.core.ProtocolWrapper; +import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.network.CoreNetworkHandler; import de.steamwar.network.NetworkSender; import de.steamwar.network.packets.common.PlayerSkinRequestPacket; @@ -36,31 +37,10 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.UUID; import java.util.function.Consumer; -import java.util.function.Function; public class RPlayer extends REntity { - private static int skinPartsIndex() { - switch(Core.getVersion()) { - case 8: - return 10; - case 9: - return 12; - case 10: - case 12: - return 13; - case 14: - return 15; - case 15: - return 16; - case 18: - case 19: - default: - return 17; - } - } - - private static final Object skinPartsDataWatcher = BountifulWrapper.impl.getDataWatcherObject(skinPartsIndex(), Byte.class); + private static final Object skinPartsDataWatcher = BountifulWrapper.impl.getDataWatcherObject(17, Byte.class); @Getter private final UUID actualUUID; @@ -114,24 +94,7 @@ public class RPlayer extends REntity { packetSink.accept(ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, saved, GameMode.CREATIVE)); } - private static Class namedSpawnPacket = null; - private static Function namedSpawnPacketGenerator = null; - private static Reflection.Field namedSpawnUUID = null; - - static { - try { - namedSpawnPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundAddPlayerPacket"); - namedSpawnPacketGenerator = spawnPacketGenerator(namedSpawnPacket, Core.getVersion() == 8 ? 1 : 0); - namedSpawnUUID = Reflection.getField(namedSpawnPacket, UUID.class, 0); - } catch (IllegalArgumentException e) { } - } - private Object getNamedSpawnPacket() { - if (Core.getVersion() >= 21) return PacketConstructor.impl.createRPlayerSpawn(this); - - Object packet = namedSpawnPacketGenerator.apply(this); - namedSpawnUUID.set(packet, uuid); - FlatteningWrapper.impl.setNamedSpawnPacketDataWatcher(packet); - return packet; + return PacketConstructor.impl.createRPlayerSpawn(this); } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RTextDisplay.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RTextDisplay.java index 29cb8a21..17f4218e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RTextDisplay.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/RTextDisplay.java @@ -24,6 +24,7 @@ import de.steamwar.core.BountifulWrapper; import de.steamwar.core.ChatWrapper; import de.steamwar.core.Core; import lombok.Getter; +import net.minecraft.network.chat.Component; import org.bukkit.Location; import org.bukkit.entity.EntityType; import org.bukkit.entity.TextDisplay; @@ -74,8 +75,8 @@ public class RTextDisplay extends RDisplay { sendPacket(updatePacketSink, this::getText); } - private static final Class iChatBaseComponent = Reflection.getClass("net.minecraft.network.chat.Component"); - private static final Object textWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 23 : 22, iChatBaseComponent); + private static final Class iChatBaseComponent = Component.class; + private static final Object textWatcher = BountifulWrapper.impl.getDataWatcherObject(23, iChatBaseComponent); private void getText(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || !text.isEmpty()) { packetSink.accept(textWatcher, ChatWrapper.impl.stringToChatComponent(text)); @@ -87,7 +88,7 @@ public class RTextDisplay extends RDisplay { sendPacket(updatePacketSink, this::getLineWidth); } - private static final Object lineWidthWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 24 : 23, Integer.class); + private static final Object lineWidthWatcher = BountifulWrapper.impl.getDataWatcherObject(24, Integer.class); private void getLineWidth(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || lineWidth != 200) { packetSink.accept(lineWidthWatcher, lineWidth); @@ -99,7 +100,7 @@ public class RTextDisplay extends RDisplay { sendPacket(updatePacketSink, this::getTextOpacity); } - private static final Object textOpacityWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 26 : 25, Byte.class); + private static final Object textOpacityWatcher = BountifulWrapper.impl.getDataWatcherObject(26, Byte.class); private void getTextOpacity(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || textOpacity != (byte) -1) { packetSink.accept(textOpacityWatcher, textOpacity); @@ -121,7 +122,7 @@ public class RTextDisplay extends RDisplay { sendPacket(updatePacketSink, this::getTextStatus, this::getBackgroundColor); } - private static final Object backgroundColorWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 25 : 24, Integer.class); + private static final Object backgroundColorWatcher = BountifulWrapper.impl.getDataWatcherObject(25, Integer.class); private void getBackgroundColor(boolean ignoreDefault, BiConsumer packetSink) { if (ignoreDefault || backgroundColor != null) { packetSink.accept(backgroundColorWatcher, backgroundColor); @@ -140,7 +141,7 @@ public class RTextDisplay extends RDisplay { sendPacket(updatePacketSink, this::getTextStatus); } - private static final Object textStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 27 : 26, Byte.class); + private static final Object textStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(27, Byte.class); private void getTextStatus(boolean ignoreDefault, BiConsumer packetSink) { byte status = 0; diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java index 1b230121..50039b8e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java @@ -21,7 +21,6 @@ package de.steamwar.inventory; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import de.steamwar.core.Core; import de.steamwar.core.FlatteningWrapper; import de.steamwar.core.TrickyTrialsWrapper; import org.bukkit.Material; @@ -217,10 +216,8 @@ public class SWItem { } public SWItem setCustomModelData(int customModelData) { - if (Core.getVersion() > 12) { - itemMeta.setCustomModelData(customModelData); - itemStack.setItemMeta(itemMeta); - } + itemMeta.setCustomModelData(customModelData); + itemStack.setItemMeta(itemMeta); return this; } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/linkage/SpigotLinker.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/linkage/SpigotLinker.java index c157aa85..37ccaae3 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/linkage/SpigotLinker.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/linkage/SpigotLinker.java @@ -20,7 +20,6 @@ package de.steamwar.linkage; import de.steamwar.command.SWCommand; -import de.steamwar.core.Core; import de.steamwar.message.Message; import de.steamwar.network.packets.PacketHandler; import lombok.NonNull; @@ -38,17 +37,6 @@ public class SpigotLinker extends AbstractLinker { this.message = message; } - @Override - protected boolean versionCheck(@NonNull Class clazz, MinVersion minVersion, MaxVersion maxVersion) { - if (minVersion != null && Core.getVersion() < minVersion.value()) { - return false; - } - if (maxVersion != null && Core.getVersion() > maxVersion.value()) { - return false; - } - return true; - } - @Override protected boolean pluginCheck(@NonNull Class clazz, PluginCheck pluginCheck) { if (pluginCheck.has() == PluginCheck.Has.THIS && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) != null) { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/message/Message.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/message/Message.java index f24b84e6..89920d2b 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/message/Message.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/message/Message.java @@ -20,7 +20,6 @@ package de.steamwar.message; import de.steamwar.core.BountifulWrapper; -import de.steamwar.core.Core; import de.steamwar.sql.SteamwarUser; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.ClickEvent; @@ -30,7 +29,6 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import java.nio.charset.StandardCharsets; import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; @@ -82,10 +80,7 @@ public class Message { } private String fromRB(ResourceBundle bundle, String key) { - String result = bundle.getString(key); - if(Core.getVersion() < 12) - result = new String(result.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); - return result; + return bundle.getString(key); } private Locale getLocale(Player player){ diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/ServerDataHandler.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/ServerDataHandler.java index eec211b2..81ea860d 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/ServerDataHandler.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/network/handlers/ServerDataHandler.java @@ -19,17 +19,18 @@ package de.steamwar.network.handlers; -import de.steamwar.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.linkage.Linked; import de.steamwar.linkage.MinVersion; +import net.minecraft.network.protocol.game.ClientboundServerDataPacket; +import net.minecraft.network.protocol.game.ServerboundChatSessionUpdatePacket; @Linked @MinVersion(19) public class ServerDataHandler { public ServerDataHandler() { - TinyProtocol.instance.addFilter(Reflection.getClass("net.minecraft.network.protocol.game.ClientboundServerDataPacket"), (p, o) -> null); - TinyProtocol.instance.addFilter(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundChatSessionUpdatePacket"), (player, packet) -> null); + TinyProtocol.instance.addFilter(ClientboundServerDataPacket.class, (p, o) -> null); + TinyProtocol.instance.addFilter(ServerboundChatSessionUpdatePacket.class, (player, packet) -> null); } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java index 4fd2bebe..69896ae1 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/sql/SQLWrapperImpl.java @@ -28,7 +28,6 @@ import org.bukkit.entity.Player; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -46,9 +45,6 @@ public class SQLWrapperImpl implements SQLWrapper { @Override public List getMaterialWithGreaterBlastResistance(double maxBlastResistance) { - if (Core.getVersion() <= 12) { - return Collections.emptyList(); - } return Arrays.stream(Material.values()) .filter(material -> !material.isLegacy()) .filter(Material::isBlock) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/BlockIds.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/BlockIds.java index e0ec9a14..93ac2bda 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/BlockIds.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/BlockIds.java @@ -19,9 +19,16 @@ package de.steamwar.techhider; -import com.google.common.collect.ImmutableList; import de.steamwar.Reflection; +import net.minecraft.core.IdMapper; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.material.FlowingFluid; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; import org.bukkit.Material; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; import java.util.HashSet; import java.util.Set; @@ -29,31 +36,21 @@ import java.util.Set; public class BlockIds { public static final BlockIds impl = new BlockIds(); - Reflection.Method getCombinedId = Reflection.getTypedMethod(TechHider.block, null, int.class, TechHider.iBlockData); - - private static final Class blockStateList = Reflection.getClass("net.minecraft.world.level.block.state.StateDefinition"); - private static final Class fluidTypeFlowing = Reflection.getClass("net.minecraft.world.level.material.FlowingFluid"); - private static final Class fluid = Reflection.getClass("net.minecraft.world.level.material.FluidState"); - - private static final Reflection.Method getBlockData = Reflection.getTypedMethod(TechHider.block, null, TechHider.iBlockData); public int materialToId(Material material) { - return getCombinedId(getBlockData.invoke(getBlock(material))); + return getCombinedId(getBlock(material).defaultBlockState()); } - private static final Reflection.Method getStates = Reflection.getTypedMethod(TechHider.block, null, blockStateList); - private static final Reflection.Method getStateList = Reflection.getTypedMethod(blockStateList, null, ImmutableList.class); - private static final Object water = Reflection.getTypedMethod(fluidTypeFlowing, null, fluid, boolean.class).invoke(Reflection.getField(Reflection.getClass("net.minecraft.world.level.material.Fluids"), fluidTypeFlowing, 1).get(null), false); - private static final Iterable registryBlockId = (Iterable) Reflection.getField(TechHider.block, Reflection.getClass("net.minecraft.core.IdMapper"), 0).get(null); - private static final Reflection.Method getFluid = Reflection.getTypedMethod(TechHider.iBlockData, null, fluid); + private static final FluidState water = Fluids.WATER.getSource(false); + private static final Iterable registryBlockId = (Iterable) Reflection.getField(TechHider.block, IdMapper.class, 0).get(null); public Set materialToAllIds(Material material) { Set ids = new HashSet<>(); - for(Object data : (ImmutableList) getStateList.invoke(getStates.invoke(getBlock(material)))) { + for(BlockState data : getBlock(material).getStateDefinition().getPossibleStates()) { ids.add(getCombinedId(data)); } if(material == Material.WATER) { - for(Object data : registryBlockId) { - if(getFluid.invoke(data) == water) { + for(BlockState data : registryBlockId) { + if (data.getFluidState() == water) { ids.add(getCombinedId(data)); } } @@ -62,12 +59,11 @@ public class BlockIds { return ids; } - private static final Reflection.Method getBlock = Reflection.getTypedMethod(TechHider.craftMagicNumbers, "getBlock", TechHider.block, Material.class); - private Object getBlock(Material material) { - return getBlock.invoke(null, material); + private Block getBlock(Material material) { + return CraftMagicNumbers.getBlock(material); } - public int getCombinedId(Object blockData) { - return (int) getCombinedId.invoke(null, blockData); + public int getCombinedId(BlockState blockData) { + return Block.getId(blockData); } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ChunkHider.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ChunkHider.java index c1ff1e3f..65143215 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ChunkHider.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ChunkHider.java @@ -23,8 +23,11 @@ import de.steamwar.Reflection; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import lombok.Getter; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.SimpleBitStorage; import net.minecraft.world.level.block.entity.BlockEntityType; import org.bukkit.entity.Player; @@ -89,16 +92,14 @@ public class ChunkHider { }; } + private static final Registry> registry = Reflection.getField(BuiltInRegistries.class, "BLOCK_ENTITY_TYPE", Registry.class).get(null); + private static final Reflection.Method getKey = Reflection.getTypedMethod(Reflection.getClass("net.minecraft.core.Registry"), "getKey", ResourceLocation.class, Object.class); public static final Class tileEntity = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData$BlockEntityInfo"); protected static final Reflection.Field entityType = Reflection.getField(tileEntity, BlockEntityType.class, 0); - private static final Class builtInRegestries = Reflection.getClass("net.minecraft.core.registries.BuiltInRegistries"); - private static final Class registry = Reflection.getClass("net.minecraft.core.Registry"); - private static final Reflection.Field nameField = Reflection.getField(builtInRegestries, "BLOCK_ENTITY_TYPE", registry); - private static final Class resourceLocation = Reflection.getClass("net.minecraft.resources.ResourceLocation"); - private static final Reflection.Method getKey = Reflection.getTypedMethod(registry, "getKey", resourceLocation, Object.class); - private static final Reflection.Method getName = Reflection.getTypedMethod(resourceLocation, "getPath", String.class); protected boolean tileEntityVisible(Set hiddenBlockEntities, Object tile) { - return !hiddenBlockEntities.contains(getName.invoke(getKey.invoke(nameField.get(null), entityType.get(tile)))); + BlockEntityType type = entityType.get(tile); + String path = ((ResourceLocation) getKey.invoke(registry, type)).getPath(); + return !hiddenBlockEntities.contains(path); } private void blocks(SectionHider section) { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java index 46e53bcf..9eff141e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java @@ -21,9 +21,14 @@ package de.steamwar.techhider; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.Reflection; -import de.steamwar.core.Core; import lombok.Getter; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; +import net.minecraft.network.protocol.game.*; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import org.bukkit.Material; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.entity.Player; import java.util.HashMap; @@ -36,24 +41,20 @@ import java.util.stream.Collectors; public class TechHider { - public static final Class blockPosition = Reflection.getClass("net.minecraft.core.BlockPos"); - private static final Class baseBlockPosition = Reflection.getClass("net.minecraft.core.Vec3i"); + public static final Class blockPosition = BlockPos.class; + private static final Class baseBlockPosition = Vec3i.class; public static final Reflection.Field blockPositionX = Reflection.getField(baseBlockPosition, int.class, 0); public static final Reflection.Field blockPositionY = Reflection.getField(baseBlockPosition, int.class, 1); public static final Reflection.Field blockPositionZ = Reflection.getField(baseBlockPosition, int.class, 2); - public static final Class iBlockData = Reflection.getClass("net.minecraft.world.level.block.state.BlockState"); - public static final Class block = Reflection.getClass("net.minecraft.world.level.block.Block"); - private static final Reflection.Method getBlockDataByBlock = Reflection.getTypedMethod(block, null, iBlockData); + public static final Class iBlockData = BlockState.class; + public static final Class block = Block.class; - public static final Class craftMagicNumbers = Reflection.getClass("org.bukkit.craftbukkit.util.CraftMagicNumbers"); - private static final Reflection.Method getBlockByMaterial = Reflection.getTypedMethod(craftMagicNumbers, "getBlock", block, Material.class); - - public boolean iBlockDataHidden(Object iBlockData) { + public boolean iBlockDataHidden(BlockState iBlockData) { return obfuscateIds.contains(BlockIds.impl.getCombinedId(iBlockData)); } - public static final Object AIR = getBlockDataByBlock.invoke(getBlockByMaterial.invoke(null, Material.AIR)); + public static final Object AIR = CraftMagicNumbers.getBlock(Material.AIR).defaultBlockState(); public static final int AIR_ID = BlockIds.impl.materialToId(Material.AIR); private final Map, BiFunction> techhiders = new HashMap<>(); @@ -72,7 +73,7 @@ public class TechHider { this.locationEvaluator = locationEvaluator; this.obfuscateIds = obfuscate.stream().flatMap(m -> BlockIds.impl.materialToAllIds(m).stream()).collect(Collectors.toSet()); this.hiddenBlockEntities = hiddenBlockEntities; - this.obfuscationTarget = getBlockDataByBlock.invoke(getBlockByMaterial.invoke(null, obfuscationTarget)); + this.obfuscationTarget = CraftMagicNumbers.getBlock(obfuscationTarget).defaultBlockState(); this.obfuscationTargetId = BlockIds.impl.materialToId(obfuscationTarget); techhiders.put(blockActionPacket, this::blockActionHider); @@ -80,16 +81,8 @@ public class TechHider { techhiders.put(tileEntityDataPacket, this::tileEntityDataHider); techhiders.put(multiBlockChangePacket, ProtocolWrapper.impl.multiBlockChangeGenerator(this)); techhiders.put(ChunkHider.impl.mapChunkPacket(), ChunkHider.impl.chunkHiderGenerator(this)); - - if(Core.getVersion() > 12 && Core.getVersion() < 19) { - Class blockBreakClass = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket"); - techhiders.put(blockBreakClass, ProtocolWrapper.impl.blockBreakHiderGenerator(blockBreakClass, this)); - } - - if(Core.getVersion() > 8){ - techhiders.put(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundUseItemOnPacket"), (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet); - } - techhiders.put(Reflection.getClass("net.minecraft.network.protocol.game.ServerboundInteractPacket"), (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet); + techhiders.put(ServerboundUseItemOnPacket.class, (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet); + techhiders.put(ServerboundInteractPacket.class, (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet); } @@ -101,10 +94,10 @@ public class TechHider { techhiders.forEach(TinyProtocol.instance::removeFilter); } - public static final Class multiBlockChangePacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket"); + public static final Class multiBlockChangePacket = ClientboundSectionBlocksUpdatePacket.class; public static final UnaryOperator multiBlockChangeCloner = ProtocolUtils.shallowCloneGenerator(TechHider.multiBlockChangePacket); - private static final Class blockChangePacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket"); + private static final Class blockChangePacket = ClientboundBlockUpdatePacket.class; private static final Function blockChangeCloner = ProtocolUtils.shallowCloneGenerator(blockChangePacket); private static final Reflection.Field blockChangePosition = Reflection.getField(blockChangePacket, blockPosition, 0); private static final Reflection.Field blockChangeBlockData = Reflection.getField(blockChangePacket, iBlockData, 0); @@ -113,7 +106,7 @@ public class TechHider { case SKIP: return packet; case CHECK: - if(!iBlockDataHidden(blockChangeBlockData.get(packet))) + if(!iBlockDataHidden((BlockState) blockChangeBlockData.get(packet))) return packet; case HIDE: packet = blockChangeCloner.apply(packet); @@ -127,7 +120,7 @@ public class TechHider { } } - private static final Class blockActionPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundBlockEventPacket"); + private static final Class blockActionPacket = ClientboundBlockEventPacket.class; private static final Reflection.Field blockActionPosition = Reflection.getField(blockActionPacket, blockPosition, 0); private Object blockActionHider(Player p, Object packet) { if (locationEvaluator.checkBlockPos(p, blockActionPosition.get(packet)) == State.SKIP) @@ -135,7 +128,7 @@ public class TechHider { return null; } - public static final Class tileEntityDataPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket"); + public static final Class tileEntityDataPacket = ClientboundBlockEntityDataPacket.class; private static final Reflection.Field tileEntityDataPosition = Reflection.getField(tileEntityDataPacket, blockPosition, 0); private Object tileEntityDataHider(Player p, Object packet) { switch (locationEvaluator.checkBlockPos(p, tileEntityDataPosition.get(packet))) { diff --git a/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java b/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java index d4d0f9f3..403a1af4 100644 --- a/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java +++ b/Teamserver/src/de/steamwar/teamserver/listener/FreezeListener.java @@ -135,7 +135,6 @@ public class FreezeListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) public void onBlockBreak(BlockBreakEvent e) { - if (Core.getVersion() < 19) return; if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return; if (freeze) { if (e.isCancelled()) return;