Merge pull request 'Simplified 1.12-Techhider' (#150) from simplified-techhider12-nonViaCompatible into master
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Commit
aed114cda2
@ -6,19 +6,20 @@ import com.comphenix.protocol.events.PacketAdapter;
|
|||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.IFightSystem;
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||||
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
|
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
|
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||||
|
|
||||||
@ -50,19 +51,18 @@ class TechHider_12 {
|
|||||||
|
|
||||||
packet = packet.shallowClone();
|
packet = packet.shallowClone();
|
||||||
e.setPacket(packet);
|
e.setPacket(packet);
|
||||||
StructureModifier<List> list = packet.getSpecificModifier(List.class);
|
StructureModifier<List<NbtBase<?>>> list = packet.getListNbtModifier();
|
||||||
List nmsTags = list.read(0);
|
List<NbtBase<?>> nmsTags = list.read(0);
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
List newNmsTags = new ArrayList(nmsTags.size());
|
for(int i = nmsTags.size() - 1; i >= 0; i--){
|
||||||
for(Object nmsTag : nmsTags){
|
NbtCompound nbt = (NbtCompound)nmsTags.get(i);
|
||||||
NbtCompound nbt = NbtFactory.fromNMSCompound(nmsTag);
|
if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){
|
||||||
if(Config.HiddenBlockEntities.contains(nbt.getString("id")))
|
nmsTags.remove(i);
|
||||||
changed = true;
|
changed = true;
|
||||||
else
|
}
|
||||||
newNmsTags.add(nmsTag);
|
|
||||||
}
|
}
|
||||||
if(changed)
|
if(changed)
|
||||||
list.write(0, newNmsTags);
|
list.write(0, nmsTags);
|
||||||
|
|
||||||
changed = false;
|
changed = false;
|
||||||
StructureModifier<byte[]> byteArray = packet.getByteArrays();
|
StructureModifier<byte[]> byteArray = packet.getByteArrays();
|
||||||
@ -73,47 +73,33 @@ class TechHider_12 {
|
|||||||
while(i < data.length){
|
while(i < data.length){
|
||||||
byte bitsPerBlock = data[i++];
|
byte bitsPerBlock = data[i++];
|
||||||
buffer.writeByte(bitsPerBlock);
|
buffer.writeByte(bitsPerBlock);
|
||||||
if(bitsPerBlock < 4)
|
|
||||||
bitsPerBlock = 4;
|
|
||||||
else if(bitsPerBlock > 8){
|
|
||||||
bitsPerBlock = 13;
|
|
||||||
buffer.writeByte(data[++i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(bitsPerBlock != 13){
|
if(bitsPerBlock != 13){
|
||||||
int paletteLength = ITechHider.readVarInt(data, i);
|
int paletteLength = ITechHider.readVarInt(data, i);
|
||||||
int paletteLengthLength = ITechHider.readVarIntLength(data, i);
|
int paletteLengthLength = ITechHider.readVarIntLength(data, i);
|
||||||
buffer.writeBytes(data, i, paletteLengthLength);
|
buffer.writeBytes(data, i, paletteLengthLength);
|
||||||
i += paletteLengthLength;
|
i += paletteLengthLength;
|
||||||
List<Integer> palette = new ArrayList<>(paletteLength);
|
|
||||||
for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
|
|
||||||
palette.add(ITechHider.readVarInt(data, i));
|
|
||||||
i += ITechHider.readVarIntLength(data, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
int replacement = 0;
|
for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
|
||||||
for(int entry : palette){
|
int entry = ITechHider.readVarInt(data, i);
|
||||||
int blockId = entry >> 4;
|
i += ITechHider.readVarIntLength(data, i);
|
||||||
if(Config.HiddenBlocks.contains(blockId)){
|
|
||||||
while(palette.contains((++replacement) << 4));
|
if(Config.HiddenBlocks.contains(entry >> 4)){
|
||||||
entry = replacement << 4;
|
entry = obfuscateShift4;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
buffer.writeBytes(ITechHider.writeVarInt(entry));
|
buffer.writeBytes(ITechHider.writeVarInt(entry));
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
buffer.writeByte(data[++i]); //Empty palette
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Full chunk 1.12 occured");
|
||||||
|
}
|
||||||
|
|
||||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
int dataArrayLength = ITechHider.readVarInt(data, i);
|
||||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
||||||
buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
|
buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
|
||||||
i += dataArrayLengthLength;
|
i += dataArrayLengthLength;
|
||||||
i += dataArrayLength * 8;
|
i += dataArrayLength * 8;
|
||||||
}else{
|
|
||||||
int dataArrayLength = ITechHider.readVarInt(data, i);
|
|
||||||
int dataArrayLengthLength = ITechHider.readVarIntLength(data, i);
|
|
||||||
buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength);
|
|
||||||
i += dataArrayLengthLength;
|
|
||||||
i += dataArrayLength * 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.writeBytes(data, i, 4096);
|
buffer.writeBytes(data, i, 4096);
|
||||||
i += 4096; //Skylight (Not in Nether/End!!!) 2048 + Blocklight 2048
|
i += 4096; //Skylight (Not in Nether/End!!!) 2048 + Blocklight 2048
|
||||||
|
@ -104,6 +104,7 @@ public class Config {
|
|||||||
public static final List<String> ForbiddenItems;
|
public static final List<String> ForbiddenItems;
|
||||||
|
|
||||||
//tech hider parameter
|
//tech hider parameter
|
||||||
|
public static final boolean TechhiderActive;
|
||||||
public static final Set<Integer> HiddenBlocks;
|
public static final Set<Integer> HiddenBlocks;
|
||||||
public static final Set<String> HiddenBlockTags;
|
public static final Set<String> HiddenBlockTags;
|
||||||
public static final Set<String> HiddenBlockEntities;
|
public static final Set<String> HiddenBlockEntities;
|
||||||
@ -213,6 +214,7 @@ public class Config {
|
|||||||
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
|
||||||
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
|
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
|
||||||
ObfuscateWithTag = config.getString("Techhider.ObfuscateWithTag");
|
ObfuscateWithTag = config.getString("Techhider.ObfuscateWithTag");
|
||||||
|
TechhiderActive = config.getBoolean("Techhider.Active");
|
||||||
|
|
||||||
if(schemsizeX < 0){
|
if(schemsizeX < 0){
|
||||||
SchemsizeX = -schemsizeX;
|
SchemsizeX = -schemsizeX;
|
||||||
|
@ -236,6 +236,6 @@ public class TechHider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean disabled(){
|
private static boolean disabled(){
|
||||||
return Config.OnlyPublicSchematics || Config.test();
|
return Config.OnlyPublicSchematics || Config.test() || !Config.TechhiderActive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren