Search in sources :

Example 1 with Weapon

use of xyz.derkades.ublisk.weapons.Weapon in project Ublisk by Derkades.

the class AbilityListener method onInteract.

@EventHandler
public void onInteract(PlayerInteractEvent event) {
    Action action = event.getAction();
    if (action == Action.PHYSICAL)
        return;
    UPlayer player = new UPlayer(event);
    if (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) {
        for (Weapon weapon : Weapon.WEAPONS) {
            if (Weapon.itemStackIsWeapon(player.getInventory().getItemInMainHand().getItemStack(), weapon)) {
                player.doAbility(weapon.getLeftClickAbility());
            }
        }
    }
    if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) {
        for (Weapon weapon : Weapon.WEAPONS) {
            if (Weapon.itemStackIsWeapon(player.getInventory().getItemInMainHand().getItemStack(), weapon)) {
                player.doAbility(weapon.getRightClickAbility());
            }
        }
    }
}
Also used : Action(org.bukkit.event.block.Action) UPlayer(xyz.derkades.ublisk.utils.UPlayer) Weapon(xyz.derkades.ublisk.weapons.Weapon) EventHandler(org.bukkit.event.EventHandler)

Aggregations

EventHandler (org.bukkit.event.EventHandler)1 Action (org.bukkit.event.block.Action)1 UPlayer (xyz.derkades.ublisk.utils.UPlayer)1 Weapon (xyz.derkades.ublisk.weapons.Weapon)1