SteamWar/FightSystem
Archiviert
13
1

Reformatting for bugfixing

Dieser Commit ist enthalten in:
Travis CI 2019-06-22 17:11:10 +02:00
Ursprung e8b981d165
Commit d04680e4b8

Datei anzeigen

@ -30,6 +30,8 @@ import java.util.List;
public class TechHider { public class TechHider {
private TechHider(){}
private static int arenaMinX; private static int arenaMinX;
private static int arenaMaxX; private static int arenaMaxX;
private static int arenaMinZ; private static int arenaMinZ;
@ -67,6 +69,10 @@ public class TechHider {
//noinspection deprecation //noinspection deprecation
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith); obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
System.out.println("Arena: " + arenaMinX + "->" + arenaMaxX + " " + arenaMinZ + "->" + arenaMaxZ);
System.out.println("Blue: " + blueMinX + "->" + blueMaxX + " " + blueMinZ + "->" + blueMaxZ);
System.out.println("Red: " + redMinX + "->" + redMaxX + " " + redMinZ + "->" + redMaxZ);
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) {
@ -167,7 +173,6 @@ 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) {
PacketContainer packet = e.getPacket(); PacketContainer packet = e.getPacket();
@ -186,7 +191,6 @@ public class TechHider {
} }
}); });
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) {
PacketContainer packet = e.getPacket(); PacketContainer packet = e.getPacket();
@ -248,7 +252,12 @@ public class TechHider {
} }
private static boolean bypass(Player p, int chunkX, int chunkZ){ private static boolean bypass(Player p, int chunkX, int chunkZ){
if( ! (arenaMinX <= chunkX && chunkX <= arenaMaxX && arenaMinZ <= chunkZ && chunkZ <= arenaMaxZ)){ if(
arenaMinX > chunkX ||
chunkX > arenaMaxX ||
arenaMinZ > chunkZ ||
chunkZ > arenaMaxZ
){
//Außerhalb der Arena //Außerhalb der Arena
return true; return true;
} }
@ -257,9 +266,17 @@ public class TechHider {
if(ft == null){ if(ft == null){
return false; return false;
}else if(ft.equals(Fight.getBlueTeam())){ }else if(ft.equals(Fight.getBlueTeam())){
return FightSystem.isEntern() || !(redMinX <= chunkX && chunkX <= redMaxX && redMinZ <= chunkZ && chunkZ <= redMaxZ); return FightSystem.isEntern() ||
redMinX > chunkX ||
chunkX > redMaxX ||
redMinZ > chunkZ ||
chunkZ > redMaxZ;
}else{ }else{
return FightSystem.isEntern() || !(blueMinX <= chunkX && chunkX <= blueMaxX && blueMinZ <= chunkZ && chunkZ <= blueMaxZ); return FightSystem.isEntern() ||
blueMinX > chunkX ||
chunkX > blueMaxX ||
blueMinZ > chunkZ ||
chunkZ > blueMaxZ;
} }
} }
@ -276,7 +293,7 @@ public class TechHider {
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> { Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
for(Pair<Integer, Integer> chunk : chunksToReload) for(Pair<Integer, Integer> chunk : chunksToReload)
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535)); ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535));
}, 20); }, 40);
} }
private static int readVarInt(byte[] array, int startPos) { private static int readVarInt(byte[] array, int startPos) {