diff --git a/src/de/steamwar/misslewars/MWTeam.java b/src/de/steamwar/misslewars/MWTeam.java index 8577a7c..8ab6c96 100644 --- a/src/de/steamwar/misslewars/MWTeam.java +++ b/src/de/steamwar/misslewars/MWTeam.java @@ -97,4 +97,8 @@ public class MWTeam { public String getColoredName() { return color.toString() + teamName; } + + public static ItemStack getBow() { + return bow; + } } diff --git a/src/de/steamwar/misslewars/listener/ItemListener.java b/src/de/steamwar/misslewars/listener/ItemListener.java index e893f63..273937d 100644 --- a/src/de/steamwar/misslewars/listener/ItemListener.java +++ b/src/de/steamwar/misslewars/listener/ItemListener.java @@ -11,14 +11,17 @@ import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.World; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.FightState; +import de.steamwar.misslewars.MWTeam; import de.steamwar.misslewars.MissileWars; import de.steamwar.misslewars.items.SpecialItem; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; @@ -78,4 +81,12 @@ public class ItemListener extends BasicListener { }, Config.ShieldFlyTime); } } + + @EventHandler(ignoreCancelled = true) + public void onInventoryClose(InventoryCloseEvent event) { + if(event.getInventory().contains(MWTeam.getBow())) { + event.getInventory().setItem(event.getInventory().first(MWTeam.getBow()), new ItemStack(Material.AIR)); + event.getPlayer().getInventory().addItem(MWTeam.getBow()); + } + } }