Techhider (except for Full chunks)
Dieser Commit ist enthalten in:
Ursprung
579d5bebf7
Commit
4ba8e49735
@ -51,7 +51,9 @@ Money:
|
|||||||
Kits:
|
Kits:
|
||||||
MemberDefault: default
|
MemberDefault: default
|
||||||
LeaderDefault: default
|
LeaderDefault: default
|
||||||
HiddenBlocks:
|
Techhider:
|
||||||
|
ObfuscateWith: 1
|
||||||
|
HiddenBlocks:
|
||||||
- 7
|
- 7
|
||||||
- 8
|
- 8
|
||||||
- 9
|
- 9
|
||||||
@ -107,7 +109,7 @@ HiddenBlocks:
|
|||||||
- 232
|
- 232
|
||||||
- 233
|
- 233
|
||||||
- 234
|
- 234
|
||||||
HiddenBlockEntites:
|
HiddenBlockEntites:
|
||||||
- minecraft:sign
|
- minecraft:sign
|
||||||
- minecraft:dispenser
|
- minecraft:dispenser
|
||||||
- minecraft:chest
|
- minecraft:chest
|
||||||
|
@ -16,9 +16,9 @@ public class BlockPlaceListener implements Listener {
|
|||||||
|
|
||||||
if(Fight.getPlayerTeam(player) == null)
|
if(Fight.getPlayerTeam(player) == null)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
else if(FightSystem.getPlugin().getFightState() != FightState.RUNNING) {
|
else if(FightSystem.getFightState() != FightState.RUNNING) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if(FightSystem.getPlugin().getFightState() == FightState.PRE_RUNNING) {
|
if(FightSystem.getFightState() == FightState.PRE_RUNNING || FightSystem.getFightState() == FightState.SETUP) {
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke setzen!");
|
player.sendMessage(FightSystem.PREFIX + "§cDu darfst erst nach Fightbeginn Blöcke setzen!");
|
||||||
} else
|
} else
|
||||||
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr setzen!");
|
player.sendMessage(FightSystem.PREFIX + "§cDu darfst keine Blöcke mehr setzen!");
|
||||||
|
@ -81,6 +81,7 @@ public class Config {
|
|||||||
|
|
||||||
public static List<Integer> HiddenBlocks;
|
public static List<Integer> HiddenBlocks;
|
||||||
public static List<String> HiddenBlockEntities;
|
public static List<String> HiddenBlockEntities;
|
||||||
|
public static int ObfuscateWith;
|
||||||
|
|
||||||
public static void load(){
|
public static void load(){
|
||||||
if(!new File("plugins/" + FightSystem.getPlugin().getName() + "/config.yml").exists()) {
|
if(!new File("plugins/" + FightSystem.getPlugin().getName() + "/config.yml").exists()) {
|
||||||
@ -139,8 +140,9 @@ public class Config {
|
|||||||
MemberDefault = config.getString("Kits.MemberDefault");
|
MemberDefault = config.getString("Kits.MemberDefault");
|
||||||
LeaderDefault = config.getString("Kits.LeaderDefault");
|
LeaderDefault = config.getString("Kits.LeaderDefault");
|
||||||
|
|
||||||
HiddenBlocks = config.getIntegerList("HiddenBlocks");
|
HiddenBlocks = config.getIntegerList("Techhider.HiddenBlocks");
|
||||||
HiddenBlockEntities = config.getStringList("HiddenBlockEntities");
|
HiddenBlockEntities = config.getStringList("Techhider.HiddenBlockEntities");
|
||||||
|
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
|
||||||
|
|
||||||
if(SchemsizeX < 0){
|
if(SchemsizeX < 0){
|
||||||
SchemsizeX = -SchemsizeX;
|
SchemsizeX = -SchemsizeX;
|
||||||
|
@ -6,12 +6,17 @@ 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.BlockPosition;
|
||||||
|
import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
|
||||||
import com.comphenix.protocol.wrappers.MultiBlockChangeInfo;
|
import com.comphenix.protocol.wrappers.MultiBlockChangeInfo;
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||||
import com.google.common.primitives.Bytes;
|
import com.google.common.primitives.Bytes;
|
||||||
import me.yaruma.fightsystem.FightSystem;
|
import me.yaruma.fightsystem.FightSystem;
|
||||||
|
import me.yaruma.fightsystem.fight.Fight;
|
||||||
|
import me.yaruma.fightsystem.fight.FightTeam;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -20,14 +25,45 @@ import java.util.List;
|
|||||||
|
|
||||||
public class TechHider {
|
public class TechHider {
|
||||||
|
|
||||||
|
private static int arenaMinX;
|
||||||
|
private static int arenaMaxX;
|
||||||
|
private static int arenaMinZ;
|
||||||
|
private static int arenaMaxZ;
|
||||||
|
private static int blueMinX;
|
||||||
|
private static int blueMaxX;
|
||||||
|
private static int blueMinZ;
|
||||||
|
private static int blueMaxZ;
|
||||||
|
private static int redMinX;
|
||||||
|
private static int redMaxX;
|
||||||
|
private static int redMinZ;
|
||||||
|
private static int redMaxZ;
|
||||||
|
private static int obfuscateShift4;
|
||||||
|
private static Material obfuscateMaterial;
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
|
arenaMinX = Config.ArenaMinX / 16 - (Config.ArenaMinX % 16 < 0 ? 1 : 0);
|
||||||
|
arenaMinZ = Config.ArenaMinZ / 16 - (Config.ArenaMinZ % 16 < 0 ? 1 : 0);
|
||||||
|
arenaMaxX = Config.ArenaMaxX / 16 + (Config.ArenaMaxX % 16 > 0 ? 1 : 0);
|
||||||
|
arenaMaxZ = Config.ArenaMaxZ / 16 + (Config.ArenaMaxZ % 16 > 0 ? 1 : 0);
|
||||||
|
blueMinX = Config.TeamBlueCornerX / 16 - (Config.TeamBlueCornerX % 16 < 0 ? 1 : 0);
|
||||||
|
blueMinZ = Config.TeamBlueCornerZ / 16 - (Config.TeamBlueCornerZ % 16 < 0 ? 1 : 0);
|
||||||
|
int max = Config.TeamBlueCornerX + Config.SchemsizeX;
|
||||||
|
blueMaxX = max / 16 + (max % 16 > 0 ? 1 : 0);
|
||||||
|
max = Config.TeamBlueCornerZ + Config.SchemsizeZ;
|
||||||
|
blueMaxZ = max / 16 + (max % 16 > 0 ? 1 : 0);
|
||||||
|
redMinX = Config.TeamRedCornerX / 16 - (Config.TeamRedCornerX % 16 < 0 ? 1 : 0);
|
||||||
|
redMinZ = Config.TeamRedCornerZ / 16 - (Config.TeamRedCornerZ % 16 < 0 ? 1 : 0);
|
||||||
|
max = Config.TeamRedCornerX + Config.SchemsizeX;
|
||||||
|
redMaxX = max / 16 + (max % 16 > 0 ? 1 : 0);
|
||||||
|
max = Config.TeamRedCornerZ + Config.SchemsizeZ;
|
||||||
|
redMaxZ = max / 16 + (max % 16 > 0 ? 1 : 0);
|
||||||
|
obfuscateShift4 = Config.ObfuscateWith << 4;
|
||||||
|
//noinspection deprecation
|
||||||
|
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent e) {
|
public void onPacketSending(PacketEvent e) {
|
||||||
Player p = e.getPlayer();
|
|
||||||
|
|
||||||
//TODO: Check for Which chunks to hide
|
|
||||||
|
|
||||||
PacketContainer packet = e.getPacket();
|
PacketContainer packet = e.getPacket();
|
||||||
StructureModifier<Integer> ints = packet.getIntegers();
|
StructureModifier<Integer> ints = packet.getIntegers();
|
||||||
StructureModifier<byte[]> byteArray = packet.getByteArrays();
|
StructureModifier<byte[]> byteArray = packet.getByteArrays();
|
||||||
@ -36,11 +72,15 @@ public class TechHider {
|
|||||||
|
|
||||||
int chunkX = ints.read(0);
|
int chunkX = ints.read(0);
|
||||||
int chunkZ = ints.read(1);
|
int chunkZ = ints.read(1);
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
if(bypass(p, chunkX, chunkZ))
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for(int i = nmsTags.size() - 1; i >= 0; i--){
|
for(int i = nmsTags.size() - 1; i >= 0; i--){
|
||||||
NbtCompound nbt = NbtFactory.fromNMSCompound(nmsTags.get(i));
|
NbtCompound nbt = NbtFactory.fromNMSCompound(nmsTags.get(i));
|
||||||
if(nbt.getString("id").equals("minecraft:sign")){
|
if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){
|
||||||
nmsTags.remove(i);
|
nmsTags.remove(i);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@ -72,7 +112,7 @@ public class TechHider {
|
|||||||
|
|
||||||
int blockId = actPalette >> 4;
|
int blockId = actPalette >> 4;
|
||||||
if(Config.HiddenBlocks.contains(blockId)){
|
if(Config.HiddenBlocks.contains(blockId)){
|
||||||
byte[] a = writeVarInt(16);
|
byte[] a = writeVarInt(obfuscateShift4);
|
||||||
for(int j = 0; j < actPaletteLength; j++){
|
for(int j = 0; j < actPaletteLength; j++){
|
||||||
newData.remove(i);
|
newData.remove(i);
|
||||||
}
|
}
|
||||||
@ -119,42 +159,45 @@ public class TechHider {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent e) {
|
public void onPacketSending(PacketEvent e) {
|
||||||
Player p = e.getPlayer();
|
|
||||||
//TODO: Check for Which chunks to hide
|
|
||||||
|
|
||||||
PacketContainer packet = e.getPacket();
|
PacketContainer packet = e.getPacket();
|
||||||
StructureModifier<WrappedBlockData> blockStructure = packet.getBlockData();
|
StructureModifier<WrappedBlockData> blockStructure = packet.getBlockData();
|
||||||
|
BlockPosition pos = packet.getBlockPositionModifier().read(0);
|
||||||
|
|
||||||
WrappedBlockData block = packet.getBlockData().read(0);
|
Player p = e.getPlayer();
|
||||||
|
if(bypass(p, pos.getX() / 16, pos.getZ() / 16))
|
||||||
|
return;
|
||||||
|
|
||||||
|
WrappedBlockData block = blockStructure.read(0);
|
||||||
if(Config.HiddenBlocks.contains(block.getType().getId())){
|
if(Config.HiddenBlocks.contains(block.getType().getId())){
|
||||||
block.setType(Material.STONE);
|
block.setType(obfuscateMaterial);
|
||||||
blockStructure.write(0, block);
|
blockStructure.write(0, block);
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) {
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent e) {
|
public void onPacketSending(PacketEvent e) {
|
||||||
Player p = e.getPlayer();
|
|
||||||
//TODO: Check for Which chunks to hide
|
|
||||||
|
|
||||||
PacketContainer packet = e.getPacket();
|
PacketContainer packet = e.getPacket();
|
||||||
StructureModifier<MultiBlockChangeInfo[]> blockStructure = packet.getMultiBlockChangeInfoArrays();
|
StructureModifier<MultiBlockChangeInfo[]> blockStructure = packet.getMultiBlockChangeInfoArrays();
|
||||||
MultiBlockChangeInfo[] changes = blockStructure.read(0);
|
MultiBlockChangeInfo[] changes = blockStructure.read(0);
|
||||||
boolean changed = false;
|
|
||||||
|
|
||||||
int i = 0;
|
Player p = e.getPlayer();
|
||||||
|
ChunkCoordIntPair pos = changes[0].getChunk();
|
||||||
|
if(bypass(p, pos.getChunkX(), pos.getChunkZ()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
boolean changed = false;
|
||||||
for(MultiBlockChangeInfo mbci : changes){
|
for(MultiBlockChangeInfo mbci : changes){
|
||||||
WrappedBlockData block = mbci.getData();
|
WrappedBlockData block = mbci.getData();
|
||||||
if(Config.HiddenBlocks.contains(block.getType().getId())){
|
if(Config.HiddenBlocks.contains(block.getType().getId())){
|
||||||
changed = true;
|
changed = true;
|
||||||
block.setType(Material.STONE);
|
block.setType(obfuscateMaterial);
|
||||||
mbci.setData(block);
|
mbci.setData(block);
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(changed){
|
if(changed){
|
||||||
@ -165,10 +208,11 @@ public class TechHider {
|
|||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent e) {
|
public void onPacketSending(PacketEvent e) {
|
||||||
Player p = e.getPlayer();
|
|
||||||
//TODO: Check for Which chunks to hide
|
|
||||||
|
|
||||||
PacketContainer packet = e.getPacket();
|
PacketContainer packet = e.getPacket();
|
||||||
|
BlockPosition pos = packet.getBlockPositionModifier().read(0);
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
if(bypass(p, pos.getX() / 16, pos.getZ() / 16))
|
||||||
|
return;
|
||||||
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -177,17 +221,41 @@ public class TechHider {
|
|||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent e) {
|
public void onPacketReceiving(PacketEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
//TODO: Check for Which chunks to hide
|
|
||||||
|
|
||||||
PacketContainer packet = e.getPacket();
|
if(p.getGameMode() == GameMode.SPECTATOR){
|
||||||
|
|
||||||
System.out.println("EntityUse!");
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ENTITY) {
|
||||||
|
@Override
|
||||||
|
public void onPacketReceiving(PacketEvent e) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
|
if(p.getGameMode() == GameMode.SPECTATOR){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int readVarInt(byte[] array, int startPos) {
|
private static boolean bypass(Player p, int chunkX, int chunkZ){
|
||||||
|
if( ! (arenaMinX <= chunkX && chunkX <= arenaMaxX && arenaMinZ <= chunkZ && chunkZ <= arenaMaxZ)){
|
||||||
|
//Außerhalb der Arena
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FightTeam ft = Fight.getPlayerTeam(p);
|
||||||
|
if(ft == null){
|
||||||
|
return false;
|
||||||
|
}else if(ft == Fight.getBlueTeam()){
|
||||||
|
return Config.Entern || ! (redMinX <= chunkX && chunkX <= redMaxX && redMinZ <= chunkZ && chunkZ <= redMaxZ);
|
||||||
|
}else{
|
||||||
|
return Config.Entern || ! (blueMinX <= chunkX && chunkX <= blueMaxX && blueMinZ <= chunkZ && chunkZ <= blueMaxZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int readVarInt(byte[] array, int startPos) {
|
||||||
int numRead = 0;
|
int numRead = 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
byte read;
|
byte read;
|
||||||
@ -205,7 +273,7 @@ public class TechHider {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int readVarIntLength(byte[] array, int startPos) {
|
private static int readVarIntLength(byte[] array, int startPos) {
|
||||||
int numRead = 0;
|
int numRead = 0;
|
||||||
byte read;
|
byte read;
|
||||||
do {
|
do {
|
||||||
@ -219,25 +287,7 @@ public class TechHider {
|
|||||||
return numRead;
|
return numRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long readVarLong() {
|
private static byte[] writeVarInt(int value) {
|
||||||
int numRead = 0;
|
|
||||||
long result = 0;
|
|
||||||
byte read = 0;
|
|
||||||
do {
|
|
||||||
//read = readByte();
|
|
||||||
int value = (read & 0b01111111);
|
|
||||||
result |= (value << (7 * numRead));
|
|
||||||
|
|
||||||
numRead++;
|
|
||||||
if (numRead > 10) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while ((read & 0b10000000) != 0);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] writeVarInt(int value) {
|
|
||||||
ArrayList<Byte> buffer = new ArrayList<>();
|
ArrayList<Byte> buffer = new ArrayList<>();
|
||||||
do {
|
do {
|
||||||
byte temp = (byte)(value & 0b01111111);
|
byte temp = (byte)(value & 0b01111111);
|
||||||
@ -250,16 +300,4 @@ public class TechHider {
|
|||||||
} while (value != 0);
|
} while (value != 0);
|
||||||
return Bytes.toArray(buffer);
|
return Bytes.toArray(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeVarLong(long value) {
|
|
||||||
do {
|
|
||||||
byte temp = (byte)(value & 0b01111111);
|
|
||||||
// Note: >>> means that the sign bit is shifted with the rest of the number rather than being left alone
|
|
||||||
value >>>= 7;
|
|
||||||
if (value != 0) {
|
|
||||||
temp |= 0b10000000;
|
|
||||||
}
|
|
||||||
//writeByte(temp);
|
|
||||||
} while (value != 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren