diff --git a/SpigotCore_10/src/de/steamwar/core/CraftbukkitWrapper10.java b/SpigotCore_10/src/de/steamwar/core/CraftbukkitWrapper10.java
deleted file mode 100644
index 8916735..0000000
--- a/SpigotCore_10/src/de/steamwar/core/CraftbukkitWrapper10.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.core;
-
-import net.minecraft.server.v1_10_R1.MinecraftServer;
-import net.minecraft.server.v1_10_R1.PacketPlayOutMapChunk;
-import org.bukkit.craftbukkit.v1_10_R1.CraftChunk;
-import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-public class CraftbukkitWrapper10 implements CraftbukkitWrapper.ICraftbukkitWrapper {
-
- @Override
- public void sendChunk(Player p, int chunkX, int chunkZ) {
- ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public double[] getSpigotTPS() {
- return MinecraftServer.getServer().recentTps;
- }
-}
diff --git a/SpigotCore_12/src/de/steamwar/core/CraftbukkitWrapper12.java b/SpigotCore_12/src/de/steamwar/core/CraftbukkitWrapper12.java
deleted file mode 100644
index 3d084b3..0000000
--- a/SpigotCore_12/src/de/steamwar/core/CraftbukkitWrapper12.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.core;
-
-import net.minecraft.server.v1_12_R1.MinecraftServer;
-import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
-import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
-import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrapper {
-
- @Override
- public void sendChunk(Player p, int chunkX, int chunkZ) {
- ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public double[] getSpigotTPS() {
- return MinecraftServer.getServer().recentTps;
- }
-}
diff --git a/SpigotCore_14/src/de/steamwar/core/CraftbukkitWrapper14.java b/SpigotCore_14/src/de/steamwar/core/CraftbukkitWrapper14.java
deleted file mode 100644
index bc27af3..0000000
--- a/SpigotCore_14/src/de/steamwar/core/CraftbukkitWrapper14.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.core;
-
-import net.minecraft.server.v1_14_R1.MinecraftServer;
-import net.minecraft.server.v1_14_R1.PacketPlayOutMapChunk;
-import org.bukkit.craftbukkit.v1_14_R1.CraftChunk;
-import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-public class CraftbukkitWrapper14 implements CraftbukkitWrapper.ICraftbukkitWrapper {
-
- @Override
- public void sendChunk(Player p, int chunkX, int chunkZ) {
- ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public double[] getSpigotTPS() {
- return MinecraftServer.getServer().recentTps;
- }
-}
diff --git a/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java b/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java
index 84a4dc6..e650a29 100644
--- a/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java
+++ b/SpigotCore_14/src/de/steamwar/core/FlatteningWrapper14.java
@@ -22,6 +22,8 @@ package de.steamwar.core;
import com.comphenix.tinyprotocol.Reflection;
import org.bukkit.Bukkit;
import org.bukkit.Material;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
@@ -322,4 +324,25 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper
public Object formatDisplayName(String displayName) {
return displayName != null ? Optional.of(ChatWrapper.impl.stringToChatComponent(displayName)) : Optional.empty();
}
+
+ private static final Reflection.FieldAccessor> spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, Reflection.getClass("{nms.world.entity}.EntityTypes"), 0);
+ private static final Reflection.FieldAccessor> spawnLivingType = Core.getVersion() > 19 ? spawnType : Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1);
+ private static final Reflection.MethodInvoker getEntityTypes = Reflection.getMethod("{obc}.util.CraftMagicNumbers", "getEntityTypes", EntityType.class);
+ private static final Map types = new HashMap<>();
+ static {
+ types.put(EntityType.ARMOR_STAND, 1);
+ }
+ @Override
+ public void setSpawnPacketType(Object packet, EntityType type) {
+ if(type.isAlive()) {
+ spawnLivingType.set(packet, Core.getVersion() > 18 ? getEntityTypes.invoke(null, type) : types.get(type));
+ } else {
+ spawnType.set(packet, getEntityTypes.invoke(null, type));
+ }
+ }
+
+ @Override
+ public int getViewDistance(Player player) {
+ return player.getClientViewDistance();
+ }
}
diff --git a/SpigotCore_14/src/de/steamwar/techhider/BlockIds14.java b/SpigotCore_14/src/de/steamwar/techhider/BlockIds14.java
index 1a946ef..6e6ff1a 100644
--- a/SpigotCore_14/src/de/steamwar/techhider/BlockIds14.java
+++ b/SpigotCore_14/src/de/steamwar/techhider/BlockIds14.java
@@ -19,34 +19,55 @@
package de.steamwar.techhider;
-import net.minecraft.server.v1_14_R1.*;
+import com.comphenix.tinyprotocol.Reflection;
+import com.google.common.collect.ImmutableList;
import org.bukkit.Material;
import java.util.HashSet;
import java.util.Set;
public class BlockIds14 implements BlockIds {
+
+ private static final Class> blockStateList = Reflection.getClass("{nms.world.level.block.state}.BlockStateList");
+ private static final Class> fluidTypeFlowing = Reflection.getClass("{nms.world.level.material}.FluidTypeFlowing");
+ private static final Class> fluid = Reflection.getClass("{nms.world.level.material}.Fluid");
+
+ private static final Reflection.MethodInvoker getBlockData = Reflection.getTypedMethod(TechHider.block, null, TechHider.iBlockData);
@Override
public int materialToId(Material material) {
- return Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(material.name().toLowerCase())).getBlockData());
+ return getCombinedId(getBlockData.invoke(getBlock(material)));
}
+ private static final Reflection.MethodInvoker getStates = Reflection.getTypedMethod(TechHider.block, null, blockStateList);
+ private static final Reflection.MethodInvoker getStateList = Reflection.getTypedMethod(blockStateList, null, ImmutableList.class);
+ private static final Object water = Reflection.getTypedMethod(fluidTypeFlowing, null, fluid).invoke(Reflection.getField(Reflection.getClass("{nms.world.level.material}.FluidTypes"), fluidTypeFlowing, 1).get(null));
+ private static final Iterable> registryBlockId = (Iterable>) Reflection.getField(TechHider.block, Reflection.getClass("{nms.core}.RegistryBlockID"), 0).get(null);
+ private static final Reflection.MethodInvoker getFluid = Reflection.getTypedMethod(TechHider.iBlockData, null, fluid);
@Override
public Set materialToAllIds(Material material) {
Set ids = new HashSet<>();
- for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(material.name().toLowerCase())).getStates().a()) {
- ids.add(Block.getCombinedId(data));
+ for(Object data : (ImmutableList>) getStateList.invoke(getStates.invoke(getBlock(material)))) {
+ ids.add(getCombinedId(data));
}
- if(material == Material.WATER){
- Fluid water = FluidTypes.WATER.a(false);
- for(IBlockData data : Block.REGISTRY_ID){
- if(data.p() == water){
- ids.add(Block.getCombinedId(data));
+ if(material == Material.WATER) {
+ for(Object data : registryBlockId) {
+ if(getFluid.invoke(data) == water) {
+ ids.add(getCombinedId(data));
}
}
}
return ids;
}
+
+ private static final Reflection.MethodInvoker getBlock = Reflection.getTypedMethod(TechHider.craftMagicNumbers, "getBlock", TechHider.block, Material.class);
+ private Object getBlock(Material material) {
+ return getBlock.invoke(null, material);
+ }
+
+ private static final Reflection.MethodInvoker getCombinedId = Reflection.getTypedMethod(TechHider.block, null, int.class, TechHider.iBlockData);
+ private int getCombinedId(Object blockData) {
+ return (int) getCombinedId.invoke(null, blockData);
+ }
}
diff --git a/SpigotCore_14/src/de/steamwar/techhider/ProtocolWrapper14.java b/SpigotCore_14/src/de/steamwar/techhider/ProtocolWrapper14.java
index bb52f52..9b45405 100644
--- a/SpigotCore_14/src/de/steamwar/techhider/ProtocolWrapper14.java
+++ b/SpigotCore_14/src/de/steamwar/techhider/ProtocolWrapper14.java
@@ -40,7 +40,7 @@ public class ProtocolWrapper14 extends ProtocolWrapper8 {
if(bypass.bypass(p, ProtocolUtils.posToChunk(TechHider.blockPositionX.get(pos)), ProtocolUtils.posToChunk(TechHider.blockPositionZ.get(pos))))
return packet;
- if(ProtocolWrapper.impl.iBlockDataHidden(obfuscate, blockBreakBlockData.get(packet))){
+ if(TechHider.iBlockDataHidden(obfuscate, blockBreakBlockData.get(packet))){
packet = blockBreakCloner.apply(packet);
blockBreakBlockData.set(packet, obfuscationTarget);
}
diff --git a/SpigotCore_15/src/de/steamwar/core/CraftbukkitWrapper15.java b/SpigotCore_15/src/de/steamwar/core/CraftbukkitWrapper15.java
deleted file mode 100644
index d5b908f..0000000
--- a/SpigotCore_15/src/de/steamwar/core/CraftbukkitWrapper15.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2020 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.core;
-
-import net.minecraft.server.v1_15_R1.MinecraftServer;
-import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
-import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
-import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-public class CraftbukkitWrapper15 implements CraftbukkitWrapper.ICraftbukkitWrapper {
-
- @Override
- public void sendChunk(Player p, int chunkX, int chunkZ) {
- ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle(), 65535));
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public double[] getSpigotTPS() {
- return MinecraftServer.getServer().recentTps;
- }
-}
diff --git a/SpigotCore_15/src/de/steamwar/techhider/BlockIds15.java b/SpigotCore_15/src/de/steamwar/techhider/BlockIds15.java
deleted file mode 100644
index 15e7c4d..0000000
--- a/SpigotCore_15/src/de/steamwar/techhider/BlockIds15.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2021 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
- */
-
-package de.steamwar.techhider;
-
-import net.minecraft.server.v1_15_R1.*;
-import org.bukkit.Material;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class BlockIds15 implements BlockIds {
- @Override
- public int materialToId(Material material) {
- return Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(material.name().toLowerCase())).getBlockData());
- }
-
- @Override
- public Set materialToAllIds(Material material) {
- Set ids = new HashSet<>();
- for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(material.name().toLowerCase())).getStates().a()) {
- ids.add(Block.getCombinedId(data));
- }
-
- if(material == Material.WATER){
- Fluid water = FluidTypes.WATER.a(false);
- for(IBlockData data : Block.REGISTRY_ID){
- if(data.getFluid() == water){
- ids.add(Block.getCombinedId(data));
- }
- }
- }
-
- return ids;
- }
-}
diff --git a/SpigotCore_18/src/de/steamwar/core/CraftbukkitWrapper18.java b/SpigotCore_18/src/de/steamwar/core/CraftbukkitWrapper18.java
index 9f7aa13..e3d4ea7 100644
--- a/SpigotCore_18/src/de/steamwar/core/CraftbukkitWrapper18.java
+++ b/SpigotCore_18/src/de/steamwar/core/CraftbukkitWrapper18.java
@@ -19,24 +19,19 @@
package de.steamwar.core;
+import com.comphenix.tinyprotocol.Reflection;
+import com.comphenix.tinyprotocol.TinyProtocol;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
-import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.chunk.Chunk;
-import org.bukkit.craftbukkit.v1_18_R2.CraftChunk;
-import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class CraftbukkitWrapper18 implements CraftbukkitWrapper.ICraftbukkitWrapper {
- @Override
- public void sendChunk(Player p, int chunkX, int chunkZ) {
- Chunk chunk = ((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle();
- ((CraftPlayer)p).getHandle().b.a(new ClientboundLevelChunkWithLightPacket(chunk, chunk.q.l_(), null, null, false));
- }
+ private static final Reflection.MethodInvoker getHandle = Reflection.getMethod("{obc}.CraftChunk", "getHandle");
@Override
- @SuppressWarnings("deprecation")
- public double[] getSpigotTPS() {
- return MinecraftServer.getServer().recentTps;
+ public void sendChunk(Player p, int chunkX, int chunkZ) {
+ Chunk chunk = (Chunk) getHandle.invoke(p.getWorld().getChunkAt(chunkX, chunkZ));
+ TinyProtocol.instance.sendPacket(p, new ClientboundLevelChunkWithLightPacket(chunk, chunk.q.l_(), null, null, false));
}
}
diff --git a/SpigotCore_18/src/de/steamwar/core/ProtocolWrapper18.java b/SpigotCore_18/src/de/steamwar/core/ProtocolWrapper18.java
index 2a88cb4..94f6131 100644
--- a/SpigotCore_18/src/de/steamwar/core/ProtocolWrapper18.java
+++ b/SpigotCore_18/src/de/steamwar/core/ProtocolWrapper18.java
@@ -22,8 +22,6 @@ package de.steamwar.core;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Pair;
-import net.minecraft.world.entity.EntityTypes;
-import org.bukkit.entity.EntityType;
import java.util.Collections;
import java.util.List;
@@ -36,34 +34,6 @@ public class ProtocolWrapper18 implements ProtocolWrapper {
equipmentStack.set(packet, Collections.singletonList(new Pair<>(slot, stack)));
}
- private static final Reflection.FieldAccessor> spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, EntityTypes.class, 0);
- private static final Reflection.FieldAccessor spawnLivingType = Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1);
- @Override
- public void setSpawnPacketType(Object packet, EntityType type) {
- switch(type) {
- case PRIMED_TNT:
- spawnType.set(packet, EntityTypes.as);
- break;
- case ARROW:
- spawnType.set(packet, EntityTypes.d);
- break;
- case FIREBALL:
- spawnType.set(packet, EntityTypes.S);
- break;
- case ITEM_FRAME:
- spawnType.set(packet, EntityTypes.R);
- break;
- case FALLING_BLOCK:
- spawnType.set(packet, EntityTypes.C);
- break;
- case ARMOR_STAND:
- spawnLivingType.set(packet, 1);
- break;
- default:
- throw new IllegalArgumentException(type.name() + " is not implemented");
- }
- }
-
private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClass, GameProfile.class, int.class, enumGamemode, iChatBaseComponent);
@Override
public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) {
diff --git a/SpigotCore_18/src/de/steamwar/techhider/BlockIds18.java b/SpigotCore_18/src/de/steamwar/techhider/BlockIds18.java
deleted file mode 100644
index 13cf029..0000000
--- a/SpigotCore_18/src/de/steamwar/techhider/BlockIds18.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2021 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
- */
-
-package de.steamwar.techhider;
-
-import net.minecraft.core.IRegistry;
-import net.minecraft.resources.MinecraftKey;
-import net.minecraft.world.level.block.Block;
-import net.minecraft.world.level.block.state.IBlockData;
-import net.minecraft.world.level.material.Fluid;
-import net.minecraft.world.level.material.FluidTypes;
-import org.bukkit.Material;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class BlockIds18 implements BlockIds {
- @Override
- public int materialToId(Material material) {
- return Block.i(IRegistry.U.a(new MinecraftKey(material.name().toLowerCase())).n());
- }
-
- @Override
- public Set materialToAllIds(Material material) {
- Set ids = new HashSet<>();
- for(IBlockData data : IRegistry.U.a(new MinecraftKey(material.name().toLowerCase())).m().a()){
- ids.add(Block.i(data));
- }
-
- if(material == Material.WATER){
- Fluid water = FluidTypes.c.h();
- for(IBlockData data : Block.o) {
- if(data.o() == water) {
- ids.add(Block.i(data));
- }
- }
- }
-
- return ids;
- }
-}
diff --git a/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java b/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java
index 53dc78f..9dde1ad 100644
--- a/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java
+++ b/SpigotCore_18/src/de/steamwar/techhider/ChunkHider18.java
@@ -25,6 +25,7 @@ import io.netty.buffer.UnpooledByteBufAllocator;
import net.minecraft.core.IRegistry;
import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData;
import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
+import net.minecraft.resources.MinecraftKey;
import net.minecraft.util.SimpleBitStorage;
import net.minecraft.world.level.block.entity.TileEntityTypes;
import org.bukkit.World;
@@ -53,8 +54,6 @@ public class ChunkHider18 implements ChunkHider {
private static final Reflection.FieldAccessor dataField = Reflection.getField(ClientboundLevelChunkPacketData.class, byte[].class, 0);
private static final Reflection.FieldAccessor tileEntities = Reflection.getField(ClientboundLevelChunkPacketData.class, List.class, 0);
- public static final Class> tileEntity = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData$a");
- protected static final Reflection.FieldAccessor entityType = Reflection.getField(tileEntity, TileEntityTypes.class, 0);
@Override
public BiFunction chunkHiderGenerator(TechHider.BypassEvaluator bypass, int obfuscationTarget, Set obfuscate, Set hiddenBlockEntities) {
@@ -76,8 +75,13 @@ public class ChunkHider18 implements ChunkHider {
};
}
+ public static final Class> tileEntity = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData$a");
+ protected static final Reflection.FieldAccessor entityType = Reflection.getField(tileEntity, TileEntityTypes.class, 0);
+ private static final IRegistry> tileEntityTypes = Reflection.getField(IRegistry.class, IRegistry.class, 0, TileEntityTypes.class).get(null);
+ private static final Reflection.MethodInvoker getKey = Reflection.getTypedMethod(IRegistry.class, null, MinecraftKey.class, Object.class);
+ private static final Reflection.MethodInvoker getName = Reflection.getTypedMethod(MinecraftKey.class, null, String.class);
protected boolean tileEntityVisible(Set hiddenBlockEntities, Object tile) {
- return !hiddenBlockEntities.contains(IRegistry.aa.b(entityType.get(tile)).a());
+ return !hiddenBlockEntities.contains((String) getName.invoke(getKey.invoke(tileEntityTypes, entityType.get(tile))));
}
private byte[] dataHider(int obfuscationTarget, Set obfuscate, byte[] data, int sections) {
diff --git a/SpigotCore_18/src/de/steamwar/techhider/ProtocolWrapper18.java b/SpigotCore_18/src/de/steamwar/techhider/ProtocolWrapper18.java
index 7edbd8d..a52ddd5 100644
--- a/SpigotCore_18/src/de/steamwar/techhider/ProtocolWrapper18.java
+++ b/SpigotCore_18/src/de/steamwar/techhider/ProtocolWrapper18.java
@@ -20,9 +20,9 @@
package de.steamwar.techhider;
import com.comphenix.tinyprotocol.Reflection;
-import net.minecraft.core.IRegistry;
import net.minecraft.core.SectionPosition;
import net.minecraft.network.protocol.game.PacketPlayOutBlockBreak;
+import net.minecraft.world.level.block.entity.TileEntitySign;
import net.minecraft.world.level.block.entity.TileEntityTypes;
import net.minecraft.world.level.block.state.IBlockData;
import org.bukkit.Material;
@@ -45,15 +45,16 @@ public class ProtocolWrapper18 implements ProtocolWrapper {
return packet;
packet = TechHider.multiBlockChangeCloner.apply(packet);
- multiBlockChangeBlocks.set(packet, iBlockDataArrayCloner.apply(multiBlockChangeBlocks.get(packet), block -> ProtocolWrapper.impl.iBlockDataHidden(obfuscate, block) ? obfuscationTarget : block));
+ multiBlockChangeBlocks.set(packet, iBlockDataArrayCloner.apply(multiBlockChangeBlocks.get(packet), block -> TechHider.iBlockDataHidden(obfuscate, block) ? obfuscationTarget : block));
return packet;
};
}
private static final Reflection.FieldAccessor tileEntityType = Reflection.getField(TechHider.tileEntityDataPacket, TileEntityTypes.class, 0);
+ private static final TileEntityTypes> signType = Reflection.getField(TileEntityTypes.class, TileEntityTypes.class, 0, TileEntitySign.class).get(null);
@Override
public boolean unfilteredTileEntityDataAction(Object packet) {
- return tileEntityType.get(packet) != TileEntityTypes.h;
+ return tileEntityType.get(packet) != signType;
}
@Override
@@ -63,15 +64,10 @@ public class ProtocolWrapper18 implements ProtocolWrapper {
if(bypass.bypass(p, ProtocolUtils.posToChunk(TechHider.blockPositionX.get(breakPacket.b())), ProtocolUtils.posToChunk(TechHider.blockPositionZ.get(breakPacket.b()))))
return packet;
- if(!ProtocolWrapper.impl.iBlockDataHidden(obfuscate, breakPacket.c()))
+ if(!TechHider.iBlockDataHidden(obfuscate, breakPacket.c()))
return packet;
return new PacketPlayOutBlockBreak(breakPacket.b(), (IBlockData) obfuscationTarget, breakPacket.d(), breakPacket.a());
};
}
-
- @Override
- public boolean iBlockDataHidden(Set obfuscate, Object iBlockData) {
- return obfuscate.contains(Material.getMaterial(IRegistry.U.b(((IBlockData) iBlockData).b()).a().toUpperCase()));
- }
}
diff --git a/SpigotCore_19/src/de/steamwar/core/CraftbukkitWrapper19.java b/SpigotCore_19/src/de/steamwar/core/CraftbukkitWrapper19.java
deleted file mode 100644
index 99e9479..0000000
--- a/SpigotCore_19/src/de/steamwar/core/CraftbukkitWrapper19.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2021 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
-*/
-
-package de.steamwar.core;
-
-import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.world.level.chunk.Chunk;
-import org.bukkit.craftbukkit.v1_19_R1.CraftChunk;
-import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
-public class CraftbukkitWrapper19 implements CraftbukkitWrapper.ICraftbukkitWrapper {
-
- @Override
- public void sendChunk(Player p, int chunkX, int chunkZ) {
- Chunk chunk = ((CraftChunk)p.getWorld().getChunkAt(chunkX, chunkZ)).getHandle();
- ((CraftPlayer)p).getHandle().b.a(new ClientboundLevelChunkWithLightPacket(chunk, chunk.q.l_(), null, null, false));
- }
-
- @Override
- @SuppressWarnings("deprecation")
- public double[] getSpigotTPS() {
- return MinecraftServer.getServer().recentTps;
- }
-}
diff --git a/SpigotCore_19/src/de/steamwar/core/ProtocolWrapper19.java b/SpigotCore_19/src/de/steamwar/core/ProtocolWrapper19.java
index 66cc47c..86c23fb 100644
--- a/SpigotCore_19/src/de/steamwar/core/ProtocolWrapper19.java
+++ b/SpigotCore_19/src/de/steamwar/core/ProtocolWrapper19.java
@@ -22,8 +22,6 @@ package de.steamwar.core;
import com.comphenix.tinyprotocol.Reflection;
import com.mojang.authlib.GameProfile;
import com.mojang.datafixers.util.Pair;
-import net.minecraft.world.entity.EntityTypes;
-import org.bukkit.entity.EntityType;
import java.util.Collections;
import java.util.List;
@@ -36,33 +34,6 @@ public class ProtocolWrapper19 implements ProtocolWrapper {
equipmentStack.set(packet, Collections.singletonList(new Pair<>(slot, stack)));
}
- private static final Reflection.FieldAccessor> spawnType = Reflection.getField(ProtocolWrapper.spawnPacket, EntityTypes.class, 0);
- @Override
- public void setSpawnPacketType(Object packet, EntityType type) {
- switch(type) {
- case PRIMED_TNT:
- spawnType.set(packet, EntityTypes.av);
- break;
- case ARROW:
- spawnType.set(packet, EntityTypes.e);
- break;
- case FIREBALL:
- spawnType.set(packet, EntityTypes.V);
- break;
- case ITEM_FRAME:
- spawnType.set(packet, EntityTypes.U);
- break;
- case ARMOR_STAND:
- spawnType.set(packet, EntityTypes.d);
- break;
- case FALLING_BLOCK:
- spawnType.set(packet, EntityTypes.E);
- break;
- default:
- throw new IllegalArgumentException(type.name() + " is not implemented");
- }
- }
-
private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClass, GameProfile.class, int.class, enumGamemode, iChatBaseComponent, Reflection.getClass("net.minecraft.world.entity.player.ProfilePublicKey$a"));
@Override
public Object playerInfoDataConstructor(Object packet, GameProfile profile, Object mode) {
diff --git a/SpigotCore_19/src/de/steamwar/techhider/BlockIds19.java b/SpigotCore_19/src/de/steamwar/techhider/BlockIds19.java
deleted file mode 100644
index e1e0b54..0000000
--- a/SpigotCore_19/src/de/steamwar/techhider/BlockIds19.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2021 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
- */
-
-package de.steamwar.techhider;
-
-import net.minecraft.core.IRegistry;
-import net.minecraft.resources.MinecraftKey;
-import net.minecraft.world.level.block.Block;
-import net.minecraft.world.level.block.state.IBlockData;
-import net.minecraft.world.level.material.Fluid;
-import net.minecraft.world.level.material.FluidTypes;
-import org.bukkit.Material;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class BlockIds19 implements BlockIds {
- @Override
- public int materialToId(Material material) {
- return Block.i(IRegistry.V.a(new MinecraftKey(material.name().toLowerCase())).m());
- }
-
- @Override
- public Set materialToAllIds(Material material) {
- Set ids = new HashSet<>();
- for(IBlockData data : IRegistry.V.a(new MinecraftKey(material.name().toLowerCase())).k().a()){
- ids.add(Block.i(data));
- }
-
- if(material == Material.WATER){
- Fluid water = FluidTypes.c.h();
- for(IBlockData data : Block.o) {
- if(data.p() == water) {
- ids.add(Block.i(data));
- }
- }
- }
-
- return ids;
- }
-}
diff --git a/SpigotCore_19/src/de/steamwar/techhider/ChunkHider19.java b/SpigotCore_19/src/de/steamwar/techhider/ChunkHider19.java
deleted file mode 100644
index 0ebba1c..0000000
--- a/SpigotCore_19/src/de/steamwar/techhider/ChunkHider19.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- This file is a part of the SteamWar software.
-
- Copyright (C) 2021 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see .
- */
-
-package de.steamwar.techhider;
-
-import net.minecraft.core.IRegistry;
-
-import java.util.Set;
-
-public class ChunkHider19 extends ChunkHider18 {
- @Override
- protected boolean tileEntityVisible(Set hiddenBlockEntities, Object tile) {
- return !hiddenBlockEntities.contains(IRegistry.ab.b(entityType.get(tile)).a());
- }
-}
diff --git a/SpigotCore_19/src/de/steamwar/techhider/ProtocolWrapper19.java b/SpigotCore_19/src/de/steamwar/techhider/ProtocolWrapper19.java
index 240f854..9c31653 100644
--- a/SpigotCore_19/src/de/steamwar/techhider/ProtocolWrapper19.java
+++ b/SpigotCore_19/src/de/steamwar/techhider/ProtocolWrapper19.java
@@ -19,49 +19,16 @@
package de.steamwar.techhider;
-import com.comphenix.tinyprotocol.Reflection;
-import net.minecraft.core.IRegistry;
-import net.minecraft.core.SectionPosition;
-import net.minecraft.world.level.block.entity.TileEntityTypes;
-import net.minecraft.world.level.block.state.IBlockData;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.Set;
import java.util.function.BiFunction;
-import java.util.function.UnaryOperator;
-public class ProtocolWrapper19 implements ProtocolWrapper {
-
- private static final Reflection.FieldAccessor multiBlockChangeChunk = Reflection.getField(TechHider.multiBlockChangePacket, SectionPosition.class, 0);
- private static final Reflection.FieldAccessor multiBlockChangeBlocks = Reflection.getField(TechHider.multiBlockChangePacket, IBlockData[].class, 0);
- private static final BiFunction