Fix ItemFrameListener with Item in ItemFrame
Dieser Commit ist enthalten in:
Ursprung
83cb79aaee
Commit
ca13e3236c
@ -29,6 +29,9 @@ import java.util.List;
|
||||
public class SWUtils {
|
||||
|
||||
public static void giveItemToPlayer(Player player, ItemStack itemStack) {
|
||||
if (itemStack == null || itemStack.getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < player.getInventory().getSize(); i++) {
|
||||
ItemStack current = player.getInventory().getItem(i);
|
||||
if (current != null && current.isSimilar(itemStack)) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -36,7 +37,9 @@ public class ItemFrameListener implements Listener {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
event.getEntity().remove();
|
||||
ItemFrame itemFrame = (ItemFrame) event.getEntity();
|
||||
SWUtils.giveItemToPlayer((Player) event.getDamager(), itemFrame.getItem());
|
||||
itemFrame.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren