mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-05 06:57:35 +01:00
"potion-" is required to create a set bonus potion effect
refactor method
This commit is contained in:
parent
ccc4c50d16
commit
a4612a1c82
@ -21,9 +21,9 @@ import net.Indyuce.mmoitems.stat.data.ParticleData;
|
|||||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||||
|
|
||||||
public class ItemSet {
|
public class ItemSet {
|
||||||
private Map<Integer, SetBonuses> bonuses = new HashMap<>();
|
private final Map<Integer, SetBonuses> bonuses = new HashMap<>();
|
||||||
private List<String> loreTag;
|
private final List<String> loreTag;
|
||||||
private String name, id;
|
private final String name, id;
|
||||||
|
|
||||||
public ItemSet(ConfigurationSection section) {
|
public ItemSet(ConfigurationSection section) {
|
||||||
this.id = section.getName().toUpperCase().replace("-", "_");
|
this.id = section.getName().toUpperCase().replace("-", "_");
|
||||||
@ -40,20 +40,6 @@ public class ItemSet {
|
|||||||
for (String key : section.getConfigurationSection("bonuses." + j).getKeys(false)) {
|
for (String key : section.getConfigurationSection("bonuses." + j).getKeys(false)) {
|
||||||
String format = key.toUpperCase().replace("-", "_").replace(" ", "_");
|
String format = key.toUpperCase().replace("-", "_").replace(" ", "_");
|
||||||
|
|
||||||
// stat
|
|
||||||
ItemStat stat = MMOItems.plugin.getStats().get(format);
|
|
||||||
if (stat != null) {
|
|
||||||
bonuses.addStat(stat, section.getDouble("bonuses." + j + "." + key));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// potion effect
|
|
||||||
PotionEffectType potionEffectType = PotionEffectType.getByName(format);
|
|
||||||
if (potionEffectType != null) {
|
|
||||||
bonuses.addPotionEffect(new PotionEffect(potionEffectType, MMOUtils.getEffectDuration(potionEffectType), section.getInt("bonuses." + j + "." + key) - 1));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ability
|
// ability
|
||||||
if (key.startsWith("ability-")) {
|
if (key.startsWith("ability-")) {
|
||||||
AbilityData ability = new AbilityData(null, section.getConfigurationSection("bonuses." + j + "." + key));
|
AbilityData ability = new AbilityData(null, section.getConfigurationSection("bonuses." + j + "." + key));
|
||||||
@ -61,7 +47,17 @@ public class ItemSet {
|
|||||||
bonuses.addAbility(ability);
|
bonuses.addAbility(ability);
|
||||||
else
|
else
|
||||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Couldn't load set bonus ability, path: " + id + ".bonuses." + j + "." + key);
|
MMOItems.plugin.getLogger().log(Level.WARNING, "Couldn't load set bonus ability, path: " + id + ".bonuses." + j + "." + key);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// potion effect
|
||||||
|
if (key.startsWith("potion-")) {
|
||||||
|
PotionEffectType potionEffectType = PotionEffectType.getByName(format.substring("potion-".length()));
|
||||||
|
if (potionEffectType != null) {
|
||||||
|
bonuses.addPotionEffect(new PotionEffect(potionEffectType, MMOUtils.getEffectDuration(potionEffectType), section.getInt("bonuses." + j + "." + key) - 1));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// particle effect
|
// particle effect
|
||||||
@ -72,6 +68,15 @@ public class ItemSet {
|
|||||||
else
|
else
|
||||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Couldn't load set bonus particle effect, path: " + id + ".bonuses." + j + "." + key);
|
MMOItems.plugin.getLogger().log(Level.WARNING, "Couldn't load set bonus particle effect, path: " + id + ".bonuses." + j + "." + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stat
|
||||||
|
ItemStat stat = MMOItems.plugin.getStats().get(format);
|
||||||
|
if (stat != null) {
|
||||||
|
bonuses.addStat(stat, section.getDouble("bonuses." + j + "." + key));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load set bonus '" + key + "' from " + id + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bonuses.put(j, bonuses);
|
this.bonuses.put(j, bonuses);
|
||||||
@ -82,7 +87,7 @@ public class ItemSet {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getID() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class Item_Set extends StringStat {
|
|||||||
new StatEdition(inv, ItemStat.SET).enable("Write in the chat the item set ID.");
|
new StatEdition(inv, ItemStat.SET).enable("Write in the chat the item set ID.");
|
||||||
player.sendMessage("");
|
player.sendMessage("");
|
||||||
for (ItemSet set : MMOItems.plugin.getSets().getAll())
|
for (ItemSet set : MMOItems.plugin.getSets().getAll())
|
||||||
player.sendMessage(ChatColor.GRAY + "* " + ChatColor.GREEN + set.getID() + ChatColor.GRAY + " (" + set.getName() + ChatColor.GRAY + ")");
|
player.sendMessage(ChatColor.GRAY + "* " + ChatColor.GREEN + set.getId() + ChatColor.GRAY + " (" + set.getName() + ChatColor.GRAY + ")");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user