No longer using Vault for perms, only economy

This commit is contained in:
Florian CUNY 2017-12-16 16:07:00 +01:00
parent 83e35523b7
commit fe07c8ef45
18 changed files with 45 additions and 157 deletions

View File

@ -71,8 +71,6 @@ public class BSkyBlock extends JavaPlugin implements BSModule {
Settings.useEconomy = false; Settings.useEconomy = false;
} }
VaultHelper.setupPermissions();
// Set up commands // Set up commands
commandsManager = new CommandsManager(); commandsManager = new CommandsManager();
commandsManager.registerCommand(this, new IslandCommand()); commandsManager.registerCommand(this, new IslandCommand());

View File

@ -22,10 +22,6 @@ import us.tastybento.bskyblock.util.VaultHelper;
*/ */
public class IslandCreateCommand extends CommandArgument { public class IslandCreateCommand extends CommandArgument {
/**
* @param label
* @param aliases
*/
public IslandCreateCommand() { public IslandCreateCommand() {
super("create", "auto"); super("create", "auto");
} }
@ -41,7 +37,7 @@ public class IslandCreateCommand extends CommandArgument {
} }
Player player = (Player)sender; Player player = (Player)sender;
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.create")) { if (!player.hasPermission(Settings.PERMPREFIX + "island.create")) {
sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission")); sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission"));
} }
if (getIslands().hasIsland(player.getUniqueId())) { if (getIslands().hasIsland(player.getUniqueId())) {

View File

@ -21,10 +21,6 @@ import us.tastybento.bskyblock.util.VaultHelper;
*/ */
public class IslandGoCommand extends CommandArgument { public class IslandGoCommand extends CommandArgument {
/**
* @param label
* @param aliases
*/
public IslandGoCommand() { public IslandGoCommand() {
super("go", "home", "h"); super("go", "home", "h");
} }
@ -39,7 +35,7 @@ public class IslandGoCommand extends CommandArgument {
return true; return true;
} }
Player player = (Player)sender; Player player = (Player)sender;
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.home")) { if (!player.hasPermission(Settings.PERMPREFIX + "island.home")) {
sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission")); sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission"));
return true; return true;
} }

View File

@ -30,7 +30,7 @@ public class IslandResetCommand extends CommandArgument {
return true; return true;
} }
Player player = (Player)sender; Player player = (Player)sender;
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.reset")) { if (!player.hasPermission(Settings.PERMPREFIX + "island.reset")) {
sender.sendMessage(getLocale(sender).get("general.errors.no-permission")); sender.sendMessage(getLocale(sender).get("general.errors.no-permission"));
return true; return true;
} }

View File

@ -20,10 +20,6 @@ import us.tastybento.bskyblock.util.VaultHelper;
*/ */
public class IslandResetnameCommand extends CommandArgument { public class IslandResetnameCommand extends CommandArgument {
/**
* @param label
* @param aliases
*/
public IslandResetnameCommand() { public IslandResetnameCommand() {
super("setname"); super("setname");
} }
@ -40,7 +36,7 @@ public class IslandResetnameCommand extends CommandArgument {
Player player = (Player)sender; Player player = (Player)sender;
UUID playerUUID = player.getUniqueId(); UUID playerUUID = player.getUniqueId();
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.name")) { if (!player.hasPermission(Settings.PERMPREFIX + "island.name")) {
sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission")); sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission"));
return true; return true;
} }
@ -75,7 +71,7 @@ public class IslandResetnameCommand extends CommandArgument {
} }
// Set the name // Set the name
if (VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.name.format")) if (!player.hasPermission(Settings.PERMPREFIX + "island.name.format"))
getIslands().getIsland(player.getUniqueId()).setName(ChatColor.translateAlternateColorCodes('&', name)); getIslands().getIsland(player.getUniqueId()).setName(ChatColor.translateAlternateColorCodes('&', name));
else getIslands().getIsland(playerUUID).setName(name); else getIslands().getIsland(playerUUID).setName(name);

View File

@ -26,7 +26,7 @@ public class IslandSethomeCommand extends CommandArgument {
} }
Player player = (Player)sender; Player player = (Player)sender;
UUID playerUUID = player.getUniqueId(); UUID playerUUID = player.getUniqueId();
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.sethome")) { if (!player.hasPermission(Settings.PERMPREFIX + "island.sethome")) {
sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission")); sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission"));
return true; return true;
} }

View File

@ -20,10 +20,6 @@ import us.tastybento.bskyblock.util.VaultHelper;
*/ */
public class IslandSetnameCommand extends CommandArgument { public class IslandSetnameCommand extends CommandArgument {
/**
* @param label
* @param aliases
*/
public IslandSetnameCommand() { public IslandSetnameCommand() {
super("resetname"); super("resetname");
} }
@ -40,7 +36,7 @@ public class IslandSetnameCommand extends CommandArgument {
Player player = (Player)sender; Player player = (Player)sender;
UUID playerUUID = player.getUniqueId(); UUID playerUUID = player.getUniqueId();
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.name")) { if (!player.hasPermission(Settings.PERMPREFIX + "island.name")) {
sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission")); sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission"));
return true; return true;
} }

View File

@ -42,7 +42,7 @@ public abstract class AbstractIslandTeamCommandArgument extends CommandArgument
} }
player = (Player)sender; player = (Player)sender;
playerUUID = player.getUniqueId(); playerUUID = player.getUniqueId();
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team")) { if (!player.hasPermission(Settings.PERMPREFIX + "team")) {
sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission")); sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission"));
return false; return false;
} }

View File

@ -26,7 +26,7 @@ public class IslandTeamUninviteCommand extends AbstractIslandTeamCommandArgument
} }
Player player = (Player)sender; Player player = (Player)sender;
UUID playerUUID = player.getUniqueId(); UUID playerUUID = player.getUniqueId();
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team")) { if (!player.hasPermission(Settings.PERMPREFIX + "team")) {
sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission")); sender.sendMessage(ChatColor.RED + getLocale(sender).get("general.errors.no-permission"));
return true; return true;
} }

View File

@ -507,7 +507,7 @@ public class PlayersManager{
addPlayer(targetUUID); addPlayer(targetUUID);
// Check if the target player has a permission bypass (admin.noban) // Check if the target player has a permission bypass (admin.noban)
Player target = plugin.getServer().getPlayer(targetUUID); Player target = plugin.getServer().getPlayer(targetUUID);
if (target != null && VaultHelper.hasPerm(target, Settings.PERMPREFIX + "admin.noban")) { if (target != null && target.hasPermission(Settings.PERMPREFIX + "admin.noban")) {
return false; return false;
} }
Island island = plugin.getIslands().getIsland(playerUUID); Island island = plugin.getIslands().getIsland(playerUUID);

View File

@ -73,8 +73,7 @@ public class JoinLeaveListener implements Listener {
if (currentIsland != null && (currentIsland.isLocked() || plugin.getPlayers().isBanned(currentIsland.getOwner(),player.getUniqueId()))) { if (currentIsland != null && (currentIsland.isLocked() || plugin.getPlayers().isBanned(currentIsland.getOwner(),player.getUniqueId()))) {
if (DEBUG) if (DEBUG)
plugin.getLogger().info("DEBUG: Current island is locked, or player is banned"); plugin.getLogger().info("DEBUG: Current island is locked, or player is banned");
if (!currentIsland.getMembers().contains(playerUUID) && !player.isOp() if (!currentIsland.getMembers().contains(playerUUID) && !player.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
&& !VaultHelper.hasPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) {
if (DEBUG) if (DEBUG)
plugin.getLogger().info("DEBUG: No bypass - teleporting"); plugin.getLogger().info("DEBUG: No bypass - teleporting");
player.sendMessage(plugin.getLocale(player).get("locked.islandlocked")); player.sendMessage(plugin.getLocale(player).get("locked.islandlocked"));

View File

@ -118,7 +118,7 @@ public class NetherPortals implements Listener {
// Portals use is not allowed // Portals use is not allowed
if (DEBUG) if (DEBUG)
plugin.getLogger().info("DEBUG: Portal use not allowed"); plugin.getLogger().info("DEBUG: Portal use not allowed");
if (!event.getPlayer().isOp() && !VaultHelper.hasPerm(event.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { if (!event.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
event.getPlayer().sendMessage(plugin.getLocale(event.getPlayer()).get("island.protected")); event.getPlayer().sendMessage(plugin.getLocale(event.getPlayer()).get("island.protected"));
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -138,7 +138,7 @@ public class IslandGuard implements Listener {
return actionAllowed(location, flag); return actionAllowed(location, flag);
} }
// This permission bypasses protection // This permission bypasses protection
if (player.isOp() || VaultHelper.hasPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) { if (player.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return true; return true;
} }
Island island = plugin.getIslands().getProtectedIslandAt(location); Island island = plugin.getIslands().getProtectedIslandAt(location);
@ -226,9 +226,9 @@ public class IslandGuard implements Listener {
if (islandTo != null && (islandTo.getOwner() != null || islandTo.isSpawn())) { if (islandTo != null && (islandTo.getOwner() != null || islandTo.isSpawn())) {
// Lock check // Lock check
if (islandTo.isLocked() || plugin.getPlayers().isBanned(islandTo.getOwner(),player.getUniqueId())) { if (islandTo.isLocked() || plugin.getPlayers().isBanned(islandTo.getOwner(),player.getUniqueId())) {
if (!islandTo.getMembers().contains(player.getUniqueId()) && !player.isOp() if (!islandTo.getMembers().contains(player.getUniqueId())
&& !VaultHelper.hasPerm(player, Settings.PERMPREFIX + "mod.bypassprotect") && !player.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")
&& !VaultHelper.hasPerm(player, Settings.PERMPREFIX + "mod.bypasslock")) { && !player.hasPermission(Settings.PERMPREFIX + "mod.bypasslock")) {
player.sendMessage(plugin.getLocale(player.getUniqueId()).get("lock.islandlocked")); player.sendMessage(plugin.getLocale(player.getUniqueId()).get("lock.islandlocked"));
// Get the vector away from this island // Get the vector away from this island
Vector v = e.getVehicle().getLocation().toVector().subtract(islandTo.getCenter().toVector()).normalize().multiply(new Vector(1.2,0,1.2)); Vector v = e.getVehicle().getLocation().toVector().subtract(islandTo.getCenter().toVector()).normalize().multiply(new Vector(1.2,0,1.2));
@ -340,9 +340,9 @@ public class IslandGuard implements Listener {
if (islandTo != null && (islandTo.getOwner() != null || islandTo.isSpawn())) { if (islandTo != null && (islandTo.getOwner() != null || islandTo.isSpawn())) {
// Lock check // Lock check
if (islandTo.isLocked() || plugin.getPlayers().isBanned(islandTo.getOwner(),e.getPlayer().getUniqueId())) { if (islandTo.isLocked() || plugin.getPlayers().isBanned(islandTo.getOwner(),e.getPlayer().getUniqueId())) {
if (!islandTo.getMembers().contains(e.getPlayer().getUniqueId()) && !e.getPlayer().isOp() if (!islandTo.getMembers().contains(e.getPlayer().getUniqueId())
&& !VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect") && !e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")
&& !VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypasslock")) { && !e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypasslock")) {
e.getPlayer().sendMessage(plugin.getLocale(e.getPlayer().getUniqueId()).get("lock.islandlocked")); e.getPlayer().sendMessage(plugin.getLocale(e.getPlayer().getUniqueId()).get("lock.islandlocked"));
// Get the vector away from this island // Get the vector away from this island
@ -830,7 +830,7 @@ public class IslandGuard implements Listener {
// Ops can do anything // Ops can do anything
if (e.getDamager() instanceof Player) { if (e.getDamager() instanceof Player) {
Player p = (Player) e.getDamager(); Player p = (Player) e.getDamager();
if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { if (p.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
} }
@ -977,7 +977,7 @@ public class IslandGuard implements Listener {
// plugin.getLogger().info(e.getEventName()); // plugin.getLogger().info(e.getEventName());
if (Util.inWorld(e.getPlayer())) { if (Util.inWorld(e.getPlayer())) {
// This permission bypasses protection // This permission bypasses protection
if (e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { if (e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
//plugin.getLogger().info("DEBUG: checking is inside protection area"); //plugin.getLogger().info("DEBUG: checking is inside protection area");
@ -1038,7 +1038,7 @@ public class IslandGuard implements Listener {
// plugin.getLogger().info(e.getEventName()); // plugin.getLogger().info(e.getEventName());
if (Util.inWorld(e.getPlayer())) { if (Util.inWorld(e.getPlayer())) {
// This permission bypasses protection // This permission bypasses protection
if (e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { if (e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
Island island = plugin.getIslands().getProtectedIslandAt(e.getBlock().getLocation()); Island island = plugin.getIslands().getProtectedIslandAt(e.getBlock().getLocation());
@ -1116,7 +1116,7 @@ public class IslandGuard implements Listener {
// plugin.getLogger().info(e.getEventName()); // plugin.getLogger().info(e.getEventName());
if (Util.inWorld(e.getPlayer())) { if (Util.inWorld(e.getPlayer())) {
// This permission bypasses protection // This permission bypasses protection
if (e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { if (e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
Island island = plugin.getIslands().getProtectedIslandAt(e.getBlock().getLocation()); Island island = plugin.getIslands().getProtectedIslandAt(e.getBlock().getLocation());
@ -1209,7 +1209,7 @@ public class IslandGuard implements Listener {
if (e.getRemover() instanceof Player) { if (e.getRemover() instanceof Player) {
Player p = (Player) e.getRemover(); Player p = (Player) e.getRemover();
// This permission bypasses protection // This permission bypasses protection
if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { if (p.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
if (actionAllowed(p,e.getEntity().getLocation(),SettingsFlag.BREAK_BLOCKS)) { if (actionAllowed(p,e.getEntity().getLocation(),SettingsFlag.BREAK_BLOCKS)) {
@ -1391,7 +1391,7 @@ public class IslandGuard implements Listener {
} }
if (Util.inWorld(e.getPlayer())) { if (Util.inWorld(e.getPlayer())) {
// This permission bypasses protection // This permission bypasses protection
if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { if (e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
Island island = plugin.getIslands().getProtectedIslandAt(e.getBlockClicked().getLocation()); Island island = plugin.getIslands().getProtectedIslandAt(e.getBlockClicked().getLocation());
@ -1452,7 +1452,7 @@ public class IslandGuard implements Listener {
if (!Util.inWorld(e.getPlayer())) { if (!Util.inWorld(e.getPlayer())) {
return; return;
} }
if (e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { if (e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
if ((e.getClickedBlock() != null && plugin.getIslands().locationIsOnIsland(e.getPlayer(), e.getClickedBlock().getLocation()))) { if ((e.getClickedBlock() != null && plugin.getIslands().locationIsOnIsland(e.getPlayer(), e.getClickedBlock().getLocation()))) {
@ -1995,7 +1995,7 @@ public class IslandGuard implements Listener {
if (!Util.inWorld(p)) { if (!Util.inWorld(p)) {
return; return;
} }
if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { if (p.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
// You can do anything if you are Op of have the bypass // You can do anything if you are Op of have the bypass
return; return;
} }
@ -2210,7 +2210,7 @@ public class IslandGuard implements Listener {
//plugin.getLogger().info("DEBUG: target block = " + e.getPlayer().getTargetBlock(transparent, 10)); //plugin.getLogger().info("DEBUG: target block = " + e.getPlayer().getTargetBlock(transparent, 10));
} }
// Check if this is allowed // Check if this is allowed
if (e.getPlayer() != null && (e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypass"))) { if (e.getPlayer() != null && (e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypass"))) {
return; return;
} }
if (!actionAllowed(e.getBlock().getLocation(), SettingsFlag.FIRE)) { if (!actionAllowed(e.getBlock().getLocation(), SettingsFlag.FIRE)) {
@ -2269,7 +2269,7 @@ public class IslandGuard implements Listener {
plugin.getLogger().info("action = " + e.getAction()); plugin.getLogger().info("action = " + e.getAction());
} }
if (!Util.inWorld(e.getPlayer()) || !e.getAction().equals(Action.PHYSICAL) if (!Util.inWorld(e.getPlayer()) || !e.getAction().equals(Action.PHYSICAL)
|| e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect") || e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")
|| plugin.getIslands().playerIsOnIsland(e.getPlayer())) { || plugin.getIslands().playerIsOnIsland(e.getPlayer())) {
//plugin.getLogger().info("DEBUG: Not in world"); //plugin.getLogger().info("DEBUG: Not in world");
return; return;
@ -2341,7 +2341,7 @@ public class IslandGuard implements Listener {
if (DEBUG) { if (DEBUG) {
plugin.getLogger().info("egg throwing = " + e.getEventName()); plugin.getLogger().info("egg throwing = " + e.getEventName());
} }
if (!Util.inWorld(e.getPlayer()) || e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect") if (!Util.inWorld(e.getPlayer()) || e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")
|| plugin.getIslands().playerIsOnIsland(e.getPlayer()) || plugin.getIslands().isAtSpawn(e.getPlayer().getLocation())) { || plugin.getIslands().playerIsOnIsland(e.getPlayer()) || plugin.getIslands().isAtSpawn(e.getPlayer().getLocation())) {
return; return;
} }

View File

@ -45,7 +45,7 @@ public class IslandGuard1_8 implements Listener {
*/ */
private boolean actionAllowed(Player player, Location location, SettingsFlag flag) { private boolean actionAllowed(Player player, Location location, SettingsFlag flag) {
// This permission bypasses protection // This permission bypasses protection
if (player.isOp() || VaultHelper.hasPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) { if (player.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return true; return true;
} }
Island island = plugin.getIslands().getProtectedIslandAt(location); Island island = plugin.getIslands().getProtectedIslandAt(location);
@ -101,12 +101,8 @@ public class IslandGuard1_8 implements Listener {
if (!Util.inWorld(e.getPlayer())) { if (!Util.inWorld(e.getPlayer())) {
return; return;
} }
if (e.getPlayer().isOp()) {
return;
}
// This permission bypasses protection // This permission bypasses protection
if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect") if (e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
|| VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "craft.dirt")) {
return; return;
} }
// Prevents tilling of coarse dirt into dirt // Prevents tilling of coarse dirt into dirt
@ -135,7 +131,7 @@ public class IslandGuard1_8 implements Listener {
if (!Util.inWorld(p)) { if (!Util.inWorld(p)) {
return; return;
} }
if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { if (p.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
// You can do anything if you are Op // You can do anything if you are Op
return; return;
} }
@ -188,7 +184,7 @@ public class IslandGuard1_8 implements Listener {
} }
if (e.getDamager() instanceof Player) { if (e.getDamager() instanceof Player) {
Player p = (Player) e.getDamager(); Player p = (Player) e.getDamager();
if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { if (p.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
// Check if on island // Check if on island

View File

@ -70,11 +70,8 @@ public class IslandGuard1_9 implements Listener {
if (!Util.inWorld(player)) { if (!Util.inWorld(player)) {
return; return;
} }
if (player.isOp()) {
return;
}
// This permission bypasses protection // This permission bypasses protection
if (VaultHelper.hasPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) { if (player.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
// Check island // Check island
@ -106,11 +103,8 @@ public class IslandGuard1_9 implements Listener {
if (!Util.inWorld(e.getPlayer())) { if (!Util.inWorld(e.getPlayer())) {
return; return;
} }
if (e.getPlayer().isOp()) {
return;
}
// This permission bypasses protection // This permission bypasses protection
if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { if (e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
if (e.getRightClicked() != null && e.getRightClicked().getType().equals(EntityType.ENDER_CRYSTAL)) { if (e.getRightClicked() != null && e.getRightClicked().getType().equals(EntityType.ENDER_CRYSTAL)) {
@ -140,7 +134,7 @@ public class IslandGuard1_9 implements Listener {
if (!Util.inWorld(p)) { if (!Util.inWorld(p)) {
return; return;
} }
if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { if (p.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
// You can do anything if you are Op // You can do anything if you are Op
return; return;
} }
@ -217,7 +211,7 @@ public class IslandGuard1_9 implements Listener {
} }
} }
if (p != null) { if (p != null) {
if (p.isOp() || VaultHelper.hasPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) { if (p.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
if (DEBUG) { if (DEBUG) {
plugin.getLogger().info("1.9 " +"Bypassing protection"); plugin.getLogger().info("1.9 " +"Bypassing protection");
} }
@ -320,12 +314,8 @@ public class IslandGuard1_9 implements Listener {
if (!Util.inWorld(e.getPlayer())) { if (!Util.inWorld(e.getPlayer())) {
return; return;
} }
if (e.getPlayer().isOp()) {
return;
}
// This permission bypasses protection // This permission bypasses protection
if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect") if (e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
|| VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "craft.dirt")) {
return; return;
} }
// Prevents tilling of coarse dirt into dirt // Prevents tilling of coarse dirt into dirt
@ -453,7 +443,7 @@ public class IslandGuard1_9 implements Listener {
return actionAllowed(location, flag); return actionAllowed(location, flag);
} }
// This permission bypasses protection // This permission bypasses protection
if (player.isOp() || VaultHelper.hasPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) { if (player.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return true; return true;
} }
Island island = plugin.getIslands().getProtectedIslandAt(location); Island island = plugin.getIslands().getProtectedIslandAt(location);

View File

@ -117,7 +117,7 @@ public class NetherEvents implements Listener {
// plugin.getLogger().info("Block break"); // plugin.getLogger().info("Block break");
if ((e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether") && !Settings.netherIslands) if ((e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether") && !Settings.netherIslands)
|| e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) { || e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { if (e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
if (DEBUG) if (DEBUG)
@ -142,7 +142,7 @@ public class NetherEvents implements Listener {
if (!Settings.netherIslands) { if (!Settings.netherIslands) {
if (e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether") if (e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether")
|| e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) { || e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { if (e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
if (!awayFromSpawn(e.getPlayer()) && !e.getPlayer().isOp()) { if (!awayFromSpawn(e.getPlayer()) && !e.getPlayer().isOp()) {
@ -159,7 +159,7 @@ public class NetherEvents implements Listener {
if (!Settings.netherIslands) { if (!Settings.netherIslands) {
if (e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether") if (e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether")
|| e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) { || e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) { if (e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")) {
return; return;
} }
if (!awayFromSpawn(e.getPlayer()) && !e.getPlayer().isOp()) { if (!awayFromSpawn(e.getPlayer()) && !e.getPlayer().isOp()) {

View File

@ -86,7 +86,7 @@ public class VisitorGuard implements Listener {
} }
Island island = plugin.getIslands().getIslandAt(e.getItemDrop().getLocation()); Island island = plugin.getIslands().getIslandAt(e.getItemDrop().getLocation());
if ((island != null && island.getFlag(SettingsFlag.ITEM_DROP)) if ((island != null && island.getFlag(SettingsFlag.ITEM_DROP))
|| e.getPlayer().isOp() || VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect") || e.getPlayer().hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")
|| plugin.getIslands().locationIsOnIsland(e.getPlayer(), e.getItemDrop().getLocation())) { || plugin.getIslands().locationIsOnIsland(e.getPlayer(), e.getItemDrop().getLocation())) {
return; return;
} }
@ -153,7 +153,7 @@ public class VisitorGuard implements Listener {
} }
Island island = plugin.getIslands().getIslandAt(e.getItem().getLocation()); Island island = plugin.getIslands().getIslandAt(e.getItem().getLocation());
if ((island != null && island.getFlag(SettingsFlag.ITEM_PICKUP)) if ((island != null && island.getFlag(SettingsFlag.ITEM_PICKUP))
|| player.isOp() || VaultHelper.hasPerm(player, Settings.PERMPREFIX + "mod.bypassprotect") || player.hasPermission(Settings.PERMPREFIX + "mod.bypassprotect")
|| plugin.getIslands().locationIsOnIsland(player, e.getItem().getLocation())) { || plugin.getIslands().locationIsOnIsland(player, e.getItem().getLocation())) {
return; return;
} }

View File

@ -13,7 +13,6 @@ import net.milkbowl.vault.permission.Permission;
*/ */
public class VaultHelper { public class VaultHelper {
public static Economy econ = null; public static Economy econ = null;
public static Permission permission = null;
/** /**
* Sets up the economy instance * Sets up the economy instance
@ -28,82 +27,4 @@ public class VaultHelper {
} }
return econ != null; return econ != null;
} }
/**
* Sets up the permissions instance
*
* @return true if successful
*/
public static boolean setupPermissions() {
RegisteredServiceProvider<Permission> permissionProvider = Bukkit.getServer().getServicesManager()
.getRegistration(net.milkbowl.vault.permission.Permission.class);
if (permissionProvider != null) {
permission = permissionProvider.getProvider();
}
return (permission != null);
}
/**
* Checks permission of player in the world the player is in now
*
* @param player
* @param perm
* @return true if the player has the perm
*/
public static boolean hasPerm(final Player player, final String perm) {
return permission.has(player, perm);
}
/**
* Checks permission of player in world
*
* @param player
* @param perm
* @param world
* @return
*/
public static boolean hasPerm(final Player player, final String perm, final World world) {
return permission.playerHas(world.getName(), player, perm);
}
/**
* Adds permission to player
*
* @param player
* @param perm
*/
public static void addPerm(final Player player, final String perm) {
permission.playerAdd(player, perm);
}
/**
* Add permission to player in world
* @param player
* @param perm
* @param world
*/
public static void addPerm(final Player player, final String perm, final World world) {
permission.playerAdd(world.getName(), player, perm);
}
/**
* Removes a player's permission
*
* @param player
* @param perm
*/
public static void removePerm(final Player player, final String perm) {
permission.playerRemove(player, perm);
}
/**
* Removes a player's permission in world
*
* @param player
* @param perm
* @param world
*/
public static void removePerm(final Player player, final String perm, World world) {
permission.playerRemove(world.getName(), player, perm);
}
} }