Merge remote-tracking branch 'origin/ReflectionReduction' into Refactor/remove-old-dependencies

This commit is contained in:
2026-05-16 14:03:19 +02:00
45 changed files with 123 additions and 378 deletions
@@ -155,7 +155,6 @@ public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) { public void onBlockBreak(BlockBreakEvent e) {
if (Core.getVersion() < 19) return;
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return; if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) { if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true); e.setCancelled(true);
@@ -56,7 +56,6 @@ public class StorageLib implements LuaLib, Enable, Disable {
@Override @Override
public void enable() { public void enable() {
if (Core.getVersion() <= 15) return;
if (!storageDirectory.exists()) storageDirectory.mkdirs(); if (!storageDirectory.exists()) storageDirectory.mkdirs();
try { try {
@@ -132,7 +131,6 @@ public class StorageLib implements LuaLib, Enable, Disable {
@Override @Override
public void disable() { public void disable() {
if (Core.getVersion() <= 15) return;
if (!storageDirectory.exists()) storageDirectory.mkdirs(); if (!storageDirectory.exists()) storageDirectory.mkdirs();
try { try {
FileWriter fileWriter = new FileWriter(new File(storageDirectory, "global.json")); FileWriter fileWriter = new FileWriter(new File(storageDirectory, "global.json"));
@@ -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.data.observer.ObserverPhase;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.core.Core;
import de.steamwar.data.CMDs; import de.steamwar.data.CMDs;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import org.bukkit.Material; import org.bukkit.Material;
@@ -128,15 +127,14 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED)); }).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 : Material.RECOVERY_COMPASS, "§eActivation Order§8:§7 " + order, clickType -> {
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> { new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> {
if (integer < -SimulatorPhase.ORDER_LIMIT) return false; if (integer < -SimulatorPhase.ORDER_LIMIT) return false;
if (integer > SimulatorPhase.ORDER_LIMIT) return false; if (integer > SimulatorPhase.ORDER_LIMIT) return false;
observer.setOrder(integer); observer.setOrder(integer);
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
return true; 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))); orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
inventory.setItem(22, orderItem); inventory.setItem(22, orderItem);
@@ -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.data.redstone.RedstonePhase;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.core.Core;
import de.steamwar.data.CMDs; import de.steamwar.data.CMDs;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import org.bukkit.Material; import org.bukkit.Material;
@@ -154,15 +153,14 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED)); }).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 : Material.RECOVERY_COMPASS, "§eActivation Order§8:§7 " + order, clickType -> {
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> { new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> {
if (integer < -SimulatorPhase.ORDER_LIMIT) return false; if (integer < -SimulatorPhase.ORDER_LIMIT) return false;
if (integer > SimulatorPhase.ORDER_LIMIT) return false; if (integer > SimulatorPhase.ORDER_LIMIT) return false;
redstone.setOrder(integer); redstone.setOrder(integer);
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
return true; 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))); orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
inventory.setItem(22, orderItem); inventory.setItem(22, orderItem);
@@ -102,7 +102,6 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
tnt.setDisabled(!tnt.isDisabled()); tnt.setDisabled(!tnt.isDisabled());
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED)); }).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
if (Core.getVersion() > 19) {
inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> { inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> {
new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> { new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> {
if (depthLimit <= 0) return false; if (depthLimit <= 0) return false;
@@ -111,7 +110,6 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
return true; return true;
}, null).open(); }, null).open();
}).setCustomModelData(CMDs.Simulator.CREATE_STAB)); }).setCustomModelData(CMDs.Simulator.CREATE_STAB));
}
inventory.setItem(50, new SWItem(Material.CHEST, parent.getElements().size() == 1 ? "§eMake Group" : "§eAdd another TNT to Group", clickType -> { 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 tntElement = new TNTElement(tnt.getPosition().clone());
tntElement.add(new TNTPhase()); tntElement.add(new TNTPhase());
@@ -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.data.tnt.TNTPhase;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.core.Core;
import de.steamwar.data.CMDs; import de.steamwar.data.CMDs;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import org.bukkit.Material; import org.bukkit.Material;
@@ -159,15 +158,14 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED)); }).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 : Material.RECOVERY_COMPASS, "§eCalculation Order§8:§7 " + order, clickType -> {
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eCalculation Order§8:§7 " + order, clickType -> {
new SimulatorAnvilGui<>(player, "Calculation Order", order + "", Integer::parseInt, integer -> { new SimulatorAnvilGui<>(player, "Calculation Order", order + "", Integer::parseInt, integer -> {
if (integer < -SimulatorPhase.ORDER_LIMIT) return false; if (integer < -SimulatorPhase.ORDER_LIMIT) return false;
if (integer > SimulatorPhase.ORDER_LIMIT) return false; if (integer > SimulatorPhase.ORDER_LIMIT) return false;
tnt.setOrder(integer); tnt.setOrder(integer);
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
return true; 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))); orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
inventory.setItem(22, orderItem); inventory.setItem(22, orderItem);
@@ -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.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator; import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.core.Core;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -47,10 +46,7 @@ public abstract class SimulatorBaseGui {
public final void open() { public final void open() {
if (!shouldOpen()) return; if (!shouldOpen()) return;
String newTitle = title(); if (inv != null) {
String originalTitle = player.getOpenInventory().getTitle();
if (inv != null && (Core.getVersion() > 19 || newTitle.equals(originalTitle))) {
// TODO: Flickering is better but not gone! // TODO: Flickering is better but not gone!
for (int i = 9; i < size - 9; i++) { for (int i = 9; i < size - 9; i++) {
inv.setItem(i, null); inv.setItem(i, null);
@@ -60,9 +56,7 @@ public abstract class SimulatorBaseGui {
inventory.open(); inventory.open();
SimulatorWatcher.watch(player, simulator, this::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) { if (simulator != null && simulator.getStabGenerator() != null) {
populateStabGenerator(); populateStabGenerator();
} else { } else {
@@ -235,7 +235,6 @@ public class BlockBoundingBox {
endRodEastWest.setFacing(BlockFace.EAST); 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")); 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(); Directional lightningRodBottomTop = (Directional) Material.LIGHTNING_ROD.createBlockData();
lightningRodBottomTop.setFacing(BlockFace.UP); 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")); addPixel(lightningRodBottomTop, 6, 0, 6, 4, 16, 4, createItem("LAUFBAU_BLOCK_LIGHTNING_ROD", Material.LIGHTNING_ROD, "LAUFBAU_FACING_UP", "LAUFBAU_FACING_DOWN"));
@@ -247,7 +246,6 @@ public class BlockBoundingBox {
Directional lightningRodEastWest = (Directional) Material.LIGHTNING_ROD.createBlockData(); Directional lightningRodEastWest = (Directional) Material.LIGHTNING_ROD.createBlockData();
lightningRodEastWest.setFacing(BlockFace.EAST); 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")); 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(); Waterlogged conduit = (Waterlogged) Material.CONDUIT.createBlockData();
conduit.setWaterlogged(false); conduit.setWaterlogged(false);
@@ -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.BlockBoundingBox;
import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader;
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
import de.steamwar.core.Core;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.type.Fence;
import org.bukkit.block.data.type.Wall; import org.bukkit.block.data.type.Wall;
import java.util.ArrayList; import java.util.ArrayList;
@@ -40,11 +38,7 @@ public class WallBoundingBox implements BoundingBoxLoader {
@Override @Override
public void load() { public void load() {
if (Core.getVersion() > 15) {
v18(); v18();
} else {
v15();
}
} }
private void 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<String> lore = new ArrayList<>();
List<Cuboid> 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])));
}
}
}
}
}
} }
@@ -25,7 +25,6 @@ import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.bausystem.utils.WorldEditUtils;
import de.steamwar.core.Core;
import lombok.Getter; import lombok.Getter;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.bukkit.Location; import org.bukkit.Location;
@@ -57,9 +56,8 @@ public class Panzern {
private BaseBlock blockType; private BaseBlock blockType;
private BaseBlock slabType; 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 cobwebType = BlockTypes.COBWEB.getDefaultState().toBaseBlock();
private static final BaseBlock airType = BlockTypes.AIR.getDefaultState().toBaseBlock();
@Getter @Getter
private EditSession editSession; private EditSession editSession;
@@ -23,7 +23,6 @@ import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.core.Core;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket; import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket;
@@ -150,7 +149,7 @@ public class SmartPlaceListener implements Listener {
if (!Permission.BUILD.hasPermission(event.getPlayer())) return; if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return; if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return;
if (!SMART_PLACING.contains(event.getPlayer())) { 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(); SoundGroup soundGroup = event.getBlockPlaced().getBlockData().getSoundGroup();
event.getPlayer().playSound(event.getBlockPlaced().getLocation(), soundGroup.getPlaceSound(), soundGroup.getVolume() * 0.8F, soundGroup.getPitch() * 0.8F); event.getPlayer().playSound(event.getBlockPlaced().getLocation(), soundGroup.getPlaceSound(), soundGroup.getVolume() * 0.8F, soundGroup.getPitch() * 0.8F);
} }
@@ -31,7 +31,6 @@ import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
import de.steamwar.bausystem.utils.bossbar.BossBarService; import de.steamwar.bausystem.utils.bossbar.BossBarService;
import de.steamwar.command.AbstractSWCommand; import de.steamwar.command.AbstractSWCommand;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.core.Core;
import de.steamwar.core.TPSWatcher; import de.steamwar.core.TPSWatcher;
import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
@@ -59,16 +58,12 @@ public class TPSSystem implements Listener {
} }
new TPSLimitCommand(); new TPSLimitCommand();
new TickLimitCommand(); new TickLimitCommand();
if (Core.getVersion() >= 15) {
new TPSWarpCommand(); new TPSWarpCommand();
new TickWarpCommand(); new TickWarpCommand();
if (TickManager.impl.canFreeze()) { if (TickManager.impl.canFreeze()) {
new TickWarpingCommand(); new TickWarpingCommand();
} }
}
if (Core.getVersion() >= 21) {
new Tick21Command(); new Tick21Command();
}
new TPSDefaultCommand(); new TPSDefaultCommand();
new TickDefaultCommand(); new TickDefaultCommand();
new TPSBaseCommand(); new TPSBaseCommand();
@@ -20,7 +20,6 @@
package de.steamwar.bausystem.features.tracer; package de.steamwar.bausystem.features.tracer;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.core.Core;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@@ -100,11 +99,7 @@ public class TNTPoint {
List<TNTPoint> history, List<Block> destroyedBlocks) { List<TNTPoint> history, List<Block> destroyedBlocks) {
this.tntId = tntId; this.tntId = tntId;
this.explosion = explosion; this.explosion = explosion;
if (Core.getVersion() > 15) {
this.inWater = tnt.isInWater(); this.inWater = tnt.isInWater();
} else {
this.inWater = false;
}
this.afterFirstExplosion = afterFirstExplosion; this.afterFirstExplosion = afterFirstExplosion;
this.ticksSinceStart = ticksSinceStart; this.ticksSinceStart = ticksSinceStart;
fuse = tnt.getFuseTicks(); fuse = tnt.getFuseTicks();
@@ -20,7 +20,6 @@
package de.steamwar.bausystem.features.warp; package de.steamwar.bausystem.features.warp;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.core.Core;
import de.steamwar.core.SWPlayer; import de.steamwar.core.SWPlayer;
import de.steamwar.entity.RArmorStand; import de.steamwar.entity.RArmorStand;
import de.steamwar.entity.REntityServer; import de.steamwar.entity.REntityServer;
@@ -113,7 +112,7 @@ public class WarpListener implements Listener {
vector.setY(0); vector.setY(0);
Vector position = p.getLocation().toVector().clone().add(vector.normalize().multiply(5)); 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) { if ((position.getX() - current.getX()) * (position.getX() - current.getX()) + (position.getZ() - current.getZ()) * (position.getZ() - current.getZ()) < 0.1) {
name = "§a§l" + name; name = "§a§l" + name;
@@ -25,7 +25,6 @@ import de.steamwar.bausystem.region.flags.ColorMode;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.ProtectMode; import de.steamwar.bausystem.region.flags.ProtectMode;
import de.steamwar.bausystem.region.flags.TNTMode; import de.steamwar.bausystem.region.flags.TNTMode;
import de.steamwar.core.Core;
import lombok.NonNull; import lombok.NonNull;
import yapion.hierarchy.types.YAPIONObject; import yapion.hierarchy.types.YAPIONObject;
@@ -47,7 +46,7 @@ public class FixedGlobalRegionData extends RegionData {
if (flag.oneOf(Flag.COLOR, Flag.PROTECT)) { if (flag.oneOf(Flag.COLOR, Flag.PROTECT)) {
return RegionFlagPolicy.READ_ONLY; return RegionFlagPolicy.READ_ONLY;
} }
if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) { if (flag.oneOf(Flag.ITEMS)) {
return RegionFlagPolicy.WRITABLE; return RegionFlagPolicy.WRITABLE;
} }
if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE)) { if (flag.oneOf(Flag.TNT, Flag.FIRE, Flag.FREEZE)) {
@@ -22,7 +22,6 @@ package de.steamwar.bausystem.region.fixed;
import de.steamwar.bausystem.region.RegionData; import de.steamwar.bausystem.region.RegionData;
import de.steamwar.bausystem.region.RegionFlagPolicy; import de.steamwar.bausystem.region.RegionFlagPolicy;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.core.Core;
import lombok.NonNull; import lombok.NonNull;
import yapion.hierarchy.types.YAPIONObject; 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)) { if (flag.oneOf(Flag.COLOR, Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROTECT, Flag.NO_GRAVITY, Flag.CHANGED, Flag.WATER_DESTROY)) {
return RegionFlagPolicy.WRITABLE; return RegionFlagPolicy.WRITABLE;
} }
if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) { if (flag.oneOf(Flag.ITEMS)) {
return RegionFlagPolicy.WRITABLE; return RegionFlagPolicy.WRITABLE;
} }
if (flag.oneOf(Flag.TESTBLOCK)) { if (flag.oneOf(Flag.TESTBLOCK)) {
@@ -71,9 +71,6 @@ public abstract class AbstractLinker<T> {
try { try {
classes.forEach(clazz -> { 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); EventMode eventMode = clazz.getAnnotation(EventMode.class);
if (!eventModeCheck(clazz, eventMode)) return; if (!eventModeCheck(clazz, eventMode)) return;
PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class); PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class);
@@ -135,13 +132,6 @@ public abstract class AbstractLinker<T> {
instances.put(instance.getClass(), instance); 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 * @return {@code true} if the clazz passes the checks {@code false} otherwise
*/ */
@@ -26,6 +26,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE}) @Target({ElementType.TYPE})
@Deprecated
public @interface MaxVersion { public @interface MaxVersion {
int value(); int value();
} }
@@ -26,6 +26,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE}) @Target({ElementType.TYPE})
@Deprecated
public @interface MinVersion { public @interface MinVersion {
int value(); int value();
} }
@@ -98,13 +98,7 @@ public class FightSystem extends JavaPlugin {
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener()); 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.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
new OneShotStateDependent(ArenaMode.Test, FightState.All, WorldEditRendererCUIEditor::new); new OneShotStateDependent(ArenaMode.Test, FightState.All, WorldEditRendererCUIEditor::new);
if (Core.getVersion() >= 19) { Config.world.setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(Config.mode));
try {
Bukkit.getWorlds().get(0).setGameRule(GameRule.REDUCED_DEBUG_INFO, ArenaMode.AntiTest.contains(Config.mode));
} catch (Exception e) {
// Ignore if failed!
}
}
techHider = new TechHiderWrapper(); techHider = new TechHiderWrapper();
hullHider = new HullHider(); hullHider = new HullHider();
@@ -19,7 +19,6 @@
package de.steamwar.fightsystem.fight; package de.steamwar.fightsystem.fight;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.record.GlobalRecorder;
@@ -84,10 +83,7 @@ public class Fight {
public static void playSound(Sound sound, float volume, float pitch) { public static void playSound(Sound sound, float volume, float pitch) {
GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch); GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch);
//volume: max. 100, pitch: max. 2 //volume: max. 100, pitch: max. 2
if(Core.getVersion() >= 18)
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player, sound, volume, pitch)); Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player, sound, volume, pitch));
else
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
} }
public static FightTeam getTeamByName(String name) { public static FightTeam getTeamByName(String name) {
@@ -19,7 +19,6 @@
package de.steamwar.fightsystem.fight; package de.steamwar.fightsystem.fight;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
@@ -51,7 +50,7 @@ public class HotbarKitListener implements Listener {
@EventHandler @EventHandler
public void handlePlayerInteract(PlayerInteractEvent event) { 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; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
@@ -20,7 +20,6 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
@@ -44,7 +43,6 @@ public class ClickAnalyzer {
public ClickAnalyzer() { public ClickAnalyzer() {
TinyProtocol.instance.addFilter(Recording.blockPlacePacket, this::onBlockPlace); TinyProtocol.instance.addFilter(Recording.blockPlacePacket, this::onBlockPlace);
if(Core.getVersion() > 8)
TinyProtocol.instance.addFilter(ServerboundUseItemOnPacket.class, this::onBlockPlace); TinyProtocol.instance.addFilter(ServerboundUseItemOnPacket.class, this::onBlockPlace);
} }
@@ -127,7 +127,7 @@ public class AutoChecker {
else if (!itemsInInv.getOrDefault(itemType, EnumSet.noneOf(Material.class)).contains(material)) { else if (!itemsInInv.getOrDefault(itemType, EnumSet.noneOf(Material.class)).contains(material)) {
result.getForbiddenItems().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); result.getForbiddenItems().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType);
} else if (material == Material.DISPENSER && (itemType == Material.ARROW || itemType == Material.FIRE_CHARGE)) { } 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")) { if (item.containsKey("tag")) {
result.getForbiddenNbt().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType); result.getForbiddenNbt().computeIfAbsent(pos, blockVector3 -> new HashSet<>()).add(itemType);
@@ -172,7 +172,6 @@ public class AutoCheckerResult {
blockScanResult.getDefunctNbt().forEach(blockVector3 -> { 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()); 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) -> { blockScanResult.getDesignBlocks().forEach((material, poss) -> {
if (material == Material.WATER || material == Material.LAVA) return; if (material == Material.WATER || material == Material.LAVA) return;
if(material.getBlastResistance() > type.Schematic.MaxDesignBlastResistance) { if(material.getBlastResistance() > type.Schematic.MaxDesignBlastResistance) {
@@ -181,7 +180,6 @@ public class AutoCheckerResult {
}); });
} }
}); });
}
entities.forEach(blockPos -> { 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()); 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());
}); });
@@ -35,7 +35,6 @@ import de.steamwar.command.AbstractSWCommand;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeMapper;
import de.steamwar.command.TypeValidator; import de.steamwar.command.TypeValidator;
import de.steamwar.core.Core;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
@@ -161,10 +160,8 @@ public class SchematicCommand extends SWCommand {
NORMAL NORMAL
} }
private static final Function<CompoundTag, Integer> getCount = item -> Core.getVersion() >= 21 ? item.getInt("count") : item.getByte("Count"); private static final Function<CompoundTag, Integer> getCount = item -> item.getInt("count");
private static final BiFunction<CompoundTag, Integer, CompoundTag> setCount = (item, count) -> Core.getVersion() >= 21 ? private static final BiFunction<CompoundTag, Integer, CompoundTag> setCount = (item, count) -> item.createBuilder().putInt("count", count).build();
item.createBuilder().putInt("count", count).build() :
item.createBuilder().putByte("Count", count.byteValue()).build();
public static Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig<Material, String> type) throws Exception { public static Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig<Material, String> type) throws Exception {
for (BlockPos blockPos : result.getBlockScanResult().getRecords()) { for (BlockPos blockPos : result.getBlockScanResult().getRecords()) {
@@ -87,10 +87,6 @@ public class CheckPart extends SWCommand {
@Register("fix") @Register("fix")
public void fixSchematicCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig<Material, String> type) { public void fixSchematicCommand(Player player, @ErrorMessage("UTIL_CHECK_TYPE_NOT_FOUND") GameModeConfig<Material, String> type) {
if(Core.getVersion() < 15) {
SchematicSystem.MESSAGE.send("COMMAND_FIX_WRONG_VERSION", player);
return;
}
Clipboard clipboard; Clipboard clipboard;
try { try {
clipboard = WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getClipboard().getClipboard(); clipboard = WorldEdit.getInstance().getSessionManager().findByName(player.getName()).getClipboard().getClipboard();
@@ -202,10 +202,6 @@ public final class Reflection {
} }
} }
public static <T> Field<T> getField(Class<?> target, String name, Class<T> fieldType) {
return getField(target, name, fieldType, 0);
}
public static <T> Field<T> getField(Class<?> target, Class<T> fieldType, int index) { public static <T> Field<T> getField(Class<?> target, Class<T> fieldType, int index) {
return getField(target, null, fieldType, index); return getField(target, null, fieldType, index);
} }
@@ -92,11 +92,10 @@ public class BountifulWrapper {
public BountifulWrapper.PositionSetter getRelMoveSetter(Class<?> packetClass) { public BountifulWrapper.PositionSetter getRelMoveSetter(Class<?> packetClass) {
Class<?> type = Core.getVersion() > 12 ? short.class : int.class; Class<?> type = short.class;
int fieldOffset = Core.getVersion() > 12 ? 0 : 1; Reflection.Field<?> moveX = Reflection.getField(packetClass, type, 0);
Reflection.Field<?> moveX = Reflection.getField(packetClass, type, 0 + fieldOffset); Reflection.Field<?> moveY = Reflection.getField(packetClass, type, 1);
Reflection.Field<?> moveY = Reflection.getField(packetClass, type, 1 + fieldOffset); Reflection.Field<?> moveZ = Reflection.getField(packetClass, type, 2);
Reflection.Field<?> moveZ = Reflection.getField(packetClass, type, 2 + fieldOffset);
Reflection.Field<Byte> moveYaw = Reflection.getField(packetClass, byte.class, 0); Reflection.Field<Byte> moveYaw = Reflection.getField(packetClass, byte.class, 0);
Reflection.Field<Byte> movePitch = Reflection.getField(packetClass, byte.class, 1); Reflection.Field<Byte> movePitch = Reflection.getField(packetClass, byte.class, 1);
@@ -137,11 +137,9 @@ class CheckpointUtilsJ9 {
// Reopen socket // Reopen socket
serverConnection.startTcpServerListener(InetAddress.getLoopbackAddress(), port); serverConnection.startTcpServerListener(InetAddress.getLoopbackAddress(), port);
if(Core.getVersion() > 12) {
for(Object future : channels) { for(Object future : channels) {
((ChannelFuture) future).channel().config().setAutoRead(true); ((ChannelFuture) future).channel().config().setAutoRead(true);
} }
}
Bukkit.getPluginManager().callEvent(new CRIUWakeupEvent()); Bukkit.getPluginManager().callEvent(new CRIUWakeupEvent());
Core.getInstance().getLogger().log(Level.INFO, "Checkpoint restored"); Core.getInstance().getLogger().log(Level.INFO, "Checkpoint restored");
@@ -111,7 +111,6 @@ public class Core extends JavaPlugin {
getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new NetworkReceiver()); getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new NetworkReceiver());
getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge"); getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge");
if (Core.getVersion() != 20)
SteamwarGameProfileRepository.impl.inject(); SteamwarGameProfileRepository.impl.inject();
TinyProtocol.init(); TinyProtocol.init();
@@ -116,10 +116,8 @@ public class WorldEditRendererCUIEditor implements Listener {
public WorldEditRendererCUIEditor() { public WorldEditRendererCUIEditor() {
Bukkit.getPluginManager().registerEvents(this, Core.getInstance()); Bukkit.getPluginManager().registerEvents(this, Core.getInstance());
if (Core.getVersion() >= 20) {
new Command(); new Command();
} }
}
private static class Command extends SWCommand { private static class Command extends SWCommand {
@@ -46,10 +46,8 @@ public class AntiNocom implements Listener {
public AntiNocom() { public AntiNocom() {
TinyProtocol.instance.addFilter(blockDig, this::onDig); TinyProtocol.instance.addFilter(blockDig, this::onDig);
if(Core.getVersion() > 8) {
registerUseItem(); registerUseItem();
} }
}
@EventHandler @EventHandler
public void onQuit(PlayerQuitEvent e) { public void onQuit(PlayerQuitEvent e) {
@@ -59,16 +57,11 @@ public class AntiNocom implements Listener {
private void registerUseItem() { private void registerUseItem() {
Class<?> useItem = ServerboundUseItemOnPacket.class; Class<?> useItem = ServerboundUseItemOnPacket.class;
Function<Object, Object> getPosition;
if(Core.getVersion() > 12) {
Class<?> movingObjectPositionBlock = BlockHitResult.class; Class<?> movingObjectPositionBlock = BlockHitResult.class;
Reflection.Field<?> useItemPosition = Reflection.getField(useItem, movingObjectPositionBlock, 0); Reflection.Field<?> useItemPosition = Reflection.getField(useItem, movingObjectPositionBlock, 0);
Reflection.Field<?> movingBlockPosition = Reflection.getField(movingObjectPositionBlock, TechHider.blockPosition, 0); Reflection.Field<?> movingBlockPosition = Reflection.getField(movingObjectPositionBlock, TechHider.blockPosition, 0);
getPosition = (packet) -> movingBlockPosition.get(useItemPosition.get(packet)); Function<Object, Object> getPosition = (packet) -> movingBlockPosition.get(useItemPosition.get(packet));
} else {
getPosition = Reflection.getField(useItem, TechHider.blockPosition, 0)::get;
}
TinyProtocol.instance.addFilter(useItem, (player, packet) -> { TinyProtocol.instance.addFilter(useItem, (player, packet) -> {
Object pos = getPosition.apply(packet); Object pos = getPosition.apply(packet);
@@ -20,7 +20,6 @@
package de.steamwar.entity; package de.steamwar.entity;
import de.steamwar.core.BountifulWrapper; import de.steamwar.core.BountifulWrapper;
import de.steamwar.core.Core;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@@ -29,26 +28,7 @@ import java.util.function.Consumer;
public class RArmorStand extends REntity { public class RArmorStand extends REntity {
private static int sizeIndex() { private static final Object sizeWatcher = BountifulWrapper.impl.getDataWatcherObject(15, Byte.class);
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);
@Getter @Getter
private final Size size; private final Size size;
@@ -20,7 +20,6 @@
package de.steamwar.entity; package de.steamwar.entity;
import de.steamwar.core.BountifulWrapper; import de.steamwar.core.BountifulWrapper;
import de.steamwar.core.Core;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import org.bukkit.Color; import org.bukkit.Color;
@@ -111,10 +110,10 @@ public abstract class RDisplay extends REntity {
sendPacket(updatePacketSink, this::getTransformData); sendPacket(updatePacketSink, this::getTransformData);
} }
private static final Object translationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 11 : 10, Vector3f.class); private static final Object translationWatcher = BountifulWrapper.impl.getDataWatcherObject(11, Vector3f.class);
private static final Object leftRotationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 13 : 12, Quaternionf.class); private static final Object leftRotationWatcher = BountifulWrapper.impl.getDataWatcherObject(13, Quaternionf.class);
private static final Object scaleWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 12 : 11, Vector3f.class); private static final Object scaleWatcher = BountifulWrapper.impl.getDataWatcherObject(12, Vector3f.class);
private static final Object rightRotationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 14 : 13, Quaternionf.class); private static final Object rightRotationWatcher = BountifulWrapper.impl.getDataWatcherObject(14, Quaternionf.class);
private void getTransformData(boolean ignoreDefault, BiConsumer<Object, Object> dataSink) { private void getTransformData(boolean ignoreDefault, BiConsumer<Object, Object> dataSink) {
if (ignoreDefault || !transform.equals(DEFAULT_TRANSFORM)) { if (ignoreDefault || !transform.equals(DEFAULT_TRANSFORM)) {
@@ -130,8 +129,8 @@ public abstract class RDisplay extends REntity {
sendPacket(updatePacketSink, this::getInterpolationDuration); sendPacket(updatePacketSink, this::getInterpolationDuration);
} }
private static final Object transformationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 9 : 8, Integer.class); private static final Object transformationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(9, Integer.class);
private static final Object positionOrRotationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 10 : 9, Integer.class); private static final Object positionOrRotationInterpolationDurationWatcher = BountifulWrapper.impl.getDataWatcherObject(10, Integer.class);
private void getInterpolationDuration(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) { private void getInterpolationDuration(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || interpolationDelay != 0) { if (ignoreDefault || interpolationDelay != 0) {
@@ -145,7 +144,7 @@ public abstract class RDisplay extends REntity {
sendPacket(updatePacketSink, this::getViewRange); 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<Object, Object> packetSink) { private void getViewRange(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || viewRange != 1.0F) { if (ignoreDefault || viewRange != 1.0F) {
@@ -158,7 +157,7 @@ public abstract class RDisplay extends REntity {
sendPacket(updatePacketSink, this::getShadowRadius); 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<Object, Object> packetSink) { private void getShadowRadius(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || shadowRadius != 0.0F) { if (ignoreDefault || shadowRadius != 0.0F) {
@@ -171,7 +170,7 @@ public abstract class RDisplay extends REntity {
sendPacket(updatePacketSink, this::getShadowStrength); 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<Object, Object> packetSink) { private void getShadowStrength(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || shadowStrength != 1.0F) { if (ignoreDefault || shadowStrength != 1.0F) {
@@ -184,7 +183,7 @@ public abstract class RDisplay extends REntity {
sendPacket(updatePacketSink, this::getDisplayWidth); 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<Object, Object> packetSink) { private void getDisplayWidth(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || displayWidth != 0.0F) { if (ignoreDefault || displayWidth != 0.0F) {
@@ -197,7 +196,7 @@ public abstract class RDisplay extends REntity {
sendPacket(updatePacketSink, this::getDisplayHeight); 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<Object, Object> packetSink) { private void getDisplayHeight(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || displayHeight != 0.0F) { if (ignoreDefault || displayHeight != 0.0F) {
@@ -210,7 +209,7 @@ public abstract class RDisplay extends REntity {
sendPacket(updatePacketSink, this::getInterpolationDelay); 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<Object, Object> packetSink) { private void getInterpolationDelay(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || interpolationDelay != 0) { if (ignoreDefault || interpolationDelay != 0) {
@@ -223,7 +222,7 @@ public abstract class RDisplay extends REntity {
sendPacket(updatePacketSink, this::getBillboard); 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<Object, Object> packetSink) { private void getBillboard(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || billboard != Display.Billboard.FIXED) { if (ignoreDefault || billboard != Display.Billboard.FIXED) {
@@ -236,7 +235,7 @@ public abstract class RDisplay extends REntity {
sendPacket(updatePacketSink, this::getGlowColorOverride); 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<Object, Object> packetSink) { private void getGlowColorOverride(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || glowColorOverride != null) { if (ignoreDefault || glowColorOverride != null) {
@@ -249,7 +248,7 @@ public abstract class RDisplay extends REntity {
sendPacket(updatePacketSink, this::getBrightness); 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<Object, Object> packetSink) { private void getBrightness(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || brightness != null) { if (ignoreDefault || brightness != null) {
@@ -20,7 +20,10 @@
package de.steamwar.entity; package de.steamwar.entity;
import de.steamwar.Reflection; 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.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import lombok.Getter; import lombok.Getter;
@@ -37,9 +40,9 @@ import java.util.function.Function;
public class REntity { public class REntity {
private static final Object entityStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(0, Byte.class); 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 sneakingDataWatcher = BountifulWrapper.impl.getDataWatcherObject(6, 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 bowDrawnWatcher = BountifulWrapper.impl.getDataWatcherObject(6, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.NORMAL).getClass());
private static final Object nameWatcher = BountifulWrapper.impl.getDataWatcherObject(2, Core.getVersion() > 12 ? Optional.class : String.class); // Optional<IChatBaseComponent> private static final Object nameWatcher = BountifulWrapper.impl.getDataWatcherObject(2, Optional.class); // Optional<IChatBaseComponent>
private static final Object nameVisibleWatcher = BountifulWrapper.impl.getDataWatcherObject(3, Boolean.class); private static final Object nameVisibleWatcher = BountifulWrapper.impl.getDataWatcherObject(3, Boolean.class);
private static final Object noGravityDataWatcher = BountifulWrapper.impl.getDataWatcherObject(5,Boolean.class); private static final Object noGravityDataWatcher = BountifulWrapper.impl.getDataWatcherObject(5,Boolean.class);
@@ -128,7 +131,7 @@ public class REntity {
move(location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw(), rotToByte(location.getYaw())); 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) { public void move(double locX, double locY, double locZ, float pitch, float yaw, byte headYaw) {
server.preEntityMove(this, locX, locZ); server.preEntityMove(this, locX, locZ);
@@ -163,8 +166,8 @@ public class REntity {
} }
private static final Class<?> animationPacket = ClientboundAnimatePacket.class; private static final Class<?> animationPacket = ClientboundAnimatePacket.class;
private static final Reflection.Field<Integer> animationEntity = Reflection.getField(animationPacket, int.class, Core.getVersion() > 15 ? (Core.getVersion() > 19 ? 5 : 6) : 0); private static final Reflection.Field<Integer> animationEntity = Reflection.getField(animationPacket, int.class, 5);
private static final Reflection.Field<Integer> animationAnimation = Reflection.getField(animationPacket, int.class, Core.getVersion() > 15 ? (Core.getVersion() > 19 ? 6 : 7) : 1); private static final Reflection.Field<Integer> animationAnimation = Reflection.getField(animationPacket, int.class, 6);
public void showAnimation(byte animation) { public void showAnimation(byte animation) {
Object packet = Reflection.newInstance(animationPacket); Object packet = Reflection.newInstance(animationPacket);
animationEntity.set(packet, entityId); animationEntity.set(packet, entityId);
@@ -198,11 +201,7 @@ public class REntity {
public void setPose(FlatteningWrapper.EntityPose pose) { public void setPose(FlatteningWrapper.EntityPose pose) {
this.pose = pose; this.pose = pose;
if(Core.getVersion() > 12) {
server.updateEntity(this, getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(pose))); server.updateEntity(this, getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(pose)));
} else {
server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus()));
}
} }
public void setOnFire(boolean perma) { public void setOnFire(boolean perma) {
@@ -221,13 +220,7 @@ public class REntity {
public void setBowDrawn(boolean drawn, boolean offHand) { public void setBowDrawn(boolean drawn, boolean offHand) {
bowDrawn = drawn; bowDrawn = drawn;
if (Core.getVersion() >= 21) {
server.updateEntity(this, getDataWatcherPacket(bowDrawnWatcher, FlatteningWrapper.impl.getPose(FlatteningWrapper.EntityPose.SHOOTING))); 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()));
}
} }
public void setDisplayName(String displayName) { public void setDisplayName(String displayName) {
@@ -249,55 +242,22 @@ public class REntity {
public void setNoGravity(boolean noGravity) { public void setNoGravity(boolean noGravity) {
this.noGravity = 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) { public void setGlowing(boolean glowing) {
this.isGlowing = glowing; this.isGlowing = glowing;
if(Core.getVersion() > 8) {
server.updateEntity(this,getDataWatcherPacket(entityStatusWatcher,getEntityStatus())); server.updateEntity(this,getDataWatcherPacket(entityStatusWatcher,getEntityStatus()));
} }
}
public boolean isGlowing() { public boolean isGlowing() {
return isGlowing; return isGlowing;
} }
private static int spawnPacketOffset() { private static final Function<REntity, Object> spawnPacketGenerator = entitySpawnPacketGenerator(ProtocolWrapper.spawnPacket, 2);
switch (Core.getVersion()) {
case 8: private static final Reflection.Field<Integer> additionalData = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, 4);
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<REntity, Object> 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<Integer> additionalData = Reflection.getField(ProtocolWrapper.spawnPacket, int.class, objectDataOffset());
private Object spawnPacketGenerator() { private Object spawnPacketGenerator() {
Object packet = spawnPacketGenerator.apply(this); Object packet = spawnPacketGenerator.apply(this);
additionalData.set(packet, objectData); additionalData.set(packet, objectData);
@@ -308,7 +268,7 @@ public class REntity {
// empty for regular entity // empty for regular entity
} }
private static final Function<REntity, Object> livingSpawnPacketGenerator = Core.getVersion() >= 19 ? REntity::spawnPacketGenerator : entitySpawnPacketGenerator(ProtocolWrapper.spawnLivingPacket, Core.getVersion() == 8 ? 2 : 0); private static final Function<REntity, Object> livingSpawnPacketGenerator = REntity::spawnPacketGenerator;
void spawn(Consumer<Object> packetSink) { void spawn(Consumer<Object> packetSink) {
if(entityType.isAlive()) { if(entityType.isAlive()) {
packetSink.accept(livingSpawnPacketGenerator.apply(this)); packetSink.accept(livingSpawnPacketGenerator.apply(this));
@@ -324,7 +284,7 @@ public class REntity {
packetSink.accept(getHeadRotationPacket()); packetSink.accept(getHeadRotationPacket());
} }
if(Core.getVersion() > 12 && pose != FlatteningWrapper.EntityPose.NORMAL) { if(pose != FlatteningWrapper.EntityPose.NORMAL) {
packetSink.accept(getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(pose))); packetSink.accept(getDataWatcherPacket(sneakingDataWatcher, FlatteningWrapper.impl.getPose(pose)));
} }
@@ -337,9 +297,10 @@ public class REntity {
packetSink.accept(getDataWatcherPacket(nameWatcher, FlatteningWrapper.impl.formatDisplayName(displayName), nameVisibleWatcher, true)); packetSink.accept(getDataWatcherPacket(nameWatcher, FlatteningWrapper.impl.formatDisplayName(displayName), nameVisibleWatcher, true));
} }
if(Core.getVersion() > 8 && noGravity) if(noGravity) {
packetSink.accept(getDataWatcherPacket(noGravityDataWatcher, true)); packetSink.accept(getDataWatcherPacket(noGravityDataWatcher, true));
} }
}
void tick() { void tick() {
if(fireTick > 0) { if(fireTick > 0) {
@@ -351,16 +312,10 @@ public class REntity {
} }
private static final Class<?> destroyPacket = ClientboundRemoveEntitiesPacket.class; private static final Class<?> destroyPacket = ClientboundRemoveEntitiesPacket.class;
private static final Reflection.Field<?> destroyEntities; private static final Reflection.Field<?> destroyEntities = Reflection.getField(destroyPacket, IntList.class, 0);
static {
if(Core.getVersion() > 15)
destroyEntities = Reflection.getField(destroyPacket, IntList.class, 0);
else
destroyEntities = Reflection.getField(destroyPacket, int[].class, 0);
}
void despawn(Consumer<Object> packetSink){ void despawn(Consumer<Object> packetSink){
Object packet = Reflection.newInstance(destroyPacket); 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); packetSink.accept(packet);
} }
@@ -383,11 +338,9 @@ public class REntity {
status |= 1; status |= 1;
if(pose == FlatteningWrapper.EntityPose.SNEAKING) if(pose == FlatteningWrapper.EntityPose.SNEAKING)
status |= 2; status |= 2;
if(Core.getVersion() == 8 && bowDrawn)
status |= 0x10;
if(invisible) if(invisible)
status |= 0x20; status |= 0x20;
if(Core.getVersion() > 8 && isGlowing) if(isGlowing)
status |= 0x40; status |= 0x40;
return status; return status;
@@ -399,18 +352,11 @@ public class REntity {
public static final Class<?> teleportPacket = ClientboundTeleportEntityPacket.class; public static final Class<?> teleportPacket = ClientboundTeleportEntityPacket.class;
public static final Reflection.Field<Integer> teleportEntity = Reflection.getField(teleportPacket, int.class, 0); public static final Reflection.Field<Integer> 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(){ private Object getTeleportPacket(){
if (Core.getVersion() >= 21) {
return PacketConstructor.impl.teleportPacket(entityId, x, y, z, pitch, yaw); 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;
}
private static final Class<?> entityPacket = ClientboundMoveEntityPacket.class; private static final Class<?> entityPacket = ClientboundMoveEntityPacket.class;
private static final Reflection.Field<Integer> moveEntityId = Reflection.getField(entityPacket, int.class, 0); private static final Reflection.Field<Integer> moveEntityId = Reflection.getField(entityPacket, int.class, 0);
private static final BountifulWrapper.PositionSetter movePosition = BountifulWrapper.impl.getRelMoveSetter(entityPacket); private static final BountifulWrapper.PositionSetter movePosition = BountifulWrapper.impl.getRelMoveSetter(entityPacket);
@@ -19,7 +19,6 @@
package de.steamwar.entity; package de.steamwar.entity;
import de.steamwar.core.Core;
import de.steamwar.techhider.BlockIds; import de.steamwar.techhider.BlockIds;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Location; import org.bukkit.Location;
@@ -32,7 +31,7 @@ public class RFallingBlockEntity extends REntity{
private final Material material; private final Material material;
public RFallingBlockEntity(REntityServer server, Location location, 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; this.material = material;
server.addEntity(this); server.addEntity(this);
} }
@@ -22,7 +22,6 @@ package de.steamwar.entity;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import de.steamwar.core.BountifulWrapper; import de.steamwar.core.BountifulWrapper;
import de.steamwar.core.Core;
import de.steamwar.core.ProtocolWrapper; import de.steamwar.core.ProtocolWrapper;
import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.network.CoreNetworkHandler; import de.steamwar.network.CoreNetworkHandler;
@@ -41,27 +40,7 @@ import java.util.function.Consumer;
public class RPlayer extends REntity { public class RPlayer extends REntity {
private static int skinPartsIndex() { private static final Object skinPartsDataWatcher = BountifulWrapper.impl.getDataWatcherObject(17, Byte.class);
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);
@Getter @Getter
private final UUID actualUUID; private final UUID actualUUID;
@@ -76,7 +76,7 @@ public class RTextDisplay extends RDisplay {
} }
private static final Class<?> iChatBaseComponent = Component.class; private static final Class<?> iChatBaseComponent = Component.class;
private static final Object textWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() >= 21 ? 23 : 22, iChatBaseComponent); private static final Object textWatcher = BountifulWrapper.impl.getDataWatcherObject(23, iChatBaseComponent);
private void getText(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) { private void getText(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || !text.isEmpty()) { if (ignoreDefault || !text.isEmpty()) {
packetSink.accept(textWatcher, ChatWrapper.impl.stringToChatComponent(text)); packetSink.accept(textWatcher, ChatWrapper.impl.stringToChatComponent(text));
@@ -88,7 +88,7 @@ public class RTextDisplay extends RDisplay {
sendPacket(updatePacketSink, this::getLineWidth); 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<Object, Object> packetSink) { private void getLineWidth(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || lineWidth != 200) { if (ignoreDefault || lineWidth != 200) {
packetSink.accept(lineWidthWatcher, lineWidth); packetSink.accept(lineWidthWatcher, lineWidth);
@@ -100,7 +100,7 @@ public class RTextDisplay extends RDisplay {
sendPacket(updatePacketSink, this::getTextOpacity); 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<Object, Object> packetSink) { private void getTextOpacity(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || textOpacity != (byte) -1) { if (ignoreDefault || textOpacity != (byte) -1) {
packetSink.accept(textOpacityWatcher, textOpacity); packetSink.accept(textOpacityWatcher, textOpacity);
@@ -122,7 +122,7 @@ public class RTextDisplay extends RDisplay {
sendPacket(updatePacketSink, this::getTextStatus, this::getBackgroundColor); 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<Object, Object> packetSink) { private void getBackgroundColor(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
if (ignoreDefault || backgroundColor != null) { if (ignoreDefault || backgroundColor != null) {
packetSink.accept(backgroundColorWatcher, backgroundColor); packetSink.accept(backgroundColorWatcher, backgroundColor);
@@ -141,7 +141,7 @@ public class RTextDisplay extends RDisplay {
sendPacket(updatePacketSink, this::getTextStatus); 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<Object, Object> packetSink) { private void getTextStatus(boolean ignoreDefault, BiConsumer<Object, Object> packetSink) {
byte status = 0; byte status = 0;
@@ -21,7 +21,6 @@ package de.steamwar.inventory;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import de.steamwar.core.Core;
import de.steamwar.core.FlatteningWrapper; import de.steamwar.core.FlatteningWrapper;
import de.steamwar.core.TrickyTrialsWrapper; import de.steamwar.core.TrickyTrialsWrapper;
import org.bukkit.Material; import org.bukkit.Material;
@@ -217,10 +216,8 @@ public class SWItem {
} }
public SWItem setCustomModelData(int customModelData) { public SWItem setCustomModelData(int customModelData) {
if (Core.getVersion() > 12) {
itemMeta.setCustomModelData(customModelData); itemMeta.setCustomModelData(customModelData);
itemStack.setItemMeta(itemMeta); itemStack.setItemMeta(itemMeta);
}
return this; return this;
} }
@@ -20,7 +20,6 @@
package de.steamwar.linkage; package de.steamwar.linkage;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.core.Core;
import de.steamwar.message.Message; import de.steamwar.message.Message;
import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.PacketHandler;
import lombok.NonNull; import lombok.NonNull;
@@ -38,17 +37,6 @@ public class SpigotLinker extends AbstractLinker<JavaPlugin> {
this.message = message; 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 @Override
protected boolean pluginCheck(@NonNull Class<?> clazz, PluginCheck pluginCheck) { protected boolean pluginCheck(@NonNull Class<?> clazz, PluginCheck pluginCheck) {
if (pluginCheck.has() == PluginCheck.Has.THIS && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) != null) { if (pluginCheck.has() == PluginCheck.Has.THIS && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) != null) {
@@ -20,7 +20,6 @@
package de.steamwar.message; package de.steamwar.message;
import de.steamwar.core.BountifulWrapper; import de.steamwar.core.BountifulWrapper;
import de.steamwar.core.Core;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
@@ -30,7 +29,6 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Locale; import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@@ -82,10 +80,7 @@ public class Message {
} }
private String fromRB(ResourceBundle bundle, String key) { private String fromRB(ResourceBundle bundle, String key) {
String result = bundle.getString(key); return bundle.getString(key);
if(Core.getVersion() < 12)
result = new String(result.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
return result;
} }
private Locale getLocale(Player player){ private Locale getLocale(Player player){
@@ -28,7 +28,6 @@ import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -46,9 +45,6 @@ public class SQLWrapperImpl implements SQLWrapper<Material> {
@Override @Override
public List<Material> getMaterialWithGreaterBlastResistance(double maxBlastResistance) { public List<Material> getMaterialWithGreaterBlastResistance(double maxBlastResistance) {
if (Core.getVersion() <= 12) {
return Collections.emptyList();
}
return Arrays.stream(Material.values()) return Arrays.stream(Material.values())
.filter(material -> !material.isLegacy()) .filter(material -> !material.isLegacy())
.filter(Material::isBlock) .filter(Material::isBlock)
@@ -21,7 +21,6 @@ package de.steamwar.techhider;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.Reflection; import de.steamwar.Reflection;
import de.steamwar.core.Core;
import lombok.Getter; import lombok.Getter;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Vec3i; import net.minecraft.core.Vec3i;
@@ -51,7 +50,7 @@ public class TechHider {
public static final Class<?> iBlockData = BlockState.class; public static final Class<?> iBlockData = BlockState.class;
public static final Class<?> block = Block.class; public static final Class<?> block = Block.class;
public boolean iBlockDataHidden(Object iBlockData) { public boolean iBlockDataHidden(BlockState iBlockData) {
return obfuscateIds.contains(BlockIds.impl.getCombinedId(iBlockData)); return obfuscateIds.contains(BlockIds.impl.getCombinedId(iBlockData));
} }
@@ -82,15 +81,7 @@ public class TechHider {
techhiders.put(tileEntityDataPacket, this::tileEntityDataHider); techhiders.put(tileEntityDataPacket, this::tileEntityDataHider);
techhiders.put(multiBlockChangePacket, ProtocolWrapper.impl.multiBlockChangeGenerator(this)); techhiders.put(multiBlockChangePacket, ProtocolWrapper.impl.multiBlockChangeGenerator(this));
techhiders.put(ChunkHider.impl.mapChunkPacket(), ChunkHider.impl.chunkHiderGenerator(this)); techhiders.put(ChunkHider.impl.mapChunkPacket(), ChunkHider.impl.chunkHiderGenerator(this));
if(Core.getVersion() > 12 && Core.getVersion() < 19) {
Class<?> blockBreakClass = ClientboundBlockDestructionPacket.class;
techhiders.put(blockBreakClass, ProtocolWrapper.impl.blockBreakHiderGenerator(blockBreakClass, this));
}
if(Core.getVersion() > 8){
techhiders.put(ServerboundUseItemOnPacket.class, (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); techhiders.put(ServerboundInteractPacket.class, (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet);
} }
@@ -115,7 +106,7 @@ public class TechHider {
case SKIP: case SKIP:
return packet; return packet;
case CHECK: case CHECK:
if(!iBlockDataHidden(blockChangeBlockData.get(packet))) if(!iBlockDataHidden((BlockState) blockChangeBlockData.get(packet)))
return packet; return packet;
case HIDE: case HIDE:
packet = blockChangeCloner.apply(packet); packet = blockChangeCloner.apply(packet);
@@ -135,7 +135,6 @@ public class FreezeListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent e) { public void onBlockBreak(BlockBreakEvent e) {
if (Core.getVersion() < 19) return;
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return; if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
if (freeze) { if (freeze) {
if (e.isCancelled()) return; if (e.isCancelled()) return;