Support for more guild/party plugins

This commit is contained in:
Jules 2022-02-06 17:40:32 +01:00
parent 87ffe8e621
commit db90693676
6 changed files with 101 additions and 30 deletions

14
pom.xml
View File

@ -208,6 +208,13 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.denizen</groupId>
<artifactId>Dungeons</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<!-- Guild plugins -->
<dependency>
<groupId>com.massivecraft</groupId>
@ -230,6 +237,13 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.kingdoms.main</groupId>
<artifactId>Kingdoms</artifactId>
<version>1.11.15.0.0.0.1.1</version>
<scope>provided</scope>
</dependency>
<!-- Quest plugins -->
</dependencies>

View File

@ -1,13 +1,18 @@
package net.Indyuce.mmocore.guild;
import net.Indyuce.mmocore.guild.compat.FactionsGuildModule;
import net.Indyuce.mmocore.guild.compat.GuildsGuildModule;
import net.Indyuce.mmocore.guild.compat.UltimateClansGuildModule;
import net.Indyuce.mmocore.guild.provided.MMOCoreGuildModule;
import org.bukkit.Bukkit;
import javax.inject.Provider;
public enum GuildModuleType {
FACTIONS("Factions", FactionsGuildModule::new),
GUILDS("Guilds", GuildsGuildModule::new),
KINGDOMSX("Guilds", GuildsGuildModule::new),
MMOCORE("MMOCore", MMOCoreGuildModule::new),
ULTIMATE_CLANS("UltimateClans", UltimateClansGuildModule::new),
;

View File

@ -0,0 +1,18 @@
package net.Indyuce.mmocore.guild.compat;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.guild.AbstractGuild;
import net.Indyuce.mmocore.guild.GuildModule;
public class KingdomsXGuildModule implements GuildModule {
@Override
public AbstractGuild getGuild(PlayerData playerData) {
throw new RuntimeException("Not supported");
}
class CustomGuild implements AbstractGuild {
CustomGuild() {
}
}
}

View File

@ -1,21 +1,18 @@
package net.Indyuce.mmocore.party;
import net.Indyuce.mmocore.party.compat.DungeonsPartyModule;
import net.Indyuce.mmocore.party.compat.McMMOPartyModule;
import net.Indyuce.mmocore.party.compat.PAFPartyModule;
import net.Indyuce.mmocore.party.compat.PartiesPartyModule;
import net.Indyuce.mmocore.party.compat.*;
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
import org.bukkit.Bukkit;
import javax.inject.Provider;
public enum PartyModuleType {
DUNGEONSXL("DungeonsXL", () -> new DungeonsPartyModule()),
MMOCORE("MMOCore", () -> new MMOCorePartyModule()),
PARTY_AND_FRIENDS("PartyAndFriends", () -> new PAFPartyModule()),
PARTIES("Parties", () -> new PartiesPartyModule()),
MCMMO("mcMMO", () -> new McMMOPartyModule()),
// DUNGEONS("Dungeons", null),
DUNGEONS("Dungeons", DungeonsPartyModule::new),
DUNGEONSXL("DungeonsXL", DungeonsXLPartyModule::new),
MCMMO("mcMMO", McMMOPartyModule::new),
MMOCORE("MMOCore", MMOCorePartyModule::new),
PARTIES("Parties", PartiesPartyModule::new),
PARTY_AND_FRIENDS("PartyAndFriends", PAFPartyModule::new),
;
private final String pluginName;

View File

@ -1,52 +1,37 @@
package net.Indyuce.mmocore.party.compat;
import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.api.player.PlayerGroup;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.party.AbstractParty;
import net.Indyuce.mmocore.party.PartyModule;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class DungeonsPartyModule implements PartyModule {
@Override
public AbstractParty getParty(PlayerData playerData) {
PlayerGroup group = DungeonsXL.getInstance().getPlayerGroup(playerData.getPlayer());
return group == null ? null : new CustomParty(group);
throw new RuntimeException("Not supported");
}
class CustomParty implements AbstractParty {
private final PlayerGroup group;
public CustomParty(PlayerGroup group) {
this.group = group;
public CustomParty() {
}
@Override
public boolean hasMember(Player player) {
return group.getMembers().contains(player.getUniqueId());
throw new RuntimeException("Not supported");
}
@Override
public List<PlayerData> getOnlineMembers() {
List<PlayerData> list = new ArrayList<>();
for (UUID playerUid : group.getMembers().getUniqueIds()) {
PlayerData found = PlayerData.get(playerUid);
if (found.isOnline())
list.add(found);
}
return list;
throw new RuntimeException("Not supported");
}
@Override
public int countMembers() {
return group.getMembers().getUniqueIds().size();
throw new RuntimeException("Not supported");
}
}
}

View File

@ -0,0 +1,52 @@
package net.Indyuce.mmocore.party.compat;
import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.api.player.PlayerGroup;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.party.AbstractParty;
import net.Indyuce.mmocore.party.PartyModule;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class DungeonsXLPartyModule implements PartyModule {
@Override
public AbstractParty getParty(PlayerData playerData) {
PlayerGroup group = DungeonsXL.getInstance().getPlayerGroup(playerData.getPlayer());
return group == null ? null : new CustomParty(group);
}
class CustomParty implements AbstractParty {
private final PlayerGroup group;
public CustomParty(PlayerGroup group) {
this.group = group;
}
@Override
public boolean hasMember(Player player) {
return group.getMembers().contains(player.getUniqueId());
}
@Override
public List<PlayerData> getOnlineMembers() {
List<PlayerData> list = new ArrayList<>();
for (UUID playerUid : group.getMembers().getUniqueIds()) {
PlayerData found = PlayerData.get(playerUid);
if (found.isOnline())
list.add(found);
}
return list;
}
@Override
public int countMembers() {
return group.getMembers().getUniqueIds().size();
}
}
}