mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-22 04:37:42 +01:00
Fixed item set particles
This commit is contained in:
parent
1120222e91
commit
021813b57e
@ -10,6 +10,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -95,11 +96,14 @@ public class ItemSet {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
public SetBonuses getBonuses(int items) {
|
public SetBonuses getBonuses(int items) {
|
||||||
SetBonuses bonuses = new SetBonuses();
|
final SetBonuses bonuses = new SetBonuses();
|
||||||
for (int j = 2; j <= Math.min(items, itemLimit); j++)
|
for (int j = 2; j <= Math.min(items, itemLimit); j++) {
|
||||||
if (this.bonuses.containsKey(j))
|
final @Nullable SetBonuses extra = this.bonuses.get(j);
|
||||||
bonuses.merge(this.bonuses.get(j));
|
if (extra != null)
|
||||||
|
bonuses.merge(extra);
|
||||||
|
}
|
||||||
return bonuses;
|
return bonuses;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +114,8 @@ public class ItemSet {
|
|||||||
public static class SetBonuses {
|
public static class SetBonuses {
|
||||||
private final Map<ItemStat<?, ?>, Double> stats = new HashMap<>();
|
private final Map<ItemStat<?, ?>, Double> stats = new HashMap<>();
|
||||||
private final Map<PotionEffectType, PotionEffect> permEffects = new HashMap<>();
|
private final Map<PotionEffectType, PotionEffect> permEffects = new HashMap<>();
|
||||||
private final Set<AbilityData> abilities = new HashSet<>();
|
private final List<AbilityData> abilities = new ArrayList<>();
|
||||||
private final Set<ParticleData> particles = new HashSet<>();
|
private final List<ParticleData> particles = new ArrayList<>();
|
||||||
private final ArrayList<String> permissions = new ArrayList<>();
|
private final ArrayList<String> permissions = new ArrayList<>();
|
||||||
|
|
||||||
public void addStat(ItemStat<?, ?> stat, double value) {
|
public void addStat(ItemStat<?, ?> stat, double value) {
|
||||||
@ -150,11 +154,11 @@ public class ItemSet {
|
|||||||
return permEffects.values();
|
return permEffects.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<ParticleData> getParticles() {
|
public List<ParticleData> getParticles() {
|
||||||
return particles;
|
return particles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<AbilityData> getAbilities() {
|
public List<AbilityData> getAbilities() {
|
||||||
return abilities;
|
return abilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,9 +174,9 @@ public class ItemSet {
|
|||||||
if (!permEffects.containsKey(effect.getType()) || permEffects.get(effect.getType()).getAmplifier() < effect.getAmplifier())
|
if (!permEffects.containsKey(effect.getType()) || permEffects.get(effect.getType()).getAmplifier() < effect.getAmplifier())
|
||||||
permEffects.put(effect.getType(), effect);
|
permEffects.put(effect.getType(), effect);
|
||||||
|
|
||||||
abilities.addAll(bonuses.getAbilities());
|
abilities.addAll(bonuses.abilities);
|
||||||
|
particles.addAll(bonuses.particles);
|
||||||
permissions.addAll(bonuses.getPermissions());
|
permissions.addAll(bonuses.permissions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,23 +258,21 @@ public class PlayerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the player's item set
|
// Calculate the player's item set
|
||||||
Map<ItemSet, Integer> sets = new HashMap<>();
|
final Map<ItemSet, Integer> itemSetCount = new HashMap<>();
|
||||||
for (EquippedItem equipped : inventory.getEquipped()) {
|
for (EquippedItem equipped : inventory.getEquipped()) {
|
||||||
VolatileMMOItem item = equipped.getCached();
|
final String tag = equipped.getCached().getNBT().getString("MMOITEMS_ITEM_SET");
|
||||||
String tag = item.getNBT().getString("MMOITEMS_ITEM_SET");
|
final @Nullable ItemSet itemSet = MMOItems.plugin.getSets().get(tag);
|
||||||
ItemSet itemSet = MMOItems.plugin.getSets().get(tag);
|
|
||||||
if (itemSet == null)
|
if (itemSet == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
sets.put(itemSet, sets.getOrDefault(itemSet, 0) + 1);
|
itemSetCount.put(itemSet, itemSetCount.getOrDefault(itemSet, 0) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset and compute item set bonuses
|
// Reset and compute item set bonuses
|
||||||
setBonuses = null;
|
setBonuses = null;
|
||||||
for (Map.Entry<ItemSet, Integer> equippedSetBonus : sets.entrySet()) {
|
for (Map.Entry<ItemSet, Integer> equippedSetBonus : itemSetCount.entrySet()) {
|
||||||
|
|
||||||
if (setBonuses == null) {
|
if (setBonuses == null) {
|
||||||
|
|
||||||
// Set set bonuses
|
// Set set bonuses
|
||||||
setBonuses = equippedSetBonus.getKey().getBonuses(equippedSetBonus.getValue());
|
setBonuses = equippedSetBonus.getKey().getBonuses(equippedSetBonus.getValue());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user