Fixed an issue with party buffs

This commit is contained in:
Indyuce 2020-03-19 14:42:34 +01:00
parent 8417ca60ca
commit c3145bf3b3
3 changed files with 13 additions and 14 deletions

View File

@ -94,10 +94,10 @@ public class Party {
MMOCore.plugin.requestManager.registerRequest(request);
}
// @Override
// public boolean equals(Object obj) {
// return obj instanceof Party && ((Party) obj).uuid.equals(uuid);
// }
@Override
public boolean equals(Object obj) {
return obj instanceof Party && ((Party) obj).owner.getUniqueId().equals(owner.getUniqueId());
}
/*
* this class makes controling entries and departures and APPLYING PARTY
@ -117,14 +117,14 @@ public class Party {
public void add(PlayerData player) {
members.add(player);
refreshAttributes();
members.forEach(member -> applyAttributes(member));
}
public void remove(PlayerData player) {
members.remove(player);
refreshAttributes();
refreshAttributes(player);
members.forEach(member -> applyAttributes(member));
clearAttributes(player);
}
public void forEach(Consumer<? super PlayerData> action) {
@ -135,12 +135,12 @@ public class Party {
return members.size();
}
public void refreshAttributes() {
members.forEach(member -> refreshAttributes(member));
private void applyAttributes(PlayerData player) {
MMOCore.plugin.partyManager.getBonuses().forEach(stat -> player.getStats().getInstance(stat).addModifier("mmocoreParty", MMOCore.plugin.partyManager.getBonus(stat).multiply(members.size() - 1)));
}
public void refreshAttributes(PlayerData player) {
MMOCore.plugin.partyManager.getBonuses().forEach(stat -> player.getStats().getInstance(stat).addModifier("party", MMOCore.plugin.partyManager.getBonus(stat)));
private void clearAttributes(PlayerData player) {
MMOCore.plugin.partyManager.getBonuses().forEach(stat -> player.getStats().getInstance(stat).remove("mmocoreParty"));
}
}
}

View File

@ -105,8 +105,6 @@ public class ConfigManager {
messages = new ConfigFile("messages").getConfig();
hotbarSwap = MMOCore.plugin.getConfig().getBoolean("hotbar-swap");
chatInput = MMOCore.plugin.getConfig().getBoolean("use-chat-input");
expPartyBuff = MMOCore.plugin.getConfig().getDouble("party.buff.experience");
regenPartyBuff = MMOCore.plugin.getConfig().getDouble("party.buff.health-regen");
partyChatPrefix = MMOCore.plugin.getConfig().getString("party.chat-prefix");
formatSymbols.setDecimalSeparator(getFirstChar(MMOCore.plugin.getConfig().getString("number-format.decimal-separator"), ','));
combatLogTimer = MMOCore.plugin.getConfig().getInt("combat-log.timer");

View File

@ -34,6 +34,7 @@ public class PartyManager extends MMOManager {
}
public void unregisterParty(Party party) {
// IMPORTANT: clears all party stats before unregistering the party
party.getMembers().forEach(member -> party.removeMember(member));
parties.remove(party);
}
@ -45,7 +46,7 @@ public class PartyManager extends MMOManager {
public StatModifier getBonus(StatType stat) {
return buffs.get(stat);
}
public Set<StatType> getBonuses() {
return buffs.keySet();
}