mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-16 07:45:12 +01:00
Ops and mod.bypassprotect perms can bypass protection.
Moved AbstractFlagListener and clicklisteners into API package
This commit is contained in:
parent
aa1ef9bcbd
commit
3657dda094
@ -1,4 +1,4 @@
|
||||
package us.tastybento.bskyblock.listeners.flags;
|
||||
package us.tastybento.bskyblock.api.flags;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Optional;
|
||||
@ -10,8 +10,6 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.api.flags.Flag;
|
||||
import us.tastybento.bskyblock.api.flags.Flag.Type;
|
||||
import us.tastybento.bskyblock.api.localization.TextVariables;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
@ -131,7 +129,7 @@ public abstract class AbstractFlagListener implements Listener {
|
||||
// Get the island and if present
|
||||
Optional<Island> island = getIslands().getProtectedIslandAt(loc);
|
||||
// Handle Settings Flag
|
||||
if (flag.getType().equals(Type.SETTING)) {
|
||||
if (flag.getType().equals(Flag.Type.SETTING)) {
|
||||
// If the island exists, return the setting, otherwise return the default setting for this flag
|
||||
return island.map(x -> x.isAllowed(flag)).orElse(flag.isSetForWorld(loc.getWorld()));
|
||||
}
|
||||
@ -146,6 +144,12 @@ public abstract class AbstractFlagListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ops or bypass mods can do anything
|
||||
if (user.isOp() || user.hasPermission(getIWM().getPermissionPrefix(loc.getWorld()) + ".mod.bypassprotect")) {
|
||||
user = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the plugin is set in User (required for testing)
|
||||
User.setPlugin(plugin);
|
||||
|
||||
@ -187,7 +191,7 @@ public abstract class AbstractFlagListener implements Listener {
|
||||
protected IslandsManager getIslands() {
|
||||
return plugin.getIslands();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the island world manager
|
||||
* @return Island World Manager
|
@ -4,8 +4,8 @@ import org.bukkit.Material;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.Flag.Type;
|
||||
import us.tastybento.bskyblock.api.flags.clicklisteners.CycleClick;
|
||||
import us.tastybento.bskyblock.api.panels.PanelItem;
|
||||
import us.tastybento.bskyblock.listeners.flags.clicklisteners.CycleClick;
|
||||
import us.tastybento.bskyblock.managers.RanksManager;
|
||||
|
||||
public class FlagBuilder {
|
||||
@ -91,7 +91,7 @@ public class FlagBuilder {
|
||||
|
||||
/**
|
||||
* Adds a listener for clicks on this flag when it is a panel item. Default is
|
||||
* {@link us.tastybento.bskyblock.listeners.flags.clicklisteners.CycleClick}
|
||||
* {@link us.tastybento.bskyblock.api.flags.clicklisteners.CycleClick}
|
||||
* @param onClickListener - the listener for clicks. Must use the ClickOn interface
|
||||
* @return FlagBuilder
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
package us.tastybento.bskyblock.listeners.flags.clicklisteners;
|
||||
package us.tastybento.bskyblock.api.flags.clicklisteners;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.event.inventory.ClickType;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
*/
|
||||
package us.tastybento.bskyblock.listeners.flags.clicklisteners;
|
||||
package us.tastybento.bskyblock.api.flags.clicklisteners;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.event.inventory.ClickType;
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
|
||||
*/
|
||||
package us.tastybento.bskyblock.listeners.flags.clicklisteners;
|
||||
package us.tastybento.bskyblock.api.flags.clicklisteners;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.event.inventory.ClickType;
|
@ -5,6 +5,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.api.localization.TextVariables;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.api.flags.Flag;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
@ -27,6 +27,7 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.api.flags.Flag;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
@ -13,6 +13,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.api.panels.Panel;
|
||||
import us.tastybento.bskyblock.api.panels.PanelItem;
|
||||
import us.tastybento.bskyblock.api.panels.PanelItem.ClickHandler;
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.event.entity.PlayerLeashEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerUnleashEntityEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
/**
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
|
@ -20,6 +20,7 @@ import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.api.flags.Flag;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.event.block.EntityBlockFormEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
/**
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
|
||||
/**
|
||||
|
@ -9,6 +9,8 @@ import org.bukkit.Material;
|
||||
|
||||
import us.tastybento.bskyblock.api.flags.Flag;
|
||||
import us.tastybento.bskyblock.api.flags.Flag.Type;
|
||||
import us.tastybento.bskyblock.api.flags.clicklisteners.IslandToggleClickListener;
|
||||
import us.tastybento.bskyblock.api.flags.clicklisteners.WorldToggleClickListener;
|
||||
import us.tastybento.bskyblock.api.flags.FlagBuilder;
|
||||
import us.tastybento.bskyblock.listeners.flags.BlockInteractionListener;
|
||||
import us.tastybento.bskyblock.listeners.flags.BreakBlocksListener;
|
||||
@ -34,8 +36,6 @@ import us.tastybento.bskyblock.listeners.flags.PortalListener;
|
||||
import us.tastybento.bskyblock.listeners.flags.RemoveMobsListener;
|
||||
import us.tastybento.bskyblock.listeners.flags.ShearingListener;
|
||||
import us.tastybento.bskyblock.listeners.flags.TeleportationListener;
|
||||
import us.tastybento.bskyblock.listeners.flags.clicklisteners.IslandToggleClickListener;
|
||||
import us.tastybento.bskyblock.listeners.flags.clicklisteners.WorldToggleClickListener;
|
||||
import us.tastybento.bskyblock.managers.RanksManager;
|
||||
|
||||
public class Flags {
|
||||
|
@ -452,7 +452,7 @@ public class IslandWorldManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permission prefix for this world
|
||||
* Get the permission prefix for this world. No trailing dot included.
|
||||
* @param world - world
|
||||
* @return permission prefix for this world
|
||||
*/
|
||||
|
@ -53,11 +53,11 @@ import us.tastybento.bskyblock.Settings;
|
||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||
import us.tastybento.bskyblock.api.events.IslandBaseEvent;
|
||||
import us.tastybento.bskyblock.api.events.team.TeamEvent;
|
||||
import us.tastybento.bskyblock.api.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.api.flags.Flag;
|
||||
import us.tastybento.bskyblock.api.flags.FlagBuilder;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
import us.tastybento.bskyblock.listeners.flags.AbstractFlagListener;
|
||||
import us.tastybento.bskyblock.lists.Flags;
|
||||
import us.tastybento.bskyblock.managers.CommandsManager;
|
||||
import us.tastybento.bskyblock.managers.FlagsManager;
|
||||
|
@ -31,12 +31,12 @@ import org.powermock.reflect.Whitebox;
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.Settings;
|
||||
import us.tastybento.bskyblock.api.flags.Flag;
|
||||
import us.tastybento.bskyblock.api.flags.clicklisteners.CycleClick;
|
||||
import us.tastybento.bskyblock.api.panels.Panel;
|
||||
import us.tastybento.bskyblock.api.panels.PanelItem;
|
||||
import us.tastybento.bskyblock.api.user.Notifier;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
import us.tastybento.bskyblock.listeners.flags.clicklisteners.CycleClick;
|
||||
import us.tastybento.bskyblock.managers.FlagsManager;
|
||||
import us.tastybento.bskyblock.managers.IslandsManager;
|
||||
import us.tastybento.bskyblock.managers.LocalesManager;
|
||||
|
@ -20,10 +20,10 @@ import org.powermock.reflect.Whitebox;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.api.flags.Flag;
|
||||
import us.tastybento.bskyblock.api.flags.clicklisteners.WorldToggleClickListener;
|
||||
import us.tastybento.bskyblock.api.panels.Panel;
|
||||
import us.tastybento.bskyblock.api.panels.PanelItem;
|
||||
import us.tastybento.bskyblock.api.user.User;
|
||||
import us.tastybento.bskyblock.listeners.flags.clicklisteners.WorldToggleClickListener;
|
||||
import us.tastybento.bskyblock.managers.FlagsManager;
|
||||
import us.tastybento.bskyblock.managers.IslandWorldManager;
|
||||
import us.tastybento.bskyblock.util.Util;
|
||||
|
Loading…
Reference in New Issue
Block a user