Basic support for DungeonParties

This commit is contained in:
Jules 2023-04-22 16:54:55 +02:00
parent 966cd333c1
commit f4b2147226
4 changed files with 67 additions and 2 deletions

View File

@ -203,6 +203,13 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.playavalon</groupId>
<artifactId>DungeonParties</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alessiodp</groupId>
<artifactId>Parties</artifactId>

View File

@ -12,6 +12,7 @@ public enum PartyModuleType {
MCMMO("mcMMO", McMMOPartyModule::new),
MMOCORE("MMOCore", MMOCorePartyModule::new),
PARTIES("Parties", PartiesPartyModule::new),
MYTHICDUNGEONS("MythicDungeons", DungeonPartiesPartyModule::new),
OBTEAM("OBTeam", OBTeamPartyModule::new),
PARTY_AND_FRIENDS("PartyAndFriends", PAFPartyModule::new),
PARTY_AND_FRIENDS_BUNGEECORD_VELOCITY("Spigot-Party-API-PAF", PAFProxyPartyModule::new),

View File

@ -0,0 +1,57 @@
package net.Indyuce.mmocore.party.compat;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.party.AbstractParty;
import net.Indyuce.mmocore.party.PartyModule;
import net.playavalon.avnparty.AvNParty;
import net.playavalon.avnparty.party.Party;
import net.playavalon.avnparty.player.AvalonPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class DungeonPartiesPartyModule implements PartyModule, Listener {
@Nullable
@Override
public AbstractParty getParty(PlayerData playerData) {
final @Nullable Party party = AvNParty.plugin.players.get(playerData.getPlayer()).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) {
for (AvalonPlayer member : party.getPlayers())
if (member.getPlayer().getUniqueId().equals(player.getUniqueId())) return true;
return false;
}
@Override
public List<PlayerData> getOnlineMembers() {
final List<PlayerData> list = new ArrayList<>();
for (AvalonPlayer member : party.getPlayers())
try {
list.add(PlayerData.get(member.getPlayer().getUniqueId()));
} catch (Exception ignored) {
}
return list;
}
@Override
public int countMembers() {
return party.getPlayers().size();
}
}
}

View File

@ -3,9 +3,9 @@ version: ${project.version}
main: net.Indyuce.mmocore.MMOCore
author: Indyuce
description: ${project.description}
loadbefore: [ MMOItems ]
loadbefore: [ MMOItems,MythicDungeons ]
depend: [ MythicLib ]
softdepend: [ Vault,MythicMobs,PlaceholderAPI,Residence,Citizens,ProtocolLib ]
softdepend: [ Vault,MythicMobs,PlaceholderAPI,Residence,Citizens,ProtocolLib,OBTeam ]
api-version: 1.13
commands:
mmocore: