support for Guilds

This commit is contained in:
Indyuce 2022-01-22 19:18:54 +01:00
parent c9fe2c805c
commit 52183f81f6
4 changed files with 34 additions and 1 deletions

View File

@ -223,6 +223,13 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>me.glaremasters</groupId>
<artifactId>Guilds</artifactId>
<version>3.5.6.0</version>
<scope>provided</scope>
</dependency>
<!-- Quest plugins --> <!-- Quest plugins -->
</dependencies> </dependencies>

View File

@ -1,8 +1,10 @@
package net.Indyuce.mmocore.guild; package net.Indyuce.mmocore.guild;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import org.jetbrains.annotations.Nullable;
public interface GuildModule { public interface GuildModule {
@Nullable
public AbstractGuild getGuild(PlayerData playerData); public AbstractGuild getGuild(PlayerData playerData);
} }

View File

@ -12,7 +12,7 @@ public class FactionsGuildModule implements GuildModule {
@Override @Override
public AbstractGuild getGuild(PlayerData playerData) { public AbstractGuild getGuild(PlayerData playerData) {
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(playerData.getPlayer()); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(playerData.getPlayer());
return new CustomGuild(fPlayer.getFaction()); return fPlayer.hasFaction() ? new CustomGuild(fPlayer.getFaction()) : null;
} }
class CustomGuild implements AbstractGuild { class CustomGuild implements AbstractGuild {

View File

@ -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;
}
}
}