/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package de.steamwar.lobby.particle.design;
import de.steamwar.lobby.particle.ParticleElement;
import de.steamwar.lobby.particle.elements.*;
import de.steamwar.lobby.particle.elements.custom.NonMoving;
import lombok.experimental.UtilityClass;
import org.bukkit.Material;
import java.util.List;
import java.util.function.UnaryOperator;
// Parameters every entry has, independent of its design
@UtilityClass
public class EntryParameters {
public enum TickMode {
MOVE,
ALWAYS,
}
// Body places offsets, heights, rings and wings around the player's body, even while gliding or swimming
public enum Placement {
WORLD,
BODY,
}
public enum Movement {
ANY(element -> element),
MOVING(element -> data -> {
if (data.isMoving()) element.tick(data);
}),
STANDING_STILL(NonMoving::new),
;
private final UnaryOperator wrapper;
Movement(UnaryOperator wrapper) {
this.wrapper = wrapper;
}
public ParticleElement wrap(ParticleElement element) {
return wrapper.apply(element);
}
}
public enum Gliding {
ANY(element -> element),
GLIDING(Flying::new),
NOT_GLIDING(NonFlying::new),
;
private final UnaryOperator wrapper;
Gliding(UnaryOperator wrapper) {
this.wrapper = wrapper;
}
public ParticleElement wrap(ParticleElement element) {
return wrapper.apply(element);
}
}
public enum Ground {
ANY(element -> element),
ON_GROUND(Floor::new),
IN_AIR(NonFloor::new),
;
private final UnaryOperator wrapper;
Ground(UnaryOperator wrapper) {
this.wrapper = wrapper;
}
public ParticleElement wrap(ParticleElement element) {
return wrapper.apply(element);
}
}
public enum Sneak {
ANY(element -> element),
SNEAKING(Sneaking::new),
NOT_SNEAKING(element -> data -> {
if (!data.getPlayer().isSneaking()) element.tick(data);
}),
;
private final UnaryOperator wrapper;
Sneak(UnaryOperator wrapper) {
this.wrapper = wrapper;
}
public ParticleElement wrap(ParticleElement element) {
return wrapper.apply(element);
}
}
public enum Visibility {
EVERYONE(element -> element),
ONLY_SELF(OnlySelf::new),
ONLY_OTHERS(OnlyOthers::new),
;
private final UnaryOperator wrapper;
Visibility(UnaryOperator wrapper) {
this.wrapper = wrapper;
}
public ParticleElement wrap(ParticleElement element) {
return wrapper.apply(element);
}
}
public final ChoiceParameter PARTICLE = ChoiceParameter.ofEnum("particle", "PARTICLE_PARAM_PARTICLE", ParticleType.FLAME, type -> !type.isBuildable());
public final IntParameter COUNT = new IntParameter("count", "PARTICLE_PARAM_COUNT", 5, 1, 20);
public final DoubleParameter SPREAD_X = new DoubleParameter("spreadX", "PARTICLE_PARAM_SPREAD_X", 0, 0, 2, 0.05);
public final DoubleParameter SPREAD_Y = new DoubleParameter("spreadY", "PARTICLE_PARAM_SPREAD_Y", 0, 0, 2, 0.05);
public final DoubleParameter SPREAD_Z = new DoubleParameter("spreadZ", "PARTICLE_PARAM_SPREAD_Z", 0, 0, 2, 0.05);
public final DoubleParameter SPEED = new DoubleParameter("speed", "PARTICLE_PARAM_SPEED", 0.01, 0, 1, 0.01);
public final GradientParameter COLORS = new GradientParameter("colors", "PARTICLE_PARAM_COLORS", 8);
// Blocks that are also items, so they work for block and item particles alike
public final ChoiceParameter BLOCK = new ChoiceParameter<>("block", "PARTICLE_PARAM_BLOCK", Material.STONE, List.of(
new ChoiceParameter.Choice<>("stone", Material.STONE, false),
new ChoiceParameter.Choice<>("cobblestone", Material.COBBLESTONE, false),
new ChoiceParameter.Choice<>("dirt", Material.DIRT, false),
new ChoiceParameter.Choice<>("grass_block", Material.GRASS_BLOCK, false),
new ChoiceParameter.Choice<>("sand", Material.SAND, false),
new ChoiceParameter.Choice<>("red_sand", Material.RED_SAND, false),
new ChoiceParameter.Choice<>("gravel", Material.GRAVEL, false),
new ChoiceParameter.Choice<>("oak_planks", Material.OAK_PLANKS, false),
new ChoiceParameter.Choice<>("oak_leaves", Material.OAK_LEAVES, false),
new ChoiceParameter.Choice<>("cherry_leaves", Material.CHERRY_LEAVES, false),
new ChoiceParameter.Choice<>("snow_block", Material.SNOW_BLOCK, false),
new ChoiceParameter.Choice<>("ice", Material.ICE, false),
new ChoiceParameter.Choice<>("glass", Material.GLASS, false),
new ChoiceParameter.Choice<>("tnt", Material.TNT, false),
new ChoiceParameter.Choice<>("pumpkin", Material.PUMPKIN, false),
new ChoiceParameter.Choice<>("melon", Material.MELON, false),
new ChoiceParameter.Choice<>("honey_block", Material.HONEY_BLOCK, false),
new ChoiceParameter.Choice<>("slime_block", Material.SLIME_BLOCK, false),
new ChoiceParameter.Choice<>("netherrack", Material.NETHERRACK, false),
new ChoiceParameter.Choice<>("soul_sand", Material.SOUL_SAND, false),
new ChoiceParameter.Choice<>("magma_block", Material.MAGMA_BLOCK, false),
new ChoiceParameter.Choice<>("end_stone", Material.END_STONE, false),
new ChoiceParameter.Choice<>("obsidian", Material.OBSIDIAN, false),
new ChoiceParameter.Choice<>("prismarine", Material.PRISMARINE, false),
new ChoiceParameter.Choice<>("sculk", Material.SCULK, false),
new ChoiceParameter.Choice<>("amethyst_block", Material.AMETHYST_BLOCK, false),
new ChoiceParameter.Choice<>("coal_block", Material.COAL_BLOCK, false),
new ChoiceParameter.Choice<>("iron_block", Material.IRON_BLOCK, false),
new ChoiceParameter.Choice<>("gold_block", Material.GOLD_BLOCK, false),
new ChoiceParameter.Choice<>("redstone_block", Material.REDSTONE_BLOCK, false),
new ChoiceParameter.Choice<>("lapis_block", Material.LAPIS_BLOCK, false),
new ChoiceParameter.Choice<>("emerald_block", Material.EMERALD_BLOCK, false),
new ChoiceParameter.Choice<>("diamond_block", Material.DIAMOND_BLOCK, false),
new ChoiceParameter.Choice<>("white_wool", Material.WHITE_WOOL, false),
new ChoiceParameter.Choice<>("red_wool", Material.RED_WOOL, false),
new ChoiceParameter.Choice<>("orange_wool", Material.ORANGE_WOOL, false),
new ChoiceParameter.Choice<>("yellow_wool", Material.YELLOW_WOOL, false),
new ChoiceParameter.Choice<>("lime_wool", Material.LIME_WOOL, false),
new ChoiceParameter.Choice<>("light_blue_wool", Material.LIGHT_BLUE_WOOL, false),
new ChoiceParameter.Choice<>("blue_wool", Material.BLUE_WOOL, false),
new ChoiceParameter.Choice<>("purple_wool", Material.PURPLE_WOOL, false),
new ChoiceParameter.Choice<>("pink_wool", Material.PINK_WOOL, false),
new ChoiceParameter.Choice<>("black_wool", Material.BLACK_WOOL, false)
));
public final DoubleParameter OFFSET_X = new DoubleParameter("offsetX", "PARTICLE_PARAM_OFFSET_X", 0, -3, 3, 0.1);
public final DoubleParameter OFFSET_Y = new DoubleParameter("offsetY", "PARTICLE_PARAM_OFFSET_Y", 0, -3, 3, 0.1);
public final DoubleParameter OFFSET_Z = new DoubleParameter("offsetZ", "PARTICLE_PARAM_OFFSET_Z", 0, -3, 3, 0.1);
public final IntParameter INTERVAL = new IntParameter("interval", "PARTICLE_PARAM_INTERVAL", 1, 1, 100);
public final ChoiceParameter PLACEMENT = ChoiceParameter.ofEnum("placement", "PARTICLE_PARAM_PLACEMENT", Placement.WORLD);
public final ChoiceParameter TICK_MODE = ChoiceParameter.ofEnum("tickMode", "PARTICLE_PARAM_TICK_MODE", TickMode.MOVE);
public final ChoiceParameter MOVEMENT = ChoiceParameter.ofEnum("movement", "PARTICLE_PARAM_MOVEMENT", Movement.ANY);
public final ChoiceParameter GLIDING = ChoiceParameter.ofEnum("gliding", "PARTICLE_PARAM_GLIDING", Gliding.ANY);
public final ChoiceParameter GROUND = ChoiceParameter.ofEnum("ground", "PARTICLE_PARAM_GROUND", Ground.ANY);
public final ChoiceParameter SNEAK = ChoiceParameter.ofEnum("sneak", "PARTICLE_PARAM_SNEAK", Sneak.ANY);
public final ChoiceParameter VISIBILITY = ChoiceParameter.ofEnum("visibility", "PARTICLE_PARAM_VISIBILITY", Visibility.EVERYONE);
public final List> ALL = List.of(
PARTICLE, COUNT, SPREAD_X, SPREAD_Y, SPREAD_Z, SPEED, COLORS, BLOCK,
OFFSET_X, OFFSET_Y, OFFSET_Z, PLACEMENT, INTERVAL, TICK_MODE,
MOVEMENT, GLIDING, GROUND, SNEAK, VISIBILITY
);
}