diff --git a/build.gradle.kts b/build.gradle.kts index 3c873a3..eaf919a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { allprojects { - version = "2.3.3.0" + version = "2.3.3.1" apply() apply(plugin = "java") @@ -44,6 +44,7 @@ allprojects { maven("https://repo.oraxen.com/releases/") maven("https://nexus.codecrafter47.de/content/repositories/public/") maven("https://repo.opencollab.dev/main/") + maven("https://repo.md-5.net/content/groups/public/") } } diff --git a/paper/build.gradle.kts b/paper/build.gradle.kts index 01e6c6c..cf4a8bf 100644 --- a/paper/build.gradle.kts +++ b/paper/build.gradle.kts @@ -37,6 +37,7 @@ dependencies { compileOnly("com.github.FrancoBM12:API-MagicCosmetics:2.2.5") compileOnly("commons-io:commons-io:2.15.1") compileOnly("org.geysermc.geyser:api:2.2.0-SNAPSHOT") + compileOnly("LibsDisguises:LibsDisguises:10.0.42") // chat channels compileOnly(files("libs/VentureChat-3.7.1.jar")) diff --git a/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/bubble/BubbleManagerImpl.java b/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/bubble/BubbleManagerImpl.java index 3fd8b0a..5df1a56 100644 --- a/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/bubble/BubbleManagerImpl.java +++ b/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/bubble/BubbleManagerImpl.java @@ -41,6 +41,7 @@ import net.momirealms.customnameplates.paper.mechanic.bubble.image.ItemsAdderIma import net.momirealms.customnameplates.paper.mechanic.bubble.image.OraxenImageImpl; import net.momirealms.customnameplates.paper.mechanic.bubble.provider.*; import net.momirealms.customnameplates.paper.setting.CNConfig; +import net.momirealms.customnameplates.paper.util.DisguiseUtils; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.configuration.file.YamlConfiguration; @@ -257,6 +258,10 @@ public class BubbleManagerImpl implements BubbleManager, Listener { || !player.hasPermission("bubbles.use") ) return; + if (CNConfig.hasLibsDisguise && DisguiseUtils.isDisguised(player)) { + return; + } + if (Bukkit.isPrimaryThread()) { String finalText = text; CustomNameplatesPlugin.get().getScheduler().runTaskAsync(() -> onChat(player, finalText)); diff --git a/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/nameplate/tag/unlimited/UnlimitedPlayer.java b/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/nameplate/tag/unlimited/UnlimitedPlayer.java index f453b02..ef544be 100644 --- a/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/nameplate/tag/unlimited/UnlimitedPlayer.java +++ b/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/nameplate/tag/unlimited/UnlimitedPlayer.java @@ -65,7 +65,7 @@ public class UnlimitedPlayer extends UnlimitedEntity implements EntityTagPlayer return; } staticTags.add(tag); - dynamicTagVectorToArray(); + staticTagVectorToArray(); for (Player all : getNearbyPlayers()) { if (tag.getComeRule().isPassed(all, owner)) { tag.addPlayerToViewers(all); diff --git a/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/nameplate/tag/unlimited/UnlimitedTagManagerImpl.java b/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/nameplate/tag/unlimited/UnlimitedTagManagerImpl.java index 2d04b64..3c1edd8 100644 --- a/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/nameplate/tag/unlimited/UnlimitedTagManagerImpl.java +++ b/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/nameplate/tag/unlimited/UnlimitedTagManagerImpl.java @@ -174,6 +174,7 @@ public class UnlimitedTagManagerImpl implements UnlimitedTagManager { if (spawned == null) return; UnlimitedEntity unlimitedEntity = getUnlimitedObject(spawned.getUniqueId()); if (unlimitedEntity == null) return; + if (receiver == spawned) return; unlimitedEntity.addNearbyPlayerNaturally(receiver); } diff --git a/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/requirement/RequirementManagerImpl.java b/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/requirement/RequirementManagerImpl.java index f29eae5..ce51c4b 100644 --- a/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/requirement/RequirementManagerImpl.java +++ b/paper/src/main/java/net/momirealms/customnameplates/paper/mechanic/requirement/RequirementManagerImpl.java @@ -27,8 +27,10 @@ import net.momirealms.customnameplates.api.util.LogUtils; import net.momirealms.customnameplates.common.Pair; import net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl; import net.momirealms.customnameplates.paper.mechanic.requirement.papi.PapiCondition; +import net.momirealms.customnameplates.paper.setting.CNConfig; import net.momirealms.customnameplates.paper.util.ClassUtils; import net.momirealms.customnameplates.paper.util.ConfigUtils; +import net.momirealms.customnameplates.paper.util.DisguiseUtils; import net.momirealms.customnameplates.paper.util.GeyserUtils; import org.bukkit.World; import org.bukkit.configuration.ConfigurationSection; @@ -123,6 +125,7 @@ public class RequirementManagerImpl implements RequirementManager { this.registerInListRequirement(); this.registerGameModeRequirement(); this.registerGeyserRequirement(); + this.registerDisguisedRequirement(); } /** @@ -304,6 +307,20 @@ public class RequirementManagerImpl implements RequirementManager { }); } + private void registerDisguisedRequirement() { + registerRequirement("self-disguised", (args) -> { + boolean arg = (boolean) args; + return condition -> { + if (!CNConfig.hasLibsDisguise) return true; + if (arg) { + return DisguiseUtils.isDisguised(condition.getOfflinePlayer().getPlayer()); + } else { + return !DisguiseUtils.isDisguised(condition.getOfflinePlayer().getPlayer()); + } + }; + }); + } + private void registerBiomeRequirement() { registerRequirement("biome", (args) -> { HashSet biomes = new HashSet<>(ConfigUtils.stringListArgs(args)); diff --git a/paper/src/main/java/net/momirealms/customnameplates/paper/setting/CNConfig.java b/paper/src/main/java/net/momirealms/customnameplates/paper/setting/CNConfig.java index d58bf43..4101224 100644 --- a/paper/src/main/java/net/momirealms/customnameplates/paper/setting/CNConfig.java +++ b/paper/src/main/java/net/momirealms/customnameplates/paper/setting/CNConfig.java @@ -28,6 +28,7 @@ import net.momirealms.customnameplates.api.mechanic.character.CharacterArranger; import net.momirealms.customnameplates.api.util.FontUtils; import net.momirealms.customnameplates.api.util.LogUtils; import net.momirealms.customnameplates.paper.mechanic.bossbar.BarColor; +import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; @@ -85,6 +86,7 @@ public class CNConfig { public static boolean enableShader; public static boolean huskChatChannel; public static boolean carbonChatChannel; + public static boolean hasLibsDisguise; public static void load() { try { @@ -176,6 +178,8 @@ public class CNConfig { legacyColorSupport = config.getBoolean("other-settings.legacy-color-code-support"); createRealTeam = config.getBoolean("other-settings.create-real-teams", false); + + hasLibsDisguise = Bukkit.getPluginManager().getPlugin("LibsDisguises") != null; } public static boolean isOtherTeamPluginHooked() { diff --git a/paper/src/main/java/net/momirealms/customnameplates/paper/util/DisguiseUtils.java b/paper/src/main/java/net/momirealms/customnameplates/paper/util/DisguiseUtils.java new file mode 100644 index 0000000..6ccb4e6 --- /dev/null +++ b/paper/src/main/java/net/momirealms/customnameplates/paper/util/DisguiseUtils.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customnameplates.paper.util; + +import me.libraryaddict.disguise.DisguiseAPI; +import org.bukkit.entity.Player; + +public class DisguiseUtils { + + public static boolean isDisguised(Player player) { + return DisguiseAPI.isSelfDisguised(player); + } +} diff --git a/paper/src/main/resources/configs/nameplate.yml b/paper/src/main/resources/configs/nameplate.yml index a9844dc..c7ade6e 100644 --- a/paper/src/main/resources/configs/nameplate.yml +++ b/paper/src/main/resources/configs/nameplate.yml @@ -33,6 +33,7 @@ unlimited: # Conditions (Owner side) owner-conditions: potion-effect: "INVISIBILITY<0" + self-disguised: false # Requires LibsDisguises # Conditions (Viewer side) viewer-conditions: { } tag_2: @@ -42,6 +43,7 @@ unlimited: check-frequency: 20 # Decides the frequency of the condition check owner-conditions: potion-effect: "INVISIBILITY<0" + self-disguised: false viewer-conditions: condition_1: type: permission