SteamWar/FightSystem
Archiviert
13
1

BlockBreakHider #240

Manuell gemergt
Lixfel hat 1 Commits von masterBlockBreakHider nach master 2021-03-27 17:54:13 +01:00 zusammengeführt
Nur Änderungen aus Commit 9e42d34ddd werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -88,6 +88,9 @@ public class TechHider {
blockHider(); blockHider();
multiBlockHider(); multiBlockHider();
updateBlockEntity(); updateBlockEntity();
if(Core.getVersion() > 12){
blockBreakHider();
}
VersionedRunnable.call(new VersionedRunnable(TechHider_12::start, 12), VersionedRunnable.call(new VersionedRunnable(TechHider_12::start, 12),
new VersionedRunnable(TechHider_14::start, 14), new VersionedRunnable(TechHider_14::start, 14),
new VersionedRunnable(TechHider_15::start, 15)); new VersionedRunnable(TechHider_15::start, 15));
@ -132,6 +135,37 @@ public class TechHider {
}); });
} }
private static void blockBreakHider(){
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_BREAK) {
@Override
public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket();
BlockPosition pos = packet.getBlockPositionModifier().read(0);
Player p = e.getPlayer();
if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
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<WrappedBlockData> blockStructure = cached.getBlockData();
WrappedBlockData block = blockStructure.read(0);
if(Config.HiddenBlockTags.contains(block.getType().name())){
block.setType(ITechHider.obfuscateMaterial);
blockStructure.write(0, block);
}
}
});
}
private static void blockHider(){ private static void blockHider(){
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) { ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) {
@Override @Override