Added Flags#POTION_THROWING

#468
This commit is contained in:
Florian CUNY 2019-01-18 11:08:53 +01:00
parent 3f9c917a2f
commit d86b605057
4 changed files with 43 additions and 3 deletions

View File

@ -24,5 +24,4 @@ public class EggListener extends FlagListener {
e.setHatching(false);
}
}
}

View File

@ -0,0 +1,28 @@
package world.bentobox.bentobox.listeners.flags;
import org.bukkit.entity.ThrownExpBottle;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import world.bentobox.bentobox.api.flags.FlagListener;
import world.bentobox.bentobox.lists.Flags;
/**
* Handles {@link world.bentobox.bentobox.lists.Flags#POTION_THROWING}.
* @author Poslovitch
* @since 1.1
*/
public class ThrowingListener extends FlagListener {
/**
* Prevents players from throwing potions / exp bottles.
* @param e ProjectileLaunchEvent
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerThrowPotion(ProjectileLaunchEvent e) {
if (e.getEntity() instanceof ThrownPotion || e.getEntity() instanceof ThrownExpBottle) {
checkIsland(e, e.getEntity().getLocation(), Flags.POTION_THROWING);
}
}
}

View File

@ -46,6 +46,7 @@ import world.bentobox.bentobox.listeners.flags.RemoveMobsListener;
import world.bentobox.bentobox.listeners.flags.ShearingListener;
import world.bentobox.bentobox.listeners.flags.TNTListener;
import world.bentobox.bentobox.listeners.flags.TeleportationListener;
import world.bentobox.bentobox.listeners.flags.ThrowingListener;
import world.bentobox.bentobox.listeners.flags.clicklisteners.CommandRankClickListener;
import world.bentobox.bentobox.listeners.flags.clicklisteners.GeoLimitClickListener;
import world.bentobox.bentobox.managers.RanksManager;
@ -111,8 +112,13 @@ public final class Flags {
public static final Flag PRESSURE_PLATE = new Flag.Builder("PRESSURE_PLATE", Material.STONE_PRESSURE_PLATE).build();
public static final Flag TURTLE_EGGS = new Flag.Builder("TURTLE_EGGS", Material.TURTLE_EGG).build();
// Egg throwing
// Throwing things
public static final Flag EGGS = new Flag.Builder("EGGS", Material.EGG).listener(new EggListener()).build();
/**
* Prevents players from throwing potions / exp bottles.
* @since 1.1
*/
public static final Flag POTION_THROWING = new Flag.Builder("POTION_THROWING", Material.SPLASH_POTION).listener(new ThrowingListener()).build();
/*
* Fire

View File

@ -682,7 +682,7 @@ protection:
&awill not operate on islands
&awhere all members are offline.
&aMay help reduce lag.
name: "Offline Redstone"
name: "Offline Redstone"
PISTON_PUSH:
description: |-
&aAllow pistons to push
@ -692,6 +692,13 @@ protection:
description: "Toggle placing"
name: "Place blocks"
hint: "Not allowed to place blocks"
POTION_THROWING:
name: "Potion throwing"
description: |-
&aToggle throwing potions.
&aThis include splash and lingering
&apotions and experience bottles.
hint: "Not allowed to throw potions"
NETHER_PORTAL:
description: "Toggle use"
name: "Nether Portal"