Ops and mod.bypassprotect perms can bypass protection.

Moved AbstractFlagListener and clicklisteners into API package
This commit is contained in:
tastybento 2018-07-04 14:55:34 -07:00
parent aa1ef9bcbd
commit 3657dda094
34 changed files with 44 additions and 16 deletions

View File

@ -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

View File

@ -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
*/

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
/**

View File

@ -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;

View File

@ -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;
/**

View File

@ -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;
/**

View File

@ -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;
/**

View File

@ -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;

View File

@ -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;

View File

@ -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;
/**

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
/**

View File

@ -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;

View File

@ -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;

View File

@ -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;
/**

View File

@ -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;
/**

View File

@ -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;

View File

@ -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;
/**

View File

@ -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;
/**

View File

@ -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;
/**

View File

@ -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;
/**

View File

@ -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 {

View File

@ -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
*/

View File

@ -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;

View File

@ -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;

View File

@ -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;