diff --git a/pom.xml b/pom.xml index 56e2545f..0677a122 100644 --- a/pom.xml +++ b/pom.xml @@ -223,6 +223,13 @@ provided + + me.glaremasters + Guilds + 3.5.6.0 + provided + + diff --git a/src/main/java/net/Indyuce/mmocore/guild/GuildModule.java b/src/main/java/net/Indyuce/mmocore/guild/GuildModule.java index 0ff7be86..e5c494fc 100644 --- a/src/main/java/net/Indyuce/mmocore/guild/GuildModule.java +++ b/src/main/java/net/Indyuce/mmocore/guild/GuildModule.java @@ -1,8 +1,10 @@ package net.Indyuce.mmocore.guild; import net.Indyuce.mmocore.api.player.PlayerData; +import org.jetbrains.annotations.Nullable; public interface GuildModule { + @Nullable public AbstractGuild getGuild(PlayerData playerData); } diff --git a/src/main/java/net/Indyuce/mmocore/guild/compat/FactionsGuildModule.java b/src/main/java/net/Indyuce/mmocore/guild/compat/FactionsGuildModule.java index cb5b44df..f7470a10 100644 --- a/src/main/java/net/Indyuce/mmocore/guild/compat/FactionsGuildModule.java +++ b/src/main/java/net/Indyuce/mmocore/guild/compat/FactionsGuildModule.java @@ -12,7 +12,7 @@ public class FactionsGuildModule implements GuildModule { @Override public AbstractGuild getGuild(PlayerData playerData) { FPlayer fPlayer = FPlayers.getInstance().getByPlayer(playerData.getPlayer()); - return new CustomGuild(fPlayer.getFaction()); + return fPlayer.hasFaction() ? new CustomGuild(fPlayer.getFaction()) : null; } class CustomGuild implements AbstractGuild { diff --git a/src/main/java/net/Indyuce/mmocore/guild/compat/GuildsGuildModule.java b/src/main/java/net/Indyuce/mmocore/guild/compat/GuildsGuildModule.java new file mode 100644 index 00000000..d1fdb2ae --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/guild/compat/GuildsGuildModule.java @@ -0,0 +1,24 @@ +package net.Indyuce.mmocore.guild.compat; + +import me.glaremasters.guilds.Guilds; +import me.glaremasters.guilds.guild.Guild; +import net.Indyuce.mmocore.api.player.PlayerData; +import net.Indyuce.mmocore.guild.AbstractGuild; +import net.Indyuce.mmocore.guild.GuildModule; + +public class GuildsGuildModule implements GuildModule { + + @Override + public AbstractGuild getGuild(PlayerData playerData) { + Guild guild = Guilds.getApi().getGuild(playerData.getUniqueId()); + return guild == null ? null : new CustomGuild(guild); + } + + class CustomGuild implements AbstractGuild { + private final Guild guild; + + CustomGuild(Guild guild) { + this.guild = guild; + } + } +}