This commit is contained in:
SeanOMik 2021-08-14 17:33:03 -04:00
parent 2a1e9a6211
commit ddd00cf9e8
No known key found for this signature in database
GPG Key ID: CA09E5BE1F32728A
3 changed files with 16 additions and 1 deletions

View File

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

View File

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

View File

@ -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<String> 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() {