/* * This file is a part of the SteamWar software. * * Copyright (C) 2025 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; import de.steamwar.inventory.SWItem; import de.steamwar.lobby.LobbySystem; import de.steamwar.sql.SteamwarUser; import lombok.Getter; import org.bukkit.Material; import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.List; import java.util.Set; public class ParticleData { private final Material material; private final String name; private final List attributes = new ArrayList<>(); @Getter private final ParticleRequirement requirement; @Getter private final ParticleElement particleElement; public ParticleData(Material material, String name, ParticleElement particleElement) { this.material = material; this.name = name; this.requirement = ParticleRequirement.NO_REQUIRMENT; this.particleElement = particleElement; particleElement.aggregateAttributes(this); } public ParticleData(Material material, String name, ParticleRequirement requirement, ParticleElement particleElement) { this.material = material; this.name = name; this.requirement = requirement; this.particleElement = particleElement; particleElement.aggregateAttributes(this); } public ParticleData add(String attribute) { attributes.add(attribute); return this; } public SWItem toSWItem(Player player, SteamwarUser user, Set eventTeilnahme, String eggHuntConfig) { String translatedName; try { translatedName = LobbySystem.getMessage().parse(name, player); } catch (Exception e) { translatedName = name; } List lore = new ArrayList<>(); lore.add(""); if (!attributes.isEmpty()) { lore.add(LobbySystem.getMessage().parse("PARTICLE_ATTRIBUTE", player)); attributes.forEach(attribute -> lore.add(LobbySystem.getMessage().parse(attribute, player))); lore.add(""); } String unlockedBy = requirement.getRequirementName(player); if (unlockedBy != null) { lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player)); lore.add(unlockedBy); lore.add(""); } if (requirement.test(user, eventTeilnahme, eggHuntConfig)) { lore.add(LobbySystem.getMessage().parse("PARTICLE_SELECT", player)); } else { lore.add(LobbySystem.getMessage().parse("PARTICLE_LOCKED", player)); } return new SWItem(material, translatedName, lore, false, clickType -> {}); } }