mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-26 02:19:28 +00:00
Fix particle on 1.20.5+
This commit is contained in:
@@ -59,6 +59,7 @@ import net.momirealms.customcrops.mechanic.world.block.MemoryCrop;
|
||||
import net.momirealms.customcrops.util.ClassUtils;
|
||||
import net.momirealms.customcrops.util.ConfigUtils;
|
||||
import net.momirealms.customcrops.util.ItemUtils;
|
||||
import net.momirealms.customcrops.util.ParticleUtils;
|
||||
import net.momirealms.sparrow.heart.SparrowHeart;
|
||||
import net.momirealms.sparrow.heart.feature.inventory.HandSlot;
|
||||
import org.bukkit.*;
|
||||
@@ -743,7 +744,7 @@ public class ActionManagerImpl implements ActionManager {
|
||||
private void registerParticleAction() {
|
||||
registerAction("particle", (args, chance) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
Particle particleType = Particle.valueOf(section.getString("particle", "ASH").toUpperCase(Locale.ENGLISH));
|
||||
Particle particleType = ParticleUtils.getParticle(section.getString("particle", "ASH").toUpperCase(Locale.ENGLISH));
|
||||
double x = section.getDouble("x",0);
|
||||
double y = section.getDouble("y",0);
|
||||
double z = section.getDouble("z",0);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) <2024> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customcrops.util;
|
||||
|
||||
import org.bukkit.Particle;
|
||||
|
||||
public class ParticleUtils {
|
||||
|
||||
public static Particle getParticle(String particle) {
|
||||
try {
|
||||
return Particle.valueOf(particle);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return switch (particle) {
|
||||
case "REDSTONE" -> Particle.valueOf("DUST");
|
||||
case "VILLAGER_HAPPY" -> Particle.valueOf("HAPPY_VILLAGER");
|
||||
default -> Particle.valueOf(particle);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user