From 91a8a54624e26a683e3c9e6a62e8065d17bb2240 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Wed, 28 Oct 2020 16:50:10 -0500 Subject: [PATCH] Add a permission to allow players to bypass the tame limit. --- pom.xml | 2 +- src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java | 5 ++--- .../versions/version_1_14_R1/EntityTamableFox.java | 2 +- .../versions/version_1_15_R1/EntityTamableFox.java | 2 +- .../versions/version_1_16_R1/EntityTamableFox.java | 2 +- .../versions/version_1_16_R2/EntityTamableFox.java | 2 +- src/main/resources/plugin.yml | 3 +++ 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index a82c362..5b4a3ed 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.seanomik tamablefoxes - 1.7.7-SNAPSHOT + 1.7.8-SNAPSHOT jar Tamablefoxes diff --git a/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java b/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java index 436604d..fedd2b7 100644 --- a/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java +++ b/src/main/java/net/seanomik/tamablefoxes/TamableFoxes.java @@ -15,9 +15,8 @@ import org.bukkit.plugin.java.JavaPlugin; // @TODO: -/* @CHANGELOG (1.7.7-SNAPSHOT): - * Make foxes sleep on the bed with players, similar to what cats do. - * Add a configurable option to set the maximum about of foxes a player can tame. +/* @CHANGELOG (1.7.8-SNAPSHOT): + * Add a permission to allow players to bypass the tame limit. */ public final class TamableFoxes extends JavaPlugin implements Listener { private static TamableFoxes plugin; diff --git a/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/EntityTamableFox.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/EntityTamableFox.java index 9c5bc5e..45411e3 100644 --- a/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/EntityTamableFox.java +++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_14_R1/EntityTamableFox.java @@ -315,7 +315,7 @@ public class EntityTamableFox extends EntityFox { SQLiteHelper sqLiteHelper = SQLiteHelper.getInstance(); int maxTameCount = Config.getMaxPlayerFoxTames(); - if (maxTameCount > 0 && sqLiteHelper.getPlayerFoxAmount(entityhuman.getUniqueID()) >= maxTameCount) { + if ( !((Player) entityhuman.getBukkitEntity()).hasPermission("tamablefoxes.tame.unlimited") && maxTameCount > 0 && sqLiteHelper.getPlayerFoxAmount(entityhuman.getUniqueID()) >= maxTameCount) { ((Player) entityhuman.getBukkitEntity()).sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFoxDoesntTrust()); return true; diff --git a/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/EntityTamableFox.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/EntityTamableFox.java index 7d14ea6..070c1cf 100644 --- a/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/EntityTamableFox.java +++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_15_R1/EntityTamableFox.java @@ -314,7 +314,7 @@ public class EntityTamableFox extends EntityFox { SQLiteHelper sqLiteHelper = SQLiteHelper.getInstance(); int maxTameCount = Config.getMaxPlayerFoxTames(); - if (maxTameCount > 0 && sqLiteHelper.getPlayerFoxAmount(entityhuman.getUniqueID()) >= maxTameCount) { + if ( !((Player) entityhuman.getBukkitEntity()).hasPermission("tamablefoxes.tame.unlimited") && maxTameCount > 0 && sqLiteHelper.getPlayerFoxAmount(entityhuman.getUniqueID()) >= maxTameCount) { ((Player) entityhuman.getBukkitEntity()).sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFoxDoesntTrust()); return true; diff --git a/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/EntityTamableFox.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/EntityTamableFox.java index 8c0b3c6..b9dd8aa 100644 --- a/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/EntityTamableFox.java +++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R1/EntityTamableFox.java @@ -317,7 +317,7 @@ public class EntityTamableFox extends EntityFox { SQLiteHelper sqLiteHelper = SQLiteHelper.getInstance(); int maxTameCount = Config.getMaxPlayerFoxTames(); - if (maxTameCount > 0 && sqLiteHelper.getPlayerFoxAmount(entityhuman.getUniqueID()) >= maxTameCount) { + if ( !((Player) entityhuman.getBukkitEntity()).hasPermission("tamablefoxes.tame.unlimited") && maxTameCount > 0 && sqLiteHelper.getPlayerFoxAmount(entityhuman.getUniqueID()) >= maxTameCount) { ((Player) entityhuman.getBukkitEntity()).sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFoxDoesntTrust()); return EnumInteractionResult.SUCCESS; diff --git a/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/EntityTamableFox.java b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/EntityTamableFox.java index f2b4980..e0305f0 100644 --- a/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/EntityTamableFox.java +++ b/src/main/java/net/seanomik/tamablefoxes/versions/version_1_16_R2/EntityTamableFox.java @@ -314,7 +314,7 @@ public class EntityTamableFox extends EntityFox { SQLiteHelper sqLiteHelper = SQLiteHelper.getInstance(); int maxTameCount = Config.getMaxPlayerFoxTames(); - if (maxTameCount > 0 && sqLiteHelper.getPlayerFoxAmount(entityhuman.getUniqueID()) >= maxTameCount) { + if ( !((Player) entityhuman.getBukkitEntity()).hasPermission("tamablefoxes.tame.unlimited") && maxTameCount > 0 && sqLiteHelper.getPlayerFoxAmount(entityhuman.getUniqueID()) >= maxTameCount) { ((Player) entityhuman.getBukkitEntity()).sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFoxDoesntTrust()); return EnumInteractionResult.SUCCESS; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 69e9d52..e17b52b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -17,3 +17,6 @@ permissions: tamablefoxes.tame: description: "Gives the player the ability to tame a fox." default: true + tamablefoxes.tame.unlimited: + description: "Lets players bypass the tame limit." + default: op