@EventHandler(priority = EventPriority.HIGH)
  public void onPlayerInteract(org.bukkit.event.player.PlayerInteractEvent event) {
    Player p = event.getPlayer();
    if (event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
      if (p.getItemInHand().getType() == Material.EYE_OF_ENDER) {

        for (Player other : Bukkit.getServer().getOnlinePlayers()) {
          other.hidePlayer(p);
          p.hidePlayer(other);

          Inventory inventory = p.getInventory();
          inventory.setItem(8, new ItemStack(Material.ENDER_PEARL, 1));
        }

      } else if (p.getItemInHand().getType() == Material.ENDER_PEARL) {
        for (Player other : Bukkit.getServer().getOnlinePlayers()) {
          other.showPlayer(p);
          p.showPlayer(other);
          Inventory inventory = p.getInventory();
          inventory.setItem(8, new ItemStack(Material.EYE_OF_ENDER, 1));
        }
      } else if (p.getItemInHand().getType() == Material.GOLD_AXE) {
        p.launchProjectile(EnderPearl.class);
      }
    } else {

    }
  }
예제 #2
0
 public boolean heal(Player player, Player victim) {
   SuperNPlayer snplayer = SuperNManager.get(player);
   SuperNPlayer snvictim = SuperNManager.get(victim);
   if (snplayer.getPower() > SNConfigHandler.priestPowerHeal) {
     if (!snvictim.isSuper() && victim.getHealth() < victim.getMaxHealth() && !victim.isDead()) {
       SuperNManager.alterPower(
           snplayer, -SNConfigHandler.priestPowerHeal, "Healed " + victim.getName());
       SuperNManager.sendMessage(
           snvictim,
           "You were healed by " + ChatColor.WHITE + snplayer.getName() + ChatColor.RED + "!");
       double health = victim.getHealth() + SNConfigHandler.priestHealAmount;
       if (health > victim.getMaxHealth()) {
         health = victim.getMaxHealth();
       }
       victim.setHealth(health);
       ItemStack item = player.getItemInHand();
       if (item.getAmount() == 1) {
         player.setItemInHand(null);
       } else {
         item.setAmount(player.getItemInHand().getAmount() - 1);
       }
       return true;
     } else {
       SuperNManager.sendMessage(snplayer, "Player cannot be healed.");
       return false;
     }
   } else {
     SuperNManager.sendMessage(snplayer, "Not enough power to heal.");
     return false;
   }
 }
예제 #3
0
파일: Swords.java 프로젝트: nidefawl/mcMMO
 public static void parryCheck(EntityDamageByEntityEvent event, Player defender) {
   Entity y = event.getDamager();
   PlayerProfile PPd = Users.getProfile(defender);
   if (defender != null
       && Utils.isSword(defender.getItemInHand())
       && mcPermissions.skillPermission(SkillType.SWORDS, defender)) {
     if (PPd.getSkillLevel(SkillType.SWORDS) >= 900) {
       if (Math.random() * 3000 <= 900) {
         event.setCancelled(true);
         defender.sendMessage(ChatColor.GREEN + "**PARRIED**");
         defender
             .getItemInHand()
             .setDurability((short) (defender.getItemInHand().getDurability() + 1));
         if (y instanceof Player) {
           Player attacker = (Player) y;
           attacker.sendMessage(ChatColor.GREEN + "**PARRIED**");
         }
       }
     } else {
       if (Math.random() * 3000 <= PPd.getSkillLevel(SkillType.SWORDS)) {
         event.setCancelled(true);
         defender.sendMessage(ChatColor.YELLOW + "*CLANG* SUCCESSFUL PARRY *CLANG*");
         defender
             .getItemInHand()
             .setDurability((short) (defender.getItemInHand().getDurability() + 1));
         if (y instanceof Player) {
           Player attacker = (Player) y;
           attacker.sendMessage(ChatColor.DARK_RED + "**TARGET HAS PARRIED THAT ATTACK**");
         }
       }
     }
   }
 }
예제 #4
0
  public static void useJailStick(Player player) {
    Boolean enabled = Jail.jailStickToggle.get(player);
    if (enabled == null || !enabled) return;

    if (!InputOutput.global.getBoolean(Setting.EnableJailStick.getString(), false)
        || !InputOutput.jailStickParameters.containsKey(player.getItemInHand().getTypeId())) return;
    if (!Util.permission(
        player,
        "jail.usejailstick." + String.valueOf(player.getItemInHand().getTypeId()),
        PermissionDefault.OP)) return;
    String[] param = InputOutput.jailStickParameters.get(player.getItemInHand().getTypeId());

    List<Block> targets = player.getLineOfSight(null, Integer.parseInt(param[1]));
    for (Block b : targets) {
      for (Player p : Bukkit.getServer().getOnlinePlayers()) {
        if (p == player) continue;
        if ((b.getLocation().equals(p.getLocation().getBlock().getLocation())
                || b.getLocation().equals(p.getEyeLocation().getBlock().getLocation()))
            && Util.permission(player, "jail.canbestickjailed", PermissionDefault.TRUE)) {
          String args[] = new String[4];
          args[0] = p.getName();
          args[1] = param[2];
          args[2] = param[3];
          args[3] = param[4];
          PrisonerManager.PrepareJail((CommandSender) player, args);
        }
      }
    }
  }
예제 #5
0
 public boolean banish(Player player, Player victim) {
   SuperNPlayer snplayer = SuperNManager.get(player);
   SuperNPlayer snvictim = SuperNManager.get(victim);
   if (!SupernaturalsPlugin.instance.getPvP(victim)) {
     SuperNManager.sendMessage(snplayer, "Cannot cast in a non-PvP zone.");
     return false;
   }
   if (snplayer.getPower() > SNConfigHandler.priestPowerBanish) {
     if (snvictim.isSuper()) {
       SuperNManager.alterPower(
           snplayer, -SNConfigHandler.priestPowerBanish, "Banished " + victim.getName());
       SuperNManager.sendMessage(
           snvictim,
           "You were banished by " + ChatColor.WHITE + snplayer.getName() + ChatColor.RED + "!");
       victim.teleport(SNConfigHandler.priestBanishLocation);
       ItemStack item = player.getItemInHand();
       if (item.getAmount() == 1) {
         player.setItemInHand(null);
       } else {
         item.setAmount(player.getItemInHand().getAmount() - 1);
       }
       return true;
     }
     SuperNManager.sendMessage(snplayer, "Can only banish supernatural players.");
     return false;
   } else {
     SuperNManager.sendMessage(snplayer, "Not enough power to banish.");
     return false;
   }
 }
예제 #6
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void togglePlayerStacker(PlayerInteractEvent event) {
    // Do nothing if player is not right clicking.
    Action action = event.getAction();
    if (action != RIGHT_CLICK_AIR && action != RIGHT_CLICK_BLOCK) return;

    // Do nothing if player does not have permission.
    Player player = event.getPlayer();
    if (!Perm.PLAYERSTACKER.has(player)) return;

    // Do nothing if player is not clicking the player hider item.
    if (!player.getItemInHand().equals(plugin.getSettings().getPlayerStackerItemDisabled())
        && !player.getItemInHand().equals(plugin.getSettings().getPlayerStackerItemEnabled()))
      return;

    // Do nothing if user is null.
    User user = plugin.getUser(player.getUniqueId());
    if (user == null) return;

    // Toggle users stacking option.
    user.setStacking(!user.isStacking());

    // Update players inventory with the newer player hider item.
    if (plugin.getSettings().getPlayerStackerSlot() >= 0) {
      ItemStack reverse =
          player.getItemInHand().equals(plugin.getSettings().getPlayerStackerItemEnabled())
              ? plugin.getSettings().getPlayerStackerItemDisabled()
              : plugin.getSettings().getPlayerStackerItemEnabled();
      player.getInventory().setItem(plugin.getSettings().getPlayerStackerSlot(), reverse);
      player.updateInventory();
    }

    // Play a clicking sound.
    player.playSound(player.getLocation(), Sound.CLICK, 2.0F, 1.0F);
  }
  @EventHandler
  public void onPlayerInteract(PlayerInteractEvent e) {
    Player p = e.getPlayer();
    if (p.getItemInHand().getType() == Material.EYE_OF_ENDER
        && p.getItemInHand().getDurability() == 1) {
      Action a = e.getAction();
      if ((a == Action.RIGHT_CLICK_AIR) || (a == Action.RIGHT_CLICK_BLOCK)) {
        try {
          if (p.getInventory().getHelmet().getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)
              == 7) {
            if (p.getInventory()
                    .getChestplate()
                    .getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)
                == 7) {
              if (p.getInventory()
                      .getLeggings()
                      .getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)
                  == 7) {
                if (p.getInventory()
                        .getBoots()
                        .getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)
                    == 7) {
                  p.launchProjectile(EnderPearl.class);
                }
              }
            }
          } else if (p.getInventory().getChestplate() != null) {
            if (p.getInventory().getChestplate().hasItemMeta()) {
              if (p.getInventory().getChestplate().getItemMeta().hasDisplayName()) {
                if (p.getInventory()
                    .getChestplate()
                    .getItemMeta()
                    .getDisplayName()
                    .equalsIgnoreCase(
                        ChatColor.BLUE
                            + ""
                            + ChatColor.BOLD
                            + "Uber"
                            + ChatColor.GOLD
                            + ""
                            + ChatColor.BOLD
                            + "Chestplate")) {
                  if (p.getInventory()
                      .getChestplate()
                      .getItemMeta()
                      .getLore()
                      .contains(ChatColor.GRAY + "Ender Fake")) {
                    p.launchProjectile(EnderPearl.class);
                  }
                }
              }
            }
          }
        } catch (Exception x) {

        }
        e.setCancelled(true);
      }
    }
  }
예제 #8
0
 public boolean drainPower(Player player, Player victim) {
   SuperNPlayer snplayer = SuperNManager.get(player);
   SuperNPlayer snvictim = SuperNManager.get(victim);
   if (!SupernaturalsPlugin.instance.getPvP(victim)) {
     SuperNManager.sendMessage(snplayer, "Cannot cast in a non-PvP zone.");
     return false;
   }
   if (snplayer.getPower() > SNConfigHandler.priestPowerDrain) {
     if (snvictim.isSuper()) {
       double power = snvictim.getPower();
       power *= SNConfigHandler.priestDrainFactor;
       SuperNManager.alterPower(
           snplayer,
           -SNConfigHandler.priestPowerDrain,
           "Drained  " + snvictim.getName() + "'s power!");
       SuperNManager.alterPower(snvictim, -power, "Drained by " + snplayer.getName());
       ItemStack item = player.getItemInHand();
       if (item.getAmount() == 1) {
         player.setItemInHand(null);
       } else {
         item.setAmount(player.getItemInHand().getAmount() - 1);
       }
       return true;
     } else {
       SuperNManager.sendMessage(snplayer, "Only supernatural players can be power drained.");
       return false;
     }
   } else {
     SuperNManager.sendMessage(snplayer, "Not enough power to drain power.");
     return false;
   }
 }
  @EventHandler(priority = EventPriority.NORMAL)
  public void onRightHandPlayerInteact(PlayerInteractEvent event) {
    if (event.isCancelled()) return;

    final Player player = event.getPlayer();

    if (player != null
        && (event.getAction() == Action.RIGHT_CLICK_BLOCK
            || event.getAction() == Action.RIGHT_CLICK_AIR)) {
      Location loc = player.getLocation();
      // If block is not null use block location, if null use player loc
      final Block block = event.getClickedBlock();
      if (block != null) loc = block.getLocation();

      if (player.getWorld() != plugin.getIslandWorld()) return;
      if (player.isOp()) return;
      if (player.hasPermission("islandworld.bypass.island")) return;

      if (player.getItemInHand().getType() == Material.MONSTER_EGG) {
        if (!(plugin.canBuildOnLocation(player, loc))) event.setCancelled(true);
      } else if (player.getItemInHand().getType() == Material.FIREBALL) {
        if (!plugin.canBuildOnLocation(player, loc)) event.setCancelled(true);
      }
    }
    plugin.debug("Evento :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }
예제 #10
0
  public static void enchantValidate(Player p, String e, int rlvl) { // shut up for now :P
    HashMap<Enchantment, Integer> fen = new HashMap<Enchantment, Integer>();
    ItemStack i = null;
    int lvl = 0;
    Enchantment en = Enchantment.getById(getEnchantId(e));

    if (p.getItemInHand().getTypeId() == ((ItemStack) item.get(p.getName())).getTypeId()) {
      i = p.getItemInHand();
      if (i.getAmount() == 1) {
        if (i.containsEnchantment(en)) {
          int plvl = i.getEnchantmentLevel(en);
          lvl = plvl + rlvl;
        } else {
          lvl = rlvl;
        }
        fen.put(en, lvl);
        enchants.put(p.getName(), fen);
        ChatListener.add(p, 2);
        p.sendMessage(
            "The enchant will cost you: "
                + getEnchantCost(p, e.toLowerCase(), rlvl)
                + "! Should I continue? Please type \"yes\" or \"no\"!");
      } else {
        p.sendMessage(
            ChatColor.RED + "You have more then one item in your slot, please try again!");
      }
    }
  }
예제 #11
0
  /*
   * @Return: True if they have an ability matching the held item. False if
   * they do not have any abilities matching held item
   */
  public boolean useAbility(Player sender, Player target) {
    // check if they're holding anything
    if (sender.getItemInHand() == null) {
      return false;
    }

    ItemStack i = sender.getItemInHand();

    // sees if they are fightclassed
    FightClass f = FightClass.get(sender);
    // goes through each ability, seeeing if any of the MID's match the
    // lore of the item
    for (Ability a : f.getAbilities()) {
      if (i.getItemMeta().hasLore()
          && i.getItemMeta().getLore().get(0).equalsIgnoreCase(a.getMID())) {
        // check if cost is able to be paid, and pay it
        if (a.useCost(sender)) {
          if (!sender.equals(target)) {
            a.effect(sender, target);
          }
        } else {
          // nothing
        }
        return true;
      }
    }
    return false;
  }
예제 #12
0
 @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
 public void onPlayerInteract(PlayerInteractEvent event) {
   Player player = event.getPlayer();
   Block block = event.getClickedBlock();
   if (player.getItemInHand().getType() == Material.STICK) {
     select(player, event);
   }
   /*if(player.getItemInHand().getType() == Material.STICK && player.getItemInHand().hasItemMeta()){
   	if(player.getItemInHand().getItemMeta().getDisplayName().contains(Tools.SelectionTool)){
   		select(player, event);
   	}else if(player.getItemInHand().getItemMeta().getDisplayName().contains(Tools.InfoTool)){
   		info(player, block, event);
   	}
   }*/
   if (block == null) {
     return;
   }
   if (event.getAction() != Action.LEFT_CLICK_BLOCK
       && event.getAction() != Action.RIGHT_CLICK_BLOCK) {
     pressure(player, block, event);
     return;
   }
   if (event.isCancelled()) {
     return;
   }
   if (player.getItemInHand().getType() == Material.ARMOR_STAND) {
     armorStand(player, block, event);
   }
   interact(player, block, event);
 }
예제 #13
0
 public boolean exorcise(Player player, Player victim) {
   SuperNPlayer snplayer = SuperNManager.get(player);
   SuperNPlayer snvictim = SuperNManager.get(victim);
   if (!SupernaturalsPlugin.instance.getPvP(victim)) {
     SuperNManager.sendMessage(snplayer, "Cannot cast in a non-PvP zone.");
     return false;
   }
   if (snplayer.getPower() > SNConfigHandler.priestPowerExorcise) {
     if (snvictim.isSuper()) {
       SuperNManager.alterPower(
           snplayer, -SNConfigHandler.priestPowerExorcise, "Exorcised " + victim.getName());
       SuperNManager.sendMessage(
           snvictim,
           "You were exorcised by " + ChatColor.WHITE + snplayer.getName() + ChatColor.RED + "!");
       SuperNManager.cure(snvictim);
       ItemStack item = player.getItemInHand();
       if (item.getAmount() == 1) {
         player.setItemInHand(null);
       } else {
         item.setAmount(player.getItemInHand().getAmount() - 1);
       }
       return true;
     } else {
       SuperNManager.sendMessage(snplayer, "Only supernatural players can be exorcised.");
       return false;
     }
   } else {
     SuperNManager.sendMessage(snplayer, "Not enough power to exorcise.");
     return false;
   }
 }
예제 #14
0
  Esell(Player player, String[] args) {
    HyperConomy hc = HyperConomy.hc;
    LanguageFile L = hc.getLanguageFile();
    ShopFactory s = hc.getShopFactory();
    DataHandler dh = hc.getDataFunctions();
    InventoryManipulation im = hc.getInventoryManipulation();
    try {
      if (player.getGameMode() == GameMode.CREATIVE
          && hc.s().gB("block-selling-in-creative-mode")) {
        player.sendMessage(L.get("CANT_SELL_CREATIVE"));
        return;
      }
      if (s.inAnyShop(player)) {
        HyperPlayer hp = dh.getHyperPlayer(player);
        if (hp.hasSellPermission(s.getShop(player))) {
          String name = args[0];
          if (args[0].equalsIgnoreCase("max")) {
            if (!im.hasenchants(player.getItemInHand())) {
              player.sendMessage(L.get("HAS_NO_ENCHANTMENTS"));
            }
            ArrayList<String> enchants = im.getEnchantments(player.getItemInHand());
            for (String e : enchants) {
              if (s.getShop(player).has(e)) {
                PlayerTransaction pt = new PlayerTransaction(TransactionType.SELL);
                pt.setHyperObject(dh.getHyperObject(e, hp.getEconomy()));
                TransactionResponse response = hp.processTransaction(pt);
                response.sendMessages();
              } else {
                player.sendMessage(L.get("CANT_BE_TRADED"));
              }
            }

          } else {
            if (hc.getDataFunctions().enchantTest(name)) {
              if (s.getShop(player).has(name)) {
                PlayerTransaction pt = new PlayerTransaction(TransactionType.SELL);
                pt.setHyperObject(dh.getHyperObject(name, hp.getEconomy()));
                TransactionResponse response = hp.processTransaction(pt);
                response.sendMessages();
              } else {
                player.sendMessage(L.get("CANT_BE_TRADED"));
              }
            } else {
              player.sendMessage(L.get("ENCHANTMENT_NOT_IN_DATABASE"));
            }
          }
        } else {
          player.sendMessage(L.get("NO_TRADE_PERMISSION"));
        }
      } else {
        player.sendMessage(L.get("MUST_BE_IN_SHOP"));
      }
    } catch (Exception e) {
      player.sendMessage(L.get("ESELL_INVALID"));
    }
  }
 @Override
 public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
   if (sender instanceof Player) {
     Player player = (Player) sender;
     if (player.getItemInHand() != null && args.length > 0) {
       this.nmsHandler.setName(player.getItemInHand(), this.combineSplit(args));
     }
   }
   return true;
 }
예제 #16
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();
      }
    }
  }
예제 #17
0
  /** Called when a block is broken. */
  @Override
  public void onBlockBreak(BlockBreakEvent event) {
    if (event.isCancelled()) {
      return;
    }

    Player player = event.getPlayer();
    WorldConfiguration wcfg = getWorldConfig(player);

    if (!wcfg.itemDurability) {
      ItemStack held = player.getItemInHand();
      if (held.getTypeId() > 0) {
        held.setDurability((short) -1);
        player.setItemInHand(held);
      }
    }

    if (!plugin.getGlobalRegionManager().canBuild(player, event.getBlock())) {
      player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
      event.setCancelled(true);
      return;
    }

    if (wcfg.getBlacklist() != null) {
      if (!wcfg.getBlacklist()
          .check(
              new BlockBreakBlacklistEvent(
                  plugin.wrapPlayer(player),
                  toVector(event.getBlock()),
                  event.getBlock().getTypeId()),
              false,
              false)) {
        event.setCancelled(true);
        return;
      }

      if (!wcfg.getBlacklist()
          .check(
              new DestroyWithBlacklistEvent(
                  plugin.wrapPlayer(player),
                  toVector(event.getBlock()),
                  player.getItemInHand().getTypeId()),
              false,
              false)) {
        event.setCancelled(true);
        return;
      }
    }

    if (wcfg.isChestProtected(event.getBlock(), player)) {
      player.sendMessage(ChatColor.DARK_RED + "The chest is protected.");
      event.setCancelled(true);
      return;
    }
  }
  /*
   * Called when a block is broken.
   */
  @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
  public void onBlockBreak(BlockBreakEvent event) {
    Player player = event.getPlayer();
    WorldConfiguration wcfg = getWorldConfig(player);

    if (!wcfg.itemDurability) {
      ItemStack held = player.getItemInHand();
      if (held.getTypeId() > 0
          && !(ItemType.usesDamageValue(held.getTypeId())
              || BlockType.usesData(held.getTypeId()))) {
        held.setDurability((short) 0);
        player.setItemInHand(held);
      }
    }

    if (!plugin.getGlobalRegionManager().canBuild(player, event.getBlock())
        || !plugin.getGlobalRegionManager().canConstruct(player, event.getBlock())) {
      player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
      event.setCancelled(true);
      return;
    }

    if (wcfg.getBlacklist() != null) {
      if (!wcfg.getBlacklist()
          .check(
              new BlockBreakBlacklistEvent(
                  plugin.wrapPlayer(player),
                  toVector(event.getBlock()),
                  event.getBlock().getTypeId()),
              false,
              false)) {
        event.setCancelled(true);
        return;
      }

      if (!wcfg.getBlacklist()
          .check(
              new DestroyWithBlacklistEvent(
                  plugin.wrapPlayer(player),
                  toVector(event.getBlock()),
                  player.getItemInHand().getTypeId()),
              false,
              false)) {
        event.setCancelled(true);
        return;
      }
    }

    if (wcfg.isChestProtected(event.getBlock(), player)) {
      player.sendMessage(ChatColor.DARK_RED + "The chest is protected.");
      event.setCancelled(true);
      return;
    }
  }
예제 #19
0
 private double getWeaponBonus(Character character, Stat stat) {
   double bonus = 0D;
   Player player = character.getPlayer().getPlayer();
   Material weaponType = player.getItemInHand().getType();
   bonus +=
       plugin
           .getConfig()
           .getDouble("rolls.weapons." + weaponType.toString() + "." + stat.toString());
   bonus += getEtBonus(player.getItemInHand(), stat);
   bonus += getEnchantmentBonus(player.getItemInHand(), stat);
   return bonus;
 }
예제 #20
0
  /**
   * Handle the Super Breaker ability.
   *
   * @param player The player using the ability
   * @param block The block being affected
   */
  public static void SuperBreakerBlockCheck(Player player, Block block) {
    Material type = block.getType();
    int tier = m.getTier(player.getItemInHand());
    int durabilityLoss = LoadProperties.abilityDurabilityLoss;
    PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);

    switch (type) {
      case OBSIDIAN:
        if (tier < 4) {
          return;
        }
        durabilityLoss = durabilityLoss * 5; // Obsidian needs to do more damage than normal
        /* FALL THROUGH */

      case DIAMOND_ORE:
      case GLOWING_REDSTONE_ORE:
      case GOLD_ORE:
      case LAPIS_ORE:
      case REDSTONE_ORE:
        if (tier < 3) {
          return;
        }
        /* FALL THROUGH */

      case IRON_ORE:
        if (tier < 2) {
          return;
        }
        /* FALL THROUGH */

      case COAL_ORE:
      case ENDER_STONE:
      case GLOWSTONE:
      case MOSSY_COBBLESTONE:
      case NETHERRACK:
      case SANDSTONE:
      case STONE:
        if (!block.hasMetadata("mcmmoPlacedBlock")) {
          return;
        }

        Bukkit.getPluginManager().callEvent(armswing);
        Skills.abilityDurabilityLoss(player.getItemInHand(), durabilityLoss);

        miningBlockCheck(player, block);
        miningBlockCheck(player, block);

        if (LoadProperties.spoutEnabled) {
          SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
        }
    }
  }
예제 #21
0
 @Override
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (sender instanceof Player) {
     Player p = (Player) sender;
     if ((p.hasPermission("advancedrename.relore")) || (p.hasPermission("advancedrename.*"))) {
       if (args.length >= 1) {
         if ((p.getItemInHand() != null) && (p.getItemInHand().getType() != Material.AIR)) {
           String name = args[0];
           for (int i = 0; i < args.length; i++) {
             name = name + " " + args[i];
           }
           name = ChatColor.translateAlternateColorCodes('&', name);
           if ((name.contains(";"))) {
             ItemStack i = p.getItemInHand();
             ItemMeta im = i.getItemMeta();
             String[] lore = name.split(";");
             List<String> il = new ArrayList<String>();
             for (int l = 1; l < lore.length; l++) {
               il.add(lore[l]);
             }
             im.setLore(il);
             i.setItemMeta(im);
             p.updateInventory();
             p.sendMessage(Main.pr + "�uccessfully lore set for the item.");
             return true;
           } else {
             ItemStack i = p.getItemInHand();
             ItemMeta im = i.getItemMeta();
             List<String> il = new ArrayList<String>();
             il.add(name);
             im.setLore(il);
             i.setItemMeta(im);
             p.updateInventory();
             p.sendMessage(Main.pr + "�uccessfully lore set for the item.");
             return true;
           }
         } else {
           p.sendMessage(Main.pr + "Please hold a Item in your hand.");
           return true;
         }
       }
     } else {
       p.sendMessage(Main.pr + "You dont have permission to use this command!");
       return true;
     }
   } else {
     sender.sendMessage("[AdvancedRename] You must be a player to relore a item.");
     return true;
   }
   return false;
 }
예제 #22
0
 @Override
 public void updateProgress(Event event) {
   if (event instanceof NPCTargetEvent) {
     NPCTargetEvent e = (NPCTargetEvent) event;
     if (e.getTarget().getEntityId() == this.player.getEntityId()) {
       if (((HumanNPC) e.getEntity()).getUID() == this.objective.getDestinationNPCID()) {
         Player player = (Player) e.getTarget();
         if (player.getItemInHand().getType() == this.objective.getMaterial()) {
           this.getProgress().setLastItem(player.getItemInHand());
         }
       }
     }
   }
 }
예제 #23
0
 public static void giveTool(Player player, int type) {
   final Inventory inv = player.getInventory();
   if (inv.contains(type))
     player.sendMessage(ChatColor.RED + "You have already a " + materialName(type));
   else {
     final int free = inv.firstEmpty();
     if (free >= 0) {
       if (player.getItemInHand() != null && player.getItemInHand().getTypeId() != 0)
         inv.setItem(free, player.getItemInHand());
       player.setItemInHand(new ItemStack(type, 1));
       player.sendMessage(ChatColor.GREEN + "Here's your " + materialName(type));
     } else player.sendMessage(ChatColor.RED + "You have no empty slot in your inventory");
   }
 }
예제 #24
0
  @EventHandler
  public void onPlayerAction(PlayerInteractEvent e) {
    Player player = e.getPlayer();
    if ((e.getAction() == Action.RIGHT_CLICK_AIR
        || (e.getAction() == Action.RIGHT_CLICK_BLOCK) && !e.isCancelled())) {
      ItemStack item = player.getItemInHand();
      if (item.getType() == Material.BOW
          || item.getType() == Material.SNOW_BALL
          || item.getType() == Material.EGG
          || item.getType() == Material.POTION) return;

      RPGItem rItem = ItemManager.toRPGItem(item);
      if (rItem == null) return;
      if (!WorldGuard.canPvP(player.getLocation()) && !rItem.ignoreWorldGuard) return;
      if (rItem.getHasPermission() == true
          && player.hasPermission(rItem.getPermission()) == false) {
        e.setCancelled(true);
        player.sendMessage(
            ChatColor.RED
                + String.format(
                    Locale.get("message.error.permission", Locale.getPlayerLocale(player))));
      }
      rItem.rightClick(player);
      if (player.getItemInHand().getTypeId() != 0) {
        RPGItem.updateItem(item, Locale.getPlayerLocale(player));
      } else player.setItemInHand(null);
      player.updateInventory();
    } else if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
      ItemStack item = player.getItemInHand();
      if (item.getType() == Material.BOW
          || item.getType() == Material.SNOW_BALL
          || item.getType() == Material.EGG
          || item.getType() == Material.POTION) return;

      RPGItem rItem = ItemManager.toRPGItem(item);
      if (rItem == null) return;
      if (!WorldGuard.canPvP(player.getLocation()) && !rItem.ignoreWorldGuard) return;
      if (rItem.getHasPermission() == true
          && player.hasPermission(rItem.getPermission()) == false) {
        e.setCancelled(true);
        player.sendMessage(
            ChatColor.RED
                + String.format(
                    Locale.get("message.error.permission", Locale.getPlayerLocale(player))));
      }
      rItem.leftClick(player);
      RPGItem.updateItem(item, Locale.getPlayerLocale(player));
    }
  }
예제 #25
0
  /**
   * Event - onBlockRightClick - If a player right clicks a block check their permissions and set a
   * Coordinate.
   */
  @Override
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.isCancelled()) {
      return;
    }

    Player player = event.getPlayer();

    if (player.getItemInHand().getTypeId() == this.plugin.configMV.getInt("setwand", 270)
        && MultiVerse.Permissions.has(player, "multiverse.portal.create")) {
      String[] whitelist = this.plugin.configMV.getString("portalblocks", "").split(",");
      if (whitelist.length > 0 && whitelist[0] != "") {
        for (String element : whitelist) {
          int w = Integer.valueOf(element);
          if (w != event.getClickedBlock().getTypeId()) {
            return;
          }
        }
      }
      Location l = event.getClickedBlock().getLocation();
      if (this.plugin.playerSessions.get(player.getName()).compareLocation2(l)) {
        return;
      }
      this.plugin.playerSessions.get(player.getName()).setLocation2(l);
      player.sendMessage("Position 2 - Set");
    }
  }
예제 #26
0
 @EventHandler
 public void onDamageFisherman(EntityDamageByEntityEvent e) {
   if (this.pl.comecou)
     if (((e.getEntity() instanceof Player)) && ((e.getDamager() instanceof Player))) {
       Entity ent = e.getEntity();
       Player player = (Player) e.getEntity();
       Player damager = (Player) e.getDamager();
       Player p = (Player) ent;
       if ((this.pl.km.temKit(player))
           && (this.pl.km.getPlayerKit(player, this.pl.km.getKitByName("Fisherman")))
           && (damager.getItemInHand() != null)
           && (damager.getItemInHand().getType() != null)) {
         if (damager.hasPermission("planeta.vip") && (damager.hasPermission("hg.youtuber"))) {
           BossBar.setMessage(
               damager,
               p.getName()
                   + " - Fisherman (§bSopas "
                   + AmountAPI.getAmount(p, Material.MUSHROOM_SOUP)
                   + " §f)",
               1);
         } else {
           BossBar.setMessage(damager, p.getName() + " - Fisherman", 1);
         }
       }
     }
 }
  @EventHandler(priority = EventPriority.NORMAL)
  public void grapple(ProjectileHitEvent event) {
    Entity proj = event.getEntity();
    Location hit = proj.getLocation();

    if (contains(hit, x1, x2, y1, y2, z1, z2) == true) {

      if (proj instanceof Snowball) {
        Snowball fish = (Snowball) proj;
        Entity shooter = fish.getShooter();

        if (shooter instanceof Player) {
          Player p = (Player) shooter;
          Location loc = p.getLocation();
          ItemStack is = p.getItemInHand();
          Material mat = is.getType();

          if (mat == Material.FISHING_ROD) {

            p.setFallDistance(0);
            p.playSound(loc, Sound.ARROW_HIT, 1, 1);

            int hitx = hit.getBlockX();
            int hity = hit.getBlockY();
            int hitz = hit.getBlockZ();
            int locx = loc.getBlockX();
            int locy = loc.getBlockY();
            int locz = loc.getBlockZ();
            double co[] = new double[3];

            if (hitx > locx) {
              co[0] = 1.2;
            } else if (hitx < locx) {
              co[0] = -1.2;
            } else if (hitx == locx) {
              co[0] = 0;
            }

            if (hity > locy) {
              co[1] = 1.4;
            } else if (hity < locy) {
              co[1] = -0.8;
            } else if (hity == locy) {
              co[1] = 0;
            }

            if (hitz > locz) {
              co[2] = 1.2;
            } else if (hitz < locz) {
              co[2] = -1.2;
            } else if (hitz == locz) {
              co[2] = 0;
            }

            p.setVelocity(new Vector(co[0], co[1], co[2]));
          }
        }
      }
    }
  }
예제 #28
0
  public boolean canGreenThumbBlock(BlockState blockState) {
    Player player = getPlayer();

    return player.getItemInHand().getType() == Material.SEEDS
        && BlockUtils.canMakeMossy(blockState)
        && Permissions.greenThumbBlock(player, blockState.getType());
  }
예제 #29
0
 @EventHandler
 public void onFish(PlayerFishEvent event) {
   Player player = event.getPlayer();
   ItemStack itemStack = player.getItemInHand();
   if (itemStack == null) {
     return;
   }
   if (itemStack.getType() == Material.AIR) {
     return;
   }
   ItemMeta meta = itemStack.getItemMeta();
   if (meta == null) {
     return;
   }
   Map<Enchantment, Integer> enchants = meta.getEnchants();
   if (enchants == null) {
     return;
   }
   if (enchants.isEmpty()) {
     return;
   }
   for (Entry<Enchantment, Integer> entry : enchants.entrySet()) {
     Enchantment enchantment = entry.getKey();
     if (enchantment instanceof IEnchant) {
       IEnchant enchant = (IEnchant) enchantment;
       enchant.onFish(event, entry.getValue());
     }
   }
 }
예제 #30
0
 /**
  * Process Mining block drops.
  *
  * @param player The player mining the block
  * @param block The block being broken
  */
 protected void processDrops() {
   if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
     Mining.silkTouchDrops(block, blockLocation, blockType);
   } else {
     Mining.miningDrops(block, blockLocation, blockType);
   }
 }