mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-01-06 07:07:38 +01:00
Compatibility with new MythicDungeons API
This commit is contained in:
parent
be62d73fcb
commit
2d08d4403b
@ -109,6 +109,14 @@
|
|||||||
<id>simonsators Repo</id>
|
<id>simonsators Repo</id>
|
||||||
<url>https://simonsator.de/repo</url>
|
<url>https://simonsator.de/repo</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<!-- MythicDungeons repository -->
|
||||||
|
<repository>
|
||||||
|
<id>aestrus-releases</id>
|
||||||
|
<name>Aestrus's Repository</name>
|
||||||
|
<url>https://maven.aestrus.io/releases</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -144,6 +152,13 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.playavalon</groupId>
|
||||||
|
<artifactId>MythicDungeons</artifactId>
|
||||||
|
<version>1.3.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.phoenixdevt</groupId>
|
<groupId>fr.phoenixdevt</groupId>
|
||||||
<artifactId>Profile-API</artifactId>
|
<artifactId>Profile-API</artifactId>
|
||||||
@ -216,13 +231,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.playavalon</groupId>
|
|
||||||
<artifactId>DungeonParties</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alessiodp</groupId>
|
<groupId>com.alessiodp</groupId>
|
||||||
<artifactId>Parties</artifactId>
|
<artifactId>Parties</artifactId>
|
||||||
|
@ -17,6 +17,10 @@ public interface AbstractParty {
|
|||||||
*/
|
*/
|
||||||
List<PlayerData> getOnlineMembers();
|
List<PlayerData> getOnlineMembers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Prefer using {@link #getOnlineMembers()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
default PlayerData getMember(int n) {
|
default PlayerData getMember(int n) {
|
||||||
return getOnlineMembers().get(n);
|
return getOnlineMembers().get(n);
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,15 @@ import org.bukkit.Bukkit;
|
|||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
|
|
||||||
public enum PartyModuleType {
|
public enum PartyModuleType {
|
||||||
|
MMOCORE("MMOCore", MMOCorePartyModule::new),
|
||||||
// DUNGEONS("Dungeons", DungeonsPartyModule::new),
|
// DUNGEONS("Dungeons", DungeonsPartyModule::new),
|
||||||
DUNGEONSXL("DungeonsXL", DungeonsXLPartyModule::new),
|
DUNGEONSXL("DungeonsXL", DungeonsXLPartyModule::new),
|
||||||
MCMMO("mcMMO", McMMOPartyModule::new),
|
MCMMO("mcMMO", McMMOPartyModule::new),
|
||||||
MMOCORE("MMOCore", MMOCorePartyModule::new),
|
MYTHICDUNGEONS("MythicDungeons", MythicDungeonsPartyModule::new),
|
||||||
PARTIES("Parties", PartiesPartyModule::new),
|
|
||||||
MYTHICDUNGEONS("MythicDungeons", DungeonPartiesPartyModule::new),
|
|
||||||
OBTEAM("OBTeam", OBTeamPartyModule::new),
|
OBTEAM("OBTeam", OBTeamPartyModule::new),
|
||||||
PARTY_AND_FRIENDS("PartyAndFriends", PAFPartyModule::new),
|
PARTY_AND_FRIENDS("PartyAndFriends", PAFPartyModule::new),
|
||||||
PARTY_AND_FRIENDS_BUNGEECORD_VELOCITY("Spigot-Party-API-PAF", PAFProxyPartyModule::new),
|
PARTY_AND_FRIENDS_BUNGEECORD_VELOCITY("Spigot-Party-API-PAF", PAFProxyPartyModule::new),
|
||||||
|
PARTIES("Parties", PartiesPartyModule::new),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String pluginName;
|
private final String pluginName;
|
||||||
|
@ -3,9 +3,10 @@ package net.Indyuce.mmocore.party.compat;
|
|||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.party.AbstractParty;
|
import net.Indyuce.mmocore.party.AbstractParty;
|
||||||
import net.Indyuce.mmocore.party.PartyModule;
|
import net.Indyuce.mmocore.party.PartyModule;
|
||||||
import net.playavalon.avnparty.AvNParty;
|
import net.playavalon.mythicdungeons.api.MythicDungeonsService;
|
||||||
import net.playavalon.avnparty.party.Party;
|
import net.playavalon.mythicdungeons.player.party.partysystem.MythicParty;
|
||||||
import net.playavalon.avnparty.player.AvalonPlayer;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -13,26 +14,33 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DungeonPartiesPartyModule implements PartyModule, Listener {
|
public class MythicDungeonsPartyModule implements PartyModule, Listener {
|
||||||
|
private final MythicDungeonsService hook;
|
||||||
|
|
||||||
|
public MythicDungeonsPartyModule() {
|
||||||
|
this.hook = Bukkit.getServer().getServicesManager().load(MythicDungeonsService.class);
|
||||||
|
Validate.notNull(hook, "Could not load compatibility with MythicDungeons");
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public AbstractParty getParty(PlayerData playerData) {
|
public AbstractParty getParty(PlayerData playerData) {
|
||||||
final @Nullable Party party = AvNParty.plugin.players.get(playerData.getPlayer()).getParty();
|
final MythicParty party = hook.getParty(playerData.getPlayer());
|
||||||
return party == null ? null : new CustomParty(party);
|
return party == null ? null : new CustomParty(party);
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomParty implements AbstractParty {
|
|
||||||
private final Party party;
|
|
||||||
|
|
||||||
public CustomParty(Party party) {
|
static class CustomParty implements AbstractParty {
|
||||||
|
private final MythicParty party;
|
||||||
|
|
||||||
|
public CustomParty(MythicParty party) {
|
||||||
this.party = party;
|
this.party = party;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasMember(Player player) {
|
public boolean hasMember(Player player) {
|
||||||
for (AvalonPlayer member : party.getPlayers())
|
for (Player member : party.getPlayers())
|
||||||
if (member.getPlayer().getUniqueId().equals(player.getUniqueId())) return true;
|
if (member.getUniqueId().equals(player.getUniqueId())) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +48,7 @@ public class DungeonPartiesPartyModule implements PartyModule, Listener {
|
|||||||
public List<PlayerData> getOnlineMembers() {
|
public List<PlayerData> getOnlineMembers() {
|
||||||
final List<PlayerData> list = new ArrayList<>();
|
final List<PlayerData> list = new ArrayList<>();
|
||||||
|
|
||||||
for (AvalonPlayer member : party.getPlayers())
|
for (Player member : party.getPlayers())
|
||||||
try {
|
try {
|
||||||
list.add(PlayerData.get(member.getPlayer()));
|
list.add(PlayerData.get(member.getPlayer()));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
Loading…
Reference in New Issue
Block a user