use of com.comphenix.protocol.wrappers.EnumWrappers.PlayerDigType in project CombatLogX by SirBlobman.
the class ForceFieldAdapter method onPacketReceiving.
@Override
public void onPacketReceiving(PacketEvent e) {
if (e.isCancelled()) {
return;
}
Player player = e.getPlayer();
ICombatManager combatManager = this.plugin.getCombatManager();
if (!combatManager.isInCombat(player)) {
return;
}
World world = player.getWorld();
PacketContainer packetContainer = e.getPacket();
Location location = getLocation0(world, packetContainer);
if (location == null) {
return;
}
if (isForceFieldBlock(player, location)) {
PacketType packetType = packetContainer.getType();
if (packetType == Client.BLOCK_DIG) {
StructureModifier<PlayerDigType> playerDigTypeModifier = packetContainer.getPlayerDigTypes();
PlayerDigType playerDigType = playerDigTypeModifier.readSafely(0);
GameMode gameMode = player.getGameMode();
if (playerDigType == PlayerDigType.STOP_DESTROY_BLOCK || (playerDigType == PlayerDigType.START_DESTROY_BLOCK && gameMode == GameMode.CREATIVE)) {
this.forceFieldListener.sendForceField(player, location);
}
}
if (packetType == Client.USE_ITEM) {
this.forceFieldListener.sendForceField(player, location);
}
}
}
Aggregations