mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-25 00:26:21 +01:00
Support for MythicDungeons & Heroes party systems
This commit is contained in:
parent
25509be21b
commit
d248f11a0e
@ -105,6 +105,12 @@
|
||||
<url>https://simonsator.de/repo</url>
|
||||
</repository>
|
||||
|
||||
<!-- Heroes Repository
|
||||
<repository>
|
||||
<id>herocraft</id>
|
||||
<url>https://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository> -->
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -146,6 +152,7 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.20</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Plugin dependencies -->
|
||||
@ -154,6 +161,7 @@
|
||||
<artifactId>Mythic-Dist</artifactId>
|
||||
<version>5.0.1</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -161,6 +169,7 @@
|
||||
<artifactId>MythicDungeons</artifactId>
|
||||
<version>1.4.1-SNAPSHOT-CUSTOM</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -176,6 +185,7 @@
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -183,6 +193,7 @@
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7.1</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -190,6 +201,7 @@
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.2-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@ -208,6 +220,7 @@
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>4.8.0</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -215,6 +228,7 @@
|
||||
<artifactId>Citizens</artifactId>
|
||||
<version>2.0.30</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Party plugins -->
|
||||
@ -223,6 +237,7 @@
|
||||
<artifactId>DevelopmentPAFSpigot</artifactId>
|
||||
<version>1.0.65</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -230,6 +245,7 @@
|
||||
<artifactId>Party-and-Friends-MySQL-Edition-Spigot-API</artifactId>
|
||||
<version>1.5.4-RELEASE</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -237,6 +253,7 @@
|
||||
<artifactId>spigot-party-api-for-party-and-friends</artifactId>
|
||||
<version>1.0.4-RELEASE</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -244,6 +261,7 @@
|
||||
<artifactId>OBTeam</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -251,6 +269,7 @@
|
||||
<artifactId>Parties</artifactId>
|
||||
<version>3.1.14</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -258,6 +277,7 @@
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.209</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -265,6 +285,15 @@
|
||||
<artifactId>DungeonsXL</artifactId>
|
||||
<version>0.18-SNAPSHOT-1149</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.herocraftonline</groupId>
|
||||
<artifactId>Heroes</artifactId>
|
||||
<version>1.9.22</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -272,6 +301,7 @@
|
||||
<artifactId>Bedrock</artifactId>
|
||||
<version>1.2.5</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -279,6 +309,7 @@
|
||||
<artifactId>Dungeons</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Quest Plugins -->
|
||||
@ -287,24 +318,28 @@
|
||||
<artifactId>Quests</artifactId>
|
||||
<version>4.4.1-b340</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.skytasul.quests</groupId>
|
||||
<artifactId>BeautyQuests</artifactId>
|
||||
<version>0.19.5</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.guillaumevdn</groupId>
|
||||
<artifactId>QuestCreator</artifactId>
|
||||
<version>6.39.0</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.guillaumevdn</groupId>
|
||||
<artifactId>GCore</artifactId>
|
||||
<version>8.39.0</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Guild plugins -->
|
||||
@ -321,6 +356,7 @@
|
||||
<artifactId>UClansV7-API</artifactId>
|
||||
<version>7.1.0</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -328,6 +364,7 @@
|
||||
<artifactId>Guilds</artifactId>
|
||||
<version>3.5.6.0</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -335,6 +372,7 @@
|
||||
<artifactId>Kingdoms</artifactId>
|
||||
<version>1.15.5</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@ -6,6 +6,7 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.manager.MMOCoreManager;
|
||||
import net.Indyuce.mmocore.party.AbstractParty;
|
||||
import net.Indyuce.mmocore.party.PartyUtils;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -23,7 +24,7 @@ public class PartyManager implements MMOCoreManager {
|
||||
public void initialize(boolean clearBefore) {
|
||||
if (clearBefore) {
|
||||
// Fixes MMOCore#1035, first remove existing buffs of players.
|
||||
PlayerData.getAll().forEach(MMOCore.plugin.partyModule::clearStatBonuses);
|
||||
PlayerData.getAll().forEach(PartyUtils::clearStatBonuses);
|
||||
buffs.clear();
|
||||
}
|
||||
|
||||
@ -40,7 +41,7 @@ public class PartyManager implements MMOCoreManager {
|
||||
if (clearBefore)
|
||||
for (PlayerData playerData : PlayerData.getAll()) {
|
||||
AbstractParty party = MMOCore.plugin.partyModule.getParty(playerData);
|
||||
if (party != null) MMOCore.plugin.partyModule.applyStatBonuses(playerData, party.countMembers());
|
||||
if (party != null) PartyUtils.applyStatBonuses(playerData, party.countMembers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.Indyuce.mmocore.party;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -10,17 +11,17 @@ public interface AbstractParty {
|
||||
/**
|
||||
* @return If given player is in that party
|
||||
*/
|
||||
boolean hasMember(Player player);
|
||||
default boolean hasMember(@NotNull Player player) {
|
||||
for (PlayerData member : getOnlineMembers())
|
||||
if (member.getPlayer().equals(player)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return List of online members
|
||||
*/
|
||||
List<PlayerData> getOnlineMembers();
|
||||
|
||||
/**
|
||||
* @deprecated Prefer using {@link #getOnlineMembers()}
|
||||
*/
|
||||
@Deprecated
|
||||
default PlayerData getMember(int n) {
|
||||
return getOnlineMembers().get(n);
|
||||
}
|
||||
|
@ -1,26 +1,21 @@
|
||||
package net.Indyuce.mmocore.party;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface PartyModule {
|
||||
|
||||
@Nullable
|
||||
public AbstractParty getParty(PlayerData playerData);
|
||||
public AbstractParty getParty(@NotNull PlayerData playerData);
|
||||
|
||||
|
||||
/**
|
||||
* Applies party stat bonuses to a specific player
|
||||
*/
|
||||
@Deprecated
|
||||
default void applyStatBonuses(PlayerData player, int memberCount) {
|
||||
MMOCore.plugin.partyManager.getBonuses().forEach(buff -> buff.multiply(memberCount - 1).register(player.getMMOPlayerData()));
|
||||
PartyUtils.applyStatBonuses(player, memberCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear party stat bonuses from a player
|
||||
*/
|
||||
@Deprecated
|
||||
default void clearStatBonuses(PlayerData player) {
|
||||
MMOCore.plugin.partyManager.getBonuses().forEach(buff -> buff.unregister(player.getMMOPlayerData()));
|
||||
PartyUtils.clearStatBonuses(player);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,9 @@ public enum PartyModuleType {
|
||||
MMOCORE("MMOCore", MMOCorePartyModule::new),
|
||||
// DUNGEONS("Dungeons", DungeonsPartyModule::new),
|
||||
DUNGEONSXL("DungeonsXL", DungeonsXLPartyModule::new),
|
||||
HEROES("Heroes", HeroesPartyModule::new),
|
||||
MCMMO("mcMMO", McMMOPartyModule::new),
|
||||
MYTHICDUNGEONS_INJECT("MythicDungeons", MythicDungeonsPartyInjector::new),
|
||||
MYTHICDUNGEONS("MythicDungeons", MythicDungeonsPartyModule::new),
|
||||
OBTEAM("OBTeam", OBTeamPartyModule::new),
|
||||
PARTY_AND_FRIENDS("PartyAndFriends", PAFPartyModule::new),
|
||||
|
@ -0,0 +1,22 @@
|
||||
package net.Indyuce.mmocore.party;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PartyUtils {
|
||||
|
||||
/**
|
||||
* Applies party stat bonuses to a specific player
|
||||
*/
|
||||
public static void applyStatBonuses(@NotNull PlayerData player, int memberCount) {
|
||||
MMOCore.plugin.partyManager.getBonuses().forEach(buff -> buff.multiply(memberCount - 1).register(player.getMMOPlayerData()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear party stat bonuses from a player
|
||||
*/
|
||||
public static void clearStatBonuses(@NotNull PlayerData player) {
|
||||
MMOCore.plugin.partyManager.getBonuses().forEach(buff -> buff.unregister(player.getMMOPlayerData()));
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ public class DungeonsPartyModule implements PartyModule {
|
||||
throw new RuntimeException("Not supported");
|
||||
}
|
||||
|
||||
class CustomParty implements AbstractParty {
|
||||
private static class CustomParty implements AbstractParty {
|
||||
|
||||
public CustomParty() {
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.party.AbstractParty;
|
||||
import net.Indyuce.mmocore.party.PartyModule;
|
||||
import net.Indyuce.mmocore.party.PartyUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -34,25 +35,25 @@ public class DungeonsXLPartyModule implements PartyModule, Listener {
|
||||
public void onPlayerJoin(GroupPlayerJoinEvent event) {
|
||||
//We add 1 because this returns the members of the group excluding the player that just joined.
|
||||
int membersSize = event.getGroup().getMembers().size() + 1;
|
||||
applyStatBonuses(PlayerData.get(event.getPlayer().getPlayer()), membersSize);
|
||||
PartyUtils.applyStatBonuses(PlayerData.get(event.getPlayer().getPlayer()), membersSize);
|
||||
event.getGroup().getMembers().getOnlinePlayers()
|
||||
.forEach(p -> applyStatBonuses(PlayerData.get(p), membersSize));
|
||||
.forEach(p -> PartyUtils.applyStatBonuses(PlayerData.get(p), membersSize));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeave(GroupPlayerLeaveEvent event) {
|
||||
int membersSize = event.getGroup().getMembers().size();
|
||||
clearStatBonuses(PlayerData.get(event.getPlayer().getPlayer()));
|
||||
PartyUtils.clearStatBonuses(PlayerData.get(event.getPlayer().getPlayer()));
|
||||
event.getGroup().getMembers().getOnlinePlayers()
|
||||
.forEach(p -> applyStatBonuses(PlayerData.get(p), membersSize));
|
||||
.forEach(p -> PartyUtils.applyStatBonuses(PlayerData.get(p), membersSize));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGroupDisband(GroupDisbandEvent event) {
|
||||
event.getGroup().getMembers().getOnlinePlayers().forEach(p -> clearStatBonuses(PlayerData.get(p)));
|
||||
event.getGroup().getMembers().getOnlinePlayers().forEach(p -> PartyUtils.clearStatBonuses(PlayerData.get(p)));
|
||||
}
|
||||
|
||||
class CustomParty implements AbstractParty {
|
||||
private static class CustomParty implements AbstractParty {
|
||||
private final PlayerGroup group;
|
||||
|
||||
public CustomParty(PlayerGroup group) {
|
||||
@ -81,6 +82,5 @@ public class DungeonsXLPartyModule implements PartyModule, Listener {
|
||||
public int countMembers() {
|
||||
return group.getMembers().getUniqueIds().size();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
package net.Indyuce.mmocore.party.compat;
|
||||
|
||||
import com.herocraftonline.heroes.Heroes;
|
||||
import com.herocraftonline.heroes.characters.Hero;
|
||||
import com.herocraftonline.heroes.characters.party.HeroParty;
|
||||
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.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HeroesPartyModule implements PartyModule, Listener {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public AbstractParty getParty(PlayerData playerData) {
|
||||
final Hero hero = Heroes.getInstance().getCharacterManager().getHero(playerData.getPlayer());
|
||||
return hero.getParty() == null ? null : new CustomParty(hero.getParty());
|
||||
}
|
||||
|
||||
private static class CustomParty implements AbstractParty {
|
||||
private final HeroParty party;
|
||||
|
||||
public CustomParty(HeroParty party) {
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMember(@NotNull Player player) {
|
||||
return party.isPartyMember(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerData> getOnlineMembers() {
|
||||
final List<PlayerData> list = new ArrayList<>();
|
||||
|
||||
for (Hero hero : party.getMembers())
|
||||
try {
|
||||
list.add(PlayerData.get(hero.getPlayer()));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countMembers() {
|
||||
return party.getMembers().size();
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.party.AbstractParty;
|
||||
import net.Indyuce.mmocore.party.PartyModule;
|
||||
import net.Indyuce.mmocore.party.PartyUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -43,8 +44,8 @@ public class McMMOPartyModule implements PartyModule, Listener {
|
||||
int membersSize = party.getMembers().size();
|
||||
if(membersSize!=1 || party.getOnlineMembers().get(0)!=event.getPlayer()) {
|
||||
party.getOnlineMembers()
|
||||
.forEach(p -> applyStatBonuses(PlayerData.get(p), membersSize+1));
|
||||
applyStatBonuses(PlayerData.get(event.getPlayer()), membersSize+1);
|
||||
.forEach(p -> PartyUtils.applyStatBonuses(PlayerData.get(p), membersSize+1));
|
||||
PartyUtils.applyStatBonuses(PlayerData.get(event.getPlayer()), membersSize+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -54,13 +55,13 @@ public class McMMOPartyModule implements PartyModule, Listener {
|
||||
//This is the size of the party before the player leaves=> we decrement it by 1.
|
||||
int membersSize = party.getMembers().size() - 1;
|
||||
party.getOnlineMembers()
|
||||
.forEach(p -> applyStatBonuses(PlayerData.get(p), membersSize));
|
||||
clearStatBonuses(PlayerData.get(event.getPlayer().getPlayer()));
|
||||
.forEach(p -> PartyUtils.applyStatBonuses(PlayerData.get(p), membersSize));
|
||||
PartyUtils.clearStatBonuses(PlayerData.get(event.getPlayer().getPlayer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CustomParty implements AbstractParty {
|
||||
private static class CustomParty implements AbstractParty {
|
||||
private final Party party;
|
||||
|
||||
public CustomParty(Party party) {
|
||||
|
@ -0,0 +1,59 @@
|
||||
package net.Indyuce.mmocore.party.compat;
|
||||
|
||||
import io.lumine.mythic.lib.data.SynchronizedDataHolder;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
|
||||
import net.Indyuce.mmocore.party.provided.Party;
|
||||
import net.playavalon.mythicdungeons.api.party.IDungeonParty;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Used to inject MMOCore party system into MythicDungeons
|
||||
*/
|
||||
public class MythicDungeonsPartyInjector extends MMOCorePartyModule {
|
||||
public MythicDungeonsPartyInjector() {
|
||||
MMOCore.plugin.getLogger().log(Level.INFO, "Injecting MMOCore party system into MythicDungeons");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Party newRegisteredParty(PlayerData owner) {
|
||||
final CustomParty party = new CustomParty(this, owner);
|
||||
parties.add(party);
|
||||
party.initDungeonParty(MMOCore.plugin);
|
||||
return party;
|
||||
}
|
||||
|
||||
private static class CustomParty extends Party implements IDungeonParty {
|
||||
public CustomParty(MMOCorePartyModule module, PlayerData owner) {
|
||||
super(module, owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlayer(Player player) {
|
||||
addMember(PlayerData.get(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlayer(Player player) {
|
||||
removeMember(PlayerData.get(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Player> getPlayers() {
|
||||
return getMembers().stream().map(SynchronizedDataHolder::getPlayer).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public OfflinePlayer getLeader() {
|
||||
return getOwner().getPlayer();
|
||||
}
|
||||
}
|
||||
}
|
@ -29,8 +29,7 @@ public class MythicDungeonsPartyModule implements PartyModule, Listener {
|
||||
return party == null ? null : new CustomParty(party);
|
||||
}
|
||||
|
||||
|
||||
static class CustomParty implements AbstractParty {
|
||||
private static class CustomParty implements AbstractParty {
|
||||
private final MythicParty party;
|
||||
|
||||
public CustomParty(MythicParty party) {
|
||||
|
@ -3,11 +3,9 @@ package net.Indyuce.mmocore.party.compat;
|
||||
import com.civious.obteam.mechanics.Team;
|
||||
import com.civious.obteam.mechanics.TeamManager;
|
||||
import com.civious.obteam.mechanics.TeamMember;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.party.AbstractParty;
|
||||
import net.Indyuce.mmocore.party.PartyModule;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -23,8 +21,7 @@ public class OBTeamPartyModule implements PartyModule, Listener {
|
||||
final @Nullable Team team = TeamManager.getInstance().getTeam(playerData.getPlayer());
|
||||
return team == null ? null : new CustomParty(team);
|
||||
}
|
||||
|
||||
class CustomParty implements AbstractParty {
|
||||
private static class CustomParty implements AbstractParty {
|
||||
private final Team team;
|
||||
|
||||
public CustomParty(Team team) {
|
||||
|
@ -22,7 +22,7 @@ public class PAFPartyModule implements PartyModule {
|
||||
return party == null ? null : new CustomParty(party);
|
||||
}
|
||||
|
||||
class CustomParty implements AbstractParty {
|
||||
private static class CustomParty implements AbstractParty {
|
||||
private final PlayerParty party;
|
||||
|
||||
public CustomParty(PlayerParty party) {
|
||||
|
@ -22,7 +22,7 @@ public class PAFProxyPartyModule implements PartyModule {
|
||||
return party == null ? null : new CustomParty(party);
|
||||
}
|
||||
|
||||
class CustomParty implements AbstractParty {
|
||||
private static class CustomParty implements AbstractParty {
|
||||
private final PlayerParty party;
|
||||
|
||||
public CustomParty(PlayerParty party) {
|
||||
|
@ -10,6 +10,7 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.party.AbstractParty;
|
||||
import net.Indyuce.mmocore.party.PartyModule;
|
||||
import net.Indyuce.mmocore.party.PartyUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -39,18 +40,18 @@ public class PartiesPartyModule implements PartyModule, Listener {
|
||||
public void onPlayerJoin(BukkitPartiesPlayerPostJoinEvent event) {
|
||||
int membersSize = event.getParty().getMembers().size();
|
||||
event.getParty().getOnlineMembers()
|
||||
.forEach(p -> applyStatBonuses(PlayerData.get(p.getPlayerUUID()), membersSize));
|
||||
.forEach(p -> PartyUtils.applyStatBonuses(PlayerData.get(p.getPlayerUUID()), membersSize));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeave(BukkitPartiesPlayerPostLeaveEvent event) {
|
||||
int membersSize = event.getParty().getMembers().size();
|
||||
clearStatBonuses(PlayerData.get(event.getPartyPlayer().getPlayerUUID()));
|
||||
PartyUtils.clearStatBonuses(PlayerData.get(event.getPartyPlayer().getPlayerUUID()));
|
||||
event.getParty().getOnlineMembers()
|
||||
.forEach(p -> applyStatBonuses(PlayerData.get(p.getPlayerUUID()), membersSize));
|
||||
.forEach(p -> PartyUtils.applyStatBonuses(PlayerData.get(p.getPlayerUUID()), membersSize));
|
||||
}
|
||||
|
||||
class CustomParty implements AbstractParty {
|
||||
private static class CustomParty implements AbstractParty {
|
||||
private final Party party;
|
||||
|
||||
public CustomParty(Party party) {
|
||||
|
@ -9,13 +9,14 @@ import org.bukkit.Bukkit;
|
||||
import java.util.*;
|
||||
|
||||
public class MMOCorePartyModule implements PartyModule {
|
||||
private final Set<Party> parties = new HashSet<>();
|
||||
private final Map<UUID, Party> playerParties = new HashMap<>();
|
||||
protected final Set<Party> parties = new HashSet<>();
|
||||
protected final Map<UUID, Party> playerParties = new HashMap<>();
|
||||
|
||||
public MMOCorePartyModule() {
|
||||
Bukkit.getPluginManager().registerEvents(new PartyListener(this), MMOCore.plugin);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void registerParty(Party party) {
|
||||
parties.add(party);
|
||||
}
|
||||
@ -24,8 +25,8 @@ public class MMOCorePartyModule implements PartyModule {
|
||||
* Creates and registers a new party with given owner
|
||||
*/
|
||||
public Party newRegisteredParty(PlayerData owner) {
|
||||
Party party = new Party(this, owner);
|
||||
registerParty(party);
|
||||
final Party party = new Party(this, owner);
|
||||
parties.add(party);
|
||||
return party;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import net.Indyuce.mmocore.gui.api.PluginInventory;
|
||||
import net.Indyuce.mmocore.gui.social.party.EditablePartyView;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
import net.Indyuce.mmocore.party.AbstractParty;
|
||||
import net.Indyuce.mmocore.party.PartyUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -107,8 +108,8 @@ public class Party implements AbstractParty {
|
||||
members.remove(data);
|
||||
|
||||
module.setParty(data, null);
|
||||
module.clearStatBonuses(data);
|
||||
members.forEach(member -> module.applyStatBonuses(member, members.size()));
|
||||
PartyUtils.clearStatBonuses(data);
|
||||
members.forEach(member -> PartyUtils.applyStatBonuses(member, members.size()));
|
||||
updateOpenInventories();
|
||||
|
||||
// Disband the party if no member left
|
||||
@ -132,7 +133,7 @@ public class Party implements AbstractParty {
|
||||
|
||||
module.setParty(data, this);
|
||||
members.add(data);
|
||||
members.forEach(member -> module.applyStatBonuses(member, members.size()));
|
||||
members.forEach(member -> PartyUtils.applyStatBonuses(member, members.size()));
|
||||
|
||||
updateOpenInventories();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user