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<SkillSlot> skillSlots = new ArrayList<>();
|
||||||
private final List<SkillTree> skillTrees = 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, LinearValue> stats = new HashMap<>();
|
||||||
private final Map<String, ClassSkill> skills = new LinkedHashMap<>();
|
private final Map<String, ClassSkill> skills = new LinkedHashMap<>();
|
||||||
private final List<Subclass> subclasses = new ArrayList<>();
|
private final List<Subclass> subclasses = new ArrayList<>();
|
||||||
@ -206,7 +206,14 @@ public class PlayerClass implements ExperienceObject, PreloadedObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Casting particle
|
// 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
|
// Other class options
|
||||||
if (config.contains("options"))
|
if (config.contains("options"))
|
||||||
@ -216,7 +223,7 @@ public class PlayerClass implements ExperienceObject, PreloadedObject {
|
|||||||
config.getBoolean("options." + key));
|
config.getBoolean("options." + key));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING,
|
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
|
// Experience sources
|
||||||
@ -366,9 +373,9 @@ public class PlayerClass implements ExperienceObject, PreloadedObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return A list of passive skills which correspond to class
|
* @return A list of passive skills which correspond to class
|
||||||
* scripts wrapped in a format recognized by MythicLib.
|
* scripts wrapped in a format recognized by MythicLib.
|
||||||
* Class scripts are handled just like
|
* Class scripts are handled just like
|
||||||
* passive skills
|
* passive skills
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<PassiveSkill> getScripts() {
|
public List<PassiveSkill> getScripts() {
|
||||||
|
@ -1,40 +1,41 @@
|
|||||||
package net.Indyuce.mmocore.loot.chest.particle;
|
package net.Indyuce.mmocore.loot.chest.particle;
|
||||||
|
|
||||||
|
import io.lumine.mythic.lib.UtilityMethods;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class CastingParticle {
|
public class CastingParticle {
|
||||||
private final Consumer<Location> display;
|
private final Consumer<Location> display;
|
||||||
|
|
||||||
public CastingParticle(ConfigurationSection config) {
|
public CastingParticle(@NotNull ConfigurationSection config) {
|
||||||
Validate.notNull(config, "Casting particle config cannot be null");
|
Validate.notNull(config, "Casting particle config cannot be null");
|
||||||
|
|
||||||
String format = config.getString("particle");
|
final Particle particle = Particle.valueOf(UtilityMethods.enumName(Objects.requireNonNull(config.getString("particle"), "Could not find particle name")));
|
||||||
Validate.notNull(format, "Could not read particle name");
|
|
||||||
Particle particle = Particle.valueOf(format.toUpperCase().replace("-", "_").replace(" ", "_"));
|
|
||||||
|
|
||||||
if (config.contains("color")) {
|
// Color
|
||||||
final float size = (float) config.getDouble("size") == 0 ? 1 : (float) Math.max(config.getDouble("size"), 0);
|
if (particle.getDataType() == Particle.DustOptions.class) {
|
||||||
Color color = Color.fromRGB(config.getInt("color.red"), config.getInt("color.green"), config.getInt("color.blue"));
|
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));
|
display = loc -> loc.getWorld().spawnParticle(particle, loc, 1, new Particle.DustOptions(color, size));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.contains("material")) {
|
// Material
|
||||||
format = config.getString("material");
|
else if (particle.getDataType() == BlockData.class) {
|
||||||
Validate.notNull(format, "Could not read material name");
|
final Material material = Material.valueOf(UtilityMethods.enumName(Objects.requireNonNull(config.getString("material"), "Particle requires a block")));
|
||||||
Material material = Material.valueOf(format.toUpperCase().replace("-", "_").replace(" ", "_"));
|
|
||||||
display = loc -> loc.getWorld().spawnParticle(particle, loc, 1, material.createBlockData());
|
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) {
|
public CastingParticle(Particle particle) {
|
||||||
|
Loading…
Reference in New Issue
Block a user