Exemple #1
0
  @Override
  public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
    if (!plugin.getConfigManager().getProperties().bedHeal) return;

    // This player is no longer in bed so remove them from the bedHealer set
    Hero hero = plugin.getHeroManager().getHero(event.getPlayer());
    if (hero.hasEffect("BedHeal")) {
      hero.removeEffect(hero.getEffect("BedHeal"));
    }
  }
Exemple #2
0
  @Override
  public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    if (event.useItemInHand() == Result.DENY) return;

    Hero hero = plugin.getHeroManager().getHero(player);
    if (hero.hasEffectType(EffectType.DISARM)) Util.disarmCheck(hero, plugin);

    if (!hero.canEquipItem(player.getInventory().getHeldItemSlot())) {
      event.setCancelled(true);
      Util.syncInventory(player, plugin);
      return;
    }

    // Remove effects dependant on non-interaction
    if (hero.hasEffect("Invisible")) {
      hero.removeEffect(hero.getEffect("Invisible"));
    }

    Block clickedBlock = event.getClickedBlock();
    if (clickedBlock != null) {
      switch (clickedBlock.getType()) {
        case DISPENSER:
        case BED:
        case FURNACE:
        case BURNING_FURNACE:
        case WOOD_DOOR:
        case LEVER:
        case IRON_DOOR:
        case JUKEBOX:
        case DIODE_BLOCK_OFF:
        case DIODE_BLOCK_ON:
        case CHEST:
        case LOCKED_CHEST:
        case TRAP_DOOR:
          hero.cancelDelayedSkill();
          return;
      }
    }

    if (player.getItemInHand() != null) {
      Material material = player.getItemInHand().getType();
      if (hero.hasBind(material)) {
        if (event.getAction() == Action.RIGHT_CLICK_AIR
            || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
          String[] args = hero.getBind(material);
          plugin.onCommand(player, null, "skill", args);
        } else {
          hero.cancelDelayedSkill();
        }
      } else {
        hero.cancelDelayedSkill();
      }
    }
  }