From 67ed66777f80ee2f2a237f6547d4134de50b38bd Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 26 Mar 2023 13:06:49 +0200 Subject: [PATCH 01/18] Add basic stuff for EasterEgg hunt --- src/de/steamwar/lobby/LobbySystem.java | 4 + src/de/steamwar/lobby/LobbySystem.properties | 22 ++- .../steamwar/lobby/LobbySystem_de.properties | 24 ++- .../lobby/otherparticle/Particle.java | 47 +++++ .../otherparticle/ParticleRequirement.java | 179 ++++++++++++++++++ .../lobby/particle/ParticleBuilder.java | 15 ++ .../ParticleListener.java | 7 +- src/de/steamwar/lobby/special/easter/Egg.java | 102 ++++++++++ .../special/easter/EggClickListener.java | 64 +++++++ .../lobby/special/easter/EggDifficulty.java | 19 ++ .../lobby/special/easter/EggHunt.java | 35 ++++ .../lobby/special/easter/EggHuntCommand.java | 38 ++++ 12 files changed, 537 insertions(+), 19 deletions(-) create mode 100644 src/de/steamwar/lobby/otherparticle/Particle.java create mode 100644 src/de/steamwar/lobby/otherparticle/ParticleRequirement.java create mode 100644 src/de/steamwar/lobby/particle/ParticleBuilder.java rename src/de/steamwar/lobby/{listener => particle}/ParticleListener.java (95%) create mode 100644 src/de/steamwar/lobby/special/easter/Egg.java create mode 100644 src/de/steamwar/lobby/special/easter/EggClickListener.java create mode 100644 src/de/steamwar/lobby/special/easter/EggDifficulty.java create mode 100644 src/de/steamwar/lobby/special/easter/EggHunt.java create mode 100644 src/de/steamwar/lobby/special/easter/EggHuntCommand.java diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java index fd85f70..383d657 100644 --- a/src/de/steamwar/lobby/LobbySystem.java +++ b/src/de/steamwar/lobby/LobbySystem.java @@ -27,6 +27,8 @@ import de.steamwar.lobby.command.PortalCommand; import de.steamwar.lobby.jumpandrun.JumpAndRun; import de.steamwar.lobby.listener.*; import de.steamwar.lobby.map.CustomMapCommand; +import de.steamwar.lobby.particle.ParticleListener; +import de.steamwar.lobby.special.easter.EggHunt; import de.steamwar.lobby.team.TeamPlayer; import de.steamwar.message.Message; import org.bukkit.plugin.java.JavaPlugin; @@ -71,6 +73,8 @@ public class LobbySystem extends JavaPlugin { new TeleporterListener(); new TeamPlayer(); + EggHunt.init(); + new AlphaWall(l -> l.getX() > 1199, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getZ() > 892, AlphaWall.REFLECT_Z); diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 78e8745..788714f 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -20,9 +20,15 @@ PARTICLE_INVENTORY = §6Particle PARTICLE_DESELECT = §8No particle PARTICLE_LOCKED = {0} §8- §c§lLocked -PARTICLE_UNLOCKED_BY_TEAM = §fJoin the team +PARTICLE_UNLOCKED_BY = §eUnlocked by +PARTICLE_UNLOCKED_BY_TEAM = §fJoin a team +PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM = §fTeam {0} PARTICLE_UNLOCKED_BY_EVENT = §fEvent participation PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServer Team +PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. or 3. Place +PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION = §f{0} +PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_HALF = §fFind 45 Easter Eggs +PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_DIFFICULTY = §fFind all Easter Eggs with difficulty {0} PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Double ring @@ -32,8 +38,6 @@ PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f in air PARTICLE_ATTRIBUTE_WING = §8-§f Wings PARTICLE_ATTRIBUTE = §eAttributes§7: -PARTICLE_UNLOCKED_BY = §eUnlocked by - PARTICLE_SELECT = §eClick to select PARTICLE_SNEEZE = §aSneeze @@ -71,9 +75,6 @@ PARTICLE_WATER_FIRE = §bWater§7/§cFire PARTICLE_MAGIC_ENCHANTING = §5Magic/Enchantment PARTICLE_WINGS_EVIL = §5Purple wings -PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. or 3. Place -PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION = §f{0} - PARTICLE_EVENT_ENCHANTING = §cEnchantment PARTICLE_EVENT_CLOUD = §fClouds PARTICLE_EVENT_SMOKE = §7Smoke @@ -86,4 +87,11 @@ PARTICLE_EVENT_WARGEARCLASH = §fClash JUMP_AND_RUN_PROGRESS = §e{0}§8/§f{1} §c{2} §7{3} JUMP_AND_RUN_CANCEL = {0} JUMP_AND_RUN_TIME = mm:ss SSS -JUMP_AND_RUN_FINISHED = §aFinished in {0} with {1} fails \ No newline at end of file +JUMP_AND_RUN_FINISHED = §aFinished in {0} with {1} fails + +# Easter Egg Hunt +DIFFICULTY_EASY = §aEasy +DIFFICULTY_MEDIUM = §eMedium +DIFFICULTY_HARD = §cHard +DIFFICULTY_EXTREME = §5Extreme +DIFFICULTY_ADVANCED = §5Advanced \ No newline at end of file diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index 6065269..3a1e68e 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -20,9 +20,15 @@ PARTICLE_INVENTORY = §6Partikel PARTICLE_DESELECT = §8Keine Partikel PARTICLE_LOCKED = {0} §8- §c§lGesperrt +PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch PARTICLE_UNLOCKED_BY_TEAM = §fTeambeitritt +PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM = §fTeam {0} PARTICLE_UNLOCKED_BY_EVENT = §fEventteilnahme PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServerteam +PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION = §f{0} +PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_HALF = §fFinde 45 Oster-Eierer +PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_DIFFICULTY = §fAlle Eierer mit Schwierigkeit {0} finden PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Doppelring @@ -32,8 +38,6 @@ PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f in Luft PARTICLE_ATTRIBUTE_WING = §8-§f Flügel PARTICLE_ATTRIBUTE = §eAttribute§7: -PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch - PARTICLE_SELECT = §eZum Auswählen klicken PARTICLE_SNEEZE = §aSneeze @@ -71,11 +75,6 @@ PARTICLE_WATER_FIRE = §bWasser§7/§cFeuer PARTICLE_MAGIC_ENCHANTING = §5Magie§7/§eZauber PARTICLE_WINGS_EVIL = §5Lila Flügel -PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION = §f{0} - -JUMP_AND_RUN_FINISHED = §aBeendet in {0} mit {1} Fails - PARTICLE_EVENT_ENCHANTING = §cVerzaubert PARTICLE_EVENT_CLOUD = §fWolken PARTICLE_EVENT_SMOKE = §7Rauch @@ -83,4 +82,13 @@ PARTICLE_EVENT_WATER = §bWasser PARTICLE_EVENT_WINGS = §fFlügel PARTICLE_EVENT_RAIN_CLOUD = §fRegenwolke PARTICLE_EVENT_WGS = §fWGS -PARTICLE_EVENT_WARGEARCLASH = §fClash \ No newline at end of file +PARTICLE_EVENT_WARGEARCLASH = §fClash + +JUMP_AND_RUN_FINISHED = §aBeendet in {0} mit {1} Fails + +# Easter Egg Hunt +DIFFICULTY_EASY = §aLeicht +DIFFICULTY_MEDIUM = §eMedium +DIFFICULTY_HARD = §cHart +DIFFICULTY_EXTREME = §5Extrem +DIFFICULTY_ADVANCED = §5Advanced \ No newline at end of file diff --git a/src/de/steamwar/lobby/otherparticle/Particle.java b/src/de/steamwar/lobby/otherparticle/Particle.java new file mode 100644 index 0000000..7811f6a --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/Particle.java @@ -0,0 +1,47 @@ +package de.steamwar.lobby.otherparticle; + +import de.steamwar.inventory.SWItem; +import de.steamwar.lobby.LobbySystem; +import de.steamwar.sql.SteamwarUser; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; + +public class Particle { + + private ParticleItem item; + + private static class ParticleItem { + + private Material material; + private String name; + private Set attributes = new LinkedHashSet<>(); + private String unlockedBy; + + public SWItem toSWItem(Player player) { + String translatedName = LobbySystem.getMessage().parse(name, player); + 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(""); + } + if (unlockedBy != null) { + lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player)); + lore.add(LobbySystem.getMessage().parse(unlockedBy, player)); + lore.add(""); + } + lore.add(LobbySystem.getMessage().parse("PARTICLE_SELECT", player)); + return new SWItem(material, translatedName, lore, false, clickType -> {}); + } + } + + private Predicate unlocked = player -> true; + +} diff --git a/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java b/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java new file mode 100644 index 0000000..28e3d20 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java @@ -0,0 +1,179 @@ +package de.steamwar.lobby.otherparticle; + +import de.steamwar.lobby.LobbySystem; +import de.steamwar.lobby.special.easter.EggDifficulty; +import de.steamwar.lobby.special.easter.EggHunt; +import de.steamwar.sql.Event; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.Team; +import de.steamwar.sql.UserGroup; +import org.bukkit.entity.Player; + +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +public interface ParticleRequirement { + + String getRequirementName(Player player); + ParticleRequirementPredicate getRequirement(); + + ParticleRequirement NO_REQUIRMENT = new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return null; + } + + @Override + public ParticleRequirementPredicate getRequirement() { + return (player, eventTeilname, eggHuntConfig) -> true; + } + }; + ParticleRequirement HAS_TEAM = new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_TEAM", player); + } + + @Override + public ParticleRequirementPredicate getRequirement() { + return (steamwarUser, eventTeilname, eggHuntConfig) -> steamwarUser.getTeam() != 0 || steamwarUser.getUserGroup() != UserGroup.Member; + } + }; + ParticleRequirement EVENT_PARTICIPATION = new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_EVENT", player); + } + + @Override + public ParticleRequirementPredicate getRequirement() { + return (steamwarUser, eventTeilname, eggHuntConfig) -> !eventTeilname.isEmpty(); + } + }; + ParticleRequirement SERVER_TEAM = new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_SERVER_TEAM", player); + } + + @Override + public ParticleRequirementPredicate getRequirement() { + return (steamwarUser, eventTeilname, eggHuntConfig) -> false; + } + }; + ParticleRequirement EGG_HUNT_EASY = _easterEggHuntDifficulty(EggDifficulty.EASY); + ParticleRequirement EGG_HUNT_MEDIUM = _easterEggHuntDifficulty(EggDifficulty.MEDIUM); + ParticleRequirement EGG_HUNT_HARD = _easterEggHuntDifficulty(EggDifficulty.HARD); + ParticleRequirement EGG_HUNT_EXTREME = _easterEggHuntDifficulty(EggDifficulty.EXTREME); + ParticleRequirement EGG_HUNT_ADVANCED = _easterEggHuntDifficulty(EggDifficulty.ADVANCED); + ParticleRequirement EGG_HUNT_FOUND_HALF = new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_HALF", player); + } + + @Override + public ParticleRequirementPredicate getRequirement() { + return (user, eventTeilname, eggHuntConfig) -> { + if (eggHuntConfig == null) return false; + int count = 0; + for (int i = 0; i < eggHuntConfig.length(); i++) { + if (eggHuntConfig.charAt(i) == '1') { + count++; + } + } + return count >= EggHunt.getEggList().size() / 2; + }; + } + }; + + static ParticleRequirement specificTeam(int teamId) { + if (teamId == 0) return NO_REQUIRMENT; + String teamKuerzel = Team.get(teamId).getTeamKuerzel(); + return new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM", player, teamKuerzel); + } + + @Override + public ParticleRequirementPredicate getRequirement() { + return (steamwarUser, eventTeilname, eggHuntConfig) -> steamwarUser.getTeam() == teamId; + } + }; + } + + static ParticleRequirement eventParticipation(int eventId) { + String eventName = Event.get(eventId).getEventName(); + return new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION", player, eventName); + } + + @Override + public ParticleRequirementPredicate getRequirement() { + return (steamwarUser, eventTeilname, eggHuntConfig) -> eventTeilname.contains(eventId); + } + }; + } + + static ParticleRequirement eventPlacement(int eventId, int... placementTeams) { + String eventName = Event.get(eventId).getEventName(); + Set teams = new HashSet<>(); + for (int i : placementTeams) teams.add(i); + return new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT", player, eventName); + } + + @Override + public ParticleRequirementPredicate getRequirement() { + return (steamwarUser, eventTeilname, eggHuntConfig) -> { + if (!eventTeilname.contains(eventId)) return false; + return teams.contains(steamwarUser.getTeam()); + }; + } + }; + } + + static ParticleRequirement _easterEggHuntDifficulty(EggDifficulty difficulty) { + AtomicInteger count = new AtomicInteger(); + List eggs = EggHunt.getEggList() + .stream() + .map(egg -> { + int id = count.getAndIncrement(); + if (egg.getDifficulty() == difficulty) { + return id; + } else { + return null; + } + }) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + + return new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_DIFFICULTY", player, LobbySystem.getMessage().parse(difficulty.getMessage(), player)); + } + + @Override + public ParticleRequirementPredicate getRequirement() { + return (steamwarUser, integers, eggHuntConfig) -> { + if (eggHuntConfig == null) return false; + return eggs.stream().allMatch(id -> eggHuntConfig.length() >= id && eggHuntConfig.charAt(id) == '1'); + }; + } + }; + } + + interface ParticleRequirementPredicate { + boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig); + } +} diff --git a/src/de/steamwar/lobby/particle/ParticleBuilder.java b/src/de/steamwar/lobby/particle/ParticleBuilder.java new file mode 100644 index 0000000..0b8b589 --- /dev/null +++ b/src/de/steamwar/lobby/particle/ParticleBuilder.java @@ -0,0 +1,15 @@ +package de.steamwar.lobby.particle; + +public class ParticleBuilder { + + public ParticleBuilder() { + } + + public void cloud() {} + + public void offset() {} + + public void rotated() {} + + public void build() {} +} diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/particle/ParticleListener.java similarity index 95% rename from src/de/steamwar/lobby/listener/ParticleListener.java rename to src/de/steamwar/lobby/particle/ParticleListener.java index 43ac5b8..5c9c8f5 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/particle/ParticleListener.java @@ -17,13 +17,12 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.listener; +package de.steamwar.lobby.particle; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.jumpandrun.JumpAndRun; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleInventory; +import de.steamwar.lobby.listener.BasicListener; +import de.steamwar.lobby.listener.PlayerSpawn; import de.steamwar.lobby.particle.particles.ParticleEnum; import de.steamwar.lobby.util.LobbyPlayer; import org.bukkit.Bukkit; diff --git a/src/de/steamwar/lobby/special/easter/Egg.java b/src/de/steamwar/lobby/special/easter/Egg.java new file mode 100644 index 0000000..206fd72 --- /dev/null +++ b/src/de/steamwar/lobby/special/easter/Egg.java @@ -0,0 +1,102 @@ +package de.steamwar.lobby.special.easter; + +import de.steamwar.inventory.SWItem; +import de.steamwar.lobby.LobbySystem; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.Skull; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.profile.PlayerProfile; +import org.bukkit.util.Vector; + +import java.util.Arrays; +import java.util.Map; +import java.util.Optional; + +public class Egg { + + private static final World world = Bukkit.getWorlds().get(0); + + private final int x; + private final int y; + private final int z; + private final String message; + private final EggDifficulty difficulty; + + private Optional playerProfile = null; + + public Egg(Map config) { + this.x = (int) config.get("x"); + this.y = (int) config.get("y"); + this.z = (int) config.get("z"); + this.message = (String) config.get("name"); + this.difficulty = EggDifficulty.valueOf(((String) config.get("difficulty")).toUpperCase()); + } + + public Vector getVector() { + return new Vector(x, y, z); + } + + public String getMessage() { + return message; + } + + public EggDifficulty getDifficulty() { + return difficulty; + } + + public Block getBlock() { + Block block = world.getBlockAt(x, y, z); + if (block.getType() != Material.PLAYER_HEAD && block.getType() != Material.PLAYER_WALL_HEAD) { + System.out.println("Block is not a skull: " + block.getType() + " " + x + "," + y + "," + z); + return null; + } + return block; + } + + public SWItem getItem(Player player, boolean found) { + if (playerProfile == null) { + Block block = getBlock(); + if (block == null) { + playerProfile = Optional.empty(); + return null; + } + + Skull skull = (Skull) block.getState(); + PlayerProfile playerProfile = skull.getOwnerProfile(); + if (playerProfile == null) { + this.playerProfile = Optional.empty(); + return null; + } + this.playerProfile = Optional.of(playerProfile); + } + + if (!playerProfile.isPresent()) { + return null; + } + + SWItem swItem; + if (found) { + swItem = new SWItem(); + ItemStack itemStack = new ItemStack(Material.PLAYER_HEAD); + SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta(); + skullMeta.setOwnerProfile(playerProfile.get()); + itemStack.setItemMeta(skullMeta); + swItem.setItemStack(itemStack); + } else { + swItem = SWItem.getPlayerSkull("MHF_Question"); + } + + swItem.setLore(Arrays.asList(LobbySystem.getMessage().parse(difficulty.getMessage(), player))); + try { + swItem.setName("§f" + LobbySystem.getMessage().parse(message, player)); + } catch (Exception e) { + swItem.setName("§f" + message); + } + return swItem; + } +} diff --git a/src/de/steamwar/lobby/special/easter/EggClickListener.java b/src/de/steamwar/lobby/special/easter/EggClickListener.java new file mode 100644 index 0000000..08664e9 --- /dev/null +++ b/src/de/steamwar/lobby/special/easter/EggClickListener.java @@ -0,0 +1,64 @@ +package de.steamwar.lobby.special.easter; + +import de.steamwar.lobby.LobbySystem; +import de.steamwar.lobby.listener.BasicListener; +import de.steamwar.sql.UserConfig; +import org.bukkit.Particle; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +public class EggClickListener extends BasicListener { + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) { + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { + return; + } + Block block = event.getClickedBlock(); + if (block == null) { + return; + } + Vector vector = block.getLocation().toVector(); + Egg egg = null; + int index = -1; + for (Egg egg1 : EggHunt.getEggList()) { + index++; + if (egg1.getVector().equals(vector)) { + egg = egg1; + break; + } + } + if (egg == null) { + return; + } + Player player = event.getPlayer(); + String found = UserConfig.getConfig(player.getUniqueId(), "egghunt"); + if (found == null) { + found = ""; + } + StringBuilder builder = new StringBuilder(found); + while (builder.length() <= index) { + builder.append("0"); + } + if (builder.charAt(index) == '1') { + return; + } + + try { + player.sendTitle(LobbySystem.getMessage().parse(egg.getMessage(), player), LobbySystem.getMessage().parse(egg.getDifficulty().getMessage(), player), 0, 80, 5); + } catch (Exception e) { + player.sendTitle(egg.getMessage(), LobbySystem.getMessage().parse(egg.getDifficulty().getMessage(), player), 0, 10, 5); + } + + player.spawnParticle(Particle.END_ROD, block.getLocation().add(0.5, 0.5, 0.5), 10, 0.5, 0.5, 0.5, 0.1); + player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.25f, 1.0f); + + builder.setCharAt(index, '1'); + UserConfig.updatePlayerConfig(player.getUniqueId(), "egghunt", builder.toString()); + } +} diff --git a/src/de/steamwar/lobby/special/easter/EggDifficulty.java b/src/de/steamwar/lobby/special/easter/EggDifficulty.java new file mode 100644 index 0000000..6c86dca --- /dev/null +++ b/src/de/steamwar/lobby/special/easter/EggDifficulty.java @@ -0,0 +1,19 @@ +package de.steamwar.lobby.special.easter; + +public enum EggDifficulty { + EASY("DIFFICULTY_EASY"), + MEDIUM("DIFFICULTY_MEDIUM"), + HARD("DIFFICULTY_HARD"), + EXTREME("DIFFICULTY_EXTREME"), + ADVANCED("DIFFICULTY_ADVANCED"); + + private final String message; + + EggDifficulty(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } +} diff --git a/src/de/steamwar/lobby/special/easter/EggHunt.java b/src/de/steamwar/lobby/special/easter/EggHunt.java new file mode 100644 index 0000000..d4f284d --- /dev/null +++ b/src/de/steamwar/lobby/special/easter/EggHunt.java @@ -0,0 +1,35 @@ +package de.steamwar.lobby.special.easter; + +import de.steamwar.lobby.LobbySystem; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class EggHunt { + + private static List eggList = new ArrayList<>(); + + public static void init() { + } + + static { + new EggHuntCommand(); + new EggClickListener(); + + File file = new File(LobbySystem.getPlugin().getDataFolder(), "eggs.yml"); + FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(file); + fileConfiguration.getList("eggs") + .forEach(o -> { + if (!(o instanceof Map)) return; + eggList.add(new Egg((Map) o)); + }); + } + + public static List getEggList() { + return eggList; + } +} diff --git a/src/de/steamwar/lobby/special/easter/EggHuntCommand.java b/src/de/steamwar/lobby/special/easter/EggHuntCommand.java new file mode 100644 index 0000000..9c87af8 --- /dev/null +++ b/src/de/steamwar/lobby/special/easter/EggHuntCommand.java @@ -0,0 +1,38 @@ +package de.steamwar.lobby.special.easter; + +import de.steamwar.command.SWCommand; +import de.steamwar.inventory.SWItem; +import de.steamwar.inventory.SWListInv; +import de.steamwar.sql.UserConfig; +import org.bukkit.entity.Player; + +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +public class EggHuntCommand extends SWCommand { + + public EggHuntCommand() { + super("egghunt", "easteregg", "easter", "egg", "eh"); + } + + @Register + public void genericCommand(Player player) { + AtomicInteger atomicInteger = new AtomicInteger(); + String found = UserConfig.getConfig(player.getUniqueId(), "egghunt"); + List> entries = EggHunt.getEggList().stream() + .map(egg -> { + int index = atomicInteger.getAndIncrement(); + SWItem swItem = egg.getItem(player, found != null && found.length() > index && found.charAt(index) == '1'); + if (swItem == null) return null; + return new SWListInv.SWListEntry<>(swItem, egg); + }) + .sorted(Comparator.comparing(eggSWListEntry -> eggSWListEntry.getObject().getDifficulty())) + .filter(Objects::nonNull).collect(Collectors.toList()); + SWListInv inv = new SWListInv<>(player, "", entries, (clickType, egg) -> { + }); + inv.open(); + } +} -- 2.39.2 From 667945e7cd37b7db6f7788de537a7cead559bd5f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 26 Mar 2023 19:04:37 +0200 Subject: [PATCH 02/18] Fix title duration --- src/de/steamwar/lobby/special/easter/EggClickListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/lobby/special/easter/EggClickListener.java b/src/de/steamwar/lobby/special/easter/EggClickListener.java index 08664e9..68cdda2 100644 --- a/src/de/steamwar/lobby/special/easter/EggClickListener.java +++ b/src/de/steamwar/lobby/special/easter/EggClickListener.java @@ -50,9 +50,9 @@ public class EggClickListener extends BasicListener { } try { - player.sendTitle(LobbySystem.getMessage().parse(egg.getMessage(), player), LobbySystem.getMessage().parse(egg.getDifficulty().getMessage(), player), 0, 80, 5); + player.sendTitle(LobbySystem.getMessage().parse(egg.getMessage(), player), LobbySystem.getMessage().parse(egg.getDifficulty().getMessage(), player), 0, 40, 5); } catch (Exception e) { - player.sendTitle(egg.getMessage(), LobbySystem.getMessage().parse(egg.getDifficulty().getMessage(), player), 0, 10, 5); + player.sendTitle(egg.getMessage(), LobbySystem.getMessage().parse(egg.getDifficulty().getMessage(), player), 0, 40, 5); } player.spawnParticle(Particle.END_ROD, block.getLocation().add(0.5, 0.5, 0.5), 10, 0.5, 0.5, 0.5, 0.1); -- 2.39.2 From 06b3d69ae622890c66619d136a9ddab9429aa2a7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 26 Mar 2023 22:06:49 +0200 Subject: [PATCH 03/18] First translations and fixes to title/subtitle --- src/de/steamwar/lobby/LobbySystem.properties | 52 ++++++++++++++++++- .../steamwar/lobby/LobbySystem_de.properties | 52 ++++++++++++++++++- .../special/easter/EggClickListener.java | 4 +- 3 files changed, 104 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 788714f..5ebdac2 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -94,4 +94,54 @@ DIFFICULTY_EASY = §aEasy DIFFICULTY_MEDIUM = §eMedium DIFFICULTY_HARD = §cHard DIFFICULTY_EXTREME = §5Extreme -DIFFICULTY_ADVANCED = §5Advanced \ No newline at end of file +DIFFICULTY_ADVANCED = §5Advanced + +EASTER_EGG_0 = Where everything began +EASTER_EGG_1 = Jump and Run +EASTER_EGG_2 = Carry me please +EASTER_EGG_3 = The crane +EASTER_EGG_4 = Trust fall +EASTER_EGG_5 = Run forrest run +EASTER_EGG_6 = Important Delivery +EASTER_EGG_7 = Ei believe I can fly +EASTER_EGG_8 = Paper airplane differently + +EASTER_EGG_9 = How did we get here? +EASTER_EGG_10 = Carving the pumpkin +EASTER_EGG_11 = Flying into sunset +EASTER_EGG_12 = Just a bunch of NPCs +EASTER_EGG_13 = Ei'm waiting +EASTER_EGG_14 = Secret Santa +EASTER_EGG_15 = Emergency Meeting +EASTER_EGG_16 = WGS2022 +EASTER_EGG_17 = The world in Preditors hands + +EASTER_EGG_18 = Split personalities +EASTER_EGG_19 = The emperor traveling +EASTER_EGG_20 = Guinness +EASTER_EGG_21 = Gulsch Kanone +EASTER_EGG_22 = Ei mit Bard +EASTER_EGG_23 = Mines of Moria +EASTER_EGG_24 = Heart of the mountain +EASTER_EGG_25 = Fly me to the moon +EASTER_EGG_26 = Visitors from another world + +EASTER_EGG_27 = Sewage +EASTER_EGG_28 = Sewage Valley +EASTER_EGG_29 = Beginning of the End +EASTER_EGG_30 = Egghaust +EASTER_EGG_31 = Touchdown +EASTER_EGG_32 = Advanced Rocketry +EASTER_EGG_33 = Borderlands +EASTER_EGG_34 = Kiss the frog +EASTER_EGG_35 = Niagara Falls + +EASTER_EGG_36 = The Escapist +EASTER_EGG_37 = Mini Egg +EASTER_EGG_38 = Goblin Cave +EASTER_EGG_39 = Asse +EASTER_EGG_40 = Yggdrasil +EASTER_EGG_41 = Bridge Review +EASTER_EGG_42 = May the cucumber be with you +EASTER_EGG_43 = Most hard working builder on SW +EASTER_EGG_44 = There is another diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index 3a1e68e..b28e806 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -91,4 +91,54 @@ DIFFICULTY_EASY = §aLeicht DIFFICULTY_MEDIUM = §eMedium DIFFICULTY_HARD = §cHart DIFFICULTY_EXTREME = §5Extrem -DIFFICULTY_ADVANCED = §5Advanced \ No newline at end of file +DIFFICULTY_ADVANCED = §5Advanced + +EASTER_EGG_0 = Wo alles begann +EASTER_EGG_1 = Jump and Run +EASTER_EGG_2 = Carry me please +EASTER_EGG_3 = Der Kran +EASTER_EGG_4 = Trust fall +EASTER_EGG_5 = Run forrest run +EASTER_EGG_6 = Wichtige Zustellung +EASTER_EGG_7 = Ei believe I can fly +EASTER_EGG_8 = Papierflieger mal anders + +EASTER_EGG_9 = Wie sind wir hier hingekommen? +EASTER_EGG_10 = Kürbisschnitzen +EASTER_EGG_11 = Flug in den Sonnentunergang +EASTER_EGG_12 = Ein haufen NPCs +EASTER_EGG_13 = Ei'm waiting +EASTER_EGG_14 = Secret Santa +EASTER_EGG_15 = Emergency Meeting +EASTER_EGG_16 = WGS2022 +EASTER_EGG_17 = Die Welt in den Händen von Preditors + +EASTER_EGG_18 = Gespaltene Persönlichkeiten +EASTER_EGG_19 = Der Kaiser auf reisen +EASTER_EGG_20 = Guinness +EASTER_EGG_21 = Gulsch Kanone +EASTER_EGG_22 = Ei mit Bard +EASTER_EGG_23 = Die Minen von Moria +EASTER_EGG_24 = Das Herz des Berges +EASTER_EGG_25 = Fly me to the moon +EASTER_EGG_26 = Besucher aus einer anderen Welt + +EASTER_EGG_27 = Abwasser +EASTER_EGG_28 = Tal der Abwässer +EASTER_EGG_29 = Der Anfang vom Ende +EASTER_EGG_30 = Egghaust +EASTER_EGG_31 = Touchdown +EASTER_EGG_32 = Advanced Rocketry +EASTER_EGG_33 = Borderlands +EASTER_EGG_34 = Küss den Frosch +EASTER_EGG_35 = Niagara Fälle + +EASTER_EGG_36 = The Escapist +EASTER_EGG_37 = Mini Ei +EASTER_EGG_38 = Koboldhöhle +EASTER_EGG_39 = Asse +EASTER_EGG_40 = Yggdrasil +EASTER_EGG_41 = Bridge Review +EASTER_EGG_42 = Möge die Gurke mit dir sein +EASTER_EGG_43 = Most hard working builder on SW +EASTER_EGG_44 = There is another diff --git a/src/de/steamwar/lobby/special/easter/EggClickListener.java b/src/de/steamwar/lobby/special/easter/EggClickListener.java index 68cdda2..e9503c8 100644 --- a/src/de/steamwar/lobby/special/easter/EggClickListener.java +++ b/src/de/steamwar/lobby/special/easter/EggClickListener.java @@ -50,9 +50,9 @@ public class EggClickListener extends BasicListener { } try { - player.sendTitle(LobbySystem.getMessage().parse(egg.getMessage(), player), LobbySystem.getMessage().parse(egg.getDifficulty().getMessage(), player), 0, 40, 5); + player.sendTitle(LobbySystem.getMessage().parse(egg.getDifficulty().getMessage(), player), LobbySystem.getMessage().parse(egg.getMessage(), player), 0, 40, 5); } catch (Exception e) { - player.sendTitle(egg.getMessage(), LobbySystem.getMessage().parse(egg.getDifficulty().getMessage(), player), 0, 40, 5); + player.sendTitle(LobbySystem.getMessage().parse(egg.getDifficulty().getMessage(), player), egg.getMessage(), 0, 40, 5); } player.spawnParticle(Particle.END_ROD, block.getLocation().add(0.5, 0.5, 0.5), 10, 0.5, 0.5, 0.5, 0.1); -- 2.39.2 From 9b69b27310dfe58789e6d4b602475951db1ad193 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 27 Mar 2023 18:32:42 +0200 Subject: [PATCH 04/18] Finalization of translations --- src/de/steamwar/lobby/LobbySystem.properties | 50 +++++++++++++++++++ .../steamwar/lobby/LobbySystem_de.properties | 50 +++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 5ebdac2..7e9ae55 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -145,3 +145,53 @@ EASTER_EGG_41 = Bridge Review EASTER_EGG_42 = May the cucumber be with you EASTER_EGG_43 = Most hard working builder on SW EASTER_EGG_44 = There is another + +EASTER_EGG_45 = Frozen +EASTER_EGG_46 = In front of the forrest +EASTER_EGG_47 = Yes Mr. President +EASTER_EGG_48 = [PL]ague and Pain +EASTER_EGG_49 = Elevator music +EASTER_EGG_50 = Blue (Da Ba Dee) +EASTER_EGG_51 = Peak niveau +EASTER_EGG_52 = wuuuzzzzuuuuup +EASTER_EGG_53 = Point Plank + +EASTER_EGG_54 = §eSteam§8War +EASTER_EGG_55 = Read the fineprint +EASTER_EGG_56 = The same we do every night Pinky +EASTER_EGG_57 = (Don\'t) JUMP +EASTER_EGG_58 = Yin and Yang +EASTER_EGG_59 = Just hanging around +EASTER_EGG_60 = Chick-fil-A +EASTER_EGG_61 = Today in the interview +EASTER_EGG_62 = Ahoy cadets + +EASTER_EGG_63 = This is the way +EASTER_EGG_64 = Hamburg meine Perle +EASTER_EGG_65 = Icicle +EASTER_EGG_66 = Easter Rock +EASTER_EGG_67 = Eurasia +EASTER_EGG_68 = Kola-Bohrung +EASTER_EGG_69 = The hobbit +EASTER_EGG_70 = Jungle camp +EASTER_EGG_71 = Nutshell + +EASTER_EGG_72 = Fisherman´s Friend +EASTER_EGG_73 = Point nemo +EASTER_EGG_74 = I'm Groot +EASTER_EGG_75 = Crossing +EASTER_EGG_76 = Breakthrough +EASTER_EGG_77 = Doomsday Valley +EASTER_EGG_78 = North Carolina +EASTER_EGG_79 = 16 inches of power +EASTER_EGG_80 = Melons + +EASTER_EGG_81 = Maintainance +EASTER_EGG_82 = Map Room +EASTER_EGG_83 = The World upside down +EASTER_EGG_84 = Dirty Chamber +EASTER_EGG_85 = Old server Team +EASTER_EGG_86 = Union +EASTER_EGG_87 = Mushroom +EASTER_EGG_88 = Advertisement +EASTER_EGG_89 = Stairway to heaven \ No newline at end of file diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index b28e806..172fdba 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -142,3 +142,53 @@ EASTER_EGG_41 = Bridge Review EASTER_EGG_42 = Möge die Gurke mit dir sein EASTER_EGG_43 = Most hard working builder on SW EASTER_EGG_44 = There is another + +EASTER_EGG_45 = Frozen +EASTER_EGG_46 = Vor dem Wald +EASTER_EGG_47 = Yes Mr. President +EASTER_EGG_48 = [PL]ague and Pain +EASTER_EGG_49 = Elevator music +EASTER_EGG_50 = Blue (Da Ba Dee) +EASTER_EGG_51 = Peak niveau +EASTER_EGG_52 = wuuuzzzzuuuuup +EASTER_EGG_53 = Point Plank + +EASTER_EGG_54 = §eSteam§8War +EASTER_EGG_55 = Lese das Kleingedruckte +EASTER_EGG_56 = The same we do every night Pinky +EASTER_EGG_57 = (Nicht) SPRINGEN +EASTER_EGG_58 = Yin und Yang +EASTER_EGG_59 = Just hanging around +EASTER_EGG_60 = Chick-fil-A +EASTER_EGG_61 = Heute im Interview +EASTER_EGG_62 = Ahoi Kadetten + +EASTER_EGG_63 = Das ist der Weg +EASTER_EGG_64 = Hamburg meine Perle +EASTER_EGG_65 = Eiszapfen +EASTER_EGG_66 = Easter Rock +EASTER_EGG_67 = Eurasia +EASTER_EGG_68 = Kola-Bohrung +EASTER_EGG_69 = Der hobbit +EASTER_EGG_70 = Jungel Kamp +EASTER_EGG_71 = Nussschale + +EASTER_EGG_72 = Fisherman´s Friend +EASTER_EGG_73 = Point nemo +EASTER_EGG_74 = Ich bin Groot +EASTER_EGG_75 = Kreuzung +EASTER_EGG_76 = Durchbruch +EASTER_EGG_77 = Doomsday Valley +EASTER_EGG_78 = North Carolina +EASTER_EGG_79 = 16 inches of power +EASTER_EGG_80 = Melonen + +EASTER_EGG_81 = Wartungsarbeiten +EASTER_EGG_82 = Kartenraum +EASTER_EGG_83 = Die Welt steht Kopf +EASTER_EGG_84 = Schmutziges Kabuff +EASTER_EGG_85 = Altes Serverteam +EASTER_EGG_86 = Union +EASTER_EGG_87 = Mushroom +EASTER_EGG_88 = Werbung +EASTER_EGG_89 = Stairway to heaven \ No newline at end of file -- 2.39.2 From 6f308e3a5632e77b8970b3a7a452ff47b28756ec Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 27 Mar 2023 19:04:01 +0200 Subject: [PATCH 05/18] Add InventoryItem Add Selection modes --- src/de/steamwar/lobby/LobbySystem.properties | 6 ++++ .../steamwar/lobby/LobbySystem_de.properties | 6 ++++ .../lobby/special/easter/EggHunt.java | 1 + .../lobby/special/easter/EggHuntCommand.java | 35 ++++++++++++++++--- .../lobby/special/easter/EggHuntListener.java | 32 +++++++++++++++++ 5 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 src/de/steamwar/lobby/special/easter/EggHuntListener.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 7e9ae55..4049057 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -96,6 +96,12 @@ DIFFICULTY_HARD = §cHard DIFFICULTY_EXTREME = §5Extreme DIFFICULTY_ADVANCED = §5Advanced +EASTER_EGG_MENU = §0Easter Egg Hunt + +EASTER_EGG_SELECTION_ALL = §eAll +EASTER_EGG_SELECTION_FOUND = §aFound +EASTER_EGG_SELECTION_NOT_FOUND = §cNot found + EASTER_EGG_0 = Where everything began EASTER_EGG_1 = Jump and Run EASTER_EGG_2 = Carry me please diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index 172fdba..633b0bf 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -93,6 +93,12 @@ DIFFICULTY_HARD = §cHart DIFFICULTY_EXTREME = §5Extrem DIFFICULTY_ADVANCED = §5Advanced +EASTER_EGG_MENU = §0Oster Eierer Suche + +EASTER_EGG_SELECTION_ALL = §eAlle +EASTER_EGG_SELECTION_FOUND = §aGefunden +EASTER_EGG_SELECTION_NOT_FOUND = §cNicht gefunden + EASTER_EGG_0 = Wo alles begann EASTER_EGG_1 = Jump and Run EASTER_EGG_2 = Carry me please diff --git a/src/de/steamwar/lobby/special/easter/EggHunt.java b/src/de/steamwar/lobby/special/easter/EggHunt.java index d4f284d..6da2942 100644 --- a/src/de/steamwar/lobby/special/easter/EggHunt.java +++ b/src/de/steamwar/lobby/special/easter/EggHunt.java @@ -19,6 +19,7 @@ public class EggHunt { static { new EggHuntCommand(); new EggClickListener(); + new EggHuntListener(); File file = new File(LobbySystem.getPlugin().getDataFolder(), "eggs.yml"); FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(file); diff --git a/src/de/steamwar/lobby/special/easter/EggHuntCommand.java b/src/de/steamwar/lobby/special/easter/EggHuntCommand.java index 9c87af8..042c300 100644 --- a/src/de/steamwar/lobby/special/easter/EggHuntCommand.java +++ b/src/de/steamwar/lobby/special/easter/EggHuntCommand.java @@ -3,9 +3,11 @@ package de.steamwar.lobby.special.easter; import de.steamwar.command.SWCommand; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; +import de.steamwar.lobby.LobbySystem; import de.steamwar.sql.UserConfig; import org.bukkit.entity.Player; +import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Objects; @@ -19,20 +21,45 @@ public class EggHuntCommand extends SWCommand { } @Register - public void genericCommand(Player player) { + public void genericCommand(Player player, @OptionalValue("ALL") Selection selection) { AtomicInteger atomicInteger = new AtomicInteger(); String found = UserConfig.getConfig(player.getUniqueId(), "egghunt"); List> entries = EggHunt.getEggList().stream() .map(egg -> { int index = atomicInteger.getAndIncrement(); - SWItem swItem = egg.getItem(player, found != null && found.length() > index && found.charAt(index) == '1'); + boolean isFound = found != null && found.length() > index && found.charAt(index) == '1'; + if (selection == Selection.FOUND && !isFound) return null; + if (selection == Selection.NOT_FOUND && isFound) return null; + SWItem swItem = egg.getItem(player, isFound); if (swItem == null) return null; return new SWListInv.SWListEntry<>(swItem, egg); }) + .filter(Objects::nonNull) .sorted(Comparator.comparing(eggSWListEntry -> eggSWListEntry.getObject().getDifficulty())) - .filter(Objects::nonNull).collect(Collectors.toList()); - SWListInv inv = new SWListInv<>(player, "", entries, (clickType, egg) -> { + .collect(Collectors.toList()); + SWListInv inv = new SWListInv<>(player, LobbySystem.getMessage().parse("EASTER_EGG_MENU", player), false, entries, (clickType, egg) -> { }); + inv.setItem(49, new SWItem(SWItem.getDye(15), (byte) 15, LobbySystem.getMessage().parse(Selection.ALL.key, player), Collections.emptyList(), selection == Selection.ALL, clickType -> { + genericCommand(player, Selection.ALL); + })); + inv.setItem(48, new SWItem(SWItem.getDye(1), (byte) 1, LobbySystem.getMessage().parse(Selection.NOT_FOUND.key, player), Collections.emptyList(), selection == Selection.NOT_FOUND, clickType -> { + genericCommand(player, Selection.NOT_FOUND); + })); + inv.setItem(50, new SWItem(SWItem.getDye(2), (byte) 2, LobbySystem.getMessage().parse(Selection.FOUND.key, player), Collections.emptyList(), selection == Selection.FOUND, clickType -> { + genericCommand(player, Selection.FOUND); + })); inv.open(); } + + public enum Selection { + ALL("EASTER_EGG_SELECTION_ALL"), + FOUND("EASTER_EGG_SELECTION_FOUND"), + NOT_FOUND("EASTER_EGG_SELECTION_NOT_FOUND"); + + private final String key; + + Selection(String key) { + this.key = key; + } + } } diff --git a/src/de/steamwar/lobby/special/easter/EggHuntListener.java b/src/de/steamwar/lobby/special/easter/EggHuntListener.java new file mode 100644 index 0000000..9fb8a1b --- /dev/null +++ b/src/de/steamwar/lobby/special/easter/EggHuntListener.java @@ -0,0 +1,32 @@ +package de.steamwar.lobby.special.easter; + +import de.steamwar.lobby.listener.BasicListener; +import de.steamwar.lobby.util.ItemBuilder; +import org.bukkit.Material; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; + +public class EggHuntListener extends BasicListener { + + public static final int EASTER_EGG_SLOT = 7; + public static final ItemStack EASTER_HUNT = new ItemBuilder(Material.DRAGON_EGG, 1).setDisplayName("§5Easter Hunt").build(); + + @EventHandler(priority = EventPriority.LOWEST) + public void handlePlayerInteract(PlayerInteractEvent event) { + ItemStack item = event.getItem(); + if(item == null) + return; + + if (item.getType() == Material.DRAGON_EGG && item.getItemMeta() != null && item.getItemMeta().getDisplayName().equals("§5Easter Hunt")) { + event.getPlayer().performCommand("egg"); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onJoin(PlayerJoinEvent e) { + e.getPlayer().getInventory().setItem(EASTER_EGG_SLOT, EASTER_HUNT); + } +} -- 2.39.2 From 0e103b52f9041e66820bb3897e6f6f4affc2cc5e Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 27 Mar 2023 19:06:17 +0200 Subject: [PATCH 06/18] Update color of item --- src/de/steamwar/lobby/special/easter/EggHuntListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/lobby/special/easter/EggHuntListener.java b/src/de/steamwar/lobby/special/easter/EggHuntListener.java index 9fb8a1b..7492a02 100644 --- a/src/de/steamwar/lobby/special/easter/EggHuntListener.java +++ b/src/de/steamwar/lobby/special/easter/EggHuntListener.java @@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack; public class EggHuntListener extends BasicListener { public static final int EASTER_EGG_SLOT = 7; - public static final ItemStack EASTER_HUNT = new ItemBuilder(Material.DRAGON_EGG, 1).setDisplayName("§5Easter Hunt").build(); + public static final ItemStack EASTER_HUNT = new ItemBuilder(Material.DRAGON_EGG, 1).setDisplayName("§fEaster Hunt").build(); @EventHandler(priority = EventPriority.LOWEST) public void handlePlayerInteract(PlayerInteractEvent event) { @@ -20,7 +20,7 @@ public class EggHuntListener extends BasicListener { if(item == null) return; - if (item.getType() == Material.DRAGON_EGG && item.getItemMeta() != null && item.getItemMeta().getDisplayName().equals("§5Easter Hunt")) { + if (item.getType() == Material.DRAGON_EGG && item.getItemMeta() != null && item.getItemMeta().getDisplayName().equals("§fEaster Hunt")) { event.getPlayer().performCommand("egg"); } } -- 2.39.2 From bd4dc2ad21826f28d3e6814b7f3ee10a8a3accdf Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 27 Mar 2023 22:11:14 +0200 Subject: [PATCH 07/18] Update Particle --- .../lobby/otherparticle/Particle.java | 47 ++++++++----------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/de/steamwar/lobby/otherparticle/Particle.java b/src/de/steamwar/lobby/otherparticle/Particle.java index 7811f6a..6290cbc 100644 --- a/src/de/steamwar/lobby/otherparticle/Particle.java +++ b/src/de/steamwar/lobby/otherparticle/Particle.java @@ -2,7 +2,6 @@ package de.steamwar.lobby.otherparticle; import de.steamwar.inventory.SWItem; import de.steamwar.lobby.LobbySystem; -import de.steamwar.sql.SteamwarUser; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -10,38 +9,30 @@ import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import java.util.function.Predicate; public class Particle { - private ParticleItem item; + private Material material; + private String name; + private Set attributes = new LinkedHashSet<>(); + private ParticleRequirement requirement; - private static class ParticleItem { - - private Material material; - private String name; - private Set attributes = new LinkedHashSet<>(); - private String unlockedBy; - - public SWItem toSWItem(Player player) { - String translatedName = LobbySystem.getMessage().parse(name, player); - List lore = new ArrayList<>(); + public SWItem toSWItem(Player player) { + String translatedName = LobbySystem.getMessage().parse(name, player); + 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(""); - if (!attributes.isEmpty()) { - lore.add(LobbySystem.getMessage().parse("PARTICLE_ATTRIBUTE", player)); - attributes.forEach(attribute -> lore.add(LobbySystem.getMessage().parse(attribute, player))); - lore.add(""); - } - if (unlockedBy != null) { - lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player)); - lore.add(LobbySystem.getMessage().parse(unlockedBy, player)); - lore.add(""); - } - lore.add(LobbySystem.getMessage().parse("PARTICLE_SELECT", player)); - return new SWItem(material, translatedName, lore, false, clickType -> {}); } + String unlockedBy = requirement.getRequirementName(player); + if (unlockedBy != null) { + lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player)); + lore.add(unlockedBy); + lore.add(""); + } + lore.add(LobbySystem.getMessage().parse("PARTICLE_SELECT", player)); + return new SWItem(material, translatedName, lore, false, clickType -> {}); } - - private Predicate unlocked = player -> true; - } -- 2.39.2 From f22cd77464f8d2e89065486e5517d47ff2639675 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Apr 2023 21:11:38 +0200 Subject: [PATCH 08/18] Add ParticleEnum Update Particle and add new ParticleRequirment --- src/de/steamwar/lobby/LobbySystem.properties | 1 + .../steamwar/lobby/LobbySystem_de.properties | 1 + .../lobby/otherparticle/Particle.java | 25 ++++++++++++++++--- .../lobby/otherparticle/ParticleEnum.java | 5 ++++ .../otherparticle/ParticleRequirement.java | 15 +++++++++++ 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 src/de/steamwar/lobby/otherparticle/ParticleEnum.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 4049057..e4236b8 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -23,6 +23,7 @@ PARTICLE_LOCKED = {0} §8- §c§lLocked PARTICLE_UNLOCKED_BY = §eUnlocked by PARTICLE_UNLOCKED_BY_TEAM = §fJoin a team PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM = §fTeam {0} +PARTICLE_UNLOCKED_BY_SPECIFIC_USER = §fUser {0} PARTICLE_UNLOCKED_BY_EVENT = §fEvent participation PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServer Team PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. or 3. Place diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index 633b0bf..357a0af 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -23,6 +23,7 @@ PARTICLE_LOCKED = {0} §8- §c§lGesperrt PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch PARTICLE_UNLOCKED_BY_TEAM = §fTeambeitritt PARTICLE_UNLOCKED_BY_SPECIFIC_TEAM = §fTeam {0} +PARTICLE_UNLOCKED_BY_SPECIFIC_USER = §fUser {0} PARTICLE_UNLOCKED_BY_EVENT = §fEventteilnahme PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServerteam PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. oder 3. Platz diff --git a/src/de/steamwar/lobby/otherparticle/Particle.java b/src/de/steamwar/lobby/otherparticle/Particle.java index 6290cbc..3477d3a 100644 --- a/src/de/steamwar/lobby/otherparticle/Particle.java +++ b/src/de/steamwar/lobby/otherparticle/Particle.java @@ -12,10 +12,27 @@ import java.util.Set; public class Particle { - private Material material; - private String name; - private Set attributes = new LinkedHashSet<>(); - private ParticleRequirement requirement; + private final Material material; + private final String name; + private final Set attributes = new LinkedHashSet<>(); + private final ParticleRequirement requirement; + + public Particle(Material material, String name) { + this.material = material; + this.name = name; + this.requirement = ParticleRequirement.NO_REQUIRMENT; + } + + public Particle(Material material, String name, ParticleRequirement requirement) { + this.material = material; + this.name = name; + this.requirement = requirement; + } + + public Particle add(String attribute) { + attributes.add(attribute); + return this; + } public SWItem toSWItem(Player player) { String translatedName = LobbySystem.getMessage().parse(name, player); diff --git a/src/de/steamwar/lobby/otherparticle/ParticleEnum.java b/src/de/steamwar/lobby/otherparticle/ParticleEnum.java new file mode 100644 index 0000000..2e32953 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/ParticleEnum.java @@ -0,0 +1,5 @@ +package de.steamwar.lobby.otherparticle; + +public interface ParticleEnum { + Particle getParticle(); +} diff --git a/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java b/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java index 28e3d20..b911693 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java +++ b/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java @@ -173,6 +173,21 @@ public interface ParticleRequirement { }; } + static ParticleRequirement specificPlayer(int userId) { + String userName = SteamwarUser.get(userId).getUserName(); + return new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_SPECIFIC_USER", player, userName); + } + + @Override + public ParticleRequirementPredicate getRequirement() { + return (steamwarUser, integers, eggHuntConfig) -> steamwarUser.getId() == userId; + } + }; + } + interface ParticleRequirementPredicate { boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig); } -- 2.39.2 From 9576843d8328b592805f6f8aa4b83fde19aac4fd Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Apr 2023 21:52:45 +0200 Subject: [PATCH 09/18] Add element for new particle system except WingParticle --- .../{Particle.java => ParticleData.java} | 8 +-- .../lobby/otherparticle/ParticleElement.java | 44 +++++++++++++ .../lobby/otherparticle/ParticleEnum.java | 2 +- .../lobby/otherparticle/ParticleTickData.java | 36 ++++++++++ .../lobby/otherparticle/ParticleTickType.java | 9 +++ .../lobby/otherparticle/elements/Always.java | 27 ++++++++ .../lobby/otherparticle/elements/Circle.java | 28 ++++++++ .../lobby/otherparticle/elements/Cloud.java | 31 +++++++++ .../lobby/otherparticle/elements/Delayed.java | 48 ++++++++++++++ .../elements/DelegatingParticleElement.java | 30 +++++++++ .../otherparticle/elements/DoubleCircle.java | 47 +++++++++++++ .../otherparticle/elements/DustParticle.java | 44 +++++++++++++ .../lobby/otherparticle/elements/Group.java | 27 ++++++++ .../elements/LocationMutator.java | 28 ++++++++ .../otherparticle/elements/NonFloor.java | 23 +++++++ .../otherparticle/elements/NonFlying.java | 24 +++++++ .../elements/SimpleParticle.java | 66 +++++++++++++++++++ 17 files changed, 517 insertions(+), 5 deletions(-) rename src/de/steamwar/lobby/otherparticle/{Particle.java => ParticleData.java} (88%) create mode 100644 src/de/steamwar/lobby/otherparticle/ParticleElement.java create mode 100644 src/de/steamwar/lobby/otherparticle/ParticleTickData.java create mode 100644 src/de/steamwar/lobby/otherparticle/ParticleTickType.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/Always.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/Circle.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/Cloud.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/Delayed.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/DelegatingParticleElement.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/DoubleCircle.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/DustParticle.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/Group.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/NonFloor.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/NonFlying.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java diff --git a/src/de/steamwar/lobby/otherparticle/Particle.java b/src/de/steamwar/lobby/otherparticle/ParticleData.java similarity index 88% rename from src/de/steamwar/lobby/otherparticle/Particle.java rename to src/de/steamwar/lobby/otherparticle/ParticleData.java index 3477d3a..e65dd57 100644 --- a/src/de/steamwar/lobby/otherparticle/Particle.java +++ b/src/de/steamwar/lobby/otherparticle/ParticleData.java @@ -10,26 +10,26 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -public class Particle { +public class ParticleData { private final Material material; private final String name; private final Set attributes = new LinkedHashSet<>(); private final ParticleRequirement requirement; - public Particle(Material material, String name) { + public ParticleData(Material material, String name) { this.material = material; this.name = name; this.requirement = ParticleRequirement.NO_REQUIRMENT; } - public Particle(Material material, String name, ParticleRequirement requirement) { + public ParticleData(Material material, String name, ParticleRequirement requirement) { this.material = material; this.name = name; this.requirement = requirement; } - public Particle add(String attribute) { + public ParticleData add(String attribute) { attributes.add(attribute); return this; } diff --git a/src/de/steamwar/lobby/otherparticle/ParticleElement.java b/src/de/steamwar/lobby/otherparticle/ParticleElement.java new file mode 100644 index 0000000..470f92d --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/ParticleElement.java @@ -0,0 +1,44 @@ +package de.steamwar.lobby.otherparticle; + +import org.bukkit.Bukkit; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Particle; +import org.bukkit.entity.Player; + +import java.util.Random; +import java.util.function.Consumer; + +public interface ParticleElement { + Random RANDOM = new Random(); + + default Color randomColor() { + return Color.fromRGB(RANDOM.nextInt(255), RANDOM.nextInt(255), RANDOM.nextInt(255)); + } + + default float randomSize() { + return RANDOM.nextFloat() / 2 + 1; + } + + default Particle.DustOptions randomParticleDust() { + return new Particle.DustOptions(randomColor(), randomSize()); + } + + default void display(Location location, Consumer consumer) { + Bukkit.getOnlinePlayers().forEach(player -> { + int viewDistance = player.getClientViewDistance() * 16; + if (location.distanceSquared(player.getLocation()) <= viewDistance * viewDistance) { + consumer.accept(player); + } + }); + } + + default void aggregateAttributes(ParticleData particleData) { + } + + default ParticleTickType tickType() { + return ParticleTickType.MOVE; + } + + void tick(ParticleTickData particleTickData); +} diff --git a/src/de/steamwar/lobby/otherparticle/ParticleEnum.java b/src/de/steamwar/lobby/otherparticle/ParticleEnum.java index 2e32953..ef4c4b5 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleEnum.java +++ b/src/de/steamwar/lobby/otherparticle/ParticleEnum.java @@ -1,5 +1,5 @@ package de.steamwar.lobby.otherparticle; public interface ParticleEnum { - Particle getParticle(); + ParticleData getParticle(); } diff --git a/src/de/steamwar/lobby/otherparticle/ParticleTickData.java b/src/de/steamwar/lobby/otherparticle/ParticleTickData.java new file mode 100644 index 0000000..b2aa909 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/ParticleTickData.java @@ -0,0 +1,36 @@ +package de.steamwar.lobby.otherparticle; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; + +@RequiredArgsConstructor +@AllArgsConstructor +@Getter +public class ParticleTickData { + + private final World world; + private final Player player; + private Location location; + private final double deg; + + public ParticleTickData withLocation(Location location) { + ParticleTickData particleTickData = copy(); + particleTickData.location = location; + return particleTickData; + } + + public Location getLocation() { + if (location == null) { + return player.getLocation(); + } + return location; + } + + public ParticleTickData copy() { + return new ParticleTickData(world, player, location, deg); + } +} diff --git a/src/de/steamwar/lobby/otherparticle/ParticleTickType.java b/src/de/steamwar/lobby/otherparticle/ParticleTickType.java new file mode 100644 index 0000000..ac54999 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/ParticleTickType.java @@ -0,0 +1,9 @@ +package de.steamwar.lobby.otherparticle; + +public enum ParticleTickType { + + ALWAYS, + MOVE, + SNEAK, + ; +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/Always.java b/src/de/steamwar/lobby/otherparticle/elements/Always.java new file mode 100644 index 0000000..f35738d --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/Always.java @@ -0,0 +1,27 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.otherparticle.ParticleTickType; + +public class Always extends DelegatingParticleElement { + + public Always(ParticleElement particleElement) { + super(particleElement); + } + + @Override + public String attribute() { + return "PARTICLE_ATTRIBUTE_TICK"; + } + + @Override + public ParticleTickType tickType() { + return ParticleTickType.ALWAYS; + } + + @Override + public void tick(ParticleTickData particleTickData) { + particleElement.tick(particleTickData); + } +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/Circle.java b/src/de/steamwar/lobby/otherparticle/elements/Circle.java new file mode 100644 index 0000000..fd1f864 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/Circle.java @@ -0,0 +1,28 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; +import org.bukkit.Location; +import org.bukkit.util.Vector; + +public class Circle extends DelegatingParticleElement { + + public Circle(ParticleElement particleElement) { + super(particleElement); + } + + @Override + public String attribute() { + return "PARTICLE_ATTRIBUTE_CIRCLE"; + } + + @Override + public void tick(ParticleTickData particleTickData) { + Location location = particleTickData.getLocation(); + + Vector vector = new Vector(1, 0, 0); + vector.rotateAroundY(particleTickData.getDeg()); + ParticleTickData nParticleTickData = particleTickData.withLocation(location.clone().add(vector)); + particleElement.tick(nParticleTickData); + } +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/Cloud.java b/src/de/steamwar/lobby/otherparticle/elements/Cloud.java new file mode 100644 index 0000000..3ad3834 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/Cloud.java @@ -0,0 +1,31 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; +import org.bukkit.Material; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class Cloud extends DelegatingParticleElement { + + public Cloud(ParticleElement particleElement) { + super(particleElement); + } + + @Override + public String attribute() { + return "PARTICLE_ATTRIBUTE_CLOUD"; + } + + @Override + public void tick(ParticleTickData particleTickData) { + if (particleTickData.getWorld().getBlockAt(particleTickData.getPlayer().getLocation().subtract(0, 0.5, 0)).getType() == Material.AIR) { + particleTickData.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false)); + } else { + particleTickData.getPlayer().removePotionEffect(PotionEffectType.SLOW_FALLING); + return; + } + ParticleTickData nParticleTickData = particleTickData.withLocation(particleTickData.getLocation().subtract(0, -0.2, 0)); + particleElement.tick(nParticleTickData); + } +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/Delayed.java b/src/de/steamwar/lobby/otherparticle/elements/Delayed.java new file mode 100644 index 0000000..472f339 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/Delayed.java @@ -0,0 +1,48 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.LobbySystem; +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashMap; +import java.util.Map; + +public class Delayed extends DelegatingParticleElement { + + private DelayedData delayedData = new DelayedData(); + private int interval; + + private static class DelayedData implements Listener { + private Map data = new HashMap<>(); + + @EventHandler(ignoreCancelled = true) + public void onPlayerQuit(PlayerQuitEvent event) { + data.remove(event.getPlayer()); + } + } + + public Delayed(ParticleElement particleElement, int interval) { + super(particleElement); + Bukkit.getPluginManager().registerEvents(delayedData, LobbySystem.getPlugin()); + } + + @Override + public String attribute() { + return null; + } + + @Override + public void tick(ParticleTickData particleTickData) { + int currentNumber = delayedData.data.getOrDefault(particleTickData.getPlayer(), 0) % interval; + delayedData.data.put(particleTickData.getPlayer(), currentNumber + 1); + if (currentNumber != 0) { + return; + } + particleElement.tick(particleTickData); + } +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/DelegatingParticleElement.java b/src/de/steamwar/lobby/otherparticle/elements/DelegatingParticleElement.java new file mode 100644 index 0000000..e961f29 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/DelegatingParticleElement.java @@ -0,0 +1,30 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleData; +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickType; + +public abstract class DelegatingParticleElement implements ParticleElement { + + protected final ParticleElement particleElement; + + protected DelegatingParticleElement(ParticleElement particleElement) { + this.particleElement = particleElement; + } + + public abstract String attribute(); + + @Override + public void aggregateAttributes(ParticleData particleData) { + String attribute = attribute(); + if (attribute != null) { + particleData.add(attribute); + } + particleElement.aggregateAttributes(particleData); + } + + @Override + public ParticleTickType tickType() { + return particleElement.tickType(); + } +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/DoubleCircle.java b/src/de/steamwar/lobby/otherparticle/elements/DoubleCircle.java new file mode 100644 index 0000000..dbb838e --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/DoubleCircle.java @@ -0,0 +1,47 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.otherparticle.ParticleTickType; +import org.bukkit.Location; +import org.bukkit.util.Vector; + +public class DoubleCircle extends Circle { + + private ParticleElement second; + + public DoubleCircle(ParticleElement first, ParticleElement second) { + super(first); + this.second = second; + } + + @Override + public String attribute() { + return "PARTICLE_ATTRIBUTE_BI_CIRCLE"; + } + + @Override + public ParticleTickType tickType() { + if (particleElement.tickType() == second.tickType()) { + return particleElement.tickType(); + } + // TODO: This could be improved but I will not do it + return ParticleTickType.MOVE; + } + + @Override + public void tick(ParticleTickData particleTickData) { + Location location = particleTickData.getLocation(); + + Vector vector = new Vector(1, 0, 0); + vector.rotateAroundY(particleTickData.getDeg()); + ParticleTickData nParticleTickData = particleTickData.withLocation(location.clone().add(vector)); + particleElement.tick(nParticleTickData); + + vector.setX(-vector.getX()); + vector.setZ(-vector.getZ()); + + nParticleTickData = particleTickData.withLocation(location.clone().add(vector)); + second.tick(nParticleTickData); + } +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/DustParticle.java b/src/de/steamwar/lobby/otherparticle/elements/DustParticle.java new file mode 100644 index 0000000..55ca442 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/DustParticle.java @@ -0,0 +1,44 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; +import org.bukkit.Location; +import org.bukkit.Particle; + +public class DustParticle implements ParticleElement { + + private Particle particle; + private float vx = 0.01f; + private float vy = 0.01f; + private float vz = 0.01f; + private double speed = 0.01; + private int count = 5; + + public DustParticle(Particle particle) { + this.particle = particle; + } + + public DustParticle(Particle particle, float vx, float vy, float vz) { + this.particle = particle; + this.vx = vx; + this.vy = vy; + this.vz = vz; + } + + public DustParticle(Particle particle, float vx, float vy, float vz, float speed, int count) { + this.particle = particle; + this.vx = vx; + this.vy = vy; + this.vz = vz; + this.speed = speed; + this.count = count; + } + + @Override + public void tick(ParticleTickData particleTickData) { + Location location = particleTickData.getLocation().add(0.0, 0.2, 0.0); + display(location, player -> { + player.spawnParticle(particle, location, count, vx, vy, vz, speed, randomParticleDust()); + }); + } +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/Group.java b/src/de/steamwar/lobby/otherparticle/elements/Group.java new file mode 100644 index 0000000..8f0e9a7 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/Group.java @@ -0,0 +1,27 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; + +public class Group extends DelegatingParticleElement { + + private final ParticleElement[] rest; + + public Group(ParticleElement particleElement, ParticleElement... rest) { + super(particleElement); + this.rest = rest; + } + + @Override + public String attribute() { + return null; + } + + @Override + public void tick(ParticleTickData particleTickData) { + particleElement.tick(particleTickData); + for (ParticleElement particleElement : rest) { + particleElement.tick(particleTickData); + } + } +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java b/src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java new file mode 100644 index 0000000..f0e389d --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java @@ -0,0 +1,28 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; +import org.bukkit.Location; + +import java.util.function.UnaryOperator; + +public class LocationMutator extends DelegatingParticleElement { + + private UnaryOperator mutator; + + public LocationMutator(ParticleElement particleElement, UnaryOperator mutator) { + super(particleElement); + this.mutator = mutator; + } + + @Override + public String attribute() { + return null; + } + + @Override + public void tick(ParticleTickData particleTickData) { + ParticleTickData nParticleTickData = particleTickData.withLocation(mutator.apply(particleTickData.getLocation())); + particleElement.tick(nParticleTickData); + } +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/NonFloor.java b/src/de/steamwar/lobby/otherparticle/elements/NonFloor.java new file mode 100644 index 0000000..f99dc71 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/NonFloor.java @@ -0,0 +1,23 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; + +public class NonFloor extends DelegatingParticleElement { + + public NonFloor(ParticleElement particleElement) { + super(particleElement); + } + + @Override + public String attribute() { + return "PARTICLE_ATTRIBUTE_NON_FLOOR"; + } + + @Override + public void tick(ParticleTickData particleTickData) { + if (particleTickData.getWorld().getBlockAt(particleTickData.getPlayer().getLocation().subtract(0, 0.5, 0)).getType().isAir()) { + particleElement.tick(particleTickData); + } + } +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/NonFlying.java b/src/de/steamwar/lobby/otherparticle/elements/NonFlying.java new file mode 100644 index 0000000..85d7037 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/NonFlying.java @@ -0,0 +1,24 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; + +public class NonFlying extends DelegatingParticleElement { + + public NonFlying(ParticleElement particleElement) { + super(particleElement); + } + + @Override + public String attribute() { + return null; + } + + @Override + public void tick(ParticleTickData particleTickData) { + if (particleTickData.getPlayer().isGliding()) { + return; + } + particleElement.tick(particleTickData); + } +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java b/src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java new file mode 100644 index 0000000..27164a2 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java @@ -0,0 +1,66 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; +import org.bukkit.Location; +import org.bukkit.Particle; + +public class SimpleParticle implements ParticleElement { + + private final Particle particle; + private boolean customVelocity = false; + private float vx; + private float vy; + private float vz; + private double time = 0.01; + private int count = 5; + + public SimpleParticle(Particle particle) { + this.particle = particle; + } + + public SimpleParticle(Particle particle, float vx, float vy, float vz) { + this.particle = particle; + this.customVelocity = true; + this.vx = vx; + this.vy = vy; + this.vz = vz; + } + + public SimpleParticle(Particle particle, float vx, float vy, float vz, double time) { + this.particle = particle; + this.customVelocity = true; + this.vx = vx; + this.vy = vy; + this.vz = vz; + this.time = time; + } + + public SimpleParticle(Particle particle, float vx, float vy, float vz, double time, int count) { + this.particle = particle; + this.customVelocity = true; + this.vx = vx; + this.vy = vy; + this.vz = vz; + this.time = time; + this.count = count; + } + + public SimpleParticle(Particle particle, double time, int count) { + this.particle = particle; + this.time = time; + this.count = count; + } + + @Override + public void tick(ParticleTickData particleTickData) { + Location location = particleTickData.getLocation().add(0.0, 0.2, 0.0); + display(location, player -> { + if (customVelocity) { + player.spawnParticle(particle, location, count, vx, vy, vz, time); + } else { + player.spawnParticle(particle, location, count); + } + }); + } +} -- 2.39.2 From 0f8a1757ebdc7fa2f581135b6da571bd5bf579ac Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 4 Apr 2023 10:03:51 +0200 Subject: [PATCH 10/18] Add Wing --- .../lobby/otherparticle/WingDesign.java | 41 +++++++++++++++++++ .../lobby/otherparticle/elements/Wing.java | 36 ++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 src/de/steamwar/lobby/otherparticle/WingDesign.java create mode 100644 src/de/steamwar/lobby/otherparticle/elements/Wing.java diff --git a/src/de/steamwar/lobby/otherparticle/WingDesign.java b/src/de/steamwar/lobby/otherparticle/WingDesign.java new file mode 100644 index 0000000..a0a9379 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/WingDesign.java @@ -0,0 +1,41 @@ +package de.steamwar.lobby.otherparticle; + +import de.steamwar.lobby.particle.decorator.WingParticle; +import lombok.SneakyThrows; +import org.bukkit.util.Vector; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; + +public interface WingDesign { + + @SneakyThrows + static Vector[] create(String resource) { + List vectors = new ArrayList<>(); + BufferedImage bufferedImage = ImageIO.read(WingParticle.class.getResourceAsStream(resource)); + for (int x = 0; x < bufferedImage.getWidth(); x++) { + for (int y = 0; y < bufferedImage.getHeight(); y++) { + int rgb = bufferedImage.getRGB(x, y); + if (Color.WHITE.getRGB() != rgb) { + vectors.add(new Vector(x - bufferedImage.getWidth() / 2.0, bufferedImage.getHeight() - y - 1.0, 0)); + } + } + } + return vectors.toArray(new Vector[0]); + } + + Vector[] getVectors(); + + WingDesign SIMPLE = () -> create("/de/steamwar/lobby/particle/decorator/WingSimple4.png"); + WingDesign COMPLEX = () -> create("/de/steamwar/lobby/particle/decorator/WingSimple2.png"); + WingDesign SWORD = () -> create("/de/steamwar/lobby/particle/decorator/WingSword.png"); + WingDesign SW = () -> create("/de/steamwar/lobby/particle/decorator/WingSW.png"); + WingDesign WGS = () -> create("/de/steamwar/lobby/particle/decorator/WingWGS.png"); + WingDesign SWORD_CROSSED = () -> create("/de/steamwar/lobby/particle/decorator/WingSwordCrossed.png"); + WingDesign MWGL = () -> create("/de/steamwar/lobby/particle/decorator/MWGL.png"); + + WingDesign ECLIPSE = () -> create("/de/steamwar/lobby/particle/decorator/ECLIPSE-Logo.png"); +} diff --git a/src/de/steamwar/lobby/otherparticle/elements/Wing.java b/src/de/steamwar/lobby/otherparticle/elements/Wing.java new file mode 100644 index 0000000..46b91d0 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/Wing.java @@ -0,0 +1,36 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.otherparticle.WingDesign; +import org.bukkit.Location; +import org.bukkit.util.Vector; + +public class Wing extends DelegatingParticleElement { + + private double size; + private WingDesign wingDesign; + + public Wing(ParticleElement particleElement, double size, WingDesign wingDesign) { + super(particleElement); + this.wingDesign = wingDesign; + } + + @Override + public String attribute() { + return "PARTICLE_ATTRIBUTE_WING"; + } + + @Override + public void tick(ParticleTickData particleTickData) { + for (Vector dVector : wingDesign.getVectors()) { + Vector vector = new Vector(dVector.getX() * size, 0.6 + dVector.getY() * size - (particleTickData.getPlayer().isSneaking() ? 0.5 : 0) , 0.5); + vector.rotateAroundY(Math.toRadians(particleTickData.getPlayer().getLocation().getYaw() * -1)); + vector.setX(-vector.getX()); + vector.setZ(-vector.getZ()); + Location location = particleTickData.getPlayer().getLocation().clone().add(vector); + ParticleTickData current = particleTickData.withLocation(location); + particleElement.tick(current); + } + } +} -- 2.39.2 From 7c49b93abfcbea7acd9935ba6419e15adcf0db33 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 4 Apr 2023 10:05:58 +0200 Subject: [PATCH 11/18] Fix WingDesign --- .../lobby/otherparticle/WingDesign.java | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/lobby/otherparticle/WingDesign.java b/src/de/steamwar/lobby/otherparticle/WingDesign.java index a0a9379..c1687ed 100644 --- a/src/de/steamwar/lobby/otherparticle/WingDesign.java +++ b/src/de/steamwar/lobby/otherparticle/WingDesign.java @@ -27,15 +27,28 @@ public interface WingDesign { return vectors.toArray(new Vector[0]); } + class WingDesignImpl implements WingDesign { + private final Vector[] vectors; + + public WingDesignImpl(Vector[] vectors) { + this.vectors = vectors; + } + + @Override + public Vector[] getVectors() { + return vectors; + } + } + Vector[] getVectors(); - WingDesign SIMPLE = () -> create("/de/steamwar/lobby/particle/decorator/WingSimple4.png"); - WingDesign COMPLEX = () -> create("/de/steamwar/lobby/particle/decorator/WingSimple2.png"); - WingDesign SWORD = () -> create("/de/steamwar/lobby/particle/decorator/WingSword.png"); - WingDesign SW = () -> create("/de/steamwar/lobby/particle/decorator/WingSW.png"); - WingDesign WGS = () -> create("/de/steamwar/lobby/particle/decorator/WingWGS.png"); - WingDesign SWORD_CROSSED = () -> create("/de/steamwar/lobby/particle/decorator/WingSwordCrossed.png"); - WingDesign MWGL = () -> create("/de/steamwar/lobby/particle/decorator/MWGL.png"); + WingDesign SIMPLE = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/WingSimple4.png")); + WingDesign COMPLEX = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/WingSimple2.png")); + WingDesign SWORD = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/WingSword.png")); + WingDesign SW = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/WingSW.png")); + WingDesign WGS = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/WingWGS.png")); + WingDesign SWORD_CROSSED = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/WingSwordCrossed.png")); + WingDesign MWGL = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/MWGL.png")); - WingDesign ECLIPSE = () -> create("/de/steamwar/lobby/particle/decorator/ECLIPSE-Logo.png"); + WingDesign ECLIPSE = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/ECLIPSE-Logo.png")); } -- 2.39.2 From 468cc040d677bd4b88157cd32086b65da3f546ec Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 4 Apr 2023 11:20:48 +0200 Subject: [PATCH 12/18] Update old particles to new system (WIP) --- .../lobby/otherparticle/ParticleData.java | 7 ++- .../otherparticle/elements/DustParticle.java | 2 +- .../elements/LocationMutator.java | 4 ++ .../otherparticle/elements/Sneaking.java | 30 +++++++++ .../particles/EasterParticle.java | 39 ++++++++++++ .../particles/EventParticle.java | 29 +++++++++ .../particles/EventParticleParticipation.java | 45 +++++++++++++ .../particles/EventParticlePlacement.java | 51 +++++++++++++++ .../particles/PlayerParticle.java | 63 +++++++++++++++++++ .../otherparticle/particles/TeamParticle.java | 50 +++++++++++++++ .../custom/CustomEasterParticle.java | 4 ++ .../particles/custom/CustomTeamParticle.java | 24 +++++++ 12 files changed, 345 insertions(+), 3 deletions(-) create mode 100644 src/de/steamwar/lobby/otherparticle/elements/Sneaking.java create mode 100644 src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java create mode 100644 src/de/steamwar/lobby/otherparticle/particles/EventParticle.java create mode 100644 src/de/steamwar/lobby/otherparticle/particles/EventParticleParticipation.java create mode 100644 src/de/steamwar/lobby/otherparticle/particles/EventParticlePlacement.java create mode 100644 src/de/steamwar/lobby/otherparticle/particles/PlayerParticle.java create mode 100644 src/de/steamwar/lobby/otherparticle/particles/TeamParticle.java create mode 100644 src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java create mode 100644 src/de/steamwar/lobby/otherparticle/particles/custom/CustomTeamParticle.java diff --git a/src/de/steamwar/lobby/otherparticle/ParticleData.java b/src/de/steamwar/lobby/otherparticle/ParticleData.java index e65dd57..b443250 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleData.java +++ b/src/de/steamwar/lobby/otherparticle/ParticleData.java @@ -16,17 +16,20 @@ public class ParticleData { private final String name; private final Set attributes = new LinkedHashSet<>(); private final ParticleRequirement requirement; + private final ParticleElement particleElement; - public ParticleData(Material material, String name) { + public ParticleData(Material material, String name, ParticleElement particleElement) { this.material = material; this.name = name; this.requirement = ParticleRequirement.NO_REQUIRMENT; + this.particleElement = particleElement; } - public ParticleData(Material material, String name, ParticleRequirement requirement) { + public ParticleData(Material material, String name, ParticleRequirement requirement, ParticleElement particleElement) { this.material = material; this.name = name; this.requirement = requirement; + this.particleElement = particleElement; } public ParticleData add(String attribute) { diff --git a/src/de/steamwar/lobby/otherparticle/elements/DustParticle.java b/src/de/steamwar/lobby/otherparticle/elements/DustParticle.java index 55ca442..96b37c1 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/DustParticle.java +++ b/src/de/steamwar/lobby/otherparticle/elements/DustParticle.java @@ -25,7 +25,7 @@ public class DustParticle implements ParticleElement { this.vz = vz; } - public DustParticle(Particle particle, float vx, float vy, float vz, float speed, int count) { + public DustParticle(Particle particle, float vx, float vy, float vz, double speed, int count) { this.particle = particle; this.vx = vx; this.vy = vy; diff --git a/src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java b/src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java index f0e389d..2de8f8a 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java +++ b/src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java @@ -15,6 +15,10 @@ public class LocationMutator extends DelegatingParticleElement { this.mutator = mutator; } + public LocationMutator(ParticleElement particleElement, double vx, double vy, double vz) { + this(particleElement, location -> location.add(vx, vy, vz)); + } + @Override public String attribute() { return null; diff --git a/src/de/steamwar/lobby/otherparticle/elements/Sneaking.java b/src/de/steamwar/lobby/otherparticle/elements/Sneaking.java new file mode 100644 index 0000000..a087ba5 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/elements/Sneaking.java @@ -0,0 +1,30 @@ +package de.steamwar.lobby.otherparticle.elements; + +import de.steamwar.lobby.otherparticle.ParticleElement; +import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.otherparticle.ParticleTickType; + +public class Sneaking extends DelegatingParticleElement { + + public Sneaking(ParticleElement particleElement) { + super(particleElement); + } + + @Override + public ParticleTickType tickType() { + return ParticleTickType.SNEAK; + } + + @Override + public String attribute() { + return null; // TODO: Implement this attribute + } + + @Override + public void tick(ParticleTickData particleTickData) { + if (!particleTickData.getPlayer().isSneaking()) { + return; + } + particleElement.tick(particleTickData); + } +} diff --git a/src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java b/src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java new file mode 100644 index 0000000..c5291e7 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java @@ -0,0 +1,39 @@ +package de.steamwar.lobby.otherparticle.particles; + +import de.steamwar.lobby.otherparticle.ParticleData; +import de.steamwar.lobby.otherparticle.ParticleEnum; +import de.steamwar.lobby.otherparticle.ParticleRequirement; +import de.steamwar.lobby.otherparticle.elements.LocationMutator; +import de.steamwar.lobby.otherparticle.elements.SimpleParticle; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Material; +import org.bukkit.Particle; + +@AllArgsConstructor +public enum EasterParticle implements ParticleEnum { + + EGG_HUNT_EASY(new ParticleData(Material.LIME_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_EASY", ParticleRequirement.EGG_HUNT_EASY, + new LocationMutator(new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM), 0, 2.2, 0)) + ), + EGG_HUNT_MEDIUM(new ParticleData(Material.YELLOW_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_MEDIUM", ParticleRequirement.EGG_HUNT_MEDIUM, + new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + ), + EGG_HUNT_HARD(new ParticleData(Material.ORANGE_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_HARD", ParticleRequirement.EGG_HUNT_HARD, + new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + ), + EGG_HUNT_EXTREME(new ParticleData(Material.RED_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_EXTREME", ParticleRequirement.EGG_HUNT_EXTREME, + new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + ), + EGG_HUNT_ADVANCED(new ParticleData(Material.PURPLE_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_ADVANCED", ParticleRequirement.EGG_HUNT_ADVANCED, + new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + ), + EGG_HUNT_HALF(new ParticleData(Material.PURPLE_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_HALF", ParticleRequirement.EGG_HUNT_FOUND_HALF, + new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + ), + ; + public static ParticleEnum[] particles = values(); + + @Getter + private ParticleData particle; +} diff --git a/src/de/steamwar/lobby/otherparticle/particles/EventParticle.java b/src/de/steamwar/lobby/otherparticle/particles/EventParticle.java new file mode 100644 index 0000000..abaa6bd --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/particles/EventParticle.java @@ -0,0 +1,29 @@ +package de.steamwar.lobby.otherparticle.particles; + +import de.steamwar.lobby.otherparticle.ParticleData; +import de.steamwar.lobby.otherparticle.ParticleEnum; +import de.steamwar.lobby.otherparticle.ParticleRequirement; +import de.steamwar.lobby.otherparticle.elements.Always; +import de.steamwar.lobby.otherparticle.elements.Circle; +import de.steamwar.lobby.otherparticle.elements.LocationMutator; +import de.steamwar.lobby.otherparticle.elements.SimpleParticle; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Material; +import org.bukkit.Particle; + +@AllArgsConstructor +public enum EventParticle implements ParticleEnum { + + WATER(new ParticleData(Material.WATER_BUCKET, "PARTICLE_WATER", ParticleRequirement.EVENT_PARTICIPATION, + new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIP_WATER), 0, 1.1, 0)))) + ), + LAVA(new ParticleData(Material.LAVA_BUCKET, "PARTICLE_FIRE", ParticleRequirement.EVENT_PARTICIPATION, + new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIP_LAVA), 0, 1.1, 0)))) + ), + ; + public static ParticleEnum[] particles = values(); + + @Getter + private ParticleData particle; +} diff --git a/src/de/steamwar/lobby/otherparticle/particles/EventParticleParticipation.java b/src/de/steamwar/lobby/otherparticle/particles/EventParticleParticipation.java new file mode 100644 index 0000000..a55a3bd --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/particles/EventParticleParticipation.java @@ -0,0 +1,45 @@ +package de.steamwar.lobby.otherparticle.particles; + +import de.steamwar.lobby.otherparticle.ParticleData; +import de.steamwar.lobby.otherparticle.ParticleEnum; +import de.steamwar.lobby.otherparticle.ParticleRequirement; +import de.steamwar.lobby.otherparticle.WingDesign; +import de.steamwar.lobby.otherparticle.elements.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Material; +import org.bukkit.Particle; + +@AllArgsConstructor +public enum EventParticleParticipation implements ParticleEnum { + + WarGearSeason(new ParticleData(Material.BOOK, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.eventParticipation(22), + new SimpleParticle(Particle.ENCHANTMENT_TABLE)) + ), + AirshipEvent(new ParticleData(Material.SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", ParticleRequirement.eventParticipation(26), + new SimpleParticle(Particle.CLOUD)) + ), + HellsBellsWs(new ParticleData(Material.TNT, "PARTICLE_EVENT_SMOKE", ParticleRequirement.eventParticipation(28), + new Circle(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))) + ), + Underwater(new ParticleData(Material.PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(31), + new SimpleParticle(Particle.DRIP_WATER)) + ), + AdventWarShip(new ParticleData(Material.PRISMARINE_WALL, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(32), + new Group(new SimpleParticle(Particle.DRIP_WATER), new SimpleParticle(Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))) + ), + MiniWarGearLiga(new ParticleData(Material.PRISMARINE_SLAB, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(33), + new Circle(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0))) + ), + UnderwaterMWG(new ParticleData(Material.BLUE_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", ParticleRequirement.eventParticipation(35), + new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new SimpleParticle(Particle.WATER_WAKE, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.DRIP_WATER, 0.3F, 0.0F, 0.3F, 0.01), 0, 0.2, 0)), 0, 2.2, 0))) + ), + WarGearSeason2022(new ParticleData(Material.DIAMOND_SWORD, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventParticipation(37), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.DRAGON_BREATH, 0, 0, 0, 0, 1), 0.15, WingDesign.COMPLEX)), 20))) + ), + ; + public static ParticleEnum[] particles = values(); + + @Getter + private ParticleData particle; +} diff --git a/src/de/steamwar/lobby/otherparticle/particles/EventParticlePlacement.java b/src/de/steamwar/lobby/otherparticle/particles/EventParticlePlacement.java new file mode 100644 index 0000000..e339e72 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/particles/EventParticlePlacement.java @@ -0,0 +1,51 @@ +package de.steamwar.lobby.otherparticle.particles; + +import de.steamwar.lobby.otherparticle.ParticleData; +import de.steamwar.lobby.otherparticle.ParticleEnum; +import de.steamwar.lobby.otherparticle.ParticleRequirement; +import de.steamwar.lobby.otherparticle.WingDesign; +import de.steamwar.lobby.otherparticle.elements.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Material; +import org.bukkit.Particle; + +@AllArgsConstructor +public enum EventParticlePlacement implements ParticleEnum { + + WarGearSeason(new ParticleData(Material.ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.eventPlacement(22, 12, 285, 54), + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), 0, 1.1, 0))) + )), + AirshipEvent(new ParticleData(Material.SNOWBALL, "PARTICLE_EVENT_CLOUD", ParticleRequirement.eventPlacement(26, 205, 9, 54, 120, 292), + new Circle(new LocationMutator(new SimpleParticle(Particle.CLOUD, 0, 0, 0, 0.01), 0, 2.2, 0)) + )), + HellsBellsWs(new ParticleData(Material.TNT_MINECART, "PARTICLE_EVENT_SMOKE", ParticleRequirement.eventPlacement(28, 205, 9, 11), + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01), 0, 2.2, 0))) + )), + Underwater(new ParticleData(Material.PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", ParticleRequirement.eventPlacement(31, 9, 210, 520), + new Cloud(new SimpleParticle(Particle.DRIP_WATER))) + ), + AdventWarShip(new ParticleData(Material.PRISMARINE_CRYSTALS, "PARTICLE_EVENT_WATER", ParticleRequirement.eventPlacement(31, 9, 205, 210), + new Always(new LocationMutator(new Circle(new Group(new SimpleParticle(Particle.DRIP_WATER), new SimpleParticle(Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))), 0, 1.1, 0))) + ), + MiniWarGearLiga(new ParticleData(Material.IRON_SWORD, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventPlacement(33, 9, 34, 205), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0, 1), 0.15, WingDesign.MWGL)), 20))) + ), + Absturz(new ParticleData(Material.FEATHER, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventPlacement(34, 210, 205, 527, 286), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) + ), + UnderwaterMWG(new ParticleData(Material.CYAN_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", ParticleRequirement.eventPlacement(35, 9, 210), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingDesign.SW)), 20))) + ), + WarGearSeason2022(new ParticleData(Material.DIAMOND_HELMET, "PARTICLE_EVENT_WGS", ParticleRequirement.eventPlacement(37, 285, 210, 122), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 0, 1), 0.15, WingDesign.WGS)), 20))) + ), + WargearClash(new ParticleData(Material.GOLDEN_SWORD, "PARTICLE_EVENT_WARGEARCLASH", ParticleRequirement.eventPlacement(38, 210, 158, 167, 286), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.1, WingDesign.SWORD_CROSSED)), 20))) + ), + ; + public static ParticleEnum[] particles = values(); + + @Getter + private ParticleData particle; +} diff --git a/src/de/steamwar/lobby/otherparticle/particles/PlayerParticle.java b/src/de/steamwar/lobby/otherparticle/particles/PlayerParticle.java new file mode 100644 index 0000000..88d095e --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/particles/PlayerParticle.java @@ -0,0 +1,63 @@ +package de.steamwar.lobby.otherparticle.particles; + +import de.steamwar.lobby.otherparticle.ParticleData; +import de.steamwar.lobby.otherparticle.ParticleEnum; +import de.steamwar.lobby.otherparticle.elements.DustParticle; +import de.steamwar.lobby.otherparticle.elements.LocationMutator; +import de.steamwar.lobby.otherparticle.elements.SimpleParticle; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Material; +import org.bukkit.Particle; + +@AllArgsConstructor +public enum PlayerParticle implements ParticleEnum { + + SNEEZE(new ParticleData(Material.SLIME_BLOCK, "PARTICLE_SNEEZE", + new SimpleParticle(Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)) + ), + SMOKE(new ParticleData(Material.COBWEB, "PARTICLE_SMOKE", + new SimpleParticle(Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)) + ), + FIRE(new ParticleData(Material.LAVA_BUCKET, "PARTICLE_FIRE", + new SimpleParticle(Particle.DRIP_LAVA)) + ), + WATER(new ParticleData(Material.WATER_BUCKET, "PARTICLE_WATER", + new SimpleParticle(Particle.DRIP_WATER)) + ), + HEARTH(new ParticleData(Material.RED_DYE, "PARTICLE_HEART", + new LocationMutator(new SimpleParticle(Particle.HEART), 0, 2.2, 0)) + ), + NOTES(new ParticleData(Material.NOTE_BLOCK, "PARTICLE_NOTES", + new LocationMutator(new SimpleParticle(Particle.NOTE), 0, 2.2, 0)) + ), + NAUTILUS(new ParticleData(Material.NAUTILUS_SHELL, "PARTICLE_NAUTILUS", + new SimpleParticle(Particle.NAUTILUS, 0.2F, 0.2F ,0.2F, 0.01)) + ), + SNOWBALL(new ParticleData(Material.SNOWBALL, "PARTICLE_SNOWBALL", + new SimpleParticle(Particle.SNOWBALL, 0.2F, 0.2F ,0.2F, 0.01)) + ), + EFFECT(new ParticleData(Material.GLASS_BOTTLE, "PARTICLE_EFFECT", + new DustParticle(Particle.REDSTONE, 0, 0.2F, 02F, 0.01, 5)) + ), + CAMPFIRE(new ParticleData(Material.CAMPFIRE, "PARTICLE_CAMPFIRE", + new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0.2F ,0, 0.01)) + ), + MAGIC(new ParticleData(Material.CAULDRON, "PARTICLE_MAGIC", + new SimpleParticle(Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)) + ), + ANGRY(new ParticleData(Material.REDSTONE_BLOCK, "PARTICLE_ANGRY", + new SimpleParticle(Particle.VILLAGER_ANGRY, 0.2F, 0.2F, 0.2F, 0.01)) + ), + SLIME(new ParticleData(Material.SLIME_BALL, "PARTICLE_SLIME", + new SimpleParticle(Particle.SLIME)) + ), + MOB(new ParticleData(Material.ZOMBIE_HEAD, "PARTICLE_MOB", + new SimpleParticle(Particle.SPELL_MOB)) + ), + ; + public static ParticleEnum[] particles = values(); + + @Getter + private ParticleData particle; +} diff --git a/src/de/steamwar/lobby/otherparticle/particles/TeamParticle.java b/src/de/steamwar/lobby/otherparticle/particles/TeamParticle.java new file mode 100644 index 0000000..12bcd2c --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/particles/TeamParticle.java @@ -0,0 +1,50 @@ +package de.steamwar.lobby.otherparticle.particles; + +import de.steamwar.lobby.otherparticle.ParticleData; +import de.steamwar.lobby.otherparticle.ParticleEnum; +import de.steamwar.lobby.otherparticle.ParticleRequirement; +import de.steamwar.lobby.otherparticle.elements.Circle; +import de.steamwar.lobby.otherparticle.elements.LocationMutator; +import de.steamwar.lobby.otherparticle.elements.NonFloor; +import de.steamwar.lobby.otherparticle.elements.SimpleParticle; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Material; +import org.bukkit.Particle; + +@AllArgsConstructor +public enum TeamParticle implements ParticleEnum { + + SQUID(new ParticleData(Material.INK_SAC, "PARTICLE_SQUID", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)) + ), + BUBBLE(new ParticleData(Material.TUBE_CORAL, "PARTICLE_BUBBLE", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)) + ), + HONEY(new ParticleData(Material.HONEY_BOTTLE, "PARTICLE_HONEY", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)) + ), + NECTAR(new ParticleData(Material.HONEYCOMB, "PARTICLE_NECTAR", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)) + ), + FIREWORK(new ParticleData(Material.FIRE_CHARGE, "PARTICLE_FIREWORK", ParticleRequirement.HAS_TEAM, + new LocationMutator(new NonFloor(new SimpleParticle(Particle.FIREWORKS_SPARK, 0.1F, 0.1F, 0.1F, 0.2, 2)), 0, -0.2, 0)) + ), + DRAGON_BREATH(new ParticleData(Material.DRAGON_BREATH, "PARTICLE_DRAGON_BREATH", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.DRAGON_BREATH, 1F, 0.2F, 1F, 0.01)) + ), + DAMAGE(new ParticleData(Material.SPIDER_EYE, "PARTICLE_DAMAGE", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.DAMAGE_INDICATOR, 0.2F, 0, 0.2F, 0.01)) + ), + DOLPHIN(new ParticleData(Material.BLUE_DYE, "PARTICLE_DOLPHIN", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.DOLPHIN, 0.2F, 0, 0.2F, 0.01)) + ), + HEART(new ParticleData(Material.RED_CONCRETE, "PARTICLE_HEART", ParticleRequirement.HAS_TEAM, + new Circle(new LocationMutator(new SimpleParticle(Particle.HEART), 0, 2.2, 0))) + ), + ; + public static ParticleEnum[] particles = values(); + + @Getter + private ParticleData particle; +} diff --git a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java b/src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java new file mode 100644 index 0000000..6b086ea --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java @@ -0,0 +1,4 @@ +package de.steamwar.lobby.otherparticle.particles.custom; + +public enum CustomEasterParticle { +} diff --git a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomTeamParticle.java b/src/de/steamwar/lobby/otherparticle/particles/custom/CustomTeamParticle.java new file mode 100644 index 0000000..a6234bd --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/particles/custom/CustomTeamParticle.java @@ -0,0 +1,24 @@ +package de.steamwar.lobby.otherparticle.particles.custom; + +import de.steamwar.lobby.otherparticle.ParticleData; +import de.steamwar.lobby.otherparticle.ParticleEnum; +import de.steamwar.lobby.otherparticle.ParticleRequirement; +import de.steamwar.lobby.otherparticle.WingDesign; +import de.steamwar.lobby.otherparticle.elements.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Material; +import org.bukkit.Particle; + +@AllArgsConstructor +public enum CustomTeamParticle implements ParticleEnum { + + Eclipse(new ParticleData(Material.ENDER_CHEST, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.specificTeam(34), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.PORTAL, 0, 0, 0, 0.01), 0.15, WingDesign.ECLIPSE)), 20))) + ), + ; + public static ParticleEnum[] particles = values(); + + @Getter + private ParticleData particle; +} -- 2.39.2 From 29474ebfafb5c9d577cec4ab37c0a65b6ac33f7a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 4 Apr 2023 14:33:00 +0200 Subject: [PATCH 13/18] Add ServerTeamParticle and CustomPlayerParticle --- src/de/steamwar/lobby/LobbySystem.properties | 2 +- .../steamwar/lobby/LobbySystem_de.properties | 2 +- .../lobby/otherparticle/ParticleData.java | 21 +++- .../otherparticle/ParticleInventory.java | 97 ++++++++++++++++++ .../otherparticle/ParticleRequirement.java | 65 ++++++------ .../elements/SimpleParticle.java | 2 +- .../particles/EasterParticle.java | 3 +- .../particles/ServerTeamParticle.java | 99 +++++++++++++++++++ .../custom/CustomEasterParticle.java | 14 ++- .../custom/CustomPlayerParticle.java | 16 +++ .../special/easter/EggClickListener.java | 4 +- .../lobby/special/easter/EggHunt.java | 2 + .../lobby/special/easter/EggHuntCommand.java | 2 +- 13 files changed, 283 insertions(+), 46 deletions(-) create mode 100644 src/de/steamwar/lobby/otherparticle/ParticleInventory.java create mode 100644 src/de/steamwar/lobby/otherparticle/particles/ServerTeamParticle.java create mode 100644 src/de/steamwar/lobby/otherparticle/particles/custom/CustomPlayerParticle.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index e4236b8..4b3918e 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -18,7 +18,6 @@ PORTAL_NO_WORLDEDIT_SELECTION = §cNo WorldEdit selection # Particle PARTICLE_INVENTORY = §6Particle PARTICLE_DESELECT = §8No particle -PARTICLE_LOCKED = {0} §8- §c§lLocked PARTICLE_UNLOCKED_BY = §eUnlocked by PARTICLE_UNLOCKED_BY_TEAM = §fJoin a team @@ -40,6 +39,7 @@ PARTICLE_ATTRIBUTE_WING = §8-§f Wings PARTICLE_ATTRIBUTE = §eAttributes§7: PARTICLE_SELECT = §eClick to select +PARTICLE_LOCKED = §c§lLocked PARTICLE_SNEEZE = §aSneeze PARTICLE_SMOKE = §7Smoke diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index 357a0af..a28262e 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -18,7 +18,6 @@ PORTAL_NO_WORLDEDIT_SELECTION = §cKeine WorldEdit Selection # Particle PARTICLE_INVENTORY = §6Partikel PARTICLE_DESELECT = §8Keine Partikel -PARTICLE_LOCKED = {0} §8- §c§lGesperrt PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch PARTICLE_UNLOCKED_BY_TEAM = §fTeambeitritt @@ -40,6 +39,7 @@ PARTICLE_ATTRIBUTE_WING = §8-§f Flügel PARTICLE_ATTRIBUTE = §eAttribute§7: PARTICLE_SELECT = §eZum Auswählen klicken +PARTICLE_LOCKED = §c§lGesperrt PARTICLE_SNEEZE = §aSneeze PARTICLE_SMOKE = §7Rauch diff --git a/src/de/steamwar/lobby/otherparticle/ParticleData.java b/src/de/steamwar/lobby/otherparticle/ParticleData.java index b443250..8a70c08 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleData.java +++ b/src/de/steamwar/lobby/otherparticle/ParticleData.java @@ -2,6 +2,9 @@ package de.steamwar.lobby.otherparticle; import de.steamwar.inventory.SWItem; import de.steamwar.lobby.LobbySystem; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserGroup; +import lombok.Getter; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -15,7 +18,11 @@ public class ParticleData { private final Material material; private final String name; private final Set attributes = new LinkedHashSet<>(); + + @Getter private final ParticleRequirement requirement; + + @Getter private final ParticleElement particleElement; public ParticleData(Material material, String name, ParticleElement particleElement) { @@ -23,6 +30,7 @@ public class ParticleData { this.name = name; this.requirement = ParticleRequirement.NO_REQUIRMENT; this.particleElement = particleElement; + particleElement.aggregateAttributes(this); } public ParticleData(Material material, String name, ParticleRequirement requirement, ParticleElement particleElement) { @@ -30,6 +38,7 @@ public class ParticleData { this.name = name; this.requirement = requirement; this.particleElement = particleElement; + particleElement.aggregateAttributes(this); } public ParticleData add(String attribute) { @@ -37,7 +46,7 @@ public class ParticleData { return this; } - public SWItem toSWItem(Player player) { + public SWItem toSWItem(Player player, SteamwarUser user, Set eventTeilnahme, String eggHuntConfig) { String translatedName = LobbySystem.getMessage().parse(name, player); List lore = new ArrayList<>(); lore.add(""); @@ -46,13 +55,21 @@ public class ParticleData { attributes.forEach(attribute -> lore.add(LobbySystem.getMessage().parse(attribute, player))); lore.add(""); } + + boolean selectable = requirement.getRequirement().test(user, eventTeilnahme, eggHuntConfig); + selectable |= user.getUserGroup() != UserGroup.Member; + String unlockedBy = requirement.getRequirementName(player); if (unlockedBy != null) { lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player)); lore.add(unlockedBy); lore.add(""); } - lore.add(LobbySystem.getMessage().parse("PARTICLE_SELECT", player)); + if (selectable) { + 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 -> {}); } } diff --git a/src/de/steamwar/lobby/otherparticle/ParticleInventory.java b/src/de/steamwar/lobby/otherparticle/ParticleInventory.java new file mode 100644 index 0000000..252a140 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/ParticleInventory.java @@ -0,0 +1,97 @@ +package de.steamwar.lobby.otherparticle; + +import de.steamwar.inventory.SWItem; +import de.steamwar.inventory.SWListInv; +import de.steamwar.lobby.LobbySystem; +import de.steamwar.lobby.otherparticle.particles.*; +import de.steamwar.lobby.otherparticle.particles.custom.CustomEasterParticle; +import de.steamwar.lobby.otherparticle.particles.custom.CustomPlayerParticle; +import de.steamwar.lobby.otherparticle.particles.custom.CustomTeamParticle; +import de.steamwar.lobby.special.easter.EggHunt; +import de.steamwar.lobby.util.LobbyPlayer; +import de.steamwar.sql.*; +import lombok.experimental.UtilityClass; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +@UtilityClass +public class ParticleInventory { + + private final Class[] PARTICLES = { + PlayerParticle.class, + CustomPlayerParticle.class, + TeamParticle.class, + CustomTeamParticle.class, + ServerTeamParticle.class, + EventParticle.class, + EventParticlePlacement.class, + EventParticleParticipation.class, + EasterParticle.class, + CustomEasterParticle.class, + }; + + public String convertToString(ParticleEnum particleEnum) { + return particleEnum.getClass().getSimpleName() + "@" + ((Enum)particleEnum).name(); + } + + public ParticleEnum convertFromString(String string) { + String[] split = string.split("@"); + Class clazz = null; + for (Class aClass : PARTICLES) { + if (aClass.getSimpleName().equals(split[0])) { + clazz = aClass; + break; + } + } + if (clazz != null) { + try { + return (ParticleEnum) Enum.valueOf((Class) clazz, split[1]); + } catch (Exception e) { + return null; + } + } + // TODO: Add conversion from last version + return null; + } + + public void openInventory(Player player) { + LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); + + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Set events = user.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(user.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet()); + String eggHuntConfig = UserConfig.getConfig(user.getId(), EggHunt.EGG_HUNT_CONFIG_KEY); + + List> particleList = new ArrayList<>(); + for (Class clazz : PARTICLES) { + addParticles(particleList, (ParticleEnum[]) clazz.getEnumConstants(), player, user, events, eggHuntConfig); + } + + SWListInv particleSWListInv = new SWListInv<>(player, LobbySystem.getMessage().parse("PARTICLE_INVENTORY", player), false, particleList, (clickType, particle) -> { + if (particle == null) return; + // lobbyPlayer.setParticle(particle); // TODO: Update this + player.closeInventory(); + }); + particleSWListInv.setItem(49, Material.BARRIER, LobbySystem.getMessage().parse("PARTICLE_DESELECT", player), new ArrayList<>(), false, clickType -> { + lobbyPlayer.setParticle(null); + }); + particleSWListInv.open(); + } + + private void addParticles(List> particleList, ParticleEnum[] particleEnums, Player player, SteamwarUser user, Set events, String eggHuntConfig) { + for (ParticleEnum particle : particleEnums) { + ParticleData particleData = particle.getParticle(); + SWItem swItem = particleData.toSWItem(player, user, events, eggHuntConfig); + if (particleData.getRequirement().test(user, events, eggHuntConfig) || user.getUserGroup() != UserGroup.Member) { + particleList.add(new SWListInv.SWListEntry<>(swItem, particle)); + } else { + particleList.add(new SWListInv.SWListEntry<>(swItem, null)); + } + } + } +} diff --git a/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java b/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java index b911693..71f404d 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java +++ b/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java @@ -6,7 +6,6 @@ import de.steamwar.lobby.special.easter.EggHunt; import de.steamwar.sql.Event; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.Team; -import de.steamwar.sql.UserGroup; import org.bukkit.entity.Player; import java.util.HashSet; @@ -19,7 +18,7 @@ import java.util.stream.Collectors; public interface ParticleRequirement { String getRequirementName(Player player); - ParticleRequirementPredicate getRequirement(); + boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig); ParticleRequirement NO_REQUIRMENT = new ParticleRequirement() { @Override @@ -28,8 +27,8 @@ public interface ParticleRequirement { } @Override - public ParticleRequirementPredicate getRequirement() { - return (player, eventTeilname, eggHuntConfig) -> true; + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + return true; } }; ParticleRequirement HAS_TEAM = new ParticleRequirement() { @@ -39,8 +38,8 @@ public interface ParticleRequirement { } @Override - public ParticleRequirementPredicate getRequirement() { - return (steamwarUser, eventTeilname, eggHuntConfig) -> steamwarUser.getTeam() != 0 || steamwarUser.getUserGroup() != UserGroup.Member; + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + return user.getTeam() != 0; } }; ParticleRequirement EVENT_PARTICIPATION = new ParticleRequirement() { @@ -50,8 +49,8 @@ public interface ParticleRequirement { } @Override - public ParticleRequirementPredicate getRequirement() { - return (steamwarUser, eventTeilname, eggHuntConfig) -> !eventTeilname.isEmpty(); + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + return !eventTeilname.isEmpty(); } }; ParticleRequirement SERVER_TEAM = new ParticleRequirement() { @@ -61,8 +60,8 @@ public interface ParticleRequirement { } @Override - public ParticleRequirementPredicate getRequirement() { - return (steamwarUser, eventTeilname, eggHuntConfig) -> false; + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + return false; } }; ParticleRequirement EGG_HUNT_EASY = _easterEggHuntDifficulty(EggDifficulty.EASY); @@ -77,17 +76,15 @@ public interface ParticleRequirement { } @Override - public ParticleRequirementPredicate getRequirement() { - return (user, eventTeilname, eggHuntConfig) -> { - if (eggHuntConfig == null) return false; - int count = 0; - for (int i = 0; i < eggHuntConfig.length(); i++) { - if (eggHuntConfig.charAt(i) == '1') { - count++; - } + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + if (eggHuntConfig == null) return false; + int count = 0; + for (int i = 0; i < eggHuntConfig.length(); i++) { + if (eggHuntConfig.charAt(i) == '1') { + count++; } - return count >= EggHunt.getEggList().size() / 2; - }; + } + return count >= EggHunt.getEggList().size() / 2; } }; @@ -101,8 +98,8 @@ public interface ParticleRequirement { } @Override - public ParticleRequirementPredicate getRequirement() { - return (steamwarUser, eventTeilname, eggHuntConfig) -> steamwarUser.getTeam() == teamId; + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + return user.getTeam() == teamId; } }; } @@ -116,8 +113,8 @@ public interface ParticleRequirement { } @Override - public ParticleRequirementPredicate getRequirement() { - return (steamwarUser, eventTeilname, eggHuntConfig) -> eventTeilname.contains(eventId); + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + return eventTeilname.contains(eventId); } }; } @@ -133,11 +130,9 @@ public interface ParticleRequirement { } @Override - public ParticleRequirementPredicate getRequirement() { - return (steamwarUser, eventTeilname, eggHuntConfig) -> { - if (!eventTeilname.contains(eventId)) return false; - return teams.contains(steamwarUser.getTeam()); - }; + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + if (!eventTeilname.contains(eventId)) return false; + return teams.contains(user.getTeam()); } }; } @@ -164,11 +159,9 @@ public interface ParticleRequirement { } @Override - public ParticleRequirementPredicate getRequirement() { - return (steamwarUser, integers, eggHuntConfig) -> { - if (eggHuntConfig == null) return false; - return eggs.stream().allMatch(id -> eggHuntConfig.length() >= id && eggHuntConfig.charAt(id) == '1'); - }; + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + if (eggHuntConfig == null) return false; + return eggs.stream().allMatch(id -> eggHuntConfig.length() >= id && eggHuntConfig.charAt(id) == '1'); } }; } @@ -182,8 +175,8 @@ public interface ParticleRequirement { } @Override - public ParticleRequirementPredicate getRequirement() { - return (steamwarUser, integers, eggHuntConfig) -> steamwarUser.getId() == userId; + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + return user.getId() == userId; } }; } diff --git a/src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java b/src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java index 27164a2..d8e1204 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java +++ b/src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java @@ -12,7 +12,7 @@ public class SimpleParticle implements ParticleElement { private float vx; private float vy; private float vz; - private double time = 0.01; + private double time = 1; private int count = 5; public SimpleParticle(Particle particle) { diff --git a/src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java b/src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java index c5291e7..6ea1ca4 100644 --- a/src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java +++ b/src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java @@ -3,6 +3,7 @@ package de.steamwar.lobby.otherparticle.particles; import de.steamwar.lobby.otherparticle.ParticleData; import de.steamwar.lobby.otherparticle.ParticleEnum; import de.steamwar.lobby.otherparticle.ParticleRequirement; +import de.steamwar.lobby.otherparticle.elements.Always; import de.steamwar.lobby.otherparticle.elements.LocationMutator; import de.steamwar.lobby.otherparticle.elements.SimpleParticle; import lombok.AllArgsConstructor; @@ -14,7 +15,7 @@ import org.bukkit.Particle; public enum EasterParticle implements ParticleEnum { EGG_HUNT_EASY(new ParticleData(Material.LIME_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_EASY", ParticleRequirement.EGG_HUNT_EASY, - new LocationMutator(new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM), 0, 2.2, 0)) + new Always(new LocationMutator(new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM, 0.2F, 0.1f, 0.2F, 1, 5), 0, 2.2, 0))) ), EGG_HUNT_MEDIUM(new ParticleData(Material.YELLOW_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_MEDIUM", ParticleRequirement.EGG_HUNT_MEDIUM, new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) diff --git a/src/de/steamwar/lobby/otherparticle/particles/ServerTeamParticle.java b/src/de/steamwar/lobby/otherparticle/particles/ServerTeamParticle.java new file mode 100644 index 0000000..ada98bf --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/particles/ServerTeamParticle.java @@ -0,0 +1,99 @@ +package de.steamwar.lobby.otherparticle.particles; + +import de.steamwar.lobby.otherparticle.ParticleData; +import de.steamwar.lobby.otherparticle.ParticleEnum; +import de.steamwar.lobby.otherparticle.ParticleRequirement; +import de.steamwar.lobby.otherparticle.WingDesign; +import de.steamwar.lobby.otherparticle.elements.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Material; +import org.bukkit.Particle; + +@AllArgsConstructor +public enum ServerTeamParticle implements ParticleEnum { + + WITCH(new ParticleData(Material.EXPERIENCE_BOTTLE, "PARTICLE_WITCH", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.SPELL_WITCH)) + ), + ENCHANTING(new ParticleData(Material.ENCHANTING_TABLE, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.ENCHANTMENT_TABLE)) + ), + HAPPY(new ParticleData(Material.EMERALD_BLOCK, "PARTICLE_HAPPY", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.HEART, 0.2F, 0.2F, 0.2F, 0.01)) + ), + FLAME(new ParticleData(Material.FLINT_AND_STEEL, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.FLAME, 0, 0.2F, 0, 0.01)) + ), + END_ROD(new ParticleData(Material.END_ROD, "PARTICLE_END_ROD", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)) + ), + CLOUD(new ParticleData(Material.WHITE_WOOL, "PARTICLE_CLOUD", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.CLOUD))) + ), + TOTEM(new ParticleData(Material.TOTEM_OF_UNDYING, "PARTICLE_TOTEM", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.TOTEM, 0.2F, 0.2F, 0.2F, 0.01))) + ), + ENCHANTING_CLOUD(new ParticleData(Material.WHITE_DYE, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.ENCHANTMENT_TABLE))) + ), + FLAME_CLOUD(new ParticleData(Material.FIRE_CORAL_BLOCK, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.FLAME))) + ), + SNEEZE_CLOUD(new ParticleData(Material.LIME_SHULKER_BOX, "PARTICLE_SNEEZE", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.SNEEZE))) + ), + SLIME_CLOUD(new ParticleData(Material.GREEN_SHULKER_BOX, "PARTICLE_SLIME", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.SLIME))) + ), + SMOKE_CLOUD(new ParticleData(Material.DEAD_BRAIN_CORAL_BLOCK, "PARTICLE_SMOKE", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0.2F, 0.2F, 0.2F, 0.01))) + ), + TOWN_CLOUD(new ParticleData(Material.FIREWORK_STAR, "PARTICLE_TOWN", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.TOWN_AURA))) + ), + FLAME_CIRCLE(new ParticleData(Material.MAGMA_BLOCK, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, + new Circle(new LocationMutator(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0.01), 0, 1.1, 0))) + ), + ENCHANTING_CIRCLE(new ParticleData(Material.WHITE_DYE, "PARTICLE_ENCHANTING_CIRCLE", ParticleRequirement.SERVER_TEAM, + new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0.2F, 0.2F, 0.2F, 0.01), 0, 1.1, 0))) + ), + NOTES_CIRCLE(new ParticleData(Material.NOTE_BLOCK, "PARTICLE_NOTES", ParticleRequirement.SERVER_TEAM, + new Circle(new LocationMutator(new SimpleParticle(Particle.NOTE, 0, 0, 0, 0.01), 0, 2.2, 0))) + ), + WATER_FIRE(new ParticleData(Material.GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, + new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIP_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIP_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0)) + ), + WATER_FIRE_ALWAYS(new ParticleData(Material.GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, + new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIP_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIP_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0))) + ), + MAGIC_ENCHANTING(new ParticleData(Material.DIAMOND_SWORD, "PARTICLE_MAGIC_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 1.1, 0)) + ), + MAGIC_ENCHANTING_ALWAYS(new ParticleData(Material.WOODEN_SWORD, "PARTICLE_MAGIC_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 1.1, 0))) + ), + MAGIC_CLOUD_CIRCLE(new ParticleData(Material.GLOWSTONE_DUST, "PARTICLE_MAGIC", ParticleRequirement.SERVER_TEAM, + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), 0, 1.1, 0)))) + ), + FLAME_CLOUD_CIRCLE(new ParticleData(Material.FIRE_CORAL, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0.01), 0, 1.1, 0)))) + ), + FIREWORK_CLOUD_CIRCLE(new ParticleData(Material.FIREWORK_ROCKET, "PARTICLE_FIREWORK", ParticleRequirement.SERVER_TEAM, + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 0.01), 0, 1.1, 0)))) + ), + WATER_CLOUD_CIRCLE(new ParticleData(Material.CYAN_DYE, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0.01), 0, 1.1, 0)))) + ), + ENCHANTING_DOUBLE_CIRCLE(new ParticleData(Material.BUBBLE_CORAL_BLOCK, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 2.2, 0))) + ), + EVIL_WINGS(new ParticleData(Material.PURPUR_SLAB, "PARTICLE_WINGS_EVIL", ParticleRequirement.SERVER_TEAM, + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.SPELL_WITCH, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) + ), + ; + public static ParticleEnum[] particles = values(); + + @Getter + private ParticleData particle; +} diff --git a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java b/src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java index 6b086ea..274b7db 100644 --- a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java +++ b/src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java @@ -1,4 +1,16 @@ package de.steamwar.lobby.otherparticle.particles.custom; -public enum CustomEasterParticle { +import de.steamwar.lobby.otherparticle.ParticleData; +import de.steamwar.lobby.otherparticle.ParticleEnum; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +public enum CustomEasterParticle implements ParticleEnum { + + ; + public static ParticleEnum[] particles = values(); + + @Getter + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomPlayerParticle.java b/src/de/steamwar/lobby/otherparticle/particles/custom/CustomPlayerParticle.java new file mode 100644 index 0000000..29cc9a5 --- /dev/null +++ b/src/de/steamwar/lobby/otherparticle/particles/custom/CustomPlayerParticle.java @@ -0,0 +1,16 @@ +package de.steamwar.lobby.otherparticle.particles.custom; + +import de.steamwar.lobby.otherparticle.ParticleData; +import de.steamwar.lobby.otherparticle.ParticleEnum; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +public enum CustomPlayerParticle implements ParticleEnum { + + ; + public static ParticleEnum[] particles = values(); + + @Getter + private ParticleData particle; +} diff --git a/src/de/steamwar/lobby/special/easter/EggClickListener.java b/src/de/steamwar/lobby/special/easter/EggClickListener.java index e9503c8..5b25c44 100644 --- a/src/de/steamwar/lobby/special/easter/EggClickListener.java +++ b/src/de/steamwar/lobby/special/easter/EggClickListener.java @@ -37,7 +37,7 @@ public class EggClickListener extends BasicListener { return; } Player player = event.getPlayer(); - String found = UserConfig.getConfig(player.getUniqueId(), "egghunt"); + String found = UserConfig.getConfig(player.getUniqueId(), EggHunt.EGG_HUNT_CONFIG_KEY); if (found == null) { found = ""; } @@ -59,6 +59,6 @@ public class EggClickListener extends BasicListener { player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.25f, 1.0f); builder.setCharAt(index, '1'); - UserConfig.updatePlayerConfig(player.getUniqueId(), "egghunt", builder.toString()); + UserConfig.updatePlayerConfig(player.getUniqueId(), EggHunt.EGG_HUNT_CONFIG_KEY, builder.toString()); } } diff --git a/src/de/steamwar/lobby/special/easter/EggHunt.java b/src/de/steamwar/lobby/special/easter/EggHunt.java index 6da2942..ad721df 100644 --- a/src/de/steamwar/lobby/special/easter/EggHunt.java +++ b/src/de/steamwar/lobby/special/easter/EggHunt.java @@ -13,6 +13,8 @@ public class EggHunt { private static List eggList = new ArrayList<>(); + public static final String EGG_HUNT_CONFIG_KEY = "egghunt2022"; + public static void init() { } diff --git a/src/de/steamwar/lobby/special/easter/EggHuntCommand.java b/src/de/steamwar/lobby/special/easter/EggHuntCommand.java index 042c300..eeab79f 100644 --- a/src/de/steamwar/lobby/special/easter/EggHuntCommand.java +++ b/src/de/steamwar/lobby/special/easter/EggHuntCommand.java @@ -23,7 +23,7 @@ public class EggHuntCommand extends SWCommand { @Register public void genericCommand(Player player, @OptionalValue("ALL") Selection selection) { AtomicInteger atomicInteger = new AtomicInteger(); - String found = UserConfig.getConfig(player.getUniqueId(), "egghunt"); + String found = UserConfig.getConfig(player.getUniqueId(), EggHunt.EGG_HUNT_CONFIG_KEY); List> entries = EggHunt.getEggList().stream() .map(egg -> { int index = atomicInteger.getAndIncrement(); -- 2.39.2 From 438b336535e4ea6ad9d4ac07da8c3623aaeb67ae Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 4 Apr 2023 14:54:38 +0200 Subject: [PATCH 14/18] Remove old particle system --- .../lobby/otherparticle/ParticleData.java | 75 ---------- .../otherparticle/ParticleInventory.java | 97 ------------ .../particles/EventParticle.java | 29 ---- .../particles/EventParticleParticipation.java | 45 ------ .../particles/EventParticlePlacement.java | 51 ------- .../particles/PlayerParticle.java | 63 -------- .../particles/ServerTeamParticle.java | 99 ------------- .../otherparticle/particles/TeamParticle.java | 50 ------- .../steamwar/lobby/particle/BaseParticle.java | 49 ------ .../lobby/particle/DustSimpleParticle.java | 60 -------- .../lobby/particle/EventParticleItem.java | 74 --------- .../lobby/particle/ParticleBuilder.java | 15 -- .../steamwar/lobby/particle/ParticleData.java | 105 ++++++++----- .../ParticleElement.java | 2 +- .../ParticleEnum.java | 2 +- .../lobby/particle/ParticleInventory.java | 131 +++++++--------- .../steamwar/lobby/particle/ParticleItem.java | 69 --------- .../lobby/particle/ParticleListener.java | 18 ++- .../ParticleRequirement.java | 51 ++++--- .../ParticleTickData.java | 2 +- .../ParticleTickType.java | 3 +- .../lobby/particle/SimpleParticle.java | 82 ---------- .../WingDesign.java | 5 +- .../particle/decorator/CircleParticle.java | 75 ---------- .../particle/decorator/CloudParticle.java | 59 -------- .../particle/decorator/NonFloorParticle.java | 46 ------ .../particle/decorator/TickParticle.java | 49 ------ .../particle/decorator/WingParticle.java | 116 --------------- .../elements/Always.java | 8 +- .../elements/Circle.java | 6 +- .../elements/Cloud.java | 6 +- .../elements/Delayed.java | 6 +- .../elements/DelegatingParticleElement.java | 8 +- .../elements/DoubleCircle.java | 8 +- .../elements/DustParticle.java | 6 +- .../elements/Group.java | 6 +- .../elements/LocationMutator.java | 6 +- .../elements/NonFloor.java | 6 +- .../elements/NonFlying.java | 6 +- .../elements/SimpleParticle.java | 6 +- .../elements/Sneaking.java | 12 +- .../elements/Wing.java | 8 +- .../lobby/particle/group/ParticleGroup.java | 47 ------ .../mutator/LocationParticleMutator.java | 54 ------- .../particles/EasterParticle.java | 14 +- .../particle/particles/EventParticle.java | 45 ++---- .../particles/EventParticleParticipation.java | 77 +++++----- .../particles/EventParticlePlacement.java | 84 +++++------ .../particle/particles/ParticleEnum.java | 26 ---- .../particle/particles/PlayerParticle.java | 89 ++++++----- .../particles/ServerTeamParticle.java | 140 +++++++++++------- .../particles/SpecialTeamParticle.java | 43 ------ .../particle/particles/TeamParticle.java | 72 +++++---- .../custom/CustomEasterParticle.java | 6 +- .../custom/CustomPlayerParticle.java | 6 +- .../particles/custom/CustomTeamParticle.java | 12 +- src/de/steamwar/lobby/util/LobbyPlayer.java | 36 +---- 57 files changed, 489 insertions(+), 1882 deletions(-) delete mode 100644 src/de/steamwar/lobby/otherparticle/ParticleData.java delete mode 100644 src/de/steamwar/lobby/otherparticle/ParticleInventory.java delete mode 100644 src/de/steamwar/lobby/otherparticle/particles/EventParticle.java delete mode 100644 src/de/steamwar/lobby/otherparticle/particles/EventParticleParticipation.java delete mode 100644 src/de/steamwar/lobby/otherparticle/particles/EventParticlePlacement.java delete mode 100644 src/de/steamwar/lobby/otherparticle/particles/PlayerParticle.java delete mode 100644 src/de/steamwar/lobby/otherparticle/particles/ServerTeamParticle.java delete mode 100644 src/de/steamwar/lobby/otherparticle/particles/TeamParticle.java delete mode 100644 src/de/steamwar/lobby/particle/BaseParticle.java delete mode 100644 src/de/steamwar/lobby/particle/DustSimpleParticle.java delete mode 100644 src/de/steamwar/lobby/particle/EventParticleItem.java delete mode 100644 src/de/steamwar/lobby/particle/ParticleBuilder.java rename src/de/steamwar/lobby/{otherparticle => particle}/ParticleElement.java (96%) rename src/de/steamwar/lobby/{otherparticle => particle}/ParticleEnum.java (62%) delete mode 100644 src/de/steamwar/lobby/particle/ParticleItem.java rename src/de/steamwar/lobby/{otherparticle => particle}/ParticleRequirement.java (90%) rename src/de/steamwar/lobby/{otherparticle => particle}/ParticleTickData.java (95%) rename src/de/steamwar/lobby/{otherparticle => particle}/ParticleTickType.java (54%) delete mode 100644 src/de/steamwar/lobby/particle/SimpleParticle.java rename src/de/steamwar/lobby/{otherparticle => particle}/WingDesign.java (90%) delete mode 100644 src/de/steamwar/lobby/particle/decorator/CircleParticle.java delete mode 100644 src/de/steamwar/lobby/particle/decorator/CloudParticle.java delete mode 100644 src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java delete mode 100644 src/de/steamwar/lobby/particle/decorator/TickParticle.java delete mode 100644 src/de/steamwar/lobby/particle/decorator/WingParticle.java rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Always.java (68%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Circle.java (81%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Cloud.java (86%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Delayed.java (89%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/DelegatingParticleElement.java (75%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/DoubleCircle.java (85%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/DustParticle.java (87%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Group.java (77%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/LocationMutator.java (83%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/NonFloor.java (76%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/NonFlying.java (73%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/SimpleParticle.java (91%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Sneaking.java (59%) rename src/de/steamwar/lobby/{otherparticle => particle}/elements/Wing.java (84%) delete mode 100644 src/de/steamwar/lobby/particle/group/ParticleGroup.java delete mode 100644 src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java rename src/de/steamwar/lobby/{otherparticle => particle}/particles/EasterParticle.java (79%) delete mode 100644 src/de/steamwar/lobby/particle/particles/ParticleEnum.java delete mode 100644 src/de/steamwar/lobby/particle/particles/SpecialTeamParticle.java rename src/de/steamwar/lobby/{otherparticle => particle}/particles/custom/CustomEasterParticle.java (60%) rename src/de/steamwar/lobby/{otherparticle => particle}/particles/custom/CustomPlayerParticle.java (60%) rename src/de/steamwar/lobby/{otherparticle => particle}/particles/custom/CustomTeamParticle.java (63%) diff --git a/src/de/steamwar/lobby/otherparticle/ParticleData.java b/src/de/steamwar/lobby/otherparticle/ParticleData.java deleted file mode 100644 index 8a70c08..0000000 --- a/src/de/steamwar/lobby/otherparticle/ParticleData.java +++ /dev/null @@ -1,75 +0,0 @@ -package de.steamwar.lobby.otherparticle; - -import de.steamwar.inventory.SWItem; -import de.steamwar.lobby.LobbySystem; -import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.UserGroup; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -public class ParticleData { - - private final Material material; - private final String name; - private final Set attributes = new LinkedHashSet<>(); - - @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 = LobbySystem.getMessage().parse(name, player); - 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(""); - } - - boolean selectable = requirement.getRequirement().test(user, eventTeilnahme, eggHuntConfig); - selectable |= user.getUserGroup() != UserGroup.Member; - - String unlockedBy = requirement.getRequirementName(player); - if (unlockedBy != null) { - lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player)); - lore.add(unlockedBy); - lore.add(""); - } - if (selectable) { - 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 -> {}); - } -} diff --git a/src/de/steamwar/lobby/otherparticle/ParticleInventory.java b/src/de/steamwar/lobby/otherparticle/ParticleInventory.java deleted file mode 100644 index 252a140..0000000 --- a/src/de/steamwar/lobby/otherparticle/ParticleInventory.java +++ /dev/null @@ -1,97 +0,0 @@ -package de.steamwar.lobby.otherparticle; - -import de.steamwar.inventory.SWItem; -import de.steamwar.inventory.SWListInv; -import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.otherparticle.particles.*; -import de.steamwar.lobby.otherparticle.particles.custom.CustomEasterParticle; -import de.steamwar.lobby.otherparticle.particles.custom.CustomPlayerParticle; -import de.steamwar.lobby.otherparticle.particles.custom.CustomTeamParticle; -import de.steamwar.lobby.special.easter.EggHunt; -import de.steamwar.lobby.util.LobbyPlayer; -import de.steamwar.sql.*; -import lombok.experimental.UtilityClass; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -@UtilityClass -public class ParticleInventory { - - private final Class[] PARTICLES = { - PlayerParticle.class, - CustomPlayerParticle.class, - TeamParticle.class, - CustomTeamParticle.class, - ServerTeamParticle.class, - EventParticle.class, - EventParticlePlacement.class, - EventParticleParticipation.class, - EasterParticle.class, - CustomEasterParticle.class, - }; - - public String convertToString(ParticleEnum particleEnum) { - return particleEnum.getClass().getSimpleName() + "@" + ((Enum)particleEnum).name(); - } - - public ParticleEnum convertFromString(String string) { - String[] split = string.split("@"); - Class clazz = null; - for (Class aClass : PARTICLES) { - if (aClass.getSimpleName().equals(split[0])) { - clazz = aClass; - break; - } - } - if (clazz != null) { - try { - return (ParticleEnum) Enum.valueOf((Class) clazz, split[1]); - } catch (Exception e) { - return null; - } - } - // TODO: Add conversion from last version - return null; - } - - public void openInventory(Player player) { - LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - - SteamwarUser user = SteamwarUser.get(player.getUniqueId()); - Set events = user.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(user.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet()); - String eggHuntConfig = UserConfig.getConfig(user.getId(), EggHunt.EGG_HUNT_CONFIG_KEY); - - List> particleList = new ArrayList<>(); - for (Class clazz : PARTICLES) { - addParticles(particleList, (ParticleEnum[]) clazz.getEnumConstants(), player, user, events, eggHuntConfig); - } - - SWListInv particleSWListInv = new SWListInv<>(player, LobbySystem.getMessage().parse("PARTICLE_INVENTORY", player), false, particleList, (clickType, particle) -> { - if (particle == null) return; - // lobbyPlayer.setParticle(particle); // TODO: Update this - player.closeInventory(); - }); - particleSWListInv.setItem(49, Material.BARRIER, LobbySystem.getMessage().parse("PARTICLE_DESELECT", player), new ArrayList<>(), false, clickType -> { - lobbyPlayer.setParticle(null); - }); - particleSWListInv.open(); - } - - private void addParticles(List> particleList, ParticleEnum[] particleEnums, Player player, SteamwarUser user, Set events, String eggHuntConfig) { - for (ParticleEnum particle : particleEnums) { - ParticleData particleData = particle.getParticle(); - SWItem swItem = particleData.toSWItem(player, user, events, eggHuntConfig); - if (particleData.getRequirement().test(user, events, eggHuntConfig) || user.getUserGroup() != UserGroup.Member) { - particleList.add(new SWListInv.SWListEntry<>(swItem, particle)); - } else { - particleList.add(new SWListInv.SWListEntry<>(swItem, null)); - } - } - } -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/EventParticle.java b/src/de/steamwar/lobby/otherparticle/particles/EventParticle.java deleted file mode 100644 index abaa6bd..0000000 --- a/src/de/steamwar/lobby/otherparticle/particles/EventParticle.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.steamwar.lobby.otherparticle.particles; - -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.elements.Always; -import de.steamwar.lobby.otherparticle.elements.Circle; -import de.steamwar.lobby.otherparticle.elements.LocationMutator; -import de.steamwar.lobby.otherparticle.elements.SimpleParticle; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.Particle; - -@AllArgsConstructor -public enum EventParticle implements ParticleEnum { - - WATER(new ParticleData(Material.WATER_BUCKET, "PARTICLE_WATER", ParticleRequirement.EVENT_PARTICIPATION, - new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIP_WATER), 0, 1.1, 0)))) - ), - LAVA(new ParticleData(Material.LAVA_BUCKET, "PARTICLE_FIRE", ParticleRequirement.EVENT_PARTICIPATION, - new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIP_LAVA), 0, 1.1, 0)))) - ), - ; - public static ParticleEnum[] particles = values(); - - @Getter - private ParticleData particle; -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/EventParticleParticipation.java b/src/de/steamwar/lobby/otherparticle/particles/EventParticleParticipation.java deleted file mode 100644 index a55a3bd..0000000 --- a/src/de/steamwar/lobby/otherparticle/particles/EventParticleParticipation.java +++ /dev/null @@ -1,45 +0,0 @@ -package de.steamwar.lobby.otherparticle.particles; - -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.WingDesign; -import de.steamwar.lobby.otherparticle.elements.*; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.Particle; - -@AllArgsConstructor -public enum EventParticleParticipation implements ParticleEnum { - - WarGearSeason(new ParticleData(Material.BOOK, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.eventParticipation(22), - new SimpleParticle(Particle.ENCHANTMENT_TABLE)) - ), - AirshipEvent(new ParticleData(Material.SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", ParticleRequirement.eventParticipation(26), - new SimpleParticle(Particle.CLOUD)) - ), - HellsBellsWs(new ParticleData(Material.TNT, "PARTICLE_EVENT_SMOKE", ParticleRequirement.eventParticipation(28), - new Circle(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))) - ), - Underwater(new ParticleData(Material.PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(31), - new SimpleParticle(Particle.DRIP_WATER)) - ), - AdventWarShip(new ParticleData(Material.PRISMARINE_WALL, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(32), - new Group(new SimpleParticle(Particle.DRIP_WATER), new SimpleParticle(Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))) - ), - MiniWarGearLiga(new ParticleData(Material.PRISMARINE_SLAB, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(33), - new Circle(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0))) - ), - UnderwaterMWG(new ParticleData(Material.BLUE_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", ParticleRequirement.eventParticipation(35), - new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new SimpleParticle(Particle.WATER_WAKE, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.DRIP_WATER, 0.3F, 0.0F, 0.3F, 0.01), 0, 0.2, 0)), 0, 2.2, 0))) - ), - WarGearSeason2022(new ParticleData(Material.DIAMOND_SWORD, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventParticipation(37), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.DRAGON_BREATH, 0, 0, 0, 0, 1), 0.15, WingDesign.COMPLEX)), 20))) - ), - ; - public static ParticleEnum[] particles = values(); - - @Getter - private ParticleData particle; -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/EventParticlePlacement.java b/src/de/steamwar/lobby/otherparticle/particles/EventParticlePlacement.java deleted file mode 100644 index e339e72..0000000 --- a/src/de/steamwar/lobby/otherparticle/particles/EventParticlePlacement.java +++ /dev/null @@ -1,51 +0,0 @@ -package de.steamwar.lobby.otherparticle.particles; - -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.WingDesign; -import de.steamwar.lobby.otherparticle.elements.*; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.Particle; - -@AllArgsConstructor -public enum EventParticlePlacement implements ParticleEnum { - - WarGearSeason(new ParticleData(Material.ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.eventPlacement(22, 12, 285, 54), - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), 0, 1.1, 0))) - )), - AirshipEvent(new ParticleData(Material.SNOWBALL, "PARTICLE_EVENT_CLOUD", ParticleRequirement.eventPlacement(26, 205, 9, 54, 120, 292), - new Circle(new LocationMutator(new SimpleParticle(Particle.CLOUD, 0, 0, 0, 0.01), 0, 2.2, 0)) - )), - HellsBellsWs(new ParticleData(Material.TNT_MINECART, "PARTICLE_EVENT_SMOKE", ParticleRequirement.eventPlacement(28, 205, 9, 11), - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01), 0, 2.2, 0))) - )), - Underwater(new ParticleData(Material.PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", ParticleRequirement.eventPlacement(31, 9, 210, 520), - new Cloud(new SimpleParticle(Particle.DRIP_WATER))) - ), - AdventWarShip(new ParticleData(Material.PRISMARINE_CRYSTALS, "PARTICLE_EVENT_WATER", ParticleRequirement.eventPlacement(31, 9, 205, 210), - new Always(new LocationMutator(new Circle(new Group(new SimpleParticle(Particle.DRIP_WATER), new SimpleParticle(Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))), 0, 1.1, 0))) - ), - MiniWarGearLiga(new ParticleData(Material.IRON_SWORD, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventPlacement(33, 9, 34, 205), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0, 1), 0.15, WingDesign.MWGL)), 20))) - ), - Absturz(new ParticleData(Material.FEATHER, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventPlacement(34, 210, 205, 527, 286), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) - ), - UnderwaterMWG(new ParticleData(Material.CYAN_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", ParticleRequirement.eventPlacement(35, 9, 210), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingDesign.SW)), 20))) - ), - WarGearSeason2022(new ParticleData(Material.DIAMOND_HELMET, "PARTICLE_EVENT_WGS", ParticleRequirement.eventPlacement(37, 285, 210, 122), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 0, 1), 0.15, WingDesign.WGS)), 20))) - ), - WargearClash(new ParticleData(Material.GOLDEN_SWORD, "PARTICLE_EVENT_WARGEARCLASH", ParticleRequirement.eventPlacement(38, 210, 158, 167, 286), - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.1, WingDesign.SWORD_CROSSED)), 20))) - ), - ; - public static ParticleEnum[] particles = values(); - - @Getter - private ParticleData particle; -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/PlayerParticle.java b/src/de/steamwar/lobby/otherparticle/particles/PlayerParticle.java deleted file mode 100644 index 88d095e..0000000 --- a/src/de/steamwar/lobby/otherparticle/particles/PlayerParticle.java +++ /dev/null @@ -1,63 +0,0 @@ -package de.steamwar.lobby.otherparticle.particles; - -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.elements.DustParticle; -import de.steamwar.lobby.otherparticle.elements.LocationMutator; -import de.steamwar.lobby.otherparticle.elements.SimpleParticle; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.Particle; - -@AllArgsConstructor -public enum PlayerParticle implements ParticleEnum { - - SNEEZE(new ParticleData(Material.SLIME_BLOCK, "PARTICLE_SNEEZE", - new SimpleParticle(Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)) - ), - SMOKE(new ParticleData(Material.COBWEB, "PARTICLE_SMOKE", - new SimpleParticle(Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)) - ), - FIRE(new ParticleData(Material.LAVA_BUCKET, "PARTICLE_FIRE", - new SimpleParticle(Particle.DRIP_LAVA)) - ), - WATER(new ParticleData(Material.WATER_BUCKET, "PARTICLE_WATER", - new SimpleParticle(Particle.DRIP_WATER)) - ), - HEARTH(new ParticleData(Material.RED_DYE, "PARTICLE_HEART", - new LocationMutator(new SimpleParticle(Particle.HEART), 0, 2.2, 0)) - ), - NOTES(new ParticleData(Material.NOTE_BLOCK, "PARTICLE_NOTES", - new LocationMutator(new SimpleParticle(Particle.NOTE), 0, 2.2, 0)) - ), - NAUTILUS(new ParticleData(Material.NAUTILUS_SHELL, "PARTICLE_NAUTILUS", - new SimpleParticle(Particle.NAUTILUS, 0.2F, 0.2F ,0.2F, 0.01)) - ), - SNOWBALL(new ParticleData(Material.SNOWBALL, "PARTICLE_SNOWBALL", - new SimpleParticle(Particle.SNOWBALL, 0.2F, 0.2F ,0.2F, 0.01)) - ), - EFFECT(new ParticleData(Material.GLASS_BOTTLE, "PARTICLE_EFFECT", - new DustParticle(Particle.REDSTONE, 0, 0.2F, 02F, 0.01, 5)) - ), - CAMPFIRE(new ParticleData(Material.CAMPFIRE, "PARTICLE_CAMPFIRE", - new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0.2F ,0, 0.01)) - ), - MAGIC(new ParticleData(Material.CAULDRON, "PARTICLE_MAGIC", - new SimpleParticle(Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)) - ), - ANGRY(new ParticleData(Material.REDSTONE_BLOCK, "PARTICLE_ANGRY", - new SimpleParticle(Particle.VILLAGER_ANGRY, 0.2F, 0.2F, 0.2F, 0.01)) - ), - SLIME(new ParticleData(Material.SLIME_BALL, "PARTICLE_SLIME", - new SimpleParticle(Particle.SLIME)) - ), - MOB(new ParticleData(Material.ZOMBIE_HEAD, "PARTICLE_MOB", - new SimpleParticle(Particle.SPELL_MOB)) - ), - ; - public static ParticleEnum[] particles = values(); - - @Getter - private ParticleData particle; -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/ServerTeamParticle.java b/src/de/steamwar/lobby/otherparticle/particles/ServerTeamParticle.java deleted file mode 100644 index ada98bf..0000000 --- a/src/de/steamwar/lobby/otherparticle/particles/ServerTeamParticle.java +++ /dev/null @@ -1,99 +0,0 @@ -package de.steamwar.lobby.otherparticle.particles; - -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.WingDesign; -import de.steamwar.lobby.otherparticle.elements.*; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.Particle; - -@AllArgsConstructor -public enum ServerTeamParticle implements ParticleEnum { - - WITCH(new ParticleData(Material.EXPERIENCE_BOTTLE, "PARTICLE_WITCH", ParticleRequirement.SERVER_TEAM, - new SimpleParticle(Particle.SPELL_WITCH)) - ), - ENCHANTING(new ParticleData(Material.ENCHANTING_TABLE, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new SimpleParticle(Particle.ENCHANTMENT_TABLE)) - ), - HAPPY(new ParticleData(Material.EMERALD_BLOCK, "PARTICLE_HAPPY", ParticleRequirement.SERVER_TEAM, - new SimpleParticle(Particle.HEART, 0.2F, 0.2F, 0.2F, 0.01)) - ), - FLAME(new ParticleData(Material.FLINT_AND_STEEL, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, - new SimpleParticle(Particle.FLAME, 0, 0.2F, 0, 0.01)) - ), - END_ROD(new ParticleData(Material.END_ROD, "PARTICLE_END_ROD", ParticleRequirement.SERVER_TEAM, - new SimpleParticle(Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)) - ), - CLOUD(new ParticleData(Material.WHITE_WOOL, "PARTICLE_CLOUD", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.CLOUD))) - ), - TOTEM(new ParticleData(Material.TOTEM_OF_UNDYING, "PARTICLE_TOTEM", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.TOTEM, 0.2F, 0.2F, 0.2F, 0.01))) - ), - ENCHANTING_CLOUD(new ParticleData(Material.WHITE_DYE, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.ENCHANTMENT_TABLE))) - ), - FLAME_CLOUD(new ParticleData(Material.FIRE_CORAL_BLOCK, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.FLAME))) - ), - SNEEZE_CLOUD(new ParticleData(Material.LIME_SHULKER_BOX, "PARTICLE_SNEEZE", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.SNEEZE))) - ), - SLIME_CLOUD(new ParticleData(Material.GREEN_SHULKER_BOX, "PARTICLE_SLIME", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.SLIME))) - ), - SMOKE_CLOUD(new ParticleData(Material.DEAD_BRAIN_CORAL_BLOCK, "PARTICLE_SMOKE", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0.2F, 0.2F, 0.2F, 0.01))) - ), - TOWN_CLOUD(new ParticleData(Material.FIREWORK_STAR, "PARTICLE_TOWN", ParticleRequirement.SERVER_TEAM, - new Cloud(new SimpleParticle(Particle.TOWN_AURA))) - ), - FLAME_CIRCLE(new ParticleData(Material.MAGMA_BLOCK, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, - new Circle(new LocationMutator(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0.01), 0, 1.1, 0))) - ), - ENCHANTING_CIRCLE(new ParticleData(Material.WHITE_DYE, "PARTICLE_ENCHANTING_CIRCLE", ParticleRequirement.SERVER_TEAM, - new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0.2F, 0.2F, 0.2F, 0.01), 0, 1.1, 0))) - ), - NOTES_CIRCLE(new ParticleData(Material.NOTE_BLOCK, "PARTICLE_NOTES", ParticleRequirement.SERVER_TEAM, - new Circle(new LocationMutator(new SimpleParticle(Particle.NOTE, 0, 0, 0, 0.01), 0, 2.2, 0))) - ), - WATER_FIRE(new ParticleData(Material.GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, - new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIP_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIP_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0)) - ), - WATER_FIRE_ALWAYS(new ParticleData(Material.GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, - new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIP_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIP_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0))) - ), - MAGIC_ENCHANTING(new ParticleData(Material.DIAMOND_SWORD, "PARTICLE_MAGIC_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 1.1, 0)) - ), - MAGIC_ENCHANTING_ALWAYS(new ParticleData(Material.WOODEN_SWORD, "PARTICLE_MAGIC_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 1.1, 0))) - ), - MAGIC_CLOUD_CIRCLE(new ParticleData(Material.GLOWSTONE_DUST, "PARTICLE_MAGIC", ParticleRequirement.SERVER_TEAM, - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), 0, 1.1, 0)))) - ), - FLAME_CLOUD_CIRCLE(new ParticleData(Material.FIRE_CORAL, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0.01), 0, 1.1, 0)))) - ), - FIREWORK_CLOUD_CIRCLE(new ParticleData(Material.FIREWORK_ROCKET, "PARTICLE_FIREWORK", ParticleRequirement.SERVER_TEAM, - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 0.01), 0, 1.1, 0)))) - ), - WATER_CLOUD_CIRCLE(new ParticleData(Material.CYAN_DYE, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, - new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0.01), 0, 1.1, 0)))) - ), - ENCHANTING_DOUBLE_CIRCLE(new ParticleData(Material.BUBBLE_CORAL_BLOCK, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, - new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 2.2, 0))) - ), - EVIL_WINGS(new ParticleData(Material.PURPUR_SLAB, "PARTICLE_WINGS_EVIL", ParticleRequirement.SERVER_TEAM, - new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.SPELL_WITCH, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) - ), - ; - public static ParticleEnum[] particles = values(); - - @Getter - private ParticleData particle; -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/TeamParticle.java b/src/de/steamwar/lobby/otherparticle/particles/TeamParticle.java deleted file mode 100644 index 12bcd2c..0000000 --- a/src/de/steamwar/lobby/otherparticle/particles/TeamParticle.java +++ /dev/null @@ -1,50 +0,0 @@ -package de.steamwar.lobby.otherparticle.particles; - -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.elements.Circle; -import de.steamwar.lobby.otherparticle.elements.LocationMutator; -import de.steamwar.lobby.otherparticle.elements.NonFloor; -import de.steamwar.lobby.otherparticle.elements.SimpleParticle; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Material; -import org.bukkit.Particle; - -@AllArgsConstructor -public enum TeamParticle implements ParticleEnum { - - SQUID(new ParticleData(Material.INK_SAC, "PARTICLE_SQUID", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)) - ), - BUBBLE(new ParticleData(Material.TUBE_CORAL, "PARTICLE_BUBBLE", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)) - ), - HONEY(new ParticleData(Material.HONEY_BOTTLE, "PARTICLE_HONEY", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)) - ), - NECTAR(new ParticleData(Material.HONEYCOMB, "PARTICLE_NECTAR", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)) - ), - FIREWORK(new ParticleData(Material.FIRE_CHARGE, "PARTICLE_FIREWORK", ParticleRequirement.HAS_TEAM, - new LocationMutator(new NonFloor(new SimpleParticle(Particle.FIREWORKS_SPARK, 0.1F, 0.1F, 0.1F, 0.2, 2)), 0, -0.2, 0)) - ), - DRAGON_BREATH(new ParticleData(Material.DRAGON_BREATH, "PARTICLE_DRAGON_BREATH", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.DRAGON_BREATH, 1F, 0.2F, 1F, 0.01)) - ), - DAMAGE(new ParticleData(Material.SPIDER_EYE, "PARTICLE_DAMAGE", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.DAMAGE_INDICATOR, 0.2F, 0, 0.2F, 0.01)) - ), - DOLPHIN(new ParticleData(Material.BLUE_DYE, "PARTICLE_DOLPHIN", ParticleRequirement.HAS_TEAM, - new SimpleParticle(Particle.DOLPHIN, 0.2F, 0, 0.2F, 0.01)) - ), - HEART(new ParticleData(Material.RED_CONCRETE, "PARTICLE_HEART", ParticleRequirement.HAS_TEAM, - new Circle(new LocationMutator(new SimpleParticle(Particle.HEART), 0, 2.2, 0))) - ), - ; - public static ParticleEnum[] particles = values(); - - @Getter - private ParticleData particle; -} diff --git a/src/de/steamwar/lobby/particle/BaseParticle.java b/src/de/steamwar/lobby/particle/BaseParticle.java deleted file mode 100644 index 9d1a183..0000000 --- a/src/de/steamwar/lobby/particle/BaseParticle.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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 org.bukkit.Color; -import org.bukkit.Particle; - -import java.util.Random; - -public interface BaseParticle { - Random RANDOM = new Random(); - - default Color randomColor() { - return Color.fromRGB(RANDOM.nextInt(256), RANDOM.nextInt(256), RANDOM.nextInt(256)); - } - - default float randomSize() { - return RANDOM.nextFloat() / 2 + 1; - } - - default Particle.DustOptions getParticleDust() { - return new Particle.DustOptions(randomColor(), randomSize()); - } - - ParticleItem getItem(); - - default boolean needsTick() { - return false; - } - - void particle(ParticleData particleData); -} diff --git a/src/de/steamwar/lobby/particle/DustSimpleParticle.java b/src/de/steamwar/lobby/particle/DustSimpleParticle.java deleted file mode 100644 index 417b6ad..0000000 --- a/src/de/steamwar/lobby/particle/DustSimpleParticle.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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 org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Particle; - -public class DustSimpleParticle implements BaseParticle { - - private final ParticleItem particleItem; - private final Particle particle; - private float vx; - private float vy; - private float vz; - private double time = 1; - private int count = 5; - - public DustSimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time) { - this.particleItem = particleItem; - this.particle = particle; - this.vx = vx; - this.vy = vy; - this.vz = vz; - this.time = time; - } - - @Override - public ParticleItem getItem() { - return particleItem; - } - - @Override - public void particle(ParticleData particleData) { - Location location = particleData.getLocation().add(0.0, 0.2, 0.0); - Bukkit.getOnlinePlayers().forEach(player -> { - int viewDistance = player.getClientViewDistance() * 16; - if (location.distanceSquared(player.getLocation()) <= viewDistance * viewDistance) { - player.spawnParticle(particle, location, count, vx, vy, vz, time, getParticleDust()); - } - }); - } -} diff --git a/src/de/steamwar/lobby/particle/EventParticleItem.java b/src/de/steamwar/lobby/particle/EventParticleItem.java deleted file mode 100644 index 2c679b9..0000000 --- a/src/de/steamwar/lobby/particle/EventParticleItem.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.Event; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; - -public class EventParticleItem extends ParticleItem { - - public static EventParticleItem participation(Material material, String name, int eventId) { - return new EventParticleItem(material, name, "PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION", eventId); - } - - public static EventParticleItem placement(Material material, String name, int eventId) { - return new EventParticleItem(material, name, "PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT", eventId); - } - - private final String eventName; - - public EventParticleItem(Material material, String name, int eventId) { - this(material, name, null, eventId); - } - - public EventParticleItem(Material material, String name, String unlockedBy, int eventId) { - super(material, name, unlockedBy); - eventName = Event.get(eventId).getEventName(); - } - - public EventParticleItem addAttribute(String attribute) { - super.addAttribute(attribute); - return this; - } - - public SWItem toSWItem(Player player) { - String translatedName = LobbySystem.getMessage().parse(name, player); - 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(""); - } - if (unlockedBy != null) { - lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player)); - lore.add(LobbySystem.getMessage().parse(unlockedBy, player, eventName)); - lore.add(""); - } - lore.add(LobbySystem.getMessage().parse("PARTICLE_SELECT", player)); - return new SWItem(material, translatedName, lore, false, clickType -> {}); - } -} diff --git a/src/de/steamwar/lobby/particle/ParticleBuilder.java b/src/de/steamwar/lobby/particle/ParticleBuilder.java deleted file mode 100644 index 0b8b589..0000000 --- a/src/de/steamwar/lobby/particle/ParticleBuilder.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.steamwar.lobby.particle; - -public class ParticleBuilder { - - public ParticleBuilder() { - } - - public void cloud() {} - - public void offset() {} - - public void rotated() {} - - public void build() {} -} diff --git a/src/de/steamwar/lobby/particle/ParticleData.java b/src/de/steamwar/lobby/particle/ParticleData.java index 8a4523b..01ae549 100644 --- a/src/de/steamwar/lobby/particle/ParticleData.java +++ b/src/de/steamwar/lobby/particle/ParticleData.java @@ -1,54 +1,77 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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 lombok.AllArgsConstructor; +import de.steamwar.inventory.SWItem; +import de.steamwar.lobby.LobbySystem; +import de.steamwar.sql.SteamwarUser; import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.bukkit.Location; -import org.bukkit.World; +import org.bukkit.Material; import org.bukkit.entity.Player; -@RequiredArgsConstructor -@AllArgsConstructor -@Getter +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + public class ParticleData { - private final World world; - private final Player player; - private Location location; - private final double deg; - public ParticleData withLocation(Location location) { - ParticleData particleData = copy(); - particleData.location = location; - return particleData; + private final Material material; + private final String name; + private final Set attributes = new LinkedHashSet<>(); + + @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 Location getLocation() { - if (location == null) { - return player.getLocation(); + 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; } - return location; - } - public ParticleData copy() { - return new ParticleData(world, player, location, deg); + 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 -> {}); } } diff --git a/src/de/steamwar/lobby/otherparticle/ParticleElement.java b/src/de/steamwar/lobby/particle/ParticleElement.java similarity index 96% rename from src/de/steamwar/lobby/otherparticle/ParticleElement.java rename to src/de/steamwar/lobby/particle/ParticleElement.java index 470f92d..3b14c14 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleElement.java +++ b/src/de/steamwar/lobby/particle/ParticleElement.java @@ -1,4 +1,4 @@ -package de.steamwar.lobby.otherparticle; +package de.steamwar.lobby.particle; import org.bukkit.Bukkit; import org.bukkit.Color; diff --git a/src/de/steamwar/lobby/otherparticle/ParticleEnum.java b/src/de/steamwar/lobby/particle/ParticleEnum.java similarity index 62% rename from src/de/steamwar/lobby/otherparticle/ParticleEnum.java rename to src/de/steamwar/lobby/particle/ParticleEnum.java index ef4c4b5..6721442 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleEnum.java +++ b/src/de/steamwar/lobby/particle/ParticleEnum.java @@ -1,4 +1,4 @@ -package de.steamwar.lobby.otherparticle; +package de.steamwar.lobby.particle; public interface ParticleEnum { ParticleData getParticle(); diff --git a/src/de/steamwar/lobby/particle/ParticleInventory.java b/src/de/steamwar/lobby/particle/ParticleInventory.java index cfc4d6c..945b13c 100644 --- a/src/de/steamwar/lobby/particle/ParticleInventory.java +++ b/src/de/steamwar/lobby/particle/ParticleInventory.java @@ -1,34 +1,19 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 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.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.particle.particles.*; +import de.steamwar.lobby.particle.particles.custom.CustomEasterParticle; +import de.steamwar.lobby.particle.particles.custom.CustomPlayerParticle; +import de.steamwar.lobby.particle.particles.custom.CustomTeamParticle; +import de.steamwar.lobby.special.easter.EggHunt; import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.sql.Event; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.TeamTeilnahme; -import de.steamwar.sql.UserGroup; +import de.steamwar.sql.UserConfig; +import lombok.experimental.UtilityClass; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -38,49 +23,56 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; +@UtilityClass public class ParticleInventory { - private ParticleInventory() { + private final Class[] PARTICLES = { + PlayerParticle.class, + CustomPlayerParticle.class, + TeamParticle.class, + CustomTeamParticle.class, + ServerTeamParticle.class, + EventParticle.class, + EventParticlePlacement.class, + EventParticleParticipation.class, + EasterParticle.class, + CustomEasterParticle.class, + }; + + public String convertToString(ParticleEnum particleEnum) { + return particleEnum.getClass().getSimpleName() + "@" + ((Enum)particleEnum).name(); } - private static void calculateParticles(ParticleEnum[] particles, Player player, List> particleList) { - for (ParticleEnum particle : particles) { - particleList.add(new SWListInv.SWListEntry<>(particle.getParticle().getItem().toSWItem(player), particle)); + public ParticleEnum convertFromString(String string) { + String[] split = string.split("@"); + Class clazz = null; + for (Class aClass : PARTICLES) { + if (aClass.getSimpleName().equals(split[0])) { + clazz = aClass; + break; + } } + if (clazz != null) { + try { + return (ParticleEnum) Enum.valueOf((Class) clazz, split[1]); + } catch (Exception e) { + return null; + } + } + // TODO: Add conversion from last version + return null; } - private static SWInventory createInventory(Player player) { + public void openInventory(Player player) { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); - UserGroup userGroup = steamwarUser.getUserGroup(); + + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Set events = user.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(user.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet()); + String eggHuntConfig = UserConfig.getConfig(user.getId(), EggHunt.EGG_HUNT_CONFIG_KEY); List> particleList = new ArrayList<>(); - calculateParticles(PlayerParticle.particles, player, particleList); - if (steamwarUser.getTeam() != 0 || userGroup != UserGroup.Member) { - calculateParticles(TeamParticle.particles, player, particleList); - } - if (userGroup != UserGroup.Member) { - calculateParticles(ServerTeamParticle.particles, player, particleList); - } - - Set events = steamwarUser.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(steamwarUser.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet()); - if (!events.isEmpty()) { - calculateParticles(EventParticle.particles, player, particleList); - } - for (EventParticlePlacement particle : EventParticlePlacement.particles) { - boolean clickable = userGroup.isTeamGroup(); - clickable |= (steamwarUser.getTeam() != 0 && contains(particle.getPlacementTeams(), steamwarUser.getTeam())); - addParticle(particleList, particle, clickable, player); - } - for (EventParticleParticipation particle : EventParticleParticipation.particles) { - boolean clickable = userGroup.isTeamGroup(); - clickable |= events.contains(particle.getEvent()); - addParticle(particleList, particle, clickable, player); - } - for (SpecialTeamParticle particle : SpecialTeamParticle.particles) { - if (particle.getTeamId() == 0 || steamwarUser.getTeam() == particle.getTeamId() || steamwarUser.getUserGroup() != UserGroup.Member) { - addParticle(particleList, particle, true, player); - } + for (Class clazz : PARTICLES) { + addParticles(particleList, (ParticleEnum[]) clazz.getEnumConstants(), player, user, events, eggHuntConfig); } SWListInv particleSWListInv = new SWListInv<>(player, LobbySystem.getMessage().parse("PARTICLE_INVENTORY", player), false, particleList, (clickType, particle) -> { @@ -91,29 +83,18 @@ public class ParticleInventory { particleSWListInv.setItem(49, Material.BARRIER, LobbySystem.getMessage().parse("PARTICLE_DESELECT", player), new ArrayList<>(), false, clickType -> { lobbyPlayer.setParticle(null); }); - - return particleSWListInv; + particleSWListInv.open(); } - private static void addParticle(List> particleList, ParticleEnum particle, boolean clickable, Player player) { - if (clickable) { - particleList.add(new SWListInv.SWListEntry<>(particle.getParticle().getItem().toSWItem(player), particle)); - } else { - SWItem swItem = particle.getParticle().getItem().toSWItem(player); - swItem.setName(LobbySystem.getMessage().parse("PARTICLE_LOCKED", player, swItem.getItemMeta().getDisplayName())); - particleList.add(new SWListInv.SWListEntry<>(swItem, null)); + private void addParticles(List> particleList, ParticleEnum[] particleEnums, Player player, SteamwarUser user, Set events, String eggHuntConfig) { + for (ParticleEnum particle : particleEnums) { + ParticleData particleData = particle.getParticle(); + SWItem swItem = particleData.toSWItem(player, user, events, eggHuntConfig); + if (particleData.getRequirement().test(user, events, eggHuntConfig)) { + particleList.add(new SWListInv.SWListEntry<>(swItem, particle)); + } else { + particleList.add(new SWListInv.SWListEntry<>(swItem, null)); + } } } - - private static boolean contains(int[] ints, int element) { - for (int i : ints) { - if (i == element) return true; - } - return false; - } - - public static void openParticleInventory(Player player) { - createInventory(player).open(); - } } - diff --git a/src/de/steamwar/lobby/particle/ParticleItem.java b/src/de/steamwar/lobby/particle/ParticleItem.java deleted file mode 100644 index 50744d9..0000000 --- a/src/de/steamwar/lobby/particle/ParticleItem.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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 lombok.RequiredArgsConstructor; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -@RequiredArgsConstructor -public class ParticleItem { - - protected final Material material; - protected final String name; - protected final Set attributes = new LinkedHashSet<>(); - protected String unlockedBy; - - public ParticleItem(Material material, String name, String unlockedBy) { - this.material = material; - this.name = name; - this.unlockedBy = unlockedBy; - } - - public ParticleItem addAttribute(String attribute) { - this.attributes.add(attribute); - return this; - } - - public SWItem toSWItem(Player player) { - String translatedName = LobbySystem.getMessage().parse(name, player); - 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(""); - } - if (unlockedBy != null) { - lore.add(LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY", player)); - lore.add(LobbySystem.getMessage().parse(unlockedBy, player)); - lore.add(""); - } - lore.add(LobbySystem.getMessage().parse("PARTICLE_SELECT", player)); - return new SWItem(material, translatedName, lore, false, clickType -> {}); - } -} diff --git a/src/de/steamwar/lobby/particle/ParticleListener.java b/src/de/steamwar/lobby/particle/ParticleListener.java index 5c9c8f5..8253353 100644 --- a/src/de/steamwar/lobby/particle/ParticleListener.java +++ b/src/de/steamwar/lobby/particle/ParticleListener.java @@ -23,7 +23,6 @@ import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.jumpandrun.JumpAndRun; import de.steamwar.lobby.listener.BasicListener; import de.steamwar.lobby.listener.PlayerSpawn; -import de.steamwar.lobby.particle.particles.ParticleEnum; import de.steamwar.lobby.util.LobbyPlayer; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -49,9 +48,10 @@ public class ParticleListener extends BasicListener { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); ParticleEnum particle = lobbyPlayer.getParticle(); if (particle == null) return; - BaseParticle baseParticle = particle.getParticle(); - if (baseParticle.needsTick()) { - baseParticle.particle(new ParticleData(player.getWorld(), player, deg)); + ParticleData particleData = particle.getParticle(); + ParticleElement particleElement = particleData.getParticleElement(); + if (particleElement.tickType() == ParticleTickType.ALWAYS) { + particleElement.tick(new ParticleTickData(player.getWorld(), player, deg)); } }); }, 0, 1); @@ -65,7 +65,7 @@ public class ParticleListener extends BasicListener { if (!PlayerSpawn.PARTICLE.equals(event.getItem())) return; event.setCancelled(true); - ParticleInventory.openParticleInventory(player); + ParticleInventory.openInventory(player); } @EventHandler @@ -77,9 +77,11 @@ public class ParticleListener extends BasicListener { ParticleEnum particle = lobbyPlayer.getParticle(); if (particle == null) return; - BaseParticle baseParticle = particle.getParticle(); - if (baseParticle.needsTick()) return; - baseParticle.particle(new ParticleData(player.getWorld(), player, deg)); + ParticleData particleData = particle.getParticle(); + ParticleElement particleElement = particleData.getParticleElement(); + if (particleElement.tickType() == ParticleTickType.MOVE) { + particleElement.tick(new ParticleTickData(player.getWorld(), player, deg)); + } } @EventHandler diff --git a/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java b/src/de/steamwar/lobby/particle/ParticleRequirement.java similarity index 90% rename from src/de/steamwar/lobby/otherparticle/ParticleRequirement.java rename to src/de/steamwar/lobby/particle/ParticleRequirement.java index 71f404d..d228a81 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleRequirement.java +++ b/src/de/steamwar/lobby/particle/ParticleRequirement.java @@ -1,4 +1,4 @@ -package de.steamwar.lobby.otherparticle; +package de.steamwar.lobby.particle; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.special.easter.EggDifficulty; @@ -20,6 +20,18 @@ public interface ParticleRequirement { String getRequirementName(Player player); boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig); + ParticleRequirement SERVER_TEAM = new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_SERVER_TEAM", player); + } + + @Override + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + return false; + } + }; + ParticleRequirement NO_REQUIRMENT = new ParticleRequirement() { @Override public String getRequirementName(Player player) { @@ -41,7 +53,7 @@ public interface ParticleRequirement { public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { return user.getTeam() != 0; } - }; + }.or(SERVER_TEAM); ParticleRequirement EVENT_PARTICIPATION = new ParticleRequirement() { @Override public String getRequirementName(Player player) { @@ -52,18 +64,7 @@ public interface ParticleRequirement { public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { return !eventTeilname.isEmpty(); } - }; - ParticleRequirement SERVER_TEAM = new ParticleRequirement() { - @Override - public String getRequirementName(Player player) { - return LobbySystem.getMessage().parse("PARTICLE_UNLOCKED_BY_SERVER_TEAM", player); - } - - @Override - public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { - return false; - } - }; + }.or(SERVER_TEAM); ParticleRequirement EGG_HUNT_EASY = _easterEggHuntDifficulty(EggDifficulty.EASY); ParticleRequirement EGG_HUNT_MEDIUM = _easterEggHuntDifficulty(EggDifficulty.MEDIUM); ParticleRequirement EGG_HUNT_HARD = _easterEggHuntDifficulty(EggDifficulty.HARD); @@ -101,7 +102,7 @@ public interface ParticleRequirement { public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { return user.getTeam() == teamId; } - }; + }.or(SERVER_TEAM); } static ParticleRequirement eventParticipation(int eventId) { @@ -116,7 +117,7 @@ public interface ParticleRequirement { public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { return eventTeilname.contains(eventId); } - }; + }.or(SERVER_TEAM); } static ParticleRequirement eventPlacement(int eventId, int... placementTeams) { @@ -134,7 +135,7 @@ public interface ParticleRequirement { if (!eventTeilname.contains(eventId)) return false; return teams.contains(user.getTeam()); } - }; + }.or(SERVER_TEAM); } static ParticleRequirement _easterEggHuntDifficulty(EggDifficulty difficulty) { @@ -178,10 +179,20 @@ public interface ParticleRequirement { public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { return user.getId() == userId; } - }; + }.or(SERVER_TEAM); } - interface ParticleRequirementPredicate { - boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig); + default ParticleRequirement or(ParticleRequirement particleRequirement) { + return new ParticleRequirement() { + @Override + public String getRequirementName(Player player) { + return ParticleRequirement.this.getRequirementName(player); + } + + @Override + public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { + return ParticleRequirement.this.test(user, eventTeilname, eggHuntConfig) || particleRequirement.test(user, eventTeilname, eggHuntConfig); + } + }; } } diff --git a/src/de/steamwar/lobby/otherparticle/ParticleTickData.java b/src/de/steamwar/lobby/particle/ParticleTickData.java similarity index 95% rename from src/de/steamwar/lobby/otherparticle/ParticleTickData.java rename to src/de/steamwar/lobby/particle/ParticleTickData.java index b2aa909..ef55973 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleTickData.java +++ b/src/de/steamwar/lobby/particle/ParticleTickData.java @@ -1,4 +1,4 @@ -package de.steamwar.lobby.otherparticle; +package de.steamwar.lobby.particle; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/de/steamwar/lobby/otherparticle/ParticleTickType.java b/src/de/steamwar/lobby/particle/ParticleTickType.java similarity index 54% rename from src/de/steamwar/lobby/otherparticle/ParticleTickType.java rename to src/de/steamwar/lobby/particle/ParticleTickType.java index ac54999..adc25e4 100644 --- a/src/de/steamwar/lobby/otherparticle/ParticleTickType.java +++ b/src/de/steamwar/lobby/particle/ParticleTickType.java @@ -1,9 +1,8 @@ -package de.steamwar.lobby.otherparticle; +package de.steamwar.lobby.particle; public enum ParticleTickType { ALWAYS, MOVE, - SNEAK, ; } diff --git a/src/de/steamwar/lobby/particle/SimpleParticle.java b/src/de/steamwar/lobby/particle/SimpleParticle.java deleted file mode 100644 index 0f42271..0000000 --- a/src/de/steamwar/lobby/particle/SimpleParticle.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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 org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Particle; - -public class SimpleParticle implements BaseParticle { - - private final ParticleItem particleItem; - private final Particle particle; - private boolean customVelocity = false; - private float vx; - private float vy; - private float vz; - private double time = 1; - private int count = 5; - - public SimpleParticle(ParticleItem particleItem, Particle particle) { - this.particleItem = particleItem; - this.particle = particle; - } - - public SimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time) { - this.particleItem = particleItem; - this.particle = particle; - this.customVelocity = true; - this.vx = vx; - this.vy = vy; - this.vz = vz; - this.time = time; - } - - public SimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time, int count) { - this.particleItem = particleItem; - this.particle = particle; - this.customVelocity = true; - this.vx = vx; - this.vy = vy; - this.vz = vz; - this.time = time; - this.count = count; - } - - @Override - public ParticleItem getItem() { - return particleItem; - } - - @Override - public void particle(ParticleData particleData) { - Location location = particleData.getLocation().add(0.0, 0.2, 0.0); - Bukkit.getOnlinePlayers().forEach(player -> { - int viewDistance = player.getClientViewDistance() * 16; - if (location.distanceSquared(player.getLocation()) <= viewDistance * viewDistance) { - if (customVelocity) { - player.spawnParticle(particle, location, count, vx, vy, vz, time); - } else { - player.spawnParticle(particle, location, count); - } - } - }); - } -} diff --git a/src/de/steamwar/lobby/otherparticle/WingDesign.java b/src/de/steamwar/lobby/particle/WingDesign.java similarity index 90% rename from src/de/steamwar/lobby/otherparticle/WingDesign.java rename to src/de/steamwar/lobby/particle/WingDesign.java index c1687ed..dccb208 100644 --- a/src/de/steamwar/lobby/otherparticle/WingDesign.java +++ b/src/de/steamwar/lobby/particle/WingDesign.java @@ -1,6 +1,5 @@ -package de.steamwar.lobby.otherparticle; +package de.steamwar.lobby.particle; -import de.steamwar.lobby.particle.decorator.WingParticle; import lombok.SneakyThrows; import org.bukkit.util.Vector; @@ -15,7 +14,7 @@ public interface WingDesign { @SneakyThrows static Vector[] create(String resource) { List vectors = new ArrayList<>(); - BufferedImage bufferedImage = ImageIO.read(WingParticle.class.getResourceAsStream(resource)); + BufferedImage bufferedImage = ImageIO.read(WingDesign.class.getResourceAsStream(resource)); for (int x = 0; x < bufferedImage.getWidth(); x++) { for (int y = 0; y < bufferedImage.getHeight(); y++) { int rgb = bufferedImage.getRGB(x, y); diff --git a/src/de/steamwar/lobby/particle/decorator/CircleParticle.java b/src/de/steamwar/lobby/particle/decorator/CircleParticle.java deleted file mode 100644 index f46a09c..0000000 --- a/src/de/steamwar/lobby/particle/decorator/CircleParticle.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.decorator; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; -import org.bukkit.Location; -import org.bukkit.util.Vector; - -public class CircleParticle implements BaseParticle { - - private ParticleItem particleItem = null; - private BaseParticle particle; - private BaseParticle particle2; - - public CircleParticle(BaseParticle particle) { - this.particle = particle; - } - - public CircleParticle(ParticleItem particleItem, BaseParticle particle, BaseParticle particle2) { - this.particleItem = particleItem; - this.particle = particle; - this.particle2 = particle2; - } - - @Override - public ParticleItem getItem() { - if (particleItem != null) { - return particleItem.addAttribute("PARTICLE_ATTRIBUTE_BI_CIRCLE"); - } - return particle.getItem().addAttribute("PARTICLE_ATTRIBUTE_CIRCLE"); - } - - @Override - public boolean needsTick() { - return particle.needsTick() || (particle2 != null && particle2.needsTick()); - } - - @Override - public void particle(ParticleData particleData) { - Location location = particleData.getLocation(); - - Vector vector = new Vector(1, 0, 0); - vector.rotateAroundY(particleData.getDeg()); - ParticleData nData = particleData.withLocation(location.clone().add(vector)); - particle.particle(nData); - - if (particle2 == null) { - return; - } - vector.setX(-vector.getX()); - vector.setZ(-vector.getZ()); - - nData = particleData.withLocation(location.clone().add(vector)); - particle2.particle(nData); - } -} diff --git a/src/de/steamwar/lobby/particle/decorator/CloudParticle.java b/src/de/steamwar/lobby/particle/decorator/CloudParticle.java deleted file mode 100644 index 773f741..0000000 --- a/src/de/steamwar/lobby/particle/decorator/CloudParticle.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.decorator; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; -import lombok.NonNull; -import org.bukkit.Material; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public class CloudParticle implements BaseParticle { - - private BaseParticle particle; - - public CloudParticle(@NonNull BaseParticle particle) { - this.particle = particle; - } - - @Override - public ParticleItem getItem() { - return particle.getItem().addAttribute("PARTICLE_ATTRIBUTE_CLOUD"); - } - - @Override - public boolean needsTick() { - return particle.needsTick(); - } - - @Override - public void particle(ParticleData particleData) { - if (particleData.getWorld().getBlockAt(particleData.getPlayer().getLocation().subtract(0, 0.5, 0)).getType() == Material.AIR) { - particleData.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false)); - } else { - particleData.getPlayer().removePotionEffect(PotionEffectType.SLOW_FALLING); - return; - } - ParticleData nData = particleData.withLocation(particleData.getLocation().subtract(0, -0.2, 0)); - particle.particle(nData); - } -} diff --git a/src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java b/src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java deleted file mode 100644 index f0a090a..0000000 --- a/src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.decorator; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; -import org.bukkit.Material; - -public class NonFloorParticle implements BaseParticle { - - private BaseParticle particle; - - public NonFloorParticle(BaseParticle particle) { - this.particle = particle; - } - - @Override - public ParticleItem getItem() { - return particle.getItem().addAttribute("PARTICLE_ATTRIBUTE_NON_FLOOR"); - } - - @Override - public void particle(ParticleData particleData) { - if (particleData.getWorld().getBlockAt(particleData.getPlayer().getLocation().subtract(0, 0.5, 0)).getType() == Material.AIR) { - particle.particle(particleData); - } - } -} diff --git a/src/de/steamwar/lobby/particle/decorator/TickParticle.java b/src/de/steamwar/lobby/particle/decorator/TickParticle.java deleted file mode 100644 index 1eee74e..0000000 --- a/src/de/steamwar/lobby/particle/decorator/TickParticle.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.decorator; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; -import lombok.NonNull; - -public class TickParticle implements BaseParticle { - - private BaseParticle particle; - - public TickParticle(@NonNull BaseParticle particle) { - this.particle = particle; - } - - @Override - public ParticleItem getItem() { - return particle.getItem().addAttribute("PARTICLE_ATTRIBUTE_TICK"); - } - - @Override - public boolean needsTick() { - return true; - } - - @Override - public void particle(ParticleData particleData) { - particle.particle(particleData); - } -} diff --git a/src/de/steamwar/lobby/particle/decorator/WingParticle.java b/src/de/steamwar/lobby/particle/decorator/WingParticle.java deleted file mode 100644 index e12ed44..0000000 --- a/src/de/steamwar/lobby/particle/decorator/WingParticle.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.decorator; - -import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; -import lombok.SneakyThrows; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.util.Vector; - -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class WingParticle implements BaseParticle, Listener { - - private Map playerMap = new HashMap<>(); - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - playerMap.remove(event.getPlayer()); - } - - public enum WingDesign { - SIMPLE("WingSimple4.png"), - COMPLEX("WingSimple2.png"), - SWORD("WingSword.png"), - SW("WingSW.png"), - WGS("WingWGS.png"), - SWORD_CROSSED("WingSwordCrossed.png"), - MWGL("MWGL.png"), - ECLIPSE("ECLIPSE-Logo.png"), - ; - - private List vectors = new ArrayList<>(); - - @SneakyThrows - WingDesign(String wingResource) { - BufferedImage bufferedImage = ImageIO.read(WingParticle.class.getResourceAsStream(wingResource)); - for (int x = 0; x < bufferedImage.getWidth(); x++) { - for (int y = 0; y < bufferedImage.getHeight(); y++) { - int rgb = bufferedImage.getRGB(x, y); - if (Color.WHITE.getRGB() != rgb) { - vectors.add(new Vector(x - bufferedImage.getWidth() / 2.0, bufferedImage.getHeight() - y - 1.0, 0)); - } - } - } - } - } - - private BaseParticle particle; - private double size; - private WingDesign wingDesign; - - public WingParticle(BaseParticle particle, double size, WingDesign wingDesign) { - this.particle = particle; - this.size = size; - this.wingDesign = wingDesign; - - Bukkit.getPluginManager().registerEvents(this, LobbySystem.getPlugin()); - } - - @Override - public ParticleItem getItem() { - return particle.getItem().addAttribute("PARTICLE_ATTRIBUTE_WING"); - } - - @Override - public void particle(ParticleData particleData) { - int currentNumber = playerMap.getOrDefault(particleData.getPlayer(), 0) % 20; - playerMap.put(particleData.getPlayer(), currentNumber + 1); - if (currentNumber != 0) { - return; - } - if (particleData.getPlayer().isGliding()) { - return; - } - wingDesign.vectors.forEach(dVector -> { - Vector vector = new Vector(dVector.getX() * size, 0.6 + dVector.getY() * size - (particleData.getPlayer().isSneaking() ? 0.5 : 0) , 0.5); - vector.rotateAroundY(Math.toRadians(particleData.getPlayer().getLocation().getYaw() * -1)); - vector.setX(-vector.getX()); - vector.setZ(-vector.getZ()); - Location location = particleData.getPlayer().getLocation().clone().add(vector); - ParticleData current = particleData.withLocation(location); - particle.particle(current); - }); - } -} diff --git a/src/de/steamwar/lobby/otherparticle/elements/Always.java b/src/de/steamwar/lobby/particle/elements/Always.java similarity index 68% rename from src/de/steamwar/lobby/otherparticle/elements/Always.java rename to src/de/steamwar/lobby/particle/elements/Always.java index f35738d..0eeb41e 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Always.java +++ b/src/de/steamwar/lobby/particle/elements/Always.java @@ -1,8 +1,8 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; -import de.steamwar.lobby.otherparticle.ParticleTickType; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleTickType; public class Always extends DelegatingParticleElement { diff --git a/src/de/steamwar/lobby/otherparticle/elements/Circle.java b/src/de/steamwar/lobby/particle/elements/Circle.java similarity index 81% rename from src/de/steamwar/lobby/otherparticle/elements/Circle.java rename to src/de/steamwar/lobby/particle/elements/Circle.java index fd1f864..a086e4a 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Circle.java +++ b/src/de/steamwar/lobby/particle/elements/Circle.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; import org.bukkit.Location; import org.bukkit.util.Vector; diff --git a/src/de/steamwar/lobby/otherparticle/elements/Cloud.java b/src/de/steamwar/lobby/particle/elements/Cloud.java similarity index 86% rename from src/de/steamwar/lobby/otherparticle/elements/Cloud.java rename to src/de/steamwar/lobby/particle/elements/Cloud.java index 3ad3834..f7b91e7 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Cloud.java +++ b/src/de/steamwar/lobby/particle/elements/Cloud.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; import org.bukkit.Material; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; diff --git a/src/de/steamwar/lobby/otherparticle/elements/Delayed.java b/src/de/steamwar/lobby/particle/elements/Delayed.java similarity index 89% rename from src/de/steamwar/lobby/otherparticle/elements/Delayed.java rename to src/de/steamwar/lobby/particle/elements/Delayed.java index 472f339..f13d9b5 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Delayed.java +++ b/src/de/steamwar/lobby/particle/elements/Delayed.java @@ -1,8 +1,8 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; diff --git a/src/de/steamwar/lobby/otherparticle/elements/DelegatingParticleElement.java b/src/de/steamwar/lobby/particle/elements/DelegatingParticleElement.java similarity index 75% rename from src/de/steamwar/lobby/otherparticle/elements/DelegatingParticleElement.java rename to src/de/steamwar/lobby/particle/elements/DelegatingParticleElement.java index e961f29..55d6e10 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/DelegatingParticleElement.java +++ b/src/de/steamwar/lobby/particle/elements/DelegatingParticleElement.java @@ -1,8 +1,8 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickType; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickType; public abstract class DelegatingParticleElement implements ParticleElement { diff --git a/src/de/steamwar/lobby/otherparticle/elements/DoubleCircle.java b/src/de/steamwar/lobby/particle/elements/DoubleCircle.java similarity index 85% rename from src/de/steamwar/lobby/otherparticle/elements/DoubleCircle.java rename to src/de/steamwar/lobby/particle/elements/DoubleCircle.java index dbb838e..926f5f2 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/DoubleCircle.java +++ b/src/de/steamwar/lobby/particle/elements/DoubleCircle.java @@ -1,8 +1,8 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; -import de.steamwar.lobby.otherparticle.ParticleTickType; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleTickType; import org.bukkit.Location; import org.bukkit.util.Vector; diff --git a/src/de/steamwar/lobby/otherparticle/elements/DustParticle.java b/src/de/steamwar/lobby/particle/elements/DustParticle.java similarity index 87% rename from src/de/steamwar/lobby/otherparticle/elements/DustParticle.java rename to src/de/steamwar/lobby/particle/elements/DustParticle.java index 96b37c1..24ef229 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/DustParticle.java +++ b/src/de/steamwar/lobby/particle/elements/DustParticle.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; import org.bukkit.Location; import org.bukkit.Particle; diff --git a/src/de/steamwar/lobby/otherparticle/elements/Group.java b/src/de/steamwar/lobby/particle/elements/Group.java similarity index 77% rename from src/de/steamwar/lobby/otherparticle/elements/Group.java rename to src/de/steamwar/lobby/particle/elements/Group.java index 8f0e9a7..b6fc771 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Group.java +++ b/src/de/steamwar/lobby/particle/elements/Group.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; public class Group extends DelegatingParticleElement { diff --git a/src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java b/src/de/steamwar/lobby/particle/elements/LocationMutator.java similarity index 83% rename from src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java rename to src/de/steamwar/lobby/particle/elements/LocationMutator.java index 2de8f8a..41fd342 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/LocationMutator.java +++ b/src/de/steamwar/lobby/particle/elements/LocationMutator.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; import org.bukkit.Location; import java.util.function.UnaryOperator; diff --git a/src/de/steamwar/lobby/otherparticle/elements/NonFloor.java b/src/de/steamwar/lobby/particle/elements/NonFloor.java similarity index 76% rename from src/de/steamwar/lobby/otherparticle/elements/NonFloor.java rename to src/de/steamwar/lobby/particle/elements/NonFloor.java index f99dc71..ebc01eb 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/NonFloor.java +++ b/src/de/steamwar/lobby/particle/elements/NonFloor.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; public class NonFloor extends DelegatingParticleElement { diff --git a/src/de/steamwar/lobby/otherparticle/elements/NonFlying.java b/src/de/steamwar/lobby/particle/elements/NonFlying.java similarity index 73% rename from src/de/steamwar/lobby/otherparticle/elements/NonFlying.java rename to src/de/steamwar/lobby/particle/elements/NonFlying.java index 85d7037..2f74f9b 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/NonFlying.java +++ b/src/de/steamwar/lobby/particle/elements/NonFlying.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; public class NonFlying extends DelegatingParticleElement { diff --git a/src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java b/src/de/steamwar/lobby/particle/elements/SimpleParticle.java similarity index 91% rename from src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java rename to src/de/steamwar/lobby/particle/elements/SimpleParticle.java index d8e1204..fc678b0 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/SimpleParticle.java +++ b/src/de/steamwar/lobby/particle/elements/SimpleParticle.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; import org.bukkit.Location; import org.bukkit.Particle; diff --git a/src/de/steamwar/lobby/otherparticle/elements/Sneaking.java b/src/de/steamwar/lobby/particle/elements/Sneaking.java similarity index 59% rename from src/de/steamwar/lobby/otherparticle/elements/Sneaking.java rename to src/de/steamwar/lobby/particle/elements/Sneaking.java index a087ba5..42bb16c 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Sneaking.java +++ b/src/de/steamwar/lobby/particle/elements/Sneaking.java @@ -1,8 +1,7 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; -import de.steamwar.lobby.otherparticle.ParticleTickType; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; public class Sneaking extends DelegatingParticleElement { @@ -10,11 +9,6 @@ public class Sneaking extends DelegatingParticleElement { super(particleElement); } - @Override - public ParticleTickType tickType() { - return ParticleTickType.SNEAK; - } - @Override public String attribute() { return null; // TODO: Implement this attribute diff --git a/src/de/steamwar/lobby/otherparticle/elements/Wing.java b/src/de/steamwar/lobby/particle/elements/Wing.java similarity index 84% rename from src/de/steamwar/lobby/otherparticle/elements/Wing.java rename to src/de/steamwar/lobby/particle/elements/Wing.java index 46b91d0..f0f8203 100644 --- a/src/de/steamwar/lobby/otherparticle/elements/Wing.java +++ b/src/de/steamwar/lobby/particle/elements/Wing.java @@ -1,8 +1,8 @@ -package de.steamwar.lobby.otherparticle.elements; +package de.steamwar.lobby.particle.elements; -import de.steamwar.lobby.otherparticle.ParticleElement; -import de.steamwar.lobby.otherparticle.ParticleTickData; -import de.steamwar.lobby.otherparticle.WingDesign; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; +import de.steamwar.lobby.particle.WingDesign; import org.bukkit.Location; import org.bukkit.util.Vector; diff --git a/src/de/steamwar/lobby/particle/group/ParticleGroup.java b/src/de/steamwar/lobby/particle/group/ParticleGroup.java deleted file mode 100644 index 1d837c4..0000000 --- a/src/de/steamwar/lobby/particle/group/ParticleGroup.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.group; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; - -public class ParticleGroup implements BaseParticle { - - private ParticleItem particleItem; - private BaseParticle[] particles; - - public ParticleGroup(ParticleItem particleItem, BaseParticle... particles) { - this.particleItem = particleItem; - this.particles = particles; - } - - @Override - public ParticleItem getItem() { - return particleItem; - } - - @Override - public void particle(ParticleData particleData) { - for (BaseParticle particle : particles) { - particle.particle(particleData.copy()); - } - } -} diff --git a/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java b/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java deleted file mode 100644 index 602fd85..0000000 --- a/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.mutator; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleItem; -import org.bukkit.Location; - -import java.util.function.UnaryOperator; - -public class LocationParticleMutator implements BaseParticle { - - private BaseParticle particle; - private UnaryOperator mutator; - - public LocationParticleMutator(BaseParticle particle, UnaryOperator mutator) { - this.particle = particle; - this.mutator = mutator; - } - - @Override - public ParticleItem getItem() { - return particle.getItem(); - } - - @Override - public boolean needsTick() { - return particle.needsTick(); - } - - @Override - public void particle(ParticleData particleData) { - ParticleData nData = particleData.withLocation(mutator.apply(particleData.getLocation())); - particle.particle(nData); - } -} diff --git a/src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java b/src/de/steamwar/lobby/particle/particles/EasterParticle.java similarity index 79% rename from src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java rename to src/de/steamwar/lobby/particle/particles/EasterParticle.java index 6ea1ca4..8980995 100644 --- a/src/de/steamwar/lobby/otherparticle/particles/EasterParticle.java +++ b/src/de/steamwar/lobby/particle/particles/EasterParticle.java @@ -1,11 +1,11 @@ -package de.steamwar.lobby.otherparticle.particles; +package de.steamwar.lobby.particle.particles; -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.elements.Always; -import de.steamwar.lobby.otherparticle.elements.LocationMutator; -import de.steamwar.lobby.otherparticle.elements.SimpleParticle; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.elements.Always; +import de.steamwar.lobby.particle.elements.LocationMutator; +import de.steamwar.lobby.particle.elements.SimpleParticle; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; diff --git a/src/de/steamwar/lobby/particle/particles/EventParticle.java b/src/de/steamwar/lobby/particle/particles/EventParticle.java index 016ac02..a1d097f 100644 --- a/src/de/steamwar/lobby/particle/particles/EventParticle.java +++ b/src/de/steamwar/lobby/particle/particles/EventParticle.java @@ -1,46 +1,29 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.particles; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.decorator.CircleParticle; -import de.steamwar.lobby.particle.decorator.NonFloorParticle; -import de.steamwar.lobby.particle.decorator.TickParticle; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.elements.Always; +import de.steamwar.lobby.particle.elements.Circle; +import de.steamwar.lobby.particle.elements.LocationMutator; +import de.steamwar.lobby.particle.elements.SimpleParticle; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; import org.bukkit.Particle; -import static org.bukkit.Material.*; - @AllArgsConstructor public enum EventParticle implements ParticleEnum { - WATER(new TickParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(WATER_BUCKET, "PARTICLE_WATER", "PARTICLE_UNLOCKED_BY_EVENT"), Particle.DRIP_WATER), location -> location.add(0, 1.1, 0))))), - LAVA(new TickParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(LAVA_BUCKET, "PARTICLE_FIRE", "PARTICLE_UNLOCKED_BY_EVENT"), Particle.DRIP_LAVA), location -> location.add(0, 1.1, 0))))), + WATER(new ParticleData(Material.WATER_BUCKET, "PARTICLE_WATER", ParticleRequirement.EVENT_PARTICIPATION, + new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIP_WATER), 0, 1.1, 0)))) + ), + LAVA(new ParticleData(Material.LAVA_BUCKET, "PARTICLE_FIRE", ParticleRequirement.EVENT_PARTICIPATION, + new Always(new Circle(new LocationMutator(new SimpleParticle(Particle.DRIP_LAVA), 0, 1.1, 0)))) + ), ; public static ParticleEnum[] particles = values(); @Getter - private BaseParticle particle; + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java b/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java index 83689ac..a128623 100644 --- a/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java +++ b/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java @@ -1,56 +1,45 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.particles; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.EventParticleItem; -import de.steamwar.lobby.particle.ParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.decorator.CircleParticle; -import de.steamwar.lobby.particle.decorator.TickParticle; -import de.steamwar.lobby.particle.decorator.WingParticle; -import de.steamwar.lobby.particle.group.ParticleGroup; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.WingDesign; +import de.steamwar.lobby.particle.elements.*; import lombok.AllArgsConstructor; import lombok.Getter; +import org.bukkit.Material; import org.bukkit.Particle; -import static org.bukkit.Material.*; - @AllArgsConstructor -@Getter public enum EventParticleParticipation implements ParticleEnum { - WarGearSeason(22, new SimpleParticle(EventParticleItem.participation(BOOK, "PARTICLE_EVENT_ENCHANTING", 22), Particle.ENCHANTMENT_TABLE)), - AirshipEvent(26, new SimpleParticle(EventParticleItem.participation(SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", 26), Particle.CLOUD)), - HellsBellsWs(28, new CircleParticle(new SimpleParticle(EventParticleItem.participation(TNT, "PARTICLE_EVENT_SMOKE", 28), Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))), - Underwater(31, new SimpleParticle(EventParticleItem.participation(PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", 31), Particle.DRIP_WATER)), - AdventWarShip(32, new ParticleGroup(EventParticleItem.participation(PRISMARINE_WALL, "PARTICLE_EVENT_WATER", 32), new SimpleParticle(null, Particle.DRIP_WATER), new SimpleParticle(null, Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))), - MiniWarGearLiga(33, new CircleParticle(new SimpleParticle(EventParticleItem.participation(PRISMARINE_SLAB, "PARTICLE_EVENT_WATER", 33), Particle.WATER_WAKE, 0, 0, 0, 0))), - // Absturz(34, null), - UnderwaterMWG(35, new TickParticle(new LocationParticleMutator(new ParticleGroup(EventParticleItem.participation(BLUE_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", 35), new SimpleParticle(null, Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new SimpleParticle(null, Particle.WATER_WAKE, 0.3F, 0.1F, 0.3F, 0.01), new LocationParticleMutator(new SimpleParticle(null, Particle.DRIP_WATER, 0.3F, 0.0F, 0.3F, 0.01), location -> location.subtract(0, 0.2, 0))), location -> location.add(0, 2.2, 0)))), - WarGearSeason2022(37, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.participation(DIAMOND_SWORD, "PARTICLE_EVENT_WINGS", 37), Particle.DRAGON_BREATH, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.COMPLEX))), - // WargearClash(38, null), + WarGearSeason(new ParticleData(Material.BOOK, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.eventParticipation(22), + new SimpleParticle(Particle.ENCHANTMENT_TABLE)) + ), + AirshipEvent(new ParticleData(Material.SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", ParticleRequirement.eventParticipation(26), + new SimpleParticle(Particle.CLOUD)) + ), + HellsBellsWs(new ParticleData(Material.TNT, "PARTICLE_EVENT_SMOKE", ParticleRequirement.eventParticipation(28), + new Circle(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))) + ), + Underwater(new ParticleData(Material.PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(31), + new SimpleParticle(Particle.DRIP_WATER)) + ), + AdventWarShip(new ParticleData(Material.PRISMARINE_WALL, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(32), + new Group(new SimpleParticle(Particle.DRIP_WATER), new SimpleParticle(Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))) + ), + MiniWarGearLiga(new ParticleData(Material.PRISMARINE_SLAB, "PARTICLE_EVENT_WATER", ParticleRequirement.eventParticipation(33), + new Circle(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0))) + ), + UnderwaterMWG(new ParticleData(Material.BLUE_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", ParticleRequirement.eventParticipation(35), + new Always(new LocationMutator(new Group(new SimpleParticle(Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new SimpleParticle(Particle.WATER_WAKE, 0.3F, 0.1F, 0.3F, 0.01), new LocationMutator(new SimpleParticle(Particle.DRIP_WATER, 0.3F, 0.0F, 0.3F, 0.01), 0, 0.2, 0)), 0, 2.2, 0))) + ), + WarGearSeason2022(new ParticleData(Material.DIAMOND_SWORD, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventParticipation(37), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.DRAGON_BREATH, 0, 0, 0, 0, 1), 0.15, WingDesign.COMPLEX)), 20))) + ), ; - public static EventParticleParticipation[] particles = values(); + public static ParticleEnum[] particles = values(); - private int event; - private BaseParticle particle; + @Getter + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java b/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java index 187572f..e050730 100644 --- a/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java +++ b/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java @@ -1,57 +1,51 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.particles; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.EventParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.decorator.CircleParticle; -import de.steamwar.lobby.particle.decorator.CloudParticle; -import de.steamwar.lobby.particle.decorator.TickParticle; -import de.steamwar.lobby.particle.decorator.WingParticle; -import de.steamwar.lobby.particle.group.ParticleGroup; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.WingDesign; +import de.steamwar.lobby.particle.elements.*; import lombok.AllArgsConstructor; import lombok.Getter; +import org.bukkit.Material; import org.bukkit.Particle; -import static org.bukkit.Material.*; - @AllArgsConstructor -@Getter public enum EventParticlePlacement implements ParticleEnum { - WarGearSeason(22, new int[]{12, 285, 54}, new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(EventParticleItem.placement(ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", 22), Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), location -> location.add(0, 1.1, 0))))), - AirshipEvent(26, new int[]{205, 9, 54, 120, 292}, new CircleParticle(new LocationParticleMutator(new SimpleParticle(EventParticleItem.placement(SNOWBALL, "PARTICLE_EVENT_CLOUD", 26), Particle.CLOUD, 0, 0, 0, 0.01), location -> location.add(0, 2.2, 0)))), - HellsBellsWs(28, new int[]{205, 9, 11}, new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(EventParticleItem.placement(TNT_MINECART, "PARTICLE_EVENT_SMOKE", 28), Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01), location -> location.add(0, 2.2, 0))))), - Underwater(31, new int[]{9, 210, 520}, new CloudParticle(new SimpleParticle(EventParticleItem.placement(PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", 31), Particle.DRIP_WATER))), - AdventWarShip(32, new int[]{9, 205, 210}, new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleGroup(EventParticleItem.placement(PRISMARINE_CRYSTALS, "PARTICLE_EVENT_WATER", 32), new SimpleParticle(null, Particle.DRIP_WATER), new SimpleParticle(null, Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))), location -> location.add(0, 1.1, 0)))), - MiniWarGearLiga(33, new int[]{9, 34, 205}, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.placement(IRON_SWORD, "PARTICLE_EVENT_WINGS", 33), Particle.WATER_WAKE, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.MWGL))), - Absturz(34, new int[]{210, 205, 527, 286}, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.placement(FEATHER, "PARTICLE_EVENT_WINGS", 34), Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.SIMPLE))), - UnderwaterMWG(35, new int[]{9, 210}, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.placement(CYAN_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", 35), Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.SW))), - WarGearSeason2022(37, new int[]{285, 210, 122}, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.placement(DIAMOND_HELMET, "PARTICLE_EVENT_WGS", 37), Particle.FIREWORKS_SPARK, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.WGS))), - WargearClash(38, new int[]{210, 158, 167, 286}, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.placement(GOLDEN_SWORD, "PARTICLE_EVENT_WARGEARCLASH", 38), Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.1, WingParticle.WingDesign.SWORD_CROSSED))), + WarGearSeason(new ParticleData(Material.ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", ParticleRequirement.eventPlacement(22, 12, 285, 54), + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), 0, 1.1, 0))) + )), + AirshipEvent(new ParticleData(Material.SNOWBALL, "PARTICLE_EVENT_CLOUD", ParticleRequirement.eventPlacement(26, 205, 9, 54, 120, 292), + new Circle(new LocationMutator(new SimpleParticle(Particle.CLOUD, 0, 0, 0, 0.01), 0, 2.2, 0)) + )), + HellsBellsWs(new ParticleData(Material.TNT_MINECART, "PARTICLE_EVENT_SMOKE", ParticleRequirement.eventPlacement(28, 205, 9, 11), + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01), 0, 2.2, 0))) + )), + Underwater(new ParticleData(Material.PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", ParticleRequirement.eventPlacement(31, 9, 210, 520), + new Cloud(new SimpleParticle(Particle.DRIP_WATER))) + ), + AdventWarShip(new ParticleData(Material.PRISMARINE_CRYSTALS, "PARTICLE_EVENT_WATER", ParticleRequirement.eventPlacement(31, 9, 205, 210), + new Always(new LocationMutator(new Circle(new Group(new SimpleParticle(Particle.DRIP_WATER), new SimpleParticle(Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))), 0, 1.1, 0))) + ), + MiniWarGearLiga(new ParticleData(Material.IRON_SWORD, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventPlacement(33, 9, 34, 205), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0, 1), 0.15, WingDesign.MWGL)), 20))) + ), + Absturz(new ParticleData(Material.FEATHER, "PARTICLE_EVENT_WINGS", ParticleRequirement.eventPlacement(34, 210, 205, 527, 286), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) + ), + UnderwaterMWG(new ParticleData(Material.CYAN_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", ParticleRequirement.eventPlacement(35, 9, 210), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingDesign.SW)), 20))) + ), + WarGearSeason2022(new ParticleData(Material.DIAMOND_HELMET, "PARTICLE_EVENT_WGS", ParticleRequirement.eventPlacement(37, 285, 210, 122), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 0, 1), 0.15, WingDesign.WGS)), 20))) + ), + WargearClash(new ParticleData(Material.GOLDEN_SWORD, "PARTICLE_EVENT_WARGEARCLASH", ParticleRequirement.eventPlacement(38, 210, 158, 167, 286), + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.1, WingDesign.SWORD_CROSSED)), 20))) + ), ; - public static EventParticlePlacement[] particles = values(); + public static ParticleEnum[] particles = values(); - private int event; - private int[] placementTeams; - private BaseParticle particle; + @Getter + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/particle/particles/ParticleEnum.java b/src/de/steamwar/lobby/particle/particles/ParticleEnum.java deleted file mode 100644 index db97369..0000000 --- a/src/de/steamwar/lobby/particle/particles/ParticleEnum.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.particles; - -import de.steamwar.lobby.particle.BaseParticle; - -public interface ParticleEnum { - BaseParticle getParticle(); -} diff --git a/src/de/steamwar/lobby/particle/particles/PlayerParticle.java b/src/de/steamwar/lobby/particle/particles/PlayerParticle.java index 9bbbe1f..ed66d8c 100644 --- a/src/de/steamwar/lobby/particle/particles/PlayerParticle.java +++ b/src/de/steamwar/lobby/particle/particles/PlayerParticle.java @@ -1,56 +1,63 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.particles; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.DustSimpleParticle; -import de.steamwar.lobby.particle.ParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.elements.DustParticle; +import de.steamwar.lobby.particle.elements.LocationMutator; +import de.steamwar.lobby.particle.elements.SimpleParticle; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; import org.bukkit.Particle; -import static org.bukkit.Material.*; - @AllArgsConstructor public enum PlayerParticle implements ParticleEnum { - SNEEZE(new SimpleParticle(new ParticleItem(SLIME_BLOCK, "PARTICLE_SNEEZE"), Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)), - SMOKE(new SimpleParticle(new ParticleItem(COBWEB, "PARTICLE_SMOKE"), Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)), - FIRE(new SimpleParticle(new ParticleItem(LAVA_BUCKET, "PARTICLE_FIRE"), Particle.DRIP_LAVA)), - WATER(new SimpleParticle(new ParticleItem(WATER_BUCKET, "PARTICLE_WATER"), Particle.DRIP_WATER)), - HEART(new LocationParticleMutator(new SimpleParticle(new ParticleItem(RED_DYE, "PARTICLE_HEART"), Particle.HEART), location -> location.add(0, 2.2, 0))), - NOTES(new LocationParticleMutator(new SimpleParticle(new ParticleItem(NOTE_BLOCK, "PARTICLE_NOTES"), Particle.NOTE), location -> location.add(0, 2.2, 0))), - NAUTILUS(new SimpleParticle(new ParticleItem(NAUTILUS_SHELL, "PARTICLE_NAUTILUS"), Particle.NAUTILUS, 0.2F, 0.2F, 0.2F, 0.01)), - SNOWBALL(new SimpleParticle(new ParticleItem(Material.SNOWBALL, "PARTICLE_SNOWBALL"), Particle.SNOWBALL, 0.2F, 0.2F, 0.2F, 0.01)), - EFFECT(new DustSimpleParticle(new ParticleItem(GLASS_BOTTLE, "PARTICLE_EFFECT"), Particle.REDSTONE, 0F, 0.2F, 0F, 0.01)), - CAMPFIRE(new SimpleParticle(new ParticleItem(Material.CAMPFIRE, "PARTICLE_CAMPFIRE"), Particle.CAMPFIRE_COSY_SMOKE, 0F, 0.2F, 0F, 0.01)), - MAGIC(new SimpleParticle(new ParticleItem(CAULDRON, "PARTICLE_MAGIC"), Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)), - ANGRY(new SimpleParticle(new ParticleItem(REDSTONE_BLOCK, "PARTICLE_ANGRY"), Particle.VILLAGER_ANGRY, 0.2F, 0.2F, 0.2F, 0.01)), - SLIME(new SimpleParticle(new ParticleItem(SLIME_BALL, "PARTICLE_SLIME"), Particle.SLIME)), - MOB(new SimpleParticle(new ParticleItem(ZOMBIE_HEAD, "PARTICLE_MOB"), Particle.SPELL_MOB)), + SNEEZE(new ParticleData(Material.SLIME_BLOCK, "PARTICLE_SNEEZE", + new SimpleParticle(Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)) + ), + SMOKE(new ParticleData(Material.COBWEB, "PARTICLE_SMOKE", + new SimpleParticle(Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)) + ), + FIRE(new ParticleData(Material.LAVA_BUCKET, "PARTICLE_FIRE", + new SimpleParticle(Particle.DRIP_LAVA)) + ), + WATER(new ParticleData(Material.WATER_BUCKET, "PARTICLE_WATER", + new SimpleParticle(Particle.DRIP_WATER)) + ), + HEARTH(new ParticleData(Material.RED_DYE, "PARTICLE_HEART", + new LocationMutator(new SimpleParticle(Particle.HEART), 0, 2.2, 0)) + ), + NOTES(new ParticleData(Material.NOTE_BLOCK, "PARTICLE_NOTES", + new LocationMutator(new SimpleParticle(Particle.NOTE), 0, 2.2, 0)) + ), + NAUTILUS(new ParticleData(Material.NAUTILUS_SHELL, "PARTICLE_NAUTILUS", + new SimpleParticle(Particle.NAUTILUS, 0.2F, 0.2F ,0.2F, 0.01)) + ), + SNOWBALL(new ParticleData(Material.SNOWBALL, "PARTICLE_SNOWBALL", + new SimpleParticle(Particle.SNOWBALL, 0.2F, 0.2F ,0.2F, 0.01)) + ), + EFFECT(new ParticleData(Material.GLASS_BOTTLE, "PARTICLE_EFFECT", + new DustParticle(Particle.REDSTONE, 0, 0.2F, 02F, 0.01, 5)) + ), + CAMPFIRE(new ParticleData(Material.CAMPFIRE, "PARTICLE_CAMPFIRE", + new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0.2F ,0, 0.01)) + ), + MAGIC(new ParticleData(Material.CAULDRON, "PARTICLE_MAGIC", + new SimpleParticle(Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)) + ), + ANGRY(new ParticleData(Material.REDSTONE_BLOCK, "PARTICLE_ANGRY", + new SimpleParticle(Particle.VILLAGER_ANGRY, 0.2F, 0.2F, 0.2F, 0.01)) + ), + SLIME(new ParticleData(Material.SLIME_BALL, "PARTICLE_SLIME", + new SimpleParticle(Particle.SLIME)) + ), + MOB(new ParticleData(Material.ZOMBIE_HEAD, "PARTICLE_MOB", + new SimpleParticle(Particle.SPELL_MOB)) + ), ; public static ParticleEnum[] particles = values(); @Getter - private BaseParticle particle; + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java b/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java index fc9d000..0a7bc9d 100644 --- a/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java +++ b/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java @@ -1,71 +1,99 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.particles; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.decorator.CircleParticle; -import de.steamwar.lobby.particle.decorator.CloudParticle; -import de.steamwar.lobby.particle.decorator.TickParticle; -import de.steamwar.lobby.particle.decorator.WingParticle; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.WingDesign; +import de.steamwar.lobby.particle.elements.*; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; import org.bukkit.Particle; -import static org.bukkit.Material.*; - @AllArgsConstructor public enum ServerTeamParticle implements ParticleEnum { - WITCH(new SimpleParticle(new ParticleItem(EXPERIENCE_BOTTLE, "PARTICLE_WITCH", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.SPELL_WITCH)), - ENCHANTING(new SimpleParticle(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.ENCHANTMENT_TABLE)), - HAPPY(new SimpleParticle(new ParticleItem(EMERALD_BLOCK, "PARTICLE_HAPPY", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)), - FLAME(new SimpleParticle(new ParticleItem(FLINT_AND_STEEL, "PARTICLE_FLAME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FLAME, 0F, 0.2F, 0F, 0.01)), - END_ROD(new SimpleParticle(new ParticleItem(Material.END_ROD, "PARTICLE_END_ROD", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)), - CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(WHITE_WOOL, "PARTICLE_CLOUD", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.CLOUD))), - TOTEM(new CloudParticle(new SimpleParticle(new ParticleItem(TOTEM_OF_UNDYING, "PARTICLE_TOTEM", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.TOTEM, 0.2F, 0.2F, 0.2F, 0.01))), - ENCHANTING_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(WHITE_DYE, "PARTICLE_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.ENCHANTMENT_TABLE))), - FLAME_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(FIRE_CORAL_BLOCK, "PARTICLE_FLAME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FLAME))), - SNEEZE_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(LIME_SHULKER_BOX, "PARTICLE_SNEEZE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.SNEEZE))), - SLIME_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(GREEN_SHULKER_BOX, "PARTICLE_SLIME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.SLIME))), - SMOKE_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(DEAD_BRAIN_CORAL_BLOCK, "PARTICLE_SMOKE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.CAMPFIRE_COSY_SMOKE, 0.2F, 0.2F, 0.2F, 0.01))), - TOWN_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(FIREWORK_STAR, "PARTICLE_TOWN", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.TOWN_AURA))), - FLAME_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(MAGMA_BLOCK, "PARTICLE_FLAME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FLAME, 0F, 0F, 0F, 0.01), location -> location.add(0, 1.1, 0)))), - ENCHANTING_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(WHITE_DYE, "PARTICLE_ENCHANTING_CIRCLE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.ENCHANTMENT_TABLE, 0.2F, 0.2F, 0.2F, 0.01), location -> location.add(0, 1.1, 0)))), - NOTES_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(NOTE_BLOCK, "PARTICLE_NOTES", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.NOTE, 0F, 0F, 0F, 0.01), location -> location.add(0, 2.2, 0)))), - WATER_FIRE(new LocationParticleMutator(new CircleParticle(new ParticleItem(GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null, Particle.DRIP_WATER, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null, Particle.DRIP_LAVA, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 1.1, 0))), - WATER_FIRE_ALWAYS(new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleItem(MAGMA_CUBE_SPAWN_EGG, "PARTICLE_WATER_FIRE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null,Particle.DRIP_WATER, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null,Particle.DRIP_LAVA, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 1.1, 0)))), - MAGIC_ENCHANTING(new LocationParticleMutator(new CircleParticle(new ParticleItem(DIAMOND_SWORD, "PARTICLE_MAGIC_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null, Particle.CRIT_MAGIC, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null, Particle.ENCHANTMENT_TABLE, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 1.1, 0))), - MAGIC_ENCHANTING_ALWAYS(new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleItem(WOODEN_SWORD, "PARTICLE_MAGIC_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null, Particle.CRIT_MAGIC, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null, Particle.ENCHANTMENT_TABLE, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 1.1, 0)))), - MAGIC_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(GLOWSTONE_DUST, "PARTICLE_MAGIC", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.CRIT_MAGIC, 0.0F, 0.0F, 0.0F, 0.01), location -> location.add(0, 1.1, 0))))), - FLAME_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(FIRE_CORAL, "PARTICLE_FLAME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FLAME, 0.0F, 0.0F, 0.0F, 0.01), location -> location.add(0, 1.1, 0))))), - FIREWORK_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(FIREWORK_ROCKET, "PARTICLE_FIREWORK", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FIREWORKS_SPARK, 0.0F, 0.0F, 0.0F, 0.01), location -> location.add(0, 1.1, 0))))), - WATER_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(CYAN_DYE, "PARTICLE_WATER", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.WATER_WAKE, 0.0F, 0.0F, 0.0F, 0.01), location -> location.add(0, 1.1, 0))))), - ENCHANTING_DOUBLE_CIRCLE(new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleItem(BUBBLE_CORAL_BLOCK, "PARTICLE_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null, Particle.ENCHANTMENT_TABLE, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null, Particle.ENCHANTMENT_TABLE, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 2.2, 0)))), - EVIL_WINGS(new TickParticle(new WingParticle(new SimpleParticle(new ParticleItem(PURPUR_SLAB, "PARTICLE_WINGS_EVIL", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.SPELL_WITCH, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.SIMPLE))), + WITCH(new ParticleData(Material.EXPERIENCE_BOTTLE, "PARTICLE_WITCH", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.SPELL_WITCH)) + ), + ENCHANTING(new ParticleData(Material.ENCHANTING_TABLE, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.ENCHANTMENT_TABLE)) + ), + HAPPY(new ParticleData(Material.EMERALD_BLOCK, "PARTICLE_HAPPY", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.HEART, 0.2F, 0.2F, 0.2F, 0.01)) + ), + FLAME(new ParticleData(Material.FLINT_AND_STEEL, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.FLAME, 0, 0.2F, 0, 0.01)) + ), + END_ROD(new ParticleData(Material.END_ROD, "PARTICLE_END_ROD", ParticleRequirement.SERVER_TEAM, + new SimpleParticle(Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)) + ), + CLOUD(new ParticleData(Material.WHITE_WOOL, "PARTICLE_CLOUD", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.CLOUD))) + ), + TOTEM(new ParticleData(Material.TOTEM_OF_UNDYING, "PARTICLE_TOTEM", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.TOTEM, 0.2F, 0.2F, 0.2F, 0.01))) + ), + ENCHANTING_CLOUD(new ParticleData(Material.WHITE_DYE, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.ENCHANTMENT_TABLE))) + ), + FLAME_CLOUD(new ParticleData(Material.FIRE_CORAL_BLOCK, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.FLAME))) + ), + SNEEZE_CLOUD(new ParticleData(Material.LIME_SHULKER_BOX, "PARTICLE_SNEEZE", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.SNEEZE))) + ), + SLIME_CLOUD(new ParticleData(Material.GREEN_SHULKER_BOX, "PARTICLE_SLIME", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.SLIME))) + ), + SMOKE_CLOUD(new ParticleData(Material.DEAD_BRAIN_CORAL_BLOCK, "PARTICLE_SMOKE", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0.2F, 0.2F, 0.2F, 0.01))) + ), + TOWN_CLOUD(new ParticleData(Material.FIREWORK_STAR, "PARTICLE_TOWN", ParticleRequirement.SERVER_TEAM, + new Cloud(new SimpleParticle(Particle.TOWN_AURA))) + ), + FLAME_CIRCLE(new ParticleData(Material.MAGMA_BLOCK, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, + new Circle(new LocationMutator(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0.01), 0, 1.1, 0))) + ), + ENCHANTING_CIRCLE(new ParticleData(Material.WHITE_DYE, "PARTICLE_ENCHANTING_CIRCLE", ParticleRequirement.SERVER_TEAM, + new Circle(new LocationMutator(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0.2F, 0.2F, 0.2F, 0.01), 0, 1.1, 0))) + ), + NOTES_CIRCLE(new ParticleData(Material.NOTE_BLOCK, "PARTICLE_NOTES", ParticleRequirement.SERVER_TEAM, + new Circle(new LocationMutator(new SimpleParticle(Particle.NOTE, 0, 0, 0, 0.01), 0, 2.2, 0))) + ), + WATER_FIRE(new ParticleData(Material.GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, + new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIP_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIP_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0)) + ), + WATER_FIRE_ALWAYS(new ParticleData(Material.GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, + new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.DRIP_WATER, 0, 0, 0, 0.01), new SimpleParticle(Particle.DRIP_LAVA, 0, 0, 0, 0.01)), 0, 1.1, 0))) + ), + MAGIC_ENCHANTING(new ParticleData(Material.DIAMOND_SWORD, "PARTICLE_MAGIC_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 1.1, 0)) + ), + MAGIC_ENCHANTING_ALWAYS(new ParticleData(Material.WOODEN_SWORD, "PARTICLE_MAGIC_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 1.1, 0))) + ), + MAGIC_CLOUD_CIRCLE(new ParticleData(Material.GLOWSTONE_DUST, "PARTICLE_MAGIC", ParticleRequirement.SERVER_TEAM, + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.CRIT_MAGIC, 0, 0, 0, 0.01), 0, 1.1, 0)))) + ), + FLAME_CLOUD_CIRCLE(new ParticleData(Material.FIRE_CORAL, "PARTICLE_FLAME", ParticleRequirement.SERVER_TEAM, + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FLAME, 0, 0, 0, 0.01), 0, 1.1, 0)))) + ), + FIREWORK_CLOUD_CIRCLE(new ParticleData(Material.FIREWORK_ROCKET, "PARTICLE_FIREWORK", ParticleRequirement.SERVER_TEAM, + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.FIREWORKS_SPARK, 0, 0, 0, 0.01), 0, 1.1, 0)))) + ), + WATER_CLOUD_CIRCLE(new ParticleData(Material.CYAN_DYE, "PARTICLE_WATER_FIRE", ParticleRequirement.SERVER_TEAM, + new Cloud(new Circle(new LocationMutator(new SimpleParticle(Particle.WATER_WAKE, 0, 0, 0, 0.01), 0, 1.1, 0)))) + ), + ENCHANTING_DOUBLE_CIRCLE(new ParticleData(Material.BUBBLE_CORAL_BLOCK, "PARTICLE_ENCHANTING", ParticleRequirement.SERVER_TEAM, + new Always(new LocationMutator(new DoubleCircle(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01)), 0, 2.2, 0))) + ), + EVIL_WINGS(new ParticleData(Material.PURPUR_SLAB, "PARTICLE_WINGS_EVIL", ParticleRequirement.SERVER_TEAM, + new Always(new Delayed(new NonFlying(new Wing(new SimpleParticle(Particle.SPELL_WITCH, 0, 0, 0, 0, 1), 0.15, WingDesign.SIMPLE)), 20))) + ), ; public static ParticleEnum[] particles = values(); @Getter - private BaseParticle particle; + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/particle/particles/SpecialTeamParticle.java b/src/de/steamwar/lobby/particle/particles/SpecialTeamParticle.java deleted file mode 100644 index dc7566e..0000000 --- a/src/de/steamwar/lobby/particle/particles/SpecialTeamParticle.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.particles; - -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.decorator.TickParticle; -import de.steamwar.lobby.particle.decorator.WingParticle; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.bukkit.Particle; - -import static org.bukkit.Material.ENDER_CHEST; - -@Getter -@AllArgsConstructor -public enum SpecialTeamParticle implements ParticleEnum { - - Eclipse(34, new TickParticle(new WingParticle(new SimpleParticle(new ParticleItem(ENDER_CHEST, "PARTICLE_EVENT_ENCHANTING"), Particle.PORTAL, 0.0F, 0.0F, 0.0F, 0.01), 0.15, WingParticle.WingDesign.ECLIPSE))), - ; - public static SpecialTeamParticle[] particles = values(); - - private int teamId; - private BaseParticle particle; -} diff --git a/src/de/steamwar/lobby/particle/particles/TeamParticle.java b/src/de/steamwar/lobby/particle/particles/TeamParticle.java index 9efc748..ce20b77 100644 --- a/src/de/steamwar/lobby/particle/particles/TeamParticle.java +++ b/src/de/steamwar/lobby/particle/particles/TeamParticle.java @@ -1,52 +1,50 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.particles; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleItem; -import de.steamwar.lobby.particle.SimpleParticle; -import de.steamwar.lobby.particle.decorator.CircleParticle; -import de.steamwar.lobby.particle.decorator.NonFloorParticle; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.elements.Circle; +import de.steamwar.lobby.particle.elements.LocationMutator; +import de.steamwar.lobby.particle.elements.NonFloor; +import de.steamwar.lobby.particle.elements.SimpleParticle; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; import org.bukkit.Particle; -import static org.bukkit.Material.*; - @AllArgsConstructor public enum TeamParticle implements ParticleEnum { - SQUID(new SimpleParticle(new ParticleItem(INK_SAC, "PARTICLE_SQUID", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)), - BUBBLE(new SimpleParticle(new ParticleItem(TUBE_CORAL, "PARTICLE_BUBBLE", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)), - HONEY(new SimpleParticle(new ParticleItem(HONEY_BOTTLE, "PARTICLE_HONEY", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)), - NECTAR(new SimpleParticle(new ParticleItem(HONEYCOMB, "PARTICLE_NECTAR", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)), - FIREWORK(new LocationParticleMutator(new NonFloorParticle(new SimpleParticle(new ParticleItem(FIRE_CHARGE, "PARTICLE_FIREWORK", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.FIREWORKS_SPARK, 0.1F, 0.1F, 0.1F, 0.2, 2)), location -> location.subtract(0, -0.2, 0))), - DRAGON_BREATH(new SimpleParticle(new ParticleItem(Material.DRAGON_BREATH, "PARTICLE_DRAGON_BREATH", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.DRAGON_BREATH, 1F, 0.2F, 1F, 0.01)), - DAMAGE(new SimpleParticle(new ParticleItem(SPIDER_EYE, "PARTICLE_DAMAGE", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)), - DOLPHIN(new SimpleParticle(new ParticleItem(BLUE_DYE, "PARTICLE_DOLPHIN", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01)), - HEART(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(RED_CONCRETE, "PARTICLE_HEART", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.HEART), location -> location.add(0, 2.2, 0)))), + SQUID(new ParticleData(Material.INK_SAC, "PARTICLE_SQUID", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)) + ), + BUBBLE(new ParticleData(Material.TUBE_CORAL, "PARTICLE_BUBBLE", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)) + ), + HONEY(new ParticleData(Material.HONEY_BOTTLE, "PARTICLE_HONEY", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)) + ), + NECTAR(new ParticleData(Material.HONEYCOMB, "PARTICLE_NECTAR", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)) + ), + FIREWORK(new ParticleData(Material.FIRE_CHARGE, "PARTICLE_FIREWORK", ParticleRequirement.HAS_TEAM, + new LocationMutator(new NonFloor(new SimpleParticle(Particle.FIREWORKS_SPARK, 0.1F, 0.1F, 0.1F, 0.2, 2)), 0, -0.2, 0)) + ), + DRAGON_BREATH(new ParticleData(Material.DRAGON_BREATH, "PARTICLE_DRAGON_BREATH", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.DRAGON_BREATH, 1F, 0.2F, 1F, 0.01)) + ), + DAMAGE(new ParticleData(Material.SPIDER_EYE, "PARTICLE_DAMAGE", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.DAMAGE_INDICATOR, 0.2F, 0, 0.2F, 0.01)) + ), + DOLPHIN(new ParticleData(Material.BLUE_DYE, "PARTICLE_DOLPHIN", ParticleRequirement.HAS_TEAM, + new SimpleParticle(Particle.DOLPHIN, 0.2F, 0, 0.2F, 0.01)) + ), + HEART(new ParticleData(Material.RED_CONCRETE, "PARTICLE_HEART", ParticleRequirement.HAS_TEAM, + new Circle(new LocationMutator(new SimpleParticle(Particle.HEART), 0, 2.2, 0))) + ), ; public static ParticleEnum[] particles = values(); @Getter - private BaseParticle particle; + private ParticleData particle; } diff --git a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java b/src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java similarity index 60% rename from src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java rename to src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java index 274b7db..456d609 100644 --- a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomEasterParticle.java +++ b/src/de/steamwar/lobby/particle/particles/custom/CustomEasterParticle.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.particles.custom; +package de.steamwar.lobby.particle.particles.custom; -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomPlayerParticle.java b/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java similarity index 60% rename from src/de/steamwar/lobby/otherparticle/particles/custom/CustomPlayerParticle.java rename to src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java index 29cc9a5..910008e 100644 --- a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomPlayerParticle.java +++ b/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java @@ -1,7 +1,7 @@ -package de.steamwar.lobby.otherparticle.particles.custom; +package de.steamwar.lobby.particle.particles.custom; -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomTeamParticle.java b/src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java similarity index 63% rename from src/de/steamwar/lobby/otherparticle/particles/custom/CustomTeamParticle.java rename to src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java index a6234bd..37d956c 100644 --- a/src/de/steamwar/lobby/otherparticle/particles/custom/CustomTeamParticle.java +++ b/src/de/steamwar/lobby/particle/particles/custom/CustomTeamParticle.java @@ -1,10 +1,10 @@ -package de.steamwar.lobby.otherparticle.particles.custom; +package de.steamwar.lobby.particle.particles.custom; -import de.steamwar.lobby.otherparticle.ParticleData; -import de.steamwar.lobby.otherparticle.ParticleEnum; -import de.steamwar.lobby.otherparticle.ParticleRequirement; -import de.steamwar.lobby.otherparticle.WingDesign; -import de.steamwar.lobby.otherparticle.elements.*; +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.WingDesign; +import de.steamwar.lobby.particle.elements.*; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; diff --git a/src/de/steamwar/lobby/util/LobbyPlayer.java b/src/de/steamwar/lobby/util/LobbyPlayer.java index adbda25..2619af8 100644 --- a/src/de/steamwar/lobby/util/LobbyPlayer.java +++ b/src/de/steamwar/lobby/util/LobbyPlayer.java @@ -19,7 +19,8 @@ package de.steamwar.lobby.util; -import de.steamwar.lobby.particle.particles.*; +import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleInventory; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserConfig; import org.bukkit.entity.Player; @@ -43,36 +44,7 @@ public class LobbyPlayer { particle = null; String saved = UserConfig.getConfig(userId, "lobby-particle"); if (saved != null) { - try { - String[] strings = saved.split("@"); - switch (strings[0]) { - case "PlayerParticle": - particle = PlayerParticle.valueOf(strings[1]); - break; - case "TeamParticle": - particle = TeamParticle.valueOf(strings[1]); - break; - case "ServerTeamParticle": - particle = ServerTeamParticle.valueOf(strings[1]); - break; - case "EventParticle": - particle = EventParticle.valueOf(strings[1]); - break; - case "EventParticleParticipation": - particle = EventParticleParticipation.valueOf(strings[1]); - break; - case "EventParticlePlacement": - particle = EventParticlePlacement.valueOf(strings[1]); - break; - case "SpecialParticle": - particle = SpecialTeamParticle.valueOf(strings[1]); - break; - default: - break; - } - } catch (Exception e) { - setParticle(null); - } + particle = ParticleInventory.convertFromString(saved); } } @@ -92,7 +64,7 @@ public class LobbyPlayer { if (particle == null) { UserConfig.removePlayerConfig(userId, "lobby-particle"); } else { - String saved = particle.getClass().getSimpleName() + "@" + ((Enum) particle).name(); + String saved = ParticleInventory.convertToString(particle); UserConfig.updatePlayerConfig(userId, "lobby-particle", saved); } this.particle = particle; -- 2.39.2 From abda6b652da23392192a3f92f8ec82557ae6a08d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 4 Apr 2023 16:57:48 +0200 Subject: [PATCH 15/18] Fix some stuff and implement rest of EasterParticle's --- src/de/steamwar/lobby/LobbySystem.properties | 16 +++++++- .../steamwar/lobby/LobbySystem_de.properties | 13 ++++++- .../steamwar/lobby/particle/ParticleData.java | 3 +- .../lobby/particle/ParticleRequirement.java | 5 ++- .../lobby/particle/elements/Delayed.java | 4 ++ .../lobby/particle/elements/Floor.java | 23 ++++++++++++ .../lobby/particle/elements/Flying.java | 24 ++++++++++++ .../lobby/particle/elements/Group.java | 9 +++++ .../lobby/particle/elements/NonFlying.java | 2 +- .../lobby/particle/elements/Separator.java | 18 +++++++++ .../lobby/particle/elements/Sneaking.java | 2 +- .../lobby/particle/elements/Wing.java | 1 + .../particle/particles/EasterParticle.java | 37 ++++++++++++------- .../particle/particles/PlayerParticle.java | 2 +- 14 files changed, 136 insertions(+), 23 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/elements/Floor.java create mode 100644 src/de/steamwar/lobby/particle/elements/Flying.java create mode 100644 src/de/steamwar/lobby/particle/elements/Separator.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 4b3918e..d531706 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -30,13 +30,18 @@ PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION = §f{0} PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_HALF = §fFind 45 Easter Eggs PARTICLE_UNLOCKED_BY_EASTER_EGG_HUNT_DIFFICULTY = §fFind all Easter Eggs with difficulty {0} +PARTICLE_ATTRIBUTE = §eAttributes§7: PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Double ring PARTICLE_ATTRIBUTE_CLOUD = §8-§f Cloud PARTICLE_ATTRIBUTE_TICK = §8-§f Always active -PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f in air +PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f In air +PARTICLE_ATTRIBUTE_FLOOR = §8-§f On ground +PARTICLE_ATTRIBUTE_NON_FLYING = §8-§f Not flying +PARTICLE_ATTRIBUTE_FLYING = §8-§f Flying PARTICLE_ATTRIBUTE_WING = §8-§f Wings -PARTICLE_ATTRIBUTE = §eAttributes§7: +PARTICLE_ATTRIBUTE_SNEAKING = §8-§f Sneaking +PARTICLE_ATTRIBUTE_SEPARATOR = §f PARTICLE_SELECT = §eClick to select PARTICLE_LOCKED = §c§lLocked @@ -85,6 +90,13 @@ PARTICLE_EVENT_RAIN_CLOUD = §fRaincloud PARTICLE_EVENT_WGS = §fWGS PARTICLE_EVENT_WARGEARCLASH = §fClash +PARTICLE_EGG_HUNT_EASY = §aGreenery +PARTICLE_EGG_HUNT_MEDIUM = §eHide and Seek +PARTICLE_EGG_HUNT_HARD = §cOrbit +PARTICLE_EGG_HUNT_EXTREME = §5Purple rain +PARTICLE_EGG_HUNT_ADVANCED = §5Lift off +PARTICLE_EGG_HUNT_HALF = §fThe hunt is on + JUMP_AND_RUN_PROGRESS = §e{0}§8/§f{1} §c{2} §7{3} JUMP_AND_RUN_CANCEL = {0} JUMP_AND_RUN_TIME = mm:ss SSS diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index a28262e..d830095 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -34,8 +34,12 @@ PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Doppelring PARTICLE_ATTRIBUTE_CLOUD = §8-§f Wolke PARTICLE_ATTRIBUTE_TICK = §8-§f Immer aktiv -PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f in Luft +PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f In der Luft +PARTICLE_ATTRIBUTE_FLOOR = §8-§f Auf dem Boden +PARTICLE_ATTRIBUTE_NON_FLYING = §8-§f Nicht am Fliegen +PARTICLE_ATTRIBUTE_FLYING = §8-§f Am Fliegen PARTICLE_ATTRIBUTE_WING = §8-§f Flügel +PARTICLE_ATTRIBUTE_SNEAKING = §8-§f Ducken PARTICLE_ATTRIBUTE = §eAttribute§7: PARTICLE_SELECT = §eZum Auswählen klicken @@ -85,6 +89,13 @@ PARTICLE_EVENT_RAIN_CLOUD = §fRegenwolke PARTICLE_EVENT_WGS = §fWGS PARTICLE_EVENT_WARGEARCLASH = §fClash +PARTICLE_EGG_HUNT_EASY = §aGrünplfanzen +PARTICLE_EGG_HUNT_MEDIUM = §eVersteckspiel +PARTICLE_EGG_HUNT_HARD = §cOrbit +PARTICLE_EGG_HUNT_EXTREME = §5Lila regen +PARTICLE_EGG_HUNT_ADVANCED = §5Abheben +PARTICLE_EGG_HUNT_HALF = §fDie Jagd ist eröffnet + JUMP_AND_RUN_FINISHED = §aBeendet in {0} mit {1} Fails # Easter Egg Hunt diff --git a/src/de/steamwar/lobby/particle/ParticleData.java b/src/de/steamwar/lobby/particle/ParticleData.java index 01ae549..0bf1b5b 100644 --- a/src/de/steamwar/lobby/particle/ParticleData.java +++ b/src/de/steamwar/lobby/particle/ParticleData.java @@ -8,7 +8,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import java.util.ArrayList; -import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -16,7 +15,7 @@ public class ParticleData { private final Material material; private final String name; - private final Set attributes = new LinkedHashSet<>(); + private final List attributes = new ArrayList<>(); @Getter private final ParticleRequirement requirement; diff --git a/src/de/steamwar/lobby/particle/ParticleRequirement.java b/src/de/steamwar/lobby/particle/ParticleRequirement.java index d228a81..f501a75 100644 --- a/src/de/steamwar/lobby/particle/ParticleRequirement.java +++ b/src/de/steamwar/lobby/particle/ParticleRequirement.java @@ -6,6 +6,7 @@ import de.steamwar.lobby.special.easter.EggHunt; import de.steamwar.sql.Event; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.Team; +import de.steamwar.sql.UserGroup; import org.bukkit.entity.Player; import java.util.HashSet; @@ -28,7 +29,7 @@ public interface ParticleRequirement { @Override public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { - return false; + return user.getUserGroup() != UserGroup.Member; } }; @@ -162,7 +163,7 @@ public interface ParticleRequirement { @Override public boolean test(SteamwarUser user, Set eventTeilname, String eggHuntConfig) { if (eggHuntConfig == null) return false; - return eggs.stream().allMatch(id -> eggHuntConfig.length() >= id && eggHuntConfig.charAt(id) == '1'); + return eggs.stream().allMatch(id -> eggHuntConfig.length() > id && eggHuntConfig.charAt(id) == '1'); } }; } diff --git a/src/de/steamwar/lobby/particle/elements/Delayed.java b/src/de/steamwar/lobby/particle/elements/Delayed.java index f13d9b5..3fb9632 100644 --- a/src/de/steamwar/lobby/particle/elements/Delayed.java +++ b/src/de/steamwar/lobby/particle/elements/Delayed.java @@ -29,6 +29,10 @@ public class Delayed extends DelegatingParticleElement { public Delayed(ParticleElement particleElement, int interval) { super(particleElement); Bukkit.getPluginManager().registerEvents(delayedData, LobbySystem.getPlugin()); + this.interval = interval; + if (interval <= 0) { + throw new IllegalArgumentException("Interval must be greater than 0"); + } } @Override diff --git a/src/de/steamwar/lobby/particle/elements/Floor.java b/src/de/steamwar/lobby/particle/elements/Floor.java new file mode 100644 index 0000000..0b4ef7f --- /dev/null +++ b/src/de/steamwar/lobby/particle/elements/Floor.java @@ -0,0 +1,23 @@ +package de.steamwar.lobby.particle.elements; + +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; + +public class Floor extends DelegatingParticleElement { + + public Floor(ParticleElement particleElement) { + super(particleElement); + } + + @Override + public String attribute() { + return "PARTICLE_ATTRIBUTE_FLOOR"; + } + + @Override + public void tick(ParticleTickData particleTickData) { + if (!particleTickData.getWorld().getBlockAt(particleTickData.getPlayer().getLocation().subtract(0, 0.5, 0)).getType().isAir()) { + particleElement.tick(particleTickData); + } + } +} diff --git a/src/de/steamwar/lobby/particle/elements/Flying.java b/src/de/steamwar/lobby/particle/elements/Flying.java new file mode 100644 index 0000000..ed160a5 --- /dev/null +++ b/src/de/steamwar/lobby/particle/elements/Flying.java @@ -0,0 +1,24 @@ +package de.steamwar.lobby.particle.elements; + +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; + +public class Flying extends DelegatingParticleElement { + + public Flying(ParticleElement particleElement) { + super(particleElement); + } + + @Override + public String attribute() { + return "PARTICLE_ATTRIBUTE_FLYING"; + } + + @Override + public void tick(ParticleTickData particleTickData) { + if (!particleTickData.getPlayer().isGliding()) { + return; + } + particleElement.tick(particleTickData); + } +} diff --git a/src/de/steamwar/lobby/particle/elements/Group.java b/src/de/steamwar/lobby/particle/elements/Group.java index b6fc771..6e567a0 100644 --- a/src/de/steamwar/lobby/particle/elements/Group.java +++ b/src/de/steamwar/lobby/particle/elements/Group.java @@ -1,5 +1,6 @@ package de.steamwar.lobby.particle.elements; +import de.steamwar.lobby.particle.ParticleData; import de.steamwar.lobby.particle.ParticleElement; import de.steamwar.lobby.particle.ParticleTickData; @@ -17,6 +18,14 @@ public class Group extends DelegatingParticleElement { return null; } + @Override + public void aggregateAttributes(ParticleData particleData) { + particleElement.aggregateAttributes(particleData); + for (ParticleElement particleElement : rest) { + particleElement.aggregateAttributes(particleData); + } + } + @Override public void tick(ParticleTickData particleTickData) { particleElement.tick(particleTickData); diff --git a/src/de/steamwar/lobby/particle/elements/NonFlying.java b/src/de/steamwar/lobby/particle/elements/NonFlying.java index 2f74f9b..4579e21 100644 --- a/src/de/steamwar/lobby/particle/elements/NonFlying.java +++ b/src/de/steamwar/lobby/particle/elements/NonFlying.java @@ -11,7 +11,7 @@ public class NonFlying extends DelegatingParticleElement { @Override public String attribute() { - return null; + return "PARTICLE_ATTRIBUTE_NON_FLYING"; } @Override diff --git a/src/de/steamwar/lobby/particle/elements/Separator.java b/src/de/steamwar/lobby/particle/elements/Separator.java new file mode 100644 index 0000000..6792b44 --- /dev/null +++ b/src/de/steamwar/lobby/particle/elements/Separator.java @@ -0,0 +1,18 @@ +package de.steamwar.lobby.particle.elements; + +import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; + +public class Separator implements ParticleElement { + + @Override + public void aggregateAttributes(ParticleData particleData) { + particleData.add("PARTICLE_ATTRIBUTE_SEPARATOR"); + } + + @Override + public void tick(ParticleTickData particleTickData) { + // do nothing + } +} diff --git a/src/de/steamwar/lobby/particle/elements/Sneaking.java b/src/de/steamwar/lobby/particle/elements/Sneaking.java index 42bb16c..833e4c1 100644 --- a/src/de/steamwar/lobby/particle/elements/Sneaking.java +++ b/src/de/steamwar/lobby/particle/elements/Sneaking.java @@ -11,7 +11,7 @@ public class Sneaking extends DelegatingParticleElement { @Override public String attribute() { - return null; // TODO: Implement this attribute + return "PARTICLE_ATTRIBUTE_SNEAKING"; } @Override diff --git a/src/de/steamwar/lobby/particle/elements/Wing.java b/src/de/steamwar/lobby/particle/elements/Wing.java index f0f8203..6163382 100644 --- a/src/de/steamwar/lobby/particle/elements/Wing.java +++ b/src/de/steamwar/lobby/particle/elements/Wing.java @@ -13,6 +13,7 @@ public class Wing extends DelegatingParticleElement { public Wing(ParticleElement particleElement, double size, WingDesign wingDesign) { super(particleElement); + this.size = size; this.wingDesign = wingDesign; } diff --git a/src/de/steamwar/lobby/particle/particles/EasterParticle.java b/src/de/steamwar/lobby/particle/particles/EasterParticle.java index 8980995..cecd91b 100644 --- a/src/de/steamwar/lobby/particle/particles/EasterParticle.java +++ b/src/de/steamwar/lobby/particle/particles/EasterParticle.java @@ -3,34 +3,45 @@ package de.steamwar.lobby.particle.particles; import de.steamwar.lobby.particle.ParticleData; import de.steamwar.lobby.particle.ParticleEnum; import de.steamwar.lobby.particle.ParticleRequirement; -import de.steamwar.lobby.particle.elements.Always; -import de.steamwar.lobby.particle.elements.LocationMutator; -import de.steamwar.lobby.particle.elements.SimpleParticle; +import de.steamwar.lobby.particle.elements.*; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; import org.bukkit.Particle; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; @AllArgsConstructor public enum EasterParticle implements ParticleEnum { EGG_HUNT_EASY(new ParticleData(Material.LIME_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_EASY", ParticleRequirement.EGG_HUNT_EASY, - new Always(new LocationMutator(new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM, 0.2F, 0.1f, 0.2F, 1, 5), 0, 2.2, 0))) + new Always(new LocationMutator(new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM, 0.5F, 0.1f, 0.5F, 1, 1), 0, 2.2, 0))) ), EGG_HUNT_MEDIUM(new ParticleData(Material.YELLOW_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_MEDIUM", ParticleRequirement.EGG_HUNT_MEDIUM, - new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + new Always(new Floor(new Sneaking(new SimpleParticle(Particle.GLOW_SQUID_INK, 0.4F, 0.9F, 0.4F, 0.01))))) ), - EGG_HUNT_HARD(new ParticleData(Material.ORANGE_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_HARD", ParticleRequirement.EGG_HUNT_HARD, - new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + EGG_HUNT_HARD(new ParticleData(Material.RED_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_HARD", ParticleRequirement.EGG_HUNT_HARD, + new Always(new LocationMutator(new DoubleCircle(new DustParticle(Particle.REDSTONE, 0, 0, 0, 0.01, 1), new DustParticle(Particle.REDSTONE, 0, 0, 0, 0.01, 1)), 0, 0.5, 0))) ), - EGG_HUNT_EXTREME(new ParticleData(Material.RED_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_EXTREME", ParticleRequirement.EGG_HUNT_EXTREME, - new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + EGG_HUNT_EXTREME(new ParticleData(Material.PURPLE_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_EXTREME", ParticleRequirement.EGG_HUNT_EXTREME, + new Always(new LocationMutator(new SimpleParticle(Particle.FALLING_OBSIDIAN_TEAR, 0.5F, 0.1F, 0.5F, 1, 1), 0, 2.2, 0))) ), - EGG_HUNT_ADVANCED(new ParticleData(Material.PURPLE_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_ADVANCED", ParticleRequirement.EGG_HUNT_ADVANCED, - new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + EGG_HUNT_ADVANCED(new ParticleData(Material.BLACK_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_ADVANCED", ParticleRequirement.EGG_HUNT_ADVANCED, + new Always(new Sneaking(new LocationMutator(new Group( + new SimpleParticle(Particle.SMOKE_NORMAL, 0.02F, 0, 0.02F, 0.05, 1), + new SimpleParticle(Particle.SMOKE_LARGE, 0.02F, 0, 0.02F, 0.05, 1), + particleTickData -> { + Player player = particleTickData.getPlayer(); + player.setVelocity(player.getVelocity().add(new Vector(0, 0.1, 0))); + } + ), 0, -0.2, 0)))) ), - EGG_HUNT_HALF(new ParticleData(Material.PURPLE_CONCRETE_POWDER, "PARTICLE_EGG_HUNT_HALF", ParticleRequirement.EGG_HUNT_FOUND_HALF, - new SimpleParticle(Particle.FALLING_SPORE_BLOSSOM)) + EGG_HUNT_HALF(new ParticleData(Material.EGG, "PARTICLE_EGG_HUNT_HALF", ParticleRequirement.EGG_HUNT_FOUND_HALF, + new Group( + new Always(new Sneaking(new Floor(new LocationMutator(new SimpleParticle(Particle.HEART, 0, 0, 0, 0.01), 0, 1.7, 0)))), + new Separator(), + new Always(new NonFloor(new NonFlying(new LocationMutator(new Cloud(new Circle(new SimpleParticle(Particle.HEART, 0, 0, 0, 0.01))), 0, 0.5, 0)))) + )) ), ; public static ParticleEnum[] particles = values(); diff --git a/src/de/steamwar/lobby/particle/particles/PlayerParticle.java b/src/de/steamwar/lobby/particle/particles/PlayerParticle.java index ed66d8c..f54c516 100644 --- a/src/de/steamwar/lobby/particle/particles/PlayerParticle.java +++ b/src/de/steamwar/lobby/particle/particles/PlayerParticle.java @@ -38,7 +38,7 @@ public enum PlayerParticle implements ParticleEnum { new SimpleParticle(Particle.SNOWBALL, 0.2F, 0.2F ,0.2F, 0.01)) ), EFFECT(new ParticleData(Material.GLASS_BOTTLE, "PARTICLE_EFFECT", - new DustParticle(Particle.REDSTONE, 0, 0.2F, 02F, 0.01, 5)) + new DustParticle(Particle.REDSTONE, 0, 0.2F, 0, 0.01, 5)) ), CAMPFIRE(new ParticleData(Material.CAMPFIRE, "PARTICLE_CAMPFIRE", new SimpleParticle(Particle.CAMPFIRE_COSY_SMOKE, 0, 0.2F ,0, 0.01)) -- 2.39.2 From 93933ec92cb79ceec6d5ad2ad0156c76fefb69d9 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 4 Apr 2023 19:21:49 +0200 Subject: [PATCH 16/18] Add NonMoving and YOffset and custom particle for Haylim_ for helping and YouTube video --- src/de/steamwar/lobby/LobbySystem.properties | 3 ++ .../steamwar/lobby/LobbySystem_de.properties | 1 + .../lobby/particle/ParticleListener.java | 24 ++++++++-- .../lobby/particle/ParticleTickData.java | 3 +- .../particle/elements/custom/NonMoving.java | 25 ++++++++++ .../particle/elements/custom/YOffset.java | 47 +++++++++++++++++++ .../custom/CustomPlayerParticle.java | 12 +++++ 7 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/elements/custom/NonMoving.java create mode 100644 src/de/steamwar/lobby/particle/elements/custom/YOffset.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index d531706..d9e5f33 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -41,6 +41,7 @@ PARTICLE_ATTRIBUTE_NON_FLYING = §8-§f Not flying PARTICLE_ATTRIBUTE_FLYING = §8-§f Flying PARTICLE_ATTRIBUTE_WING = §8-§f Wings PARTICLE_ATTRIBUTE_SNEAKING = §8-§f Sneaking +PARTICLE_ATTRIBUTE_NON_MOVING = §8-§f Not moving PARTICLE_ATTRIBUTE_SEPARATOR = §f PARTICLE_SELECT = §eClick to select @@ -81,6 +82,8 @@ PARTICLE_WATER_FIRE = §bWater§7/§cFire PARTICLE_MAGIC_ENCHANTING = §5Magic/Enchantment PARTICLE_WINGS_EVIL = §5Purple wings +PARTICLE_PLAYER_HAYLIM_AURA = §fHaylim\'s Aura + PARTICLE_EVENT_ENCHANTING = §cEnchantment PARTICLE_EVENT_CLOUD = §fClouds PARTICLE_EVENT_SMOKE = §7Smoke diff --git a/src/de/steamwar/lobby/LobbySystem_de.properties b/src/de/steamwar/lobby/LobbySystem_de.properties index d830095..c2a3225 100644 --- a/src/de/steamwar/lobby/LobbySystem_de.properties +++ b/src/de/steamwar/lobby/LobbySystem_de.properties @@ -40,6 +40,7 @@ PARTICLE_ATTRIBUTE_NON_FLYING = §8-§f Nicht am Fliegen PARTICLE_ATTRIBUTE_FLYING = §8-§f Am Fliegen PARTICLE_ATTRIBUTE_WING = §8-§f Flügel PARTICLE_ATTRIBUTE_SNEAKING = §8-§f Ducken +PARTICLE_ATTRIBUTE_NON_MOVING = §8-§f Beim Stehen PARTICLE_ATTRIBUTE = §eAttribute§7: PARTICLE_SELECT = §eZum Auswählen klicken diff --git a/src/de/steamwar/lobby/particle/ParticleListener.java b/src/de/steamwar/lobby/particle/ParticleListener.java index 8253353..8b92071 100644 --- a/src/de/steamwar/lobby/particle/ParticleListener.java +++ b/src/de/steamwar/lobby/particle/ParticleListener.java @@ -31,6 +31,10 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashSet; +import java.util.Set; public class ParticleListener extends BasicListener { @@ -38,9 +42,14 @@ public class ParticleListener extends BasicListener { private static double deg = 0; + private static Set movingPlayers = new HashSet<>(); + public ParticleListener() { Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { - if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) return; + if (Bukkit.getOnlinePlayers().size() > PLAYER_MAX_SIZE) { + movingPlayers.clear(); + return; + } deg += 0.1; if (deg > 360) deg = 0; Bukkit.getOnlinePlayers().forEach(player -> { @@ -51,9 +60,10 @@ public class ParticleListener extends BasicListener { ParticleData particleData = particle.getParticle(); ParticleElement particleElement = particleData.getParticleElement(); if (particleElement.tickType() == ParticleTickType.ALWAYS) { - particleElement.tick(new ParticleTickData(player.getWorld(), player, deg)); + particleElement.tick(new ParticleTickData(player.getWorld(), player, deg, movingPlayers.contains(player))); } }); + movingPlayers.clear(); }, 0, 1); } @@ -80,8 +90,16 @@ public class ParticleListener extends BasicListener { ParticleData particleData = particle.getParticle(); ParticleElement particleElement = particleData.getParticleElement(); if (particleElement.tickType() == ParticleTickType.MOVE) { - particleElement.tick(new ParticleTickData(player.getWorld(), player, deg)); + particleElement.tick(new ParticleTickData(player.getWorld(), player, deg, true)); } + if (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getY() != event.getTo().getY() || event.getFrom().getZ() != event.getTo().getZ()) { + movingPlayers.add(player); + } + } + + @EventHandler(ignoreCancelled = true) + public void onPlayerQuit(PlayerQuitEvent event) { + movingPlayers.remove(event.getPlayer()); } @EventHandler diff --git a/src/de/steamwar/lobby/particle/ParticleTickData.java b/src/de/steamwar/lobby/particle/ParticleTickData.java index ef55973..b85da90 100644 --- a/src/de/steamwar/lobby/particle/ParticleTickData.java +++ b/src/de/steamwar/lobby/particle/ParticleTickData.java @@ -16,6 +16,7 @@ public class ParticleTickData { private final Player player; private Location location; private final double deg; + private final boolean isMoving; public ParticleTickData withLocation(Location location) { ParticleTickData particleTickData = copy(); @@ -31,6 +32,6 @@ public class ParticleTickData { } public ParticleTickData copy() { - return new ParticleTickData(world, player, location, deg); + return new ParticleTickData(world, player, location, deg, isMoving); } } diff --git a/src/de/steamwar/lobby/particle/elements/custom/NonMoving.java b/src/de/steamwar/lobby/particle/elements/custom/NonMoving.java new file mode 100644 index 0000000..6490958 --- /dev/null +++ b/src/de/steamwar/lobby/particle/elements/custom/NonMoving.java @@ -0,0 +1,25 @@ +package de.steamwar.lobby.particle.elements.custom; + +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; +import de.steamwar.lobby.particle.elements.DelegatingParticleElement; + +public class NonMoving extends DelegatingParticleElement { + + public NonMoving(ParticleElement particleElement) { + super(particleElement); + } + + @Override + public String attribute() { + return "PARTICLE_ATTRIBUTE_NON_MOVING"; + } + + @Override + public void tick(ParticleTickData particleTickData) { + if (particleTickData.isMoving()) { + return; + } + particleElement.tick(particleTickData); + } +} diff --git a/src/de/steamwar/lobby/particle/elements/custom/YOffset.java b/src/de/steamwar/lobby/particle/elements/custom/YOffset.java new file mode 100644 index 0000000..1be8242 --- /dev/null +++ b/src/de/steamwar/lobby/particle/elements/custom/YOffset.java @@ -0,0 +1,47 @@ +package de.steamwar.lobby.particle.elements.custom; + +import de.steamwar.lobby.particle.ParticleElement; +import de.steamwar.lobby.particle.ParticleTickData; +import de.steamwar.lobby.particle.elements.DelegatingParticleElement; + +public class YOffset extends DelegatingParticleElement { + + private double multiplication; + private double minY; + private double maxY; + private boolean inverted; + + public YOffset(ParticleElement particleElement, double speed, double minY, double maxY, boolean inverted) { + super(particleElement); + this.multiplication = speed; + this.minY = minY; + this.maxY = maxY; + this.inverted = inverted; + } + + @Override + public String attribute() { + return null; + } + + @Override + public void tick(ParticleTickData particleTickData) { + double value = ((particleTickData.getDeg() * multiplication) % 360) / 180; + double y; + if (inverted) { + if (value <= 1) { + y = maxY - (maxY - minY) * value; + } else { + y = minY + (maxY - minY) * (value - 1); + } + } else { + if (value <= 1) { + y = minY + (maxY - minY) * value; + } else { + y = maxY - (maxY - minY) * (value - 1); + } + } + ParticleTickData current = particleTickData.withLocation(particleTickData.getLocation().clone().add(0, y, 0)); + particleElement.tick(current); + } +} diff --git a/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java b/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java index 910008e..be4ee67 100644 --- a/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java +++ b/src/de/steamwar/lobby/particle/particles/custom/CustomPlayerParticle.java @@ -2,12 +2,24 @@ package de.steamwar.lobby.particle.particles.custom; import de.steamwar.lobby.particle.ParticleData; import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.ParticleRequirement; +import de.steamwar.lobby.particle.elements.*; +import de.steamwar.lobby.particle.elements.custom.NonMoving; +import de.steamwar.lobby.particle.elements.custom.YOffset; import lombok.AllArgsConstructor; import lombok.Getter; +import org.bukkit.Material; +import org.bukkit.Particle; @AllArgsConstructor public enum CustomPlayerParticle implements ParticleEnum { + Haylim_(new ParticleData(Material.WHITE_CANDLE, "PARTICLE_PLAYER_HAYLIM_AURA", ParticleRequirement.specificPlayer(9426), + new Always(new NonMoving(new NonFlying(new Group( + new DoubleCircle(new YOffset(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), 40, 0, 2, false), new YOffset(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.0,1), 40, 0, 2, true)), + new DoubleCircle(new YOffset(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.01), 40, 0, 2, true), new YOffset(new SimpleParticle(Particle.ENCHANTMENT_TABLE, 0, 0, 0, 0.0,1), 40, 0, 2, false)) + ))))) + ), ; public static ParticleEnum[] particles = values(); -- 2.39.2 From 64d9068d3d7ccd5ebb9b3f872c972976e8151651 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 6 Apr 2023 20:02:06 +0200 Subject: [PATCH 17/18] Hotfix TeamPlayer infinite Villager glitch --- src/de/steamwar/lobby/LobbySystem.java | 1 - src/de/steamwar/lobby/team/TeamPlayer.java | 13 ++++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java index 383d657..f87d9d4 100644 --- a/src/de/steamwar/lobby/LobbySystem.java +++ b/src/de/steamwar/lobby/LobbySystem.java @@ -84,7 +84,6 @@ public class LobbySystem extends JavaPlugin { @Override public void onDisable() { - TeamPlayer.cleanup(); } public static LobbySystem getPlugin() { diff --git a/src/de/steamwar/lobby/team/TeamPlayer.java b/src/de/steamwar/lobby/team/TeamPlayer.java index 040f842..75ddff8 100644 --- a/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/src/de/steamwar/lobby/team/TeamPlayer.java @@ -79,11 +79,6 @@ public class TeamPlayer extends BasicListener { entities.put(name, npc); } - public static void cleanup() { - villagers.values().forEach(Entity::remove); - entities.values().forEach(NPC::delete); - } - { SteamwarUser.getServerTeam().forEach(user -> { spawnTeamPlayer(world, user); @@ -92,6 +87,14 @@ public class TeamPlayer extends BasicListener { AtomicInteger count = new AtomicInteger(); LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players"); Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { + Collection active = world.getEntitiesByClass(Villager.class); + if (active.size() > entities.size()) { + Set duplicates = new HashSet<>(); + active.stream() + .filter(villager -> !duplicates.add(villager.getCustomName())) + .forEach(Entity::remove); + } + count.incrementAndGet(); if (count.get() % (20 * 60 * 60) == 0) { count.set(0); -- 2.39.2 From d5542e293a3ec402decd8fa13f4f24327e15e474 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 6 Apr 2023 20:03:02 +0200 Subject: [PATCH 18/18] Hotfix NPC Chat --- src/de/steamwar/lobby/LobbySystem.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index d9e5f33..f51e4e1 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -4,7 +4,7 @@ DATE=........ COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===--- # ServerTeamNPC's -NPC_CHAT_1 = §fHello, I'm {0} and I'm a(n) {1}. +NPC_CHAT_1 = §fHello, I\'m {0} and I\'m a(n) {1}. NPC_CHAT_2 = §fWelcome on §eSteam§8War§f, have fun. # Portal Command -- 2.39.2