Пример #1
0
 @EventHandler
 public void PlayerPickupItemEvent(PlayerPickupItemEvent event) {
   if (event.getItem().hasMetadata("ce.Volley")) {
     event.getItem().remove();
     event.setCancelled(true);
   }
 }
Пример #2
0
  /**
   * This method sets plugin.carriers, compass direction, and gives a hat. <br>
   * <br>
   *
   * <pre>
   * 1. Give the bomb carrier a hat so that other players know WHO has the bomb.
   * 2. Set the compass direction for all players to point to the objective:
   *    - This helps attackers find the opponents base.
   *    - This helps defenders find their own base.
   * </pre>
   *
   * @param e PlayerPickupItemEvent: checks to see if they picked up the bomb item, or a different
   *     item.
   */
  @ArenaEventHandler
  public void onBombPickup(PlayerPickupItemEvent e) {
    plugin.debug.log("onBombPickup() called");

    if (e.getItem().getItemStack().getType() != plugin.getBombBlock()) return;

    if (carrier == null) {
      carrier = e.getPlayer().getName();
      e.getPlayer().getInventory().setHelmet(new ItemStack(plugin.getBombBlock()));
      ArenaTeam team2 = getOtherTeam(e.getPlayer());
      int teamID = team2.getId();
      Location base_loc = teamBases.get(teamID);
      setCompass(base_loc);
      createBaseHologram(base_loc);
      msgAll(team2.getPlayers(), "Hurry back to defend your base from being destroyed!");
      msgAll(
          getMatch().getArena().getTeam(e.getPlayer()).getPlayers(),
          "Your team has the bomb! Follow your compass to find the other teams base.");
    } else {
      e.setCancelled(true);
      e.getPlayer()
          .sendMessage(
              "There can only be ONE bomb per Match. " + carrier + " currently has the bomb.");
      e.getItem().remove();
    }
  } // END OF PlayerPickupItemEvent
  @EventHandler
  public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    Player player = event.getPlayer();
    ArenaPlayer ap = ArenaPlayer.parsePlayer(player.getName());
    if (!arena.equals(ap.getArena())) {
      return;
    }
    if (usesPowerups != null) {
      debug.i("onPlayerPickupItem: fighting player", player);
      debug.i("item: " + event.getItem().getItemStack().getType(), player);
      Iterator<Powerup> pi = usesPowerups.puTotal.iterator();
      while (pi.hasNext()) {
        Powerup p = pi.next();
        debug.i("is it " + p.item + "?", player);
        if (event.getItem().getItemStack().getType().equals(p.item)) {
          debug.i("yes!", player);
          Powerup newP = new Powerup(p);
          if (usesPowerups.puActive.containsKey(player)) {
            usesPowerups.puActive.remove(player);
          }
          usesPowerups.puActive.put(player, newP);
          arena.broadcast(Language.parse(MSG.MODULE_POWERUPS_PLAYER, player.getName(), newP.name));
          event.setCancelled(true);
          event.getItem().remove();
          if (newP.canBeTriggered()) newP.activate(player); // activate for the first time

          return;
        }
      }
    }
  }
Пример #4
0
  @Override
  public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    if (event.isCancelled()
        || plugin
            .getConfigManager()
            .getProperties()
            .disabledWorlds
            .contains(event.getPlayer().getWorld().getName())) return;

    final Hero hero = plugin.getHeroManager().getHero(event.getPlayer());
    if (hero.hasEffectType(EffectType.DISARM)
        && Util.isWeapon(event.getItem().getItemStack().getType())) {
      event.setCancelled(true);
      return;
    }

    plugin
        .getServer()
        .getScheduler()
        .scheduleSyncDelayedTask(
            plugin,
            new Runnable() {
              @Override
              public void run() {
                hero.checkInventory();
              }
            });

    if (!hero.hasParty()) return;
    HeroParty party = hero.getParty();
    if (!party.updateMapDisplay()
        && event.getItem().getItemStack().getType().toString().equalsIgnoreCase("MAP")) {
      party.setUpdateMapDisplay(true);
    }
  }
Пример #5
0
 @EventHandler
 public void onPlayerPickup(PlayerPickupItemEvent e) {
   ItemStack item = e.getItem().getItemStack();
   String locale = Locale.getPlayerLocale(e.getPlayer());
   if (ItemManager.toRPGItem(item) != null) {
     RPGItem.updateItem(item, locale);
     e.getItem().setItemStack(item);
   }
 }
 @EventHandler
 public void onTakeUpMelon(PlayerPickupItemEvent event) {
   if (melons.contains(event.getItem()) && event.getItem().getTicksLived() > 5) {
     event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 5 * 20, 2));
     event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.BURP, 1, 1f);
     event.setCancelled(true);
     melons.remove(event.getItem());
     event.getItem().remove();
   }
   if (melonBlocks.contains(event.getItem())) event.setCancelled(true);
 }
Пример #7
0
  @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
  public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    Player p = event.getPlayer();
    ItemStack i = event.getItem().getItemStack();
    if (p == null) return;
    if (i == null) return;
    if (!p.hasPermission("orbia.keepitems") && !p.getGameMode().equals(GameMode.CREATIVE)) return;

    if (!itemHandler.isCustomItem(i) && remove.contains(i.getType())) {
      event.getItem().remove();
      event.setCancelled(true);
    }
  }
  /** Pickup * */
  @EventHandler
  public void onPickup(PlayerPickupItemEvent e) {
    /** Lobby * */
    if (Main.getState() == GameState.LOBBY) e.setCancelled(true);

    /** Spectator * */
    if (Game.spectators.contains(e.getPlayer().getName())) e.setCancelled(true);

    /** Remove dropped item in arrayList * */
    if (IngameState.dropped_items.containsValue(e.getItem())) {
      IngameState.dropped_items.remove(e.getItem());
    }
  }
  /**
   * Called when a player attempts to pickup an item
   *
   * @param event Relevant event details
   */
  @Override
  public void onPlayerPickupItem(PlayerPickupItemEvent event) {

    if (event.isCancelled()) {
      return;
    }

    GlobalConfiguration cfg = plugin.getGlobalConfiguration();
    WorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());

    if (wcfg.getBlacklist() != null) {
      Item ci = event.getItem();

      if (!wcfg.getBlacklist()
          .check(
              new ItemAcquireBlacklistEvent(
                  BukkitPlayer.wrapPlayer(plugin, event.getPlayer()),
                  toVector(ci.getLocation()),
                  ci.getItemStack().getTypeId()),
              false,
              false)) {
        event.setCancelled(true);
        return;
      }
    }
  }
Пример #10
0
 private boolean wasDroppedBy(Player player, PlayerPickupItemEvent event) {
   ItemStack itemStack = event.getItem().getItemStack();
   ItemMeta meta = itemStack.getItemMeta();
   List<String> lore = meta.getLore();
   if (lore != null && !lore.isEmpty()) {
     String lastLine = lore.get(lore.size() - 1);
     return lastLine.equalsIgnoreCase("Dropped by: " + player.getName());
   }
   return false;
 }
 public void onPlayerPickupItem(PlayerPickupItemEvent event) {
   SpoutPlayer sPlayer = SpoutManager.getPlayer(event.getPlayer());
   Item item = event.getItem();
   String music = plugin.config.getString("effect." + item.getItemStack().getType().name(), "");
   if (music == "") {
     music = plugin.config.getString("effect.DEFAULT", "");
   }
   if (music != "") {
     SpoutManager.getSoundManager().playCustomSoundEffect(plugin, sPlayer, music, true);
   }
 }
 @EventHandler(ignoreCancelled = true)
 public void onPickupItem(PlayerPickupItemEvent event) {
   Item item = event.getItem();
   ProjectileInfo info = itemProjectiles.get(item);
   if (info != null) {
     event.setCancelled(true);
     projectileHitEntity(item, event.getPlayer(), info);
     item.remove();
     itemProjectiles.remove(item);
     info.monitor.stop();
   }
 }
Пример #13
0
 @EventHandler(priority = EventPriority.MONITOR)
 public void onPickupEvent(PlayerPickupItemEvent event) {
   Player player = event.getPlayer();
   if (!plugin.isSkyWorld(player.getWorld())) {
     return;
   }
   if (wasDroppedBy(player, event)) {
     clearDropInfo(event.getItem().getItemStack());
     return; // Allowed
   }
   if (player.hasPermission("usb.mod.bypassprotection")) {
     clearDropInfo(event.getItem().getItemStack());
     return;
   }
   if (plugin.playerIsOnIsland(player) || plugin.playerIsInSpawn(player)) {
     clearDropInfo(event.getItem().getItemStack());
     return;
   }
   // You are on another's island, and the stuff dropped weren't yours.
   event.setCancelled(true);
   plugin.notifyPlayer(player, "You cannot pick up other players' loot when you are a visitor!");
 }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerPickupItemEvent(PlayerPickupItemEvent event) {
    if (event.isCancelled()) return;

    final Player player = event.getPlayer();
    final Item item = event.getItem();

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

    if (item != null
        && !(plugin.getConfig().getBoolean("flags.item-pickup", false)
            || plugin.canBuildOnLocation(player, item.getLocation()))) event.setCancelled(true);

    plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }
Пример #15
0
 /**
  * Handles all item pickup events by players. If the item that was picked up is the gem used for
  * money, credit the player $1 and remove the gem.
  *
  * @param event The item pickup event
  */
 @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
 public void onItemPickup(PlayerPickupItemEvent event) {
   Player player = event.getPlayer();
   String giveMoneyCommand = "money give " + player.getName() + " 1";
   if (event.getItem().getItemStack().getItemMeta().equals(moneyGem.getItemMeta())) {
     for (int i = 0; i < event.getItem().getItemStack().getAmount(); i++) {
       plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), giveMoneyCommand);
     }
     if (event.getItem().getItemStack().getAmount() == 1) {
       player.sendMessage(ChatColor.DARK_GREEN + "You have found a rare gem!");
     } else if (event.getItem().getItemStack().getAmount() > 1) {
       player.sendMessage(
           ChatColor.DARK_GREEN
               + "You have found "
               + event.getItem().getItemStack().getAmount()
               + " rare gems!");
     }
     event.getItem().remove();
     event.setCancelled(true);
   }
 }
Пример #16
0
 @EventHandler
 public void onItemPickup(PlayerPickupItemEvent event) {
   plugin.items.remove(event.getItem().getItemStack());
 }
Пример #17
0
 /** Prevent the hovering item from being picked up */
 @EventHandler(priority = EventPriority.HIGHEST)
 private void onItemPickup(PlayerPickupItemEvent event) {
   if (!mIsLoaded) return;
   if (mHoveringItem != null && event.getItem().getEntityId() == mHoveringItem.getEntityId())
     event.setCancelled(true);
 }
Пример #18
0
 @EventHandler
 public void onWoolPickup(PlayerPickupItemEvent event) {
   Player player = event.getPlayer();
   if (!this.complete && GameHandler.getGameHandler().getMatch().isRunning()) {
     try {
       if (event.getItem().getItemStack().getType() == Material.WOOL
           && event.getItem().getItemStack().getData().getData() == color.getData()) {
         if (Teams.getTeamByPlayer(player).orNull() == team) {
           boolean touchMessage = false;
           if (!this.playersTouched.contains(player.getUniqueId())) {
             this.playersTouched.add(player.getUniqueId());
             if (this.show && !this.complete) {
               Teams.getTeamChannel(Optional.of(team))
                   .sendLocalizedMessage(
                       new UnlocalizedChatMessage(
                           ChatColor.WHITE + "{0}",
                           new LocalizedChatMessage(
                               ChatConstant.UI_OBJECTIVE_PICKED,
                               team.getColor() + player.getName() + ChatColor.WHITE,
                               MiscUtil.convertDyeColorToChatColor(color)
                                   + name.toUpperCase().replaceAll("_", " ")
                                   + ChatColor.WHITE,
                               team.getCompleteName() + ChatColor.WHITE)));
               for (Player player1 : Bukkit.getOnlinePlayers()) {
                 if (Teams.getTeamByPlayer(player1).isPresent()
                     && Teams.getTeamByPlayer(player1).get().isObserver()) {
                   player1.sendMessage(
                       new UnlocalizedChatMessage(
                               ChatColor.GRAY + "{0}",
                               new LocalizedChatMessage(
                                   ChatConstant.UI_OBJECTIVE_PICKED_FOR,
                                   team.getColor() + player.getName() + ChatColor.GRAY,
                                   MiscUtil.convertDyeColorToChatColor(color)
                                       + name.toUpperCase().replaceAll("_", " ")
                                       + ChatColor.GRAY,
                                   team.getCompleteName() + ChatColor.GRAY))
                           .getMessage(player1.getLocale()));
                 }
               }
               touchMessage = true;
             }
           }
           boolean oldState = this.touched;
           this.touched = true;
           if (touchMessage) {
             double newProx;
             if (location != null) {
               newProx = location.distance(place.getVector());
             } else {
               newProx = player.getLocation().toVector().distance(place.getVector());
             }
             if (!oldState || newProx < proximity) {
               proximity = newProx;
             }
           }
           ObjectiveTouchEvent touchEvent =
               new ObjectiveTouchEvent(this, player, !oldState, touchMessage);
           Bukkit.getServer().getPluginManager().callEvent(touchEvent);
         }
       }
     } catch (NullPointerException e) {
     }
   }
 }
Пример #19
0
 @EventHandler
 public final void PPIE(final PlayerPickupItemEvent event) {
   if (event.getItem().hasMetadata("isminebomb")) event.setCancelled(true);
 }