SteamWar/FightSystem
Archiviert
13
1

Making techhider processing fully async

Dieser Commit ist enthalten in:
Lixfel 2019-07-21 12:44:55 +02:00
Ursprung 5d5884ca1b
Commit d430311693

Datei anzeigen

@ -66,7 +66,7 @@ public class TechHider {
obfuscateShift4 = (short)(Config.ObfuscateWith << 4); obfuscateShift4 = (short)(Config.ObfuscateWith << 4);
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith); obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) { ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
@Override @Override
public void onPacketSending(PacketEvent e) { public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket(); PacketContainer packet = e.getPacket();
@ -165,8 +165,9 @@ public class TechHider {
byteArray.write(0, Bytes.toArray(newData)); byteArray.write(0, Bytes.toArray(newData));
} }
} }
}); }).start();
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) {
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) {
@Override @Override
public void onPacketSending(PacketEvent e) { public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket(); PacketContainer packet = e.getPacket();
@ -185,8 +186,8 @@ public class TechHider {
blockStructure.write(0, block); blockStructure.write(0, block);
} }
} }
}); }).start();
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) { ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) {
@Override @Override
public void onPacketSending(PacketEvent e) { public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket(); PacketContainer packet = e.getPacket();
@ -214,8 +215,8 @@ public class TechHider {
blockStructure.write(0, changes); blockStructure.write(0, changes);
} }
} }
}); }).start();
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) { ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) {
@Override @Override
public void onPacketSending(PacketEvent e) { public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket(); PacketContainer packet = e.getPacket();
@ -227,8 +228,8 @@ public class TechHider {
e.setCancelled(true); e.setCancelled(true);
} }
}); }).start();
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) { ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) {
@Override @Override
public void onPacketReceiving(PacketEvent e) { public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
@ -237,8 +238,8 @@ public class TechHider {
e.setCancelled(true); e.setCancelled(true);
} }
} }
}); }).start();
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ENTITY) { ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ENTITY) {
@Override @Override
public void onPacketReceiving(PacketEvent e) { public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
@ -247,23 +248,17 @@ public class TechHider {
e.setCancelled(true); e.setCancelled(true);
} }
} }
}); }).start();
} }
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
){
//Außerhalb der Arena
return true;
}
FightTeam ft = Fight.getPlayerTeam(p); FightTeam ft = Fight.getPlayerTeam(p);
if(ft == null){ if(ft == null){
return false; //Außerhalb der Arena
return arenaMinX > chunkX ||
chunkX > arenaMaxX ||
arenaMinZ > chunkZ ||
chunkZ > arenaMaxZ;
}else if(ft.isBlue()){ }else if(ft.isBlue()){
return FightSystem.isEntern() || return FightSystem.isEntern() ||
redMinX > chunkX || redMinX > chunkX ||