Move pickup delay check up

This commit is contained in:
Shevchik 2014-03-05 23:43:39 +04:00
parent ca3fecdef4
commit 32a52e4f3f

View File

@ -6,6 +6,7 @@ package com.cnaude.chairs.sitaddons;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
@ -89,12 +90,12 @@ public class ChairEffects {
if (plugin.getPlayerSitData().isSitting(p)) { if (plugin.getPlayerSitData().isSitting(p)) {
for (Entity entity : p.getNearbyEntities(1, 2, 1)) { for (Entity entity : p.getNearbyEntities(1, 2, 1)) {
if (entity instanceof Item) { if (entity instanceof Item) {
if (p.getInventory().firstEmpty() != -1) { Item item = (Item) entity;
Item item = (Item) entity; if (item.getPickupDelay() == 0) {
PlayerPickupItemEvent pickupevent = new PlayerPickupItemEvent(p, item, 0); if (p.getInventory().firstEmpty() != -1) {
Bukkit.getPluginManager().callEvent(pickupevent); PlayerPickupItemEvent pickupevent = new PlayerPickupItemEvent(p, item, 0);
if (!pickupevent.isCancelled()) { Bukkit.getPluginManager().callEvent(pickupevent);
if (item.getPickupDelay() == 0) { if (!pickupevent.isCancelled()) {
p.getInventory().addItem(item.getItemStack()); p.getInventory().addItem(item.getItemStack());
entity.remove(); entity.remove();
} }