Added SPAWNER_SPAWN_EGGS (WORLD_SETTING) flag
https://github.com/BentoBoxWorld/BentoBox/issues/768
This commit is contained in:
parent
c01bb33ce1
commit
85a5b5b6bc
|
@ -0,0 +1,35 @@
|
|||
package world.bentobox.bentobox.listeners.flags.worldsettings;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import world.bentobox.bentobox.api.flags.FlagListener;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.lists.Flags;
|
||||
|
||||
/**
|
||||
* Prevents players from changing a spawner's entity using spawn eggs.
|
||||
* @since 1.7.0
|
||||
* @see world.bentobox.bentobox.lists.Flags#SPAWNER_SPAWN_EGGS
|
||||
*/
|
||||
public class SpawnerSpawnEggsListener extends FlagListener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onSpawnerChange(final PlayerInteractEvent e) {
|
||||
User user = User.getInstance(e.getPlayer());
|
||||
// Checking if the clicked block is a spawner and the item in hand is a mob egg
|
||||
if (e.getClickedBlock() != null && e.getClickedBlock().getType().equals(Material.SPAWNER)
|
||||
&& e.getItem() != null && e.getItem().getType().toString().endsWith("_SPAWN_EGG")
|
||||
&& getIWM().inWorld(e.getClickedBlock().getWorld())
|
||||
&& !(user.hasPermission(getIWM().getPermissionPrefix(e.getClickedBlock().getWorld()) + "mod.bypass." + Flags.SPAWNER_SPAWN_EGGS.getID() + ".everywhere")
|
||||
|| user.hasPermission(getIWM().getPermissionPrefix(e.getClickedBlock().getWorld()) + "mod.bypassprotect"))
|
||||
&& !Flags.SPAWNER_SPAWN_EGGS.isSetForWorld(e.getClickedBlock().getWorld())) {
|
||||
// Not allowed
|
||||
e.setCancelled(true);
|
||||
// Notify the user
|
||||
user.notify("protection.protected", TextVariables.DESCRIPTION, user.getTranslation(Flags.SPAWNER_SPAWN_EGGS.getHintReference()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -55,6 +55,7 @@ import world.bentobox.bentobox.listeners.flags.worldsettings.OfflineGrowthListen
|
|||
import world.bentobox.bentobox.listeners.flags.worldsettings.OfflineRedstoneListener;
|
||||
import world.bentobox.bentobox.listeners.flags.worldsettings.PistonPushListener;
|
||||
import world.bentobox.bentobox.listeners.flags.worldsettings.RemoveMobsListener;
|
||||
import world.bentobox.bentobox.listeners.flags.worldsettings.SpawnerSpawnEggsListener;
|
||||
import world.bentobox.bentobox.listeners.flags.worldsettings.TreesGrowingOutsideRangeListener;
|
||||
import world.bentobox.bentobox.listeners.flags.worldsettings.WitherListener;
|
||||
import world.bentobox.bentobox.managers.RanksManager;
|
||||
|
@ -437,9 +438,17 @@ public final class Flags {
|
|||
/**
|
||||
* Toggles wither explosion damage
|
||||
* @since 1.6.0
|
||||
* @see WitherListener
|
||||
*/
|
||||
public static final Flag WITHER_DAMAGE = new Flag.Builder("WITHER_DAMAGE", Material.WITHER_SKELETON_SKULL).listener(new WitherListener()).type(Type.WORLD_SETTING).build();
|
||||
|
||||
/**
|
||||
* Toggles whether players can change a spawner's entity using spawn eggs.
|
||||
* @since 1.7.0
|
||||
* @see SpawnerSpawnEggsListener
|
||||
*/
|
||||
public static final Flag SPAWNER_SPAWN_EGGS = new Flag.Builder("SPAWNER_SPAWN_EGGS", Material.SPAWNER).listener(new SpawnerSpawnEggsListener()).type(Type.WORLD_SETTING).defaultSetting(true).build();
|
||||
|
||||
/**
|
||||
* Provides a list of all the Flag instances contained in this class using reflection.
|
||||
* @return List of all the flags in this class
|
||||
|
|
|
@ -1005,6 +1005,12 @@ protection:
|
|||
description: "Toggle use"
|
||||
name: "Spawn eggs"
|
||||
hint: "No throwing spawn eggs"
|
||||
SPAWNER_SPAWN_EGGS:
|
||||
description: |-
|
||||
&aAllows to change a spawner's entity type
|
||||
&ausing spawn eggs.
|
||||
name: "Spawn eggs on spawners"
|
||||
hint: "changing a spawner's entity type using spawn eggs is not allowed"
|
||||
TNT_DAMAGE:
|
||||
description: |-
|
||||
&aAllow TNT and TNT minecarts
|
||||
|
|
Loading…
Reference in New Issue