diff --git a/src/main/java/net/Indyuce/mmocore/party/PartyModuleType.java b/src/main/java/net/Indyuce/mmocore/party/PartyModuleType.java index a67c7b06..c1bb3dc3 100644 --- a/src/main/java/net/Indyuce/mmocore/party/PartyModuleType.java +++ b/src/main/java/net/Indyuce/mmocore/party/PartyModuleType.java @@ -1,6 +1,7 @@ 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.provided.MMOCorePartyModule; @@ -13,6 +14,7 @@ public enum PartyModuleType { MMOCORE("MMOCore", () -> new MMOCorePartyModule()), PARTY_AND_FRIENDS("PartyAndFriends", () -> new PAFPartyModule()), PARTIES("Parties", () -> new PartiesPartyModule()), + MCMMO("mcMMO", () -> new McMMOPartyModule()), // DUNGEONS("Dungeons", null), ; diff --git a/src/main/java/net/Indyuce/mmocore/party/compat/DungeonsPartyModule.java b/src/main/java/net/Indyuce/mmocore/party/compat/DungeonsPartyModule.java index 4241bfe8..edda8c06 100644 --- a/src/main/java/net/Indyuce/mmocore/party/compat/DungeonsPartyModule.java +++ b/src/main/java/net/Indyuce/mmocore/party/compat/DungeonsPartyModule.java @@ -49,5 +49,4 @@ public class DungeonsPartyModule implements PartyModule { return group.getMembers().getUniqueIds().size(); } } - } diff --git a/src/main/java/net/Indyuce/mmocore/party/compat/McMMOPartyModule.java b/src/main/java/net/Indyuce/mmocore/party/compat/McMMOPartyModule.java new file mode 100644 index 00000000..7283bffa --- /dev/null +++ b/src/main/java/net/Indyuce/mmocore/party/compat/McMMOPartyModule.java @@ -0,0 +1,52 @@ +package net.Indyuce.mmocore.party.compat; + +import com.gmail.nossr50.datatypes.party.Party; +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.util.player.UserManager; +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 org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.List; + +public class McMMOPartyModule implements PartyModule { + + @Nullable + @Override + public AbstractParty getParty(PlayerData playerData) { + McMMOPlayer extPlayerData = UserManager.getPlayer(playerData.getPlayer()); + Party party = extPlayerData == null ? null : extPlayerData.getParty(); + return party == null ? null : new CustomParty(party); + } + + class CustomParty implements AbstractParty { + private final Party party; + + public CustomParty(Party party) { + this.party = party; + } + + @Override + public boolean hasMember(Player player) { + return party.hasMember(player.getUniqueId()); + } + + @Override + public List getOnlineMembers() { + List list = new ArrayList<>(); + + for (Player online : party.getOnlineMembers()) + list.add(PlayerData.get(online.getUniqueId())); + + return list; + } + + @Override + public int countMembers() { + return party.getMembers().size(); + } + } +}