From 68fbfc35765bd9ebc530eabc6bd4337d50813e3f Mon Sep 17 00:00:00 2001 From: Jules Date: Sun, 11 Feb 2024 17:17:35 +0100 Subject: [PATCH] Support for Uclans API 7 --- MMOCore-API/pom.xml | 11 ++++++++--- .../guild/compat/UltimateClansGuildModule.java | 18 +++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/MMOCore-API/pom.xml b/MMOCore-API/pom.xml index 6be4345b..8630e6f9 100644 --- a/MMOCore-API/pom.xml +++ b/MMOCore-API/pom.xml @@ -84,6 +84,11 @@ https://mvn.lumine.io/repository/maven/ + + jitpack.io + https://jitpack.io + + sk89q-repo https://maven.enginehub.org/repo/ @@ -289,9 +294,9 @@ - me.ulrich - UltimateClans - 6.0.2 + com.github.UlrichBR + UClansV7-API + 7.1.0 provided diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/guild/compat/UltimateClansGuildModule.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/guild/compat/UltimateClansGuildModule.java index 97386ae9..86d3978f 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/guild/compat/UltimateClansGuildModule.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/guild/compat/UltimateClansGuildModule.java @@ -12,6 +12,7 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import java.util.Objects; +import java.util.Optional; import java.util.UUID; public class UltimateClansGuildModule implements GuildModule { @@ -19,17 +20,21 @@ public class UltimateClansGuildModule implements GuildModule { @Override public AbstractGuild getGuild(PlayerData playerData) { - return API.getPlayerAPI().hasClan(playerData.getUniqueId()) ? new CustomGuild(API.getClanAPI().getClan(API.getPlayerAPI().getClanID(playerData.getUniqueId()))) : null; + final Optional clan_ = API.getPlayerAPI().getPlayerClan(playerData.getUniqueId()); + return clan_.isEmpty() ? null : new CustomGuild(clan_.get()); } @Override public Relationship getRelationship(Player player, Player target) { - if (!API.getPlayerAPI().hasClan(player.getUniqueId()) || !API.getPlayerAPI().hasClan(target.getUniqueId())) - return Relationship.GUILD_NEUTRAL; + final Optional _clan1 = API.getPlayerAPI().getPlayerClan(player.getUniqueId()); + if (_clan1.isEmpty()) return Relationship.GUILD_NEUTRAL; - final ClanRivalAlly clan1 = API.getClanAPI().getClan(API.getPlayerAPI().getClanID(player.getUniqueId())).getRivalAlly(); - final UUID clanId2 = API.getPlayerAPI().getClanID(target.getUniqueId()); - return clan1.getAlly().contains(clanId2) ? Relationship.GUILD_ALLY : clan1.getRival().contains(clanId2) ? Relationship.GUILD_ENEMY : Relationship.GUILD_NEUTRAL; + final Optional _clan2 = API.getPlayerAPI().getPlayerClan(target.getUniqueId()); + if (_clan2.isEmpty()) return Relationship.GUILD_NEUTRAL; + + final ClanRivalAlly allies1 = _clan1.get().getRivalAlly(); + final UUID uuid2 = _clan2.get().getId(); + return allies1.getAlly().contains(uuid2) ? Relationship.GUILD_ALLY : allies1.getRival().contains(uuid2) ? Relationship.GUILD_ENEMY : Relationship.GUILD_NEUTRAL; } class CustomGuild implements AbstractGuild { @@ -43,7 +48,6 @@ public class UltimateClansGuildModule implements GuildModule { @Override public boolean hasMember(Player player) { - // List implementation. Pretty bad return clan.getMembers().contains(player); } }