Add Bow Damge and Fire #261
@ -55,6 +55,33 @@ public class Recording implements Listener {
|
|||||||
|
|
||||||
private static final int AIR = 0;
|
private static final int AIR = 0;
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
|
private static final PacketAdapter BOW_PACKET_PROCESSOR = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.BLOCK_PLACE) {
|
||||||
|
@Override
|
||||||
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
|
PacketContainer packet = event.getPacket();
|
||||||
|
EnumWrappers.Hand hand = packet.getHands().read(0);
|
||||||
|
Player p = event.getPlayer();
|
||||||
|
|
||||||
|
if(!((hand == EnumWrappers.Hand.MAIN_HAND && p.getInventory().getItemInMainHand().getType() == Material.BOW) ||
|
||||||
|
(hand == EnumWrappers.Hand.OFF_HAND && p.getInventory().getItemInOffHand().getType() == Material.BOW)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
RecordSystem.bowSpan(p, true, hand != EnumWrappers.Hand.MAIN_HAND);
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.BLOCK_DIG) {
|
||||||
|
@Override
|
||||||
|
public void onPacketReceiving(PacketEvent e) {
|
||||||
|
if(e.getPlayer() != event.getPlayer())
|
||||||
|
return;
|
||||||
|
|
||||||
|
PacketContainer packetDig = e.getPacket();
|
||||||
|
if(packetDig.getPlayerDigTypes().read(0) == EnumWrappers.PlayerDigType.RELEASE_USE_ITEM) {
|
||||||
|
RecordSystem.bowSpan(e.getPlayer(), false, hand != EnumWrappers.Hand.MAIN_HAND);
|
||||||
|
ProtocolLibrary.getProtocolManager().removePacketListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public Recording() {
|
public Recording() {
|
||||||
new StateDependentListener(Config.recording(), FightState.All, this);
|
new StateDependentListener(Config.recording(), FightState.All, this);
|
||||||
@ -74,35 +101,17 @@ public class Recording implements Listener {
|
|||||||
despawnTNT();
|
despawnTNT();
|
||||||
}
|
}
|
||||||
}.register();
|
}.register();
|
||||||
|
new StateDependent(Config.recording(), FightState.All) {
|
||||||
//Bow Listener
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.BLOCK_PLACE) {
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent event) {
|
public void enable() {
|
||||||
PacketContainer packet = event.getPacket();
|
ProtocolLibrary.getProtocolManager().addPacketListener(BOW_PACKET_PROCESSOR);
|
||||||
EnumWrappers.Hand hand = packet.getHands().read(0);
|
|
||||||
Player p = event.getPlayer();
|
|
||||||
|
|
||||||
if(!((hand == EnumWrappers.Hand.MAIN_HAND && p.getInventory().getItemInMainHand().getType() == Material.BOW) ||
|
|
||||||
(hand == EnumWrappers.Hand.OFF_HAND && p.getInventory().getItemInOffHand().getType() == Material.BOW)))
|
|
||||||
return;
|
|
||||||
|
|
||||||
RecordSystem.bowSpan(p, true, hand != EnumWrappers.Hand.MAIN_HAND);
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.BLOCK_DIG) {
|
|
||||||
@Override
|
|
||||||
public void onPacketReceiving(PacketEvent e) {
|
|
||||||
if(e.getPlayer() != event.getPlayer())
|
|
||||||
return;
|
|
||||||
|
|
||||||
PacketContainer packetDig = e.getPacket();
|
|
||||||
if(packetDig.getPlayerDigTypes().read(0) == EnumWrappers.PlayerDigType.RELEASE_USE_ITEM) {
|
|
||||||
RecordSystem.bowSpan(e.getPlayer(), false, hand != EnumWrappers.Hand.MAIN_HAND);
|
|
||||||
ProtocolLibrary.getProtocolManager().removePacketListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
ProtocolLibrary.getProtocolManager().removePacketListener(BOW_PACKET_PROCESSOR);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren