mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-29 01:05:40 +01:00
Improved console error warnings for casting mode particles of classes
This commit is contained in:
parent
e48f536572
commit
2f004e2212
@ -68,7 +68,7 @@ public class PlayerClass implements ExperienceObject, PreloadedObject {
|
||||
|
||||
private final List<SkillSlot> skillSlots = new ArrayList<>();
|
||||
private final List<SkillTree> skillTrees = new ArrayList<>();
|
||||
private final List<PassiveSkill> classScripts = new LinkedList();
|
||||
private final List<PassiveSkill> classScripts = new ArrayList<>();
|
||||
private final Map<String, LinearValue> stats = new HashMap<>();
|
||||
private final Map<String, ClassSkill> skills = new LinkedHashMap<>();
|
||||
private final List<Subclass> subclasses = new ArrayList<>();
|
||||
@ -206,7 +206,14 @@ public class PlayerClass implements ExperienceObject, PreloadedObject {
|
||||
}
|
||||
|
||||
// Casting particle
|
||||
castParticle = config.contains("cast-particle") ? new CastingParticle(config.getConfigurationSection("cast-particle")) : null;
|
||||
CastingParticle castingParticle;
|
||||
try {
|
||||
castingParticle = config.contains("cast-particle") ? new CastingParticle(config.getConfigurationSection("cast-particle")) : null;
|
||||
} catch (RuntimeException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load casting mode particle of class '" + getId() + "': " + exception.getMessage());
|
||||
castingParticle = null;
|
||||
}
|
||||
this.castParticle = castingParticle;
|
||||
|
||||
// Other class options
|
||||
if (config.contains("options"))
|
||||
@ -216,7 +223,7 @@ public class PlayerClass implements ExperienceObject, PreloadedObject {
|
||||
config.getBoolean("options." + key));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not load option '" + key + "' from class '" + key + "': " + exception.getMessage());
|
||||
"Could not load option '" + key + "' from class '" + getId() + "': " + exception.getMessage());
|
||||
}
|
||||
|
||||
// Experience sources
|
||||
@ -366,9 +373,9 @@ public class PlayerClass implements ExperienceObject, PreloadedObject {
|
||||
|
||||
/**
|
||||
* @return A list of passive skills which correspond to class
|
||||
* scripts wrapped in a format recognized by MythicLib.
|
||||
* Class scripts are handled just like
|
||||
* passive skills
|
||||
* scripts wrapped in a format recognized by MythicLib.
|
||||
* Class scripts are handled just like
|
||||
* passive skills
|
||||
*/
|
||||
@NotNull
|
||||
public List<PassiveSkill> getScripts() {
|
||||
|
@ -1,40 +1,41 @@
|
||||
package net.Indyuce.mmocore.loot.chest.particle;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CastingParticle {
|
||||
private final Consumer<Location> display;
|
||||
|
||||
public CastingParticle(ConfigurationSection config) {
|
||||
public CastingParticle(@NotNull ConfigurationSection config) {
|
||||
Validate.notNull(config, "Casting particle config cannot be null");
|
||||
|
||||
String format = config.getString("particle");
|
||||
Validate.notNull(format, "Could not read particle name");
|
||||
Particle particle = Particle.valueOf(format.toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
final Particle particle = Particle.valueOf(UtilityMethods.enumName(Objects.requireNonNull(config.getString("particle"), "Could not find particle name")));
|
||||
|
||||
if (config.contains("color")) {
|
||||
final float size = (float) config.getDouble("size") == 0 ? 1 : (float) Math.max(config.getDouble("size"), 0);
|
||||
Color color = Color.fromRGB(config.getInt("color.red"), config.getInt("color.green"), config.getInt("color.blue"));
|
||||
// Color
|
||||
if (particle.getDataType() == Particle.DustOptions.class) {
|
||||
final float size = Math.max((float) config.getDouble("size", 1), 0);
|
||||
final Color color = Color.fromRGB(config.getInt("color.red"), config.getInt("color.green"), config.getInt("color.blue"));
|
||||
display = loc -> loc.getWorld().spawnParticle(particle, loc, 1, new Particle.DustOptions(color, size));
|
||||
return;
|
||||
}
|
||||
|
||||
if (config.contains("material")) {
|
||||
format = config.getString("material");
|
||||
Validate.notNull(format, "Could not read material name");
|
||||
Material material = Material.valueOf(format.toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
// Material
|
||||
else if (particle.getDataType() == BlockData.class) {
|
||||
final Material material = Material.valueOf(UtilityMethods.enumName(Objects.requireNonNull(config.getString("material"), "Particle requires a block")));
|
||||
display = loc -> loc.getWorld().spawnParticle(particle, loc, 1, material.createBlockData());
|
||||
return;
|
||||
}
|
||||
|
||||
display = loc -> loc.getWorld().spawnParticle(particle, loc, 0);
|
||||
// Anything else (does not work for all particles)
|
||||
else display = loc -> loc.getWorld().spawnParticle(particle, loc, 0);
|
||||
}
|
||||
|
||||
public CastingParticle(Particle particle) {
|
||||
|
Loading…
Reference in New Issue
Block a user