diff --git a/src/main/java/world/bentobox/bentobox/listeners/flags/protection/ThrowingListener.java b/src/main/java/world/bentobox/bentobox/listeners/flags/protection/ThrowingListener.java index b67424f98..fda9e53e5 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/flags/protection/ThrowingListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/flags/protection/ThrowingListener.java @@ -11,7 +11,7 @@ import world.bentobox.bentobox.lists.Flags; /** - * Handles {@link world.bentobox.bentobox.lists.Flags#POTION_THROWING}. + * Handles {@link Flags#POTION_THROWING} and {@link Flags#EXPERIENCE_BOTTLE_THROWING}. * @author Poslovitch * @since 1.1 */ @@ -23,9 +23,12 @@ public class ThrowingListener extends FlagListener { */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerThrowPotion(ProjectileLaunchEvent e) { - if (e.getEntity().getShooter() instanceof Player - && (e.getEntity() instanceof ThrownPotion || e.getEntity() instanceof ThrownExpBottle)) { - checkIsland(e, (Player)e.getEntity().getShooter(), e.getEntity().getLocation(), Flags.POTION_THROWING); + if (e.getEntity().getShooter() instanceof Player && (e.getEntity() instanceof ThrownPotion)) { + if (e.getEntity() instanceof ThrownPotion) { + checkIsland(e, (Player) e.getEntity().getShooter(), e.getEntity().getLocation(), Flags.POTION_THROWING); + } else if (e.getEntity() instanceof ThrownExpBottle) { + checkIsland(e, (Player) e.getEntity().getShooter(), e.getEntity().getLocation(), Flags.EXPERIENCE_BOTTLE_THROWING); + } } } } diff --git a/src/main/java/world/bentobox/bentobox/lists/Flags.java b/src/main/java/world/bentobox/bentobox/lists/Flags.java index 6ca0df300..acf6f1fd7 100644 --- a/src/main/java/world/bentobox/bentobox/lists/Flags.java +++ b/src/main/java/world/bentobox/bentobox/lists/Flags.java @@ -163,6 +163,12 @@ private Flags() {} * @see ThrowingListener */ public static final Flag POTION_THROWING = new Flag.Builder("POTION_THROWING", Material.SPLASH_POTION).listener(new ThrowingListener()).build(); + /** + * Prevents players from throwing experience bottles. + * @since 1.3.1 + * @see ThrowingListener + */ + public static final Flag EXPERIENCE_BOTTLE_THROWING = new Flag.Builder("EXPERIENCE_BOTTLE_THROWING", Material.EXPERIENCE_BOTTLE).build(); /* * Fire diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 2077f5396..427efb82f 100644 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -606,6 +606,10 @@ protection: name: "Enter/Exit messages" now-entering: "&bNow entering [name]" now-leaving: "&bNow leaving [name]" + EXPERIENCE_BOTTLE_THROWING: + name: "Experience bottle throwing" + description: "Toggle throwing experience bottles." + hint: "Not allowed to throw experience bottles" FIRE_BURNING: name: "Fire burning" description: |- @@ -781,8 +785,7 @@ protection: name: "Potion throwing" description: |- &aToggle throwing potions. - &aThis include splash and lingering - &apotions and experience bottles. + &aThis include splash and lingering potions. hint: "Not allowed to throw potions" NETHER_PORTAL: description: "Toggle use"