Support for Uclans API 7

This commit is contained in:
Jules 2024-02-11 17:17:35 +01:00
parent e4f1400a31
commit 68fbfc3576
2 changed files with 19 additions and 10 deletions

View File

@ -84,6 +84,11 @@
<url>https://mvn.lumine.io/repository/maven/</url> <url>https://mvn.lumine.io/repository/maven/</url>
</repository> </repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository> <repository>
<id>sk89q-repo</id> <id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url> <url>https://maven.enginehub.org/repo/</url>
@ -289,9 +294,9 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.ulrich</groupId> <groupId>com.github.UlrichBR</groupId>
<artifactId>UltimateClans</artifactId> <artifactId>UClansV7-API</artifactId>
<version>6.0.2</version> <version>7.1.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
import java.util.UUID; import java.util.UUID;
public class UltimateClansGuildModule implements GuildModule { public class UltimateClansGuildModule implements GuildModule {
@ -19,17 +20,21 @@ public class UltimateClansGuildModule implements GuildModule {
@Override @Override
public AbstractGuild getGuild(PlayerData playerData) { public AbstractGuild getGuild(PlayerData playerData) {
return API.getPlayerAPI().hasClan(playerData.getUniqueId()) ? new CustomGuild(API.getClanAPI().getClan(API.getPlayerAPI().getClanID(playerData.getUniqueId()))) : null; final Optional<ClanData> clan_ = API.getPlayerAPI().getPlayerClan(playerData.getUniqueId());
return clan_.isEmpty() ? null : new CustomGuild(clan_.get());
} }
@Override @Override
public Relationship getRelationship(Player player, Player target) { public Relationship getRelationship(Player player, Player target) {
if (!API.getPlayerAPI().hasClan(player.getUniqueId()) || !API.getPlayerAPI().hasClan(target.getUniqueId())) final Optional<ClanData> _clan1 = API.getPlayerAPI().getPlayerClan(player.getUniqueId());
return Relationship.GUILD_NEUTRAL; if (_clan1.isEmpty()) return Relationship.GUILD_NEUTRAL;
final ClanRivalAlly clan1 = API.getClanAPI().getClan(API.getPlayerAPI().getClanID(player.getUniqueId())).getRivalAlly(); final Optional<ClanData> _clan2 = API.getPlayerAPI().getPlayerClan(target.getUniqueId());
final UUID clanId2 = API.getPlayerAPI().getClanID(target.getUniqueId()); if (_clan2.isEmpty()) return Relationship.GUILD_NEUTRAL;
return clan1.getAlly().contains(clanId2) ? Relationship.GUILD_ALLY : clan1.getRival().contains(clanId2) ? Relationship.GUILD_ENEMY : 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 { class CustomGuild implements AbstractGuild {
@ -43,7 +48,6 @@ public class UltimateClansGuildModule implements GuildModule {
@Override @Override
public boolean hasMember(Player player) { public boolean hasMember(Player player) {
// List implementation. Pretty bad
return clan.getMembers().contains(player); return clan.getMembers().contains(player);
} }
} }