Merge branch 'techhider2' of SteamWar/FightSystem into master
Dieser Commit ist enthalten in:
Commit
0a8e6c7923
@ -17,6 +17,7 @@ import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||
@ -47,31 +48,24 @@ class TechHider_12 {
|
||||
if(bypass(p, chunkX, chunkZ))
|
||||
return;
|
||||
|
||||
PacketContainer cached = ITechHider.packetCache.get(packet);
|
||||
if(cached != null){
|
||||
e.setPacket(cached);
|
||||
return;
|
||||
}
|
||||
|
||||
cached = packet.deepClone();
|
||||
ITechHider.packetCache.put(packet, cached);
|
||||
e.setPacket(cached);
|
||||
StructureModifier<List> list = cached.getSpecificModifier(List.class);
|
||||
packet = packet.shallowClone();
|
||||
e.setPacket(packet);
|
||||
StructureModifier<List> list = packet.getSpecificModifier(List.class);
|
||||
List nmsTags = list.read(0);
|
||||
boolean changed = false;
|
||||
for(int i = nmsTags.size() - 1; i >= 0; i--){
|
||||
NbtCompound nbt = NbtFactory.fromNMSCompound(nmsTags.get(i));
|
||||
if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){
|
||||
nmsTags.remove(i);
|
||||
List newNmsTags = new ArrayList(nmsTags.size());
|
||||
for(Object nmsTag : nmsTags){
|
||||
NbtCompound nbt = NbtFactory.fromNMSCompound(nmsTag);
|
||||
if(Config.HiddenBlockEntities.contains(nbt.getString("id")))
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if(changed){
|
||||
list.write(0, nmsTags);
|
||||
else
|
||||
newNmsTags.add(nmsTag);
|
||||
}
|
||||
if(changed)
|
||||
list.write(0, newNmsTags);
|
||||
|
||||
changed = false;
|
||||
StructureModifier<byte[]> byteArray = cached.getByteArrays();
|
||||
StructureModifier<byte[]> byteArray = packet.getByteArrays();
|
||||
byte [] data = byteArray.read(0);
|
||||
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100);
|
||||
int i = 0;
|
||||
@ -91,20 +85,23 @@ class TechHider_12 {
|
||||
int paletteLengthLength = ITechHider.readVarIntLength(data, i);
|
||||
buffer.writeBytes(data, i, paletteLengthLength);
|
||||
i += paletteLengthLength;
|
||||
List<Integer> palette = new ArrayList<>(paletteLength);
|
||||
for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
|
||||
int actPalette = ITechHider.readVarInt(data, i);
|
||||
int actPaletteLength = ITechHider.readVarIntLength(data, i);
|
||||
|
||||
int blockId = actPalette >> 4;
|
||||
if(Config.HiddenBlocks.contains(blockId)){
|
||||
byte[] a = ITechHider.writeVarInt(obfuscateShift4);
|
||||
buffer.writeBytes(a);
|
||||
changed = true;
|
||||
}else{
|
||||
buffer.writeBytes(data, i, actPaletteLength);
|
||||
}
|
||||
i += actPaletteLength;
|
||||
palette.add(ITechHider.readVarInt(data, i));
|
||||
i += ITechHider.readVarIntLength(data, i);
|
||||
}
|
||||
|
||||
int replacement = 0;
|
||||
for(int entry : palette){
|
||||
int blockId = entry >> 4;
|
||||
if(Config.HiddenBlocks.contains(blockId)){
|
||||
while(palette.contains((++replacement) << 4));
|
||||
entry = replacement << 4;
|
||||
changed = true;
|
||||
}
|
||||
buffer.writeBytes(ITechHider.writeVarInt(entry));
|
||||
}
|
||||
|
||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||
buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren