support for mcmmo parties

This commit is contained in:
Jules 2022-01-19 14:24:37 +01:00
parent 8ad0880eea
commit 604bc2ff48
3 changed files with 54 additions and 1 deletions

View File

@ -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),
;

View File

@ -49,5 +49,4 @@ public class DungeonsPartyModule implements PartyModule {
return group.getMembers().getUniqueIds().size();
}
}
}

View File

@ -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<PlayerData> getOnlineMembers() {
List<PlayerData> list = new ArrayList<>();
for (Player online : party.getOnlineMembers())
list.add(PlayerData.get(online.getUniqueId()));
return list;
}
@Override
public int countMembers() {
return party.getMembers().size();
}
}
}