Fixed item set particles

This commit is contained in:
Indyuce 2022-12-22 00:02:55 +01:00
parent 1120222e91
commit 021813b57e
2 changed files with 20 additions and 18 deletions

View File

@ -10,6 +10,7 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@ -95,11 +96,14 @@ public class ItemSet {
return id;
}
@NotNull
public SetBonuses getBonuses(int items) {
SetBonuses bonuses = new SetBonuses();
for (int j = 2; j <= Math.min(items, itemLimit); j++)
if (this.bonuses.containsKey(j))
bonuses.merge(this.bonuses.get(j));
final SetBonuses bonuses = new SetBonuses();
for (int j = 2; j <= Math.min(items, itemLimit); j++) {
final @Nullable SetBonuses extra = this.bonuses.get(j);
if (extra != null)
bonuses.merge(extra);
}
return bonuses;
}
@ -110,8 +114,8 @@ public class ItemSet {
public static class SetBonuses {
private final Map<ItemStat<?, ?>, Double> stats = new HashMap<>();
private final Map<PotionEffectType, PotionEffect> permEffects = new HashMap<>();
private final Set<AbilityData> abilities = new HashSet<>();
private final Set<ParticleData> particles = new HashSet<>();
private final List<AbilityData> abilities = new ArrayList<>();
private final List<ParticleData> particles = new ArrayList<>();
private final ArrayList<String> permissions = new ArrayList<>();
public void addStat(ItemStat<?, ?> stat, double value) {
@ -150,11 +154,11 @@ public class ItemSet {
return permEffects.values();
}
public Set<ParticleData> getParticles() {
public List<ParticleData> getParticles() {
return particles;
}
public Set<AbilityData> getAbilities() {
public List<AbilityData> getAbilities() {
return abilities;
}
@ -170,9 +174,9 @@ public class ItemSet {
if (!permEffects.containsKey(effect.getType()) || permEffects.get(effect.getType()).getAmplifier() < effect.getAmplifier())
permEffects.put(effect.getType(), effect);
abilities.addAll(bonuses.getAbilities());
permissions.addAll(bonuses.getPermissions());
abilities.addAll(bonuses.abilities);
particles.addAll(bonuses.particles);
permissions.addAll(bonuses.permissions);
}
}

View File

@ -258,23 +258,21 @@ public class PlayerData {
}
// Calculate the player's item set
Map<ItemSet, Integer> sets = new HashMap<>();
final Map<ItemSet, Integer> itemSetCount = new HashMap<>();
for (EquippedItem equipped : inventory.getEquipped()) {
VolatileMMOItem item = equipped.getCached();
String tag = item.getNBT().getString("MMOITEMS_ITEM_SET");
ItemSet itemSet = MMOItems.plugin.getSets().get(tag);
final String tag = equipped.getCached().getNBT().getString("MMOITEMS_ITEM_SET");
final @Nullable ItemSet itemSet = MMOItems.plugin.getSets().get(tag);
if (itemSet == null)
continue;
sets.put(itemSet, sets.getOrDefault(itemSet, 0) + 1);
itemSetCount.put(itemSet, itemSetCount.getOrDefault(itemSet, 0) + 1);
}
// Reset and compute item set bonuses
setBonuses = null;
for (Map.Entry<ItemSet, Integer> equippedSetBonus : sets.entrySet()) {
for (Map.Entry<ItemSet, Integer> equippedSetBonus : itemSetCount.entrySet()) {
if (setBonuses == null) {
// Set set bonuses
setBonuses = equippedSetBonus.getKey().getBonuses(equippedSetBonus.getValue());