diff --git a/build.gradle.kts b/build.gradle.kts index c3cb81f5..d8328308 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -43,6 +43,7 @@ allprojects { maven("https://repo.kryptonmc.org/releases") maven("https://repo.oraxen.com/releases/") maven("https://nexus.codecrafter47.de/content/repositories/public/") + maven("https://repo.opencollab.dev/main/") } } diff --git a/paper/build.gradle.kts b/paper/build.gradle.kts index 231327a1..8c7f6829 100644 --- a/paper/build.gradle.kts +++ b/paper/build.gradle.kts @@ -33,6 +33,7 @@ dependencies { compileOnly("io.th0rgal:oraxen:1.165.0") 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") // chat channels compileOnly(files("libs/VentureChat-3.7.1.jar")) 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 e94b18a9..f29eae59 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 @@ -29,6 +29,7 @@ import net.momirealms.customnameplates.paper.mechanic.requirement.papi.PapiCondition; import net.momirealms.customnameplates.paper.util.ClassUtils; import net.momirealms.customnameplates.paper.util.ConfigUtils; +import net.momirealms.customnameplates.paper.util.GeyserUtils; import org.bukkit.World; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.potion.PotionEffect; @@ -121,6 +122,7 @@ private void registerInbuiltRequirements() { this.registerPapiRequirement(); this.registerInListRequirement(); this.registerGameModeRequirement(); + this.registerGeyserRequirement(); } /** @@ -289,6 +291,19 @@ private void registerRandomRequirement() { }); } + private void registerGeyserRequirement() { + registerRequirement("geyser", (args) -> { + boolean arg = (boolean) args; + return condition -> { + if (arg) { + return GeyserUtils.isBedrockPlayer(condition.getOfflinePlayer().getUniqueId()); + } else { + return !GeyserUtils.isBedrockPlayer(condition.getOfflinePlayer().getUniqueId()); + } + }; + }); + } + private void registerBiomeRequirement() { registerRequirement("biome", (args) -> { HashSet biomes = new HashSet<>(ConfigUtils.stringListArgs(args)); diff --git a/paper/src/main/java/net/momirealms/customnameplates/paper/util/GeyserUtils.java b/paper/src/main/java/net/momirealms/customnameplates/paper/util/GeyserUtils.java new file mode 100644 index 00000000..c28e54c9 --- /dev/null +++ b/paper/src/main/java/net/momirealms/customnameplates/paper/util/GeyserUtils.java @@ -0,0 +1,29 @@ +/* + * 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 org.geysermc.api.Geyser; + +import java.util.UUID; + +public class GeyserUtils { + + public static boolean isBedrockPlayer(UUID uuid) { + return Geyser.api().isBedrockPlayer(uuid); + } +}