From 808c3c06dabf2f9d78d01693a986e1f2b81143aa Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Wed, 17 Jun 2020 20:50:07 +0200 Subject: [PATCH] Added option to have same Members, operators and owner settings --- .../skyblock/permission/PermissionManager.java | 11 +++++++++++ .../permissions/listening/DamagePermission.java | 2 +- src/main/resources/config.yml | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java index 1d1b1a11..4e4bd347 100644 --- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java +++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java @@ -1,6 +1,7 @@ package com.songoda.skyblock.permission; import com.songoda.skyblock.SkyBlock; +import com.songoda.skyblock.config.FileManager; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandRole; import com.songoda.skyblock.permission.event.Stoppable; @@ -8,6 +9,7 @@ import com.songoda.skyblock.permission.permissions.basic.*; import com.songoda.skyblock.permission.permissions.listening.*; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -180,9 +182,18 @@ public class PermissionManager { if (player.hasPermission("fabledskyblock.bypass." + permission.getName().toLowerCase())) return !reversePermission; + FileManager.Config config = SkyBlock.getInstance().getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")); + FileConfiguration configLoad = config.getFileConfiguration(); + switch(island.getRole(player)){ case Owner: + if(configLoad.getBoolean("Island.Settings.OwnersAndOperatorsAsMembers", false)){ + return island.hasPermission(IslandRole.Owner, permission); + } case Operator: + if(configLoad.getBoolean("Island.Settings.OwnersAndOperatorsAsMembers", false)){ + return island.hasPermission(IslandRole.Operator, permission); + } case Member: return island.hasPermission(IslandRole.Member, permission); case Coop: diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java index baed4a95..e91520a5 100644 --- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java +++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java @@ -67,7 +67,7 @@ public class DamagePermission extends ListeningPermission { FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")); FileConfiguration configLoad = config.getFileConfiguration(); - + if (configLoad.getBoolean("Island.Settings.Damage.Enable", false) || !configLoad.getBoolean("Island.Damage.Enable", false)) { event.setCancelled(true); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ca6c6fa2..e4baadf3 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -90,7 +90,7 @@ Island: Height: 60 Member: # Max amount of players allowed to be in a team. - Capacity: 12 + Capacity: 12 # TODO Remove Chat: # If island chat should be output to console OutputToConsole: true @@ -299,6 +299,8 @@ Island: Enable: true Hunger: Enable: false + # If owners and operators should have same permission of members + OwnersAndOperatorsAsMembers: false Portal: # When disabled, when a player enters a portal, they will teleport to the nether or # end world rather than the island world.