Added ELYTRA protection flag.
https://github.com/BentoBoxWorld/BentoBox/issues/386
This commit is contained in:
parent
cb8b3234c8
commit
5c3817d9fe
|
@ -0,0 +1,44 @@
|
|||
package world.bentobox.bentobox.listeners.flags.protection;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityToggleGlideEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import world.bentobox.bentobox.api.flags.FlagListener;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.lists.Flags;
|
||||
|
||||
public class ElytraListener extends FlagListener {
|
||||
|
||||
|
||||
/**
|
||||
* Handle visitors using elytra
|
||||
* @param e - event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onGlide(EntityToggleGlideEvent e) {
|
||||
if (e.getEntity() instanceof Player) {
|
||||
Player player = (Player) e.getEntity();
|
||||
checkIsland(e, player, player.getLocation(), Flags.ELYTRA);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void wearingElytra(PlayerTeleportEvent e) {
|
||||
if (!getIWM().inWorld(e.getTo())) {
|
||||
return;
|
||||
}
|
||||
User user = User.getInstance(e.getPlayer());
|
||||
// Check user's inventory
|
||||
if (user.getInventory().all(Material.ELYTRA).isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (getIslands().getProtectedIslandAt(e.getTo()).filter(i-> !i.isAllowed(user, Flags.ELYTRA)).isPresent()) {
|
||||
user.notify("protection.flags.ELYTRA.hint");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@ import world.bentobox.bentobox.listeners.flags.protection.BreedingListener;
|
|||
import world.bentobox.bentobox.listeners.flags.protection.BucketListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.DyeListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.EggListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.ElytraListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.EntityInteractListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.ExperiencePickupListener;
|
||||
import world.bentobox.bentobox.listeners.flags.protection.FireListener;
|
||||
|
@ -419,6 +420,13 @@ public final class Flags {
|
|||
*/
|
||||
public static final Flag DYE = new Flag.Builder("DYE", Material.LIGHT_BLUE_DYE).type(Type.PROTECTION).listener(new DyeListener()).build();
|
||||
|
||||
/**
|
||||
* Protects against visitors using elytra. By default, it is allowed.
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public static final Flag ELYTRA = new Flag.Builder("ELYTRA", Material.ELYTRA).type(Type.PROTECTION).defaultRank(RanksManager.VISITOR_RANK).listener(new ElytraListener()).build();
|
||||
|
||||
/**
|
||||
* Provides a list of all the Flag instances contained in this class using reflection.
|
||||
* @return List of all the flags in this class
|
||||
|
|
|
@ -616,6 +616,10 @@ protection:
|
|||
name: "Droppers"
|
||||
description: "Toggle dropper interaction"
|
||||
hint: "Dropper interaction disabled"
|
||||
ELYTRA:
|
||||
name: "Elytra"
|
||||
description: "Toggle elytra allowed or not"
|
||||
hint: "&cWARNING: Elytra cannot be used here!"
|
||||
HOPPER:
|
||||
name: "Hoppers"
|
||||
description: "Toggle hopper interaction"
|
||||
|
|
Loading…
Reference in New Issue