diff --git a/Plugin/src/main/resources/config.yml b/Plugin/src/main/resources/config.yml index ed7b948..b73e23a 100644 --- a/Plugin/src/main/resources/config.yml +++ b/Plugin/src/main/resources/config.yml @@ -4,5 +4,8 @@ ask-for-name-after-taming: true max-fox-tames: 0 prefix: "&c[Tamable Foxes] " +no-tame-worlds: + - world_nether + tamed-behavior: attack-wild-animals: true \ No newline at end of file diff --git a/Plugin/src/main/resources/plugin.yml b/Plugin/src/main/resources/plugin.yml index 29526f6..b53c0f5 100644 --- a/Plugin/src/main/resources/plugin.yml +++ b/Plugin/src/main/resources/plugin.yml @@ -20,3 +20,6 @@ permissions: tamablefoxes.tame.unlimited: description: "Lets players bypass the tame limit." default: op + tamablefoxes.tame.anywhere: + description: "Lets players bypass the banned worlds in config.yml (so they can tame in any world)." + default: op diff --git a/Utility/src/main/java/net/seanomik/tamablefoxes/util/io/Config.java b/Utility/src/main/java/net/seanomik/tamablefoxes/util/io/Config.java index f48b861..5745d28 100644 --- a/Utility/src/main/java/net/seanomik/tamablefoxes/util/io/Config.java +++ b/Utility/src/main/java/net/seanomik/tamablefoxes/util/io/Config.java @@ -5,6 +5,9 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import java.util.ArrayList; +import java.util.List; + public class Config { private static FileConfiguration config = null; @@ -23,9 +26,15 @@ public class Config { // Check if a tamed fox attacks wild animals. public static boolean doesTamedAttackWildAnimals() { return config.getBoolean("tamed-behavior.attack-wild-animals"); } + // Get worlds that taming is not allowed in. + public static List BannedWorlds() { + return config.contains("no-tame-worlds") ? config.getStringList("no-tame-worlds") : new ArrayList<>(); + } + // Check if the player can tame the fox. public static boolean canPlayerTameFox(Player player) { - return player.hasPermission("tamablefoxes.tame") || player.isOp(); + return ( player.hasPermission("tamablefoxes.tame") || player.isOp() ) && + ( !BannedWorlds().contains(player.getWorld().getName()) || player.hasPermission("tamablefoxes.tame.anywhere") ); } public static int getMaxPlayerFoxTames() {