mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2024-12-31 20:02:12 +00:00
Allow disabling/enabling effects through settings files
This commit is contained in:
parent
950a39f6d6
commit
b07f844d59
13 changed files with 115 additions and 54 deletions
|
@ -2,7 +2,6 @@ package dev.esophose.playerparticles.command;
|
|||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.api.PlayerParticlesAPI;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.LocaleManager;
|
||||
import dev.esophose.playerparticles.manager.PermissionManager;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
|
|
|
@ -2,7 +2,6 @@ package dev.esophose.playerparticles.command;
|
|||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.api.PlayerParticlesAPI;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.LocaleManager;
|
||||
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
|
||||
import dev.esophose.playerparticles.manager.PermissionManager;
|
||||
|
|
|
@ -5,6 +5,7 @@ import dev.esophose.playerparticles.manager.LocaleManager;
|
|||
import dev.esophose.playerparticles.manager.ParticleStyleManager;
|
||||
import dev.esophose.playerparticles.manager.PermissionManager;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
import dev.esophose.playerparticles.particles.ParticleEffect;
|
||||
import dev.esophose.playerparticles.styles.DefaultStyles;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -16,6 +17,7 @@ public class ReloadCommandModule implements CommandModule {
|
|||
LocaleManager localeManager = playerParticles.getManager(LocaleManager.class);
|
||||
if (playerParticles.getManager(PermissionManager.class).canReloadPlugin(pplayer.getMessageDestination())) {
|
||||
playerParticles.reload();
|
||||
ParticleEffect.reloadSettings();
|
||||
DefaultStyles.reloadSettings(playerParticles.getManager(ParticleStyleManager.class));
|
||||
localeManager.sendMessage(pplayer, "reload-success");
|
||||
playerParticles.getLogger().info("Reloaded configuration.");
|
||||
|
|
|
@ -2,7 +2,6 @@ package dev.esophose.playerparticles.command;
|
|||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.api.PlayerParticlesAPI;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.LocaleManager;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
import dev.esophose.playerparticles.particles.ParticleEffect;
|
||||
|
@ -21,7 +20,6 @@ public class RemoveCommandModule implements CommandModule {
|
|||
|
||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||
|
||||
if (args.length == 0) {
|
||||
localeManager.sendMessage(pplayer, "remove-no-args");
|
||||
|
@ -57,34 +55,32 @@ public class RemoveCommandModule implements CommandModule {
|
|||
ParticleStyle style = ParticleStyle.fromName(args[0]);
|
||||
|
||||
if (effect != null) {
|
||||
int removedCount = 0;
|
||||
Set<Integer> toRemove = new HashSet<>();
|
||||
ParticleGroup activeGroup = pplayer.getActiveParticleGroup();
|
||||
for (int i = activeGroup.getParticles().size() - 1; i >= 0; i--) {
|
||||
if (activeGroup.getParticles().get(i).getEffect() == effect) {
|
||||
activeGroup.getParticles().remove(i);
|
||||
removedCount++;
|
||||
}
|
||||
}
|
||||
for (int id : activeGroup.getParticles().keySet())
|
||||
if (activeGroup.getParticles().get(id).getEffect() == effect)
|
||||
toRemove.add(id);
|
||||
for (int id : toRemove)
|
||||
activeGroup.getParticles().remove(id);
|
||||
|
||||
if (removedCount > 0) {
|
||||
if (toRemove.size() > 0) {
|
||||
PlayerParticlesAPI.getInstance().savePlayerParticleGroup(pplayer.getPlayer(), activeGroup);
|
||||
localeManager.sendMessage(pplayer, "remove-effect-success", StringPlaceholders.builder("amount", removedCount).addPlaceholder("effect", effect.getName()).build());
|
||||
localeManager.sendMessage(pplayer, "remove-effect-success", StringPlaceholders.builder("amount", toRemove.size()).addPlaceholder("effect", effect.getName()).build());
|
||||
} else {
|
||||
localeManager.sendMessage(pplayer, "remove-effect-none", StringPlaceholders.single("effect", effect.getName()));
|
||||
}
|
||||
} else if (style != null) {
|
||||
int removedCount = 0;
|
||||
Set<Integer> toRemove = new HashSet<>();
|
||||
ParticleGroup activeGroup = pplayer.getActiveParticleGroup();
|
||||
for (int i = activeGroup.getParticles().size() - 1; i >= 0; i--) {
|
||||
if (activeGroup.getParticles().get(i).getStyle() == style) {
|
||||
activeGroup.getParticles().remove(i);
|
||||
removedCount++;
|
||||
}
|
||||
}
|
||||
for (int id : activeGroup.getParticles().keySet())
|
||||
if (activeGroup.getParticles().get(id).getStyle() == style)
|
||||
toRemove.add(id);
|
||||
for (int id : toRemove)
|
||||
activeGroup.getParticles().remove(id);
|
||||
|
||||
if (removedCount > 0) {
|
||||
if (toRemove.size() > 0) {
|
||||
PlayerParticlesAPI.getInstance().savePlayerParticleGroup(pplayer.getPlayer(), activeGroup);
|
||||
localeManager.sendMessage(pplayer, "remove-style-success", StringPlaceholders.builder("amount", removedCount).addPlaceholder("style", style.getName()).build());
|
||||
localeManager.sendMessage(pplayer, "remove-style-success", StringPlaceholders.builder("amount", toRemove.size()).addPlaceholder("style", style.getName()).build());
|
||||
} else {
|
||||
localeManager.sendMessage(pplayer, "remove-style-none", StringPlaceholders.single("style", style.getName()));
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package dev.esophose.playerparticles.command;
|
|||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.api.PlayerParticlesAPI;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.LocaleManager;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
import dev.esophose.playerparticles.particles.ParticleGroup;
|
||||
|
|
|
@ -2,7 +2,6 @@ package dev.esophose.playerparticles.command;
|
|||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.api.PlayerParticlesAPI;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.LocaleManager;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -3,7 +3,6 @@ package dev.esophose.playerparticles.gui;
|
|||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.api.PlayerParticlesAPI;
|
||||
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LocaleManager;
|
||||
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
|
||||
|
@ -29,7 +28,6 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-playerparticles")));
|
||||
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
|
||||
|
||||
this.fillBorder(BorderColor.WHITE);
|
||||
|
|
|
@ -3,7 +3,6 @@ package dev.esophose.playerparticles.gui;
|
|||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.api.PlayerParticlesAPI;
|
||||
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LocaleManager;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
|
@ -21,7 +20,6 @@ public class GuiInventoryEditParticle extends GuiInventory {
|
|||
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-editing-particle", StringPlaceholders.single("id", editingParticle.getId()))));
|
||||
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
|
||||
|
||||
this.fillBorder(BorderColor.RED);
|
||||
|
|
|
@ -4,7 +4,6 @@ import dev.esophose.playerparticles.PlayerParticles;
|
|||
import dev.esophose.playerparticles.api.PlayerParticlesAPI;
|
||||
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
|
||||
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LocaleManager;
|
||||
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
|
||||
|
@ -26,7 +25,6 @@ public class GuiInventoryLoadPresetGroups extends GuiInventory {
|
|||
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-load-a-preset-group")));
|
||||
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
|
||||
|
||||
this.fillBorder(BorderColor.GREEN);
|
||||
|
|
|
@ -6,7 +6,6 @@ import dev.esophose.playerparticles.gui.hook.PlayerChatHook;
|
|||
import dev.esophose.playerparticles.gui.hook.PlayerChatHookData;
|
||||
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
|
||||
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LocaleManager;
|
||||
import dev.esophose.playerparticles.manager.PermissionManager;
|
||||
|
@ -28,7 +27,6 @@ public class GuiInventoryManageGroups extends GuiInventory {
|
|||
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-manage-your-groups")));
|
||||
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
|
||||
|
||||
this.fillBorder(BorderColor.BROWN);
|
||||
|
|
|
@ -3,7 +3,6 @@ package dev.esophose.playerparticles.gui;
|
|||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.api.PlayerParticlesAPI;
|
||||
import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
|
||||
import dev.esophose.playerparticles.manager.DataManager;
|
||||
import dev.esophose.playerparticles.manager.GuiManager;
|
||||
import dev.esophose.playerparticles.manager.LocaleManager;
|
||||
import dev.esophose.playerparticles.manager.PermissionManager;
|
||||
|
@ -24,7 +23,6 @@ public class GuiInventoryManageParticles extends GuiInventory {
|
|||
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-manage-your-particles")));
|
||||
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
|
||||
|
||||
this.fillBorder(BorderColor.ORANGE);
|
||||
|
|
|
@ -108,6 +108,7 @@ public class ConfigurationManager extends Manager {
|
|||
GUI_ICON_EFFECT_DRIPPING_LAVA("gui-icon.effect.dripping_lava", Collections.singletonList("LAVA_BUCKET")),
|
||||
GUI_ICON_EFFECT_DRIPPING_WATER("gui-icon.effect.dripping_water", Collections.singletonList("WATER_BUCKET")),
|
||||
GUI_ICON_EFFECT_DUST("gui-icon.effect.dust", Collections.singletonList("REDSTONE")),
|
||||
GUI_ICON_EFFECT_ELDER_GUARDIAN("gui-icon.effect.elder_guardian", Arrays.asList("ELDER_GUARDIAN_SPAWN_EGG", "PRISMARINE_CRYSTALS")),
|
||||
GUI_ICON_EFFECT_ENCHANT("gui-icon.effect.enchant", Arrays.asList("ENCHANTING_TABLE", "ENCHANTMENT_TABLE")),
|
||||
GUI_ICON_EFFECT_ENCHANTED_HIT("gui-icon.effect.enchanted_hit", Collections.singletonList("DIAMOND_SWORD")),
|
||||
GUI_ICON_EFFECT_END_ROD("gui-icon.effect.end_rod", Collections.singletonList("END_ROD")),
|
||||
|
@ -122,6 +123,7 @@ public class ConfigurationManager extends Manager {
|
|||
GUI_ICON_EFFECT_FIREWORK("gui-icon.effect.firework", Arrays.asList("FIREWORK_ROCKET", "FIREWORK")),
|
||||
GUI_ICON_EFFECT_FISHING("gui-icon.effect.fishing", Collections.singletonList("FISHING_ROD")),
|
||||
GUI_ICON_EFFECT_FLAME("gui-icon.effect.flame", Collections.singletonList("BLAZE_POWDER")),
|
||||
GUI_ICON_EFFECT_FLASH("gui-icon.effect.flash", Collections.singletonList("GOLD_INGOT")),
|
||||
GUI_ICON_EFFECT_FOOTSTEP("gui-icon.effect.footstep", Collections.singletonList("GRASS")),
|
||||
GUI_ICON_EFFECT_HAPPY_VILLAGER("gui-icon.effect.happy_villager", Arrays.asList("DARK_OAK_DOOR", "WOOD_DOOR")),
|
||||
GUI_ICON_EFFECT_HEART("gui-icon.effect.heart", Arrays.asList("POPPY", "RED_ROSE")),
|
||||
|
@ -146,7 +148,7 @@ public class ConfigurationManager extends Manager {
|
|||
GUI_ICON_EFFECT_SPLASH("gui-icon.effect.splash", Arrays.asList("SALMON", "FISH")),
|
||||
GUI_ICON_EFFECT_SQUID_INK("gui-icon.effect.squid_ink", Collections.singletonList("INK_SAC")),
|
||||
GUI_ICON_EFFECT_SWEEP_ATTACK("gui-icon.effect.sweep_attack", Arrays.asList("GOLDEN_SWORD", "GOLD_SWORD")),
|
||||
GUI_ICON_EFFECT_TOTEM_OF_UNDYING("gui-icon.effect.totem_of_undying", Collections.singletonList("TOTEM")),
|
||||
GUI_ICON_EFFECT_TOTEM_OF_UNDYING("gui-icon.effect.totem_of_undying", Arrays.asList("TOTEM_OF_UNDYING", "TOTEM")),
|
||||
GUI_ICON_EFFECT_UNDERWATER("gui-icon.effect.underwater", Collections.singletonList("TURTLE_HELMET")),
|
||||
GUI_ICON_EFFECT_WITCH("gui-icon.effect.witch", Collections.singletonList("CAULDRON")),
|
||||
GUI_ICON_STYLE("gui-icon.style", null),
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package dev.esophose.playerparticles.particles;
|
||||
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
|
||||
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
|
||||
import dev.esophose.playerparticles.manager.ParticleManager;
|
||||
import dev.esophose.playerparticles.util.NMSUtil;
|
||||
import dev.esophose.playerparticles.util.ParticleUtils;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
|
@ -44,7 +46,7 @@ public enum ParticleEffect {
|
|||
DRIPPING_LAVA("DRIP_LAVA"),
|
||||
DRIPPING_WATER("DRIP_WATER"),
|
||||
DUST("REDSTONE", ParticleProperty.COLORABLE),
|
||||
// ELDER_GUARDIAN("MOB_APPEARANCE"), // No thank you
|
||||
ELDER_GUARDIAN("MOB_APPEARANCE", false), // No thank you
|
||||
ENCHANT("ENCHANTMENT_TABLE"),
|
||||
ENCHANTED_HIT("CRIT_MAGIC"),
|
||||
END_ROD("END_ROD"),
|
||||
|
@ -59,7 +61,7 @@ public enum ParticleEffect {
|
|||
FIREWORK("FIREWORKS_SPARK"),
|
||||
FISHING("WATER_WAKE"),
|
||||
FLAME("FLAME"),
|
||||
// FLASH("FLASH"), // Also no thank you
|
||||
FLASH("FLASH", false), // Also no thank you
|
||||
FOOTSTEP("FOOTSTEP"), // Removed in Minecraft 1.13 :(
|
||||
HAPPY_VILLAGER("VILLAGER_HAPPY"),
|
||||
HEART("HEART"),
|
||||
|
@ -88,16 +90,12 @@ public enum ParticleEffect {
|
|||
UNDERWATER("SUSPENDED_DEPTH"),
|
||||
WITCH("SPELL_WITCH");
|
||||
|
||||
private static final Map<String, ParticleEffect> NAME_MAP = new HashMap<>();
|
||||
private final Particle internalEnum;
|
||||
private final List<ParticleProperty> properties;
|
||||
private Particle internalEnum;
|
||||
private List<ParticleProperty> properties;
|
||||
|
||||
// Initialize map for quick name and id lookup
|
||||
static {
|
||||
for (ParticleEffect effect : values())
|
||||
if (effect.isSupported())
|
||||
NAME_MAP.put(effect.getName(), effect);
|
||||
}
|
||||
private CommentedFileConfiguration config;
|
||||
private boolean enabledByDefault;
|
||||
private boolean enabled;
|
||||
|
||||
/**
|
||||
* Construct a new particle effect
|
||||
|
@ -106,10 +104,84 @@ public enum ParticleEffect {
|
|||
* @param properties Properties of this particle effect
|
||||
*/
|
||||
ParticleEffect(String enumName, ParticleProperty... properties) {
|
||||
this(enumName, true, properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new particle effect
|
||||
*
|
||||
* @param enumName Name of the Particle Enum when the server version is greater than or equal to 1.13
|
||||
* * @param enabledByDefault If the particle type is enabled by default
|
||||
* @param properties Properties of this particle effect
|
||||
*/
|
||||
ParticleEffect(String enumName, boolean enabledByDefault, ParticleProperty... properties) {
|
||||
this.enabledByDefault = enabledByDefault;
|
||||
this.properties = Arrays.asList(properties);
|
||||
|
||||
// Will be null if this server's version doesn't support this particle type
|
||||
this.internalEnum = Stream.of(Particle.values()).filter(x -> x.name().equals(enumName)).findFirst().orElse(null);
|
||||
|
||||
this.setDefaultSettings();
|
||||
this.loadSettings(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default settings for the particle type
|
||||
*/
|
||||
private void setDefaultSettings() {
|
||||
if (!this.isSupported())
|
||||
return;
|
||||
|
||||
File directory = new File(PlayerParticles.getInstance().getDataFolder(), "effects");
|
||||
directory.mkdirs();
|
||||
|
||||
File file = new File(directory, this.getName() + ".yml");
|
||||
this.config = CommentedFileConfiguration.loadConfiguration(PlayerParticles.getInstance(), file);
|
||||
|
||||
this.setIfNotExists("enabled", this.enabledByDefault, "If the effect is enabled or not");
|
||||
|
||||
this.config.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the settings shared for each style then calls loadSettings(CommentedFileConfiguration)
|
||||
*/
|
||||
public void loadSettings(boolean reloadConfig) {
|
||||
if (!this.isSupported())
|
||||
return;
|
||||
|
||||
if (reloadConfig)
|
||||
this.config.reloadConfig();
|
||||
|
||||
this.enabled = this.config.getBoolean("enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value to the config if it doesn't already exist
|
||||
*
|
||||
* @param setting The setting name
|
||||
* @param value The setting value
|
||||
*/
|
||||
private void setIfNotExists(String setting, Object value, String... comments) {
|
||||
if (this.config.get(setting) != null)
|
||||
return;
|
||||
|
||||
String defaultMessage = "Default: ";
|
||||
if (value instanceof String && ParticleUtils.containsConfigSpecialCharacters((String) value)) {
|
||||
defaultMessage += "'" + value + "'";
|
||||
} else {
|
||||
defaultMessage += value;
|
||||
}
|
||||
|
||||
this.config.set(setting, value, ObjectArrays.concat(comments, new String[] { defaultMessage }, String.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the settings for all ParticleEffects
|
||||
*/
|
||||
public static void reloadSettings() {
|
||||
for (ParticleEffect effect : values())
|
||||
effect.loadSettings(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,6 +212,13 @@ public enum ParticleEffect {
|
|||
return this.internalEnum != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if this effect is enabled, otherwise false
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a ParticleEffect List of all enabled effects for the server version
|
||||
*
|
||||
|
@ -148,7 +227,7 @@ public enum ParticleEffect {
|
|||
public static List<ParticleEffect> getEnabledEffects() {
|
||||
List<ParticleEffect> effects = new ArrayList<>();
|
||||
for (ParticleEffect pe : values())
|
||||
if (pe.isSupported())
|
||||
if (pe.isSupported() && pe.isEnabled())
|
||||
effects.add(pe);
|
||||
return effects;
|
||||
}
|
||||
|
@ -160,7 +239,7 @@ public enum ParticleEffect {
|
|||
* @return The particle effect
|
||||
*/
|
||||
public static ParticleEffect fromName(String name) {
|
||||
return NAME_MAP.get(name.toLowerCase());
|
||||
return Stream.of(values()).filter(x -> x.name().equalsIgnoreCase(name) && x.isSupported() && x.isEnabled()).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -555,10 +634,6 @@ public enum ParticleEffect {
|
|||
|
||||
}
|
||||
|
||||
public interface ParticleData {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a runtime exception that is thrown either if the displayed
|
||||
* particle effect requires data and has none or vice-versa or if the data
|
||||
|
|
Loading…
Reference in a new issue