Skip to content

Commit

Permalink
Added Flags#EXPERIENCE_BOTTLE_THROWING (splited from POTION_THROWING)
Browse files Browse the repository at this point in the history
  • Loading branch information
Poslovitch committed Mar 1, 2019
1 parent f422a22 commit 980cdb9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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);
}
}
}
}
6 changes: 6 additions & 0 deletions src/main/java/world/bentobox/bentobox/lists/Flags.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |-
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 980cdb9

Please sign in to comment.