diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java index 9345ba6..a7af7d3 100644 --- a/src/de/steamwar/lobby/LobbySystem.java +++ b/src/de/steamwar/lobby/LobbySystem.java @@ -29,7 +29,7 @@ import de.steamwar.lobby.jumpandrun.JumpAndRunCommand; import de.steamwar.lobby.listener.*; import de.steamwar.lobby.map.CustomMapCommand; import de.steamwar.lobby.particle.ParticleListener; -import de.steamwar.lobby.special.advent.AdventsCalendar; +import de.steamwar.lobby.particlenew.ParticleManager; import de.steamwar.lobby.team.TeamPlayer; import de.steamwar.message.Message; import org.bukkit.plugin.java.JavaPlugin; @@ -75,8 +75,10 @@ public class LobbySystem extends JavaPlugin { new TeleporterListener(); new TeamPlayer(); + new ParticleManager(); + // EggHunt.init(); - AdventsCalendar.init(); + // AdventsCalendar.init(); new AlphaWall(l -> l.getX() > 999, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X); diff --git a/src/de/steamwar/lobby/particle/ParticleListener.java b/src/de/steamwar/lobby/particle/ParticleListener.java index 535ebd0..e3ffb01 100644 --- a/src/de/steamwar/lobby/particle/ParticleListener.java +++ b/src/de/steamwar/lobby/particle/ParticleListener.java @@ -23,6 +23,7 @@ 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.particlenew.ParticleManager; import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserPerm; @@ -75,7 +76,8 @@ public class ParticleListener extends BasicListener { if (!PlayerSpawn.PARTICLE.equals(event.getItem())) return; event.setCancelled(true); - ParticleInventory.openInventory(player, true); + // ParticleInventory.openInventory(player, true); + ParticleManager.get(player).open(); } @EventHandler diff --git a/src/de/steamwar/lobby/particlenew/ParticleDesign.java b/src/de/steamwar/lobby/particlenew/ParticleDesign.java new file mode 100644 index 0000000..0fe54db --- /dev/null +++ b/src/de/steamwar/lobby/particlenew/ParticleDesign.java @@ -0,0 +1,130 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.particlenew; + +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import de.steamwar.inventory.SWListInv; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.function.Consumer; + +public class ParticleDesign implements Serializable { + + private ParticleElement[] elements = new ParticleElement[] {null, null, null, null, null}; + + public boolean isEmpty() { + for (int i = 0; i < elements.length; i++) { + if (elements[i] != null) return false; + } + return true; + } + + public void open(Player player, Runnable back) { + open(player, back, -1); + } + + private void open(Player player, Runnable back, int selected) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + int allowedElements = 1; + if (user.getTeam() != 0) allowedElements++; + if (user.getOnlinetime() / 3600.0 > 1000) allowedElements++; + if (user.prefix() != UserPerm.emptyPrefix) allowedElements += 2; + + SWInventory swInventory = new SWInventory(player, 27, "§0Particle - Design"); + swInventory.setItem(0, new SWItem(Material.ARROW, "§fBack", clickType -> { + back.run(); + })); + + for (int i = 0; i < elements.length; i++) { + final int elementIndex = i; + ParticleElement element = elements[i]; + + if (i >= allowedElements) { + swInventory.setItem(i + 2, new SWItem(Material.RED_STAINED_GLASS_PANE, "§c< LOCKED SLOT >", clickType -> { + })); + } else if (element == null) { + swInventory.setItem(i + 2, new SWItem(Material.WHITE_STAINED_GLASS_PANE, "§f< EMPTY SLOT >", Arrays.asList("§eClick to create"), false, clickType -> { + openElementSelector(player, () -> open(player, back, elementIndex), particleElement -> { + elements[elementIndex] = particleElement; + }); + })); + } else { + SWItem swItem = element.toItem(player); + swItem.setLore(Arrays.asList("§eClick to edit")); + swItem.setCallback(clickType -> { + if (selected == elementIndex) { + openElementSelector(player, () -> open(player, back, elementIndex), particleElement -> { + elements[elementIndex] = particleElement; + }); + } else { + open(player, back, elementIndex); + } + }); + swInventory.setItem(i + 2, swItem); + } + } + + for (int i = 0; i < 9; i++) { + swInventory.setItem(i + 9, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§8", clickType -> { + })); + } + if (selected != -1 && elements[selected] != null) { + SWItem[] items = elements[selected].items(player, () -> open(player, back, selected)); + for (int i = 0; i < items.length; i++) { + swInventory.setItem(i + 9, items[i]); + } + + swInventory.setItem(21, new SWItem(elements[selected].always ? Material.FEATHER : Material.GOLDEN_BOOTS, elements[selected].always ? "§7Always" : "§7Only while Moving", Arrays.asList("§eClick to change"), false, clickType -> { + elements[selected].always = !elements[selected].always; + open(player, back, selected); + })); + // swInventory.setItem(23); // TODO: Add other thing! + } + + swInventory.open(); + } + + private void openElementSelector(Player player, Runnable back, Consumer consumer) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + double playtime = user.getOnlinetime(); + + List> elements = new ArrayList<>(); + for (ParticleElements value : ParticleElements.values()) { + if (value.permissionCheck.hasPermission(player, user, playtime)) { + elements.add(new SWListInv.SWListEntry<>(new SWItem(value.material, value.name), value)); + } + } + + SWListInv swListInv = new SWListInv<>(player, "§0Particle - Element", elements, (clickType, particleElements) -> { + consumer.accept(particleElements.elementSupplier.get()); + back.run(); + }); + swListInv.addCloseRunnable(back); + swListInv.open(); + } +} diff --git a/src/de/steamwar/lobby/particlenew/ParticleElement.java b/src/de/steamwar/lobby/particlenew/ParticleElement.java new file mode 100644 index 0000000..fa74f24 --- /dev/null +++ b/src/de/steamwar/lobby/particlenew/ParticleElement.java @@ -0,0 +1,84 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.particlenew; + +import de.steamwar.inventory.SWItem; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.io.Serializable; +import java.util.function.Consumer; + +public abstract class ParticleElement implements Serializable { + + protected boolean always = false; + protected SpawnBehaviour spawnBehaviour = SpawnBehaviour.OFF; + + public abstract void spawn(Player player, double deg, boolean isMoving); + + public abstract SWItem toItem(Player player); + + public abstract SWItem[] items(Player player, Runnable back); + + public final void display(Player source, boolean isMoving, Consumer spawner) { + if (!always && !isMoving) return; + switch (spawnBehaviour) { + case OFF: + break; + case FLOOR: + if (source.getLocation().clone().add(0, -0.5, 0).getBlock().getType().isAir()) { + return; + } + break; + case NOT_FLOOR: + if (!source.getLocation().clone().add(0, -0.5, 0).getBlock().getType().isAir()) { + return; + } + break; + case FLYING: + if (!source.isGliding()) { + return; + } + break; + case NOT_FLYING: + if (source.isGliding()) { + return; + } + break; + } + + SteamwarUser sourceUser = SteamwarUser.get(source.getUniqueId()); + boolean isServerTeam = sourceUser.hasPerm(UserPerm.TEAM); + Bukkit.getOnlinePlayers().forEach(player -> { + PlayerParticles particles = ParticleManager.get(player); + + SteamwarUser playerUser = SteamwarUser.get(player.getUniqueId()); + if (particles.isShowOthers() && sourceUser.getTeam() != playerUser.getTeam() && !isServerTeam) { + spawner.accept(player); + } else if (particles.isShowTeam() && sourceUser.getTeam() == playerUser.getTeam()) { + spawner.accept(player); + } else if (particles.isShowServerteam() && isServerTeam) { + spawner.accept(player); + } + }); + } +} diff --git a/src/de/steamwar/lobby/particlenew/ParticleElements.java b/src/de/steamwar/lobby/particlenew/ParticleElements.java new file mode 100644 index 0000000..a896ea8 --- /dev/null +++ b/src/de/steamwar/lobby/particlenew/ParticleElements.java @@ -0,0 +1,53 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.particlenew; + +import de.steamwar.lobby.particlenew.elements.SimpleParticleElement; +import de.steamwar.sql.SteamwarUser; +import lombok.RequiredArgsConstructor; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.util.function.Supplier; + +@RequiredArgsConstructor +public enum ParticleElements { + + NONE(Material.BARRIER, "None", all(), () -> null), + SIMPLE(Material.BONE_MEAL, "§7Simple", all(), SimpleParticleElement::new), + + // CLOUD(Material.FEATHER, "Cloud", all(), () -> null), // TODO: Implement further + ; + + public final Material material; + public final String name; + public final PermissionCheck permissionCheck; + public final Supplier elementSupplier; + + public static PermissionCheck all() { + return (player, user, playTime) -> { + return true; + }; + } + + public interface PermissionCheck { + boolean hasPermission(Player player, SteamwarUser user, double playTime); + } +} diff --git a/src/de/steamwar/lobby/particlenew/ParticleManager.java b/src/de/steamwar/lobby/particlenew/ParticleManager.java new file mode 100644 index 0000000..ff478df --- /dev/null +++ b/src/de/steamwar/lobby/particlenew/ParticleManager.java @@ -0,0 +1,52 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.particlenew; + +import de.steamwar.lobby.listener.BasicListener; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import java.util.HashMap; +import java.util.Map; + +public class ParticleManager extends BasicListener { + + private static final Map PARTICLES_MAP = new HashMap<>(); + + public static PlayerParticles get(Player player) { + return PARTICLES_MAP.get(player); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + // TODO: Load from DB! + PlayerParticles particles = new PlayerParticles(); + particles.setPlayer(event.getPlayer()); + PARTICLES_MAP.put(event.getPlayer(), particles); + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + PlayerParticles particles = PARTICLES_MAP.remove(event.getPlayer()); + // TODO: Save to DB! + } +} diff --git a/src/de/steamwar/lobby/particlenew/PlayerParticles.java b/src/de/steamwar/lobby/particlenew/PlayerParticles.java new file mode 100644 index 0000000..662506a --- /dev/null +++ b/src/de/steamwar/lobby/particlenew/PlayerParticles.java @@ -0,0 +1,139 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.particlenew; + +import de.steamwar.inventory.SWInventory; +import de.steamwar.inventory.SWItem; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserPerm; +import lombok.Getter; +import lombok.Setter; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.io.Serializable; +import java.util.Arrays; + +public class PlayerParticles implements Serializable { + + @Setter + private transient Player player; + + private ParticleDesign[] particles = new ParticleDesign[] { + new ParticleDesign(), + new ParticleDesign(), + new ParticleDesign(), + new ParticleDesign(), + new ParticleDesign(), + new ParticleDesign(), + new ParticleDesign() + }; + private int selectedParticle = -1; + + @Getter + private boolean showOthers = false; + + @Getter + private boolean showTeam = true; + + @Getter + private boolean showServerteam = true; + + public void open() { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + boolean hasTeam = user.getTeam() != 0; + boolean isServerTeam = user.hasPerm(UserPerm.COLOR_CHAT); + + SWInventory swInventory = new SWInventory(player, 36, "§0Particles"); + + for (int i = 0; i < particles.length; i++) { + final int particleIndex = i; + + boolean locked = false; + if (i > 1 && !hasTeam && !isServerTeam) { + locked = true; + } + if (i > 3 && !isServerTeam) { + locked = true; + } + + swInventory.setItem(i + 10 + 9, new SWItem(SWItem.getDye(8), "§7", clickType -> { + })); + + boolean hasParticle = particles[particleIndex].isEmpty(); + if (locked) { + swInventory.setItem(i + 10, new SWItem(Material.RED_STAINED_GLASS_PANE, "§c< LOCKED SLOT >", clickType -> { + })); + } else if (hasParticle) { + swInventory.setItem(i + 10, new SWItem(Material.WHITE_STAINED_GLASS_PANE, "§f< EMPTY SLOT >", Arrays.asList("§eClick to create"), false, clickType -> { + particles[particleIndex].open(player, this::open); + })); + } else { + swInventory.setItem(i + 10, new SWItem(Material.LIME_STAINED_GLASS_PANE, "§a< FILLED SLOT >", Arrays.asList("§eClick to edit"), false, clickType -> { + particles[particleIndex].open(player, this::open); + })); + + if (selectedParticle == i) { + swInventory.setItem(i + 10 + 9, new SWItem(SWItem.getDye(10), "§aSelected", Arrays.asList("§eClick to turn off"), false, clickType -> { + selectedParticle = -1; + open(); + })); + } else { + swInventory.setItem(i + 10 + 9, new SWItem(SWItem.getDye(1), "§cNot Selected", Arrays.asList("§eClick to Select"), false, clickType -> { + selectedParticle = particleIndex; + open(); + })); + } + } + } + + swInventory.setItem(31, new SWItem(Material.CAULDRON, "§fSettings", clickType -> { + openSettings(); + })); + + swInventory.open(); + } + + private void openSettings() { + SWInventory swInventory = new SWInventory(player, 36, "§0Particles - Settings"); + swInventory.setItem(0, new SWItem(Material.ARROW, "§fBack", clickType -> { + open(); + })); + + swInventory.setItem(11, new SWItem(Material.SKELETON_SKULL, "§fOthers", clickType -> {})); + swInventory.setItem(20, new SWItem(SWItem.getDye(showOthers ? 10 : 1), showOthers ? "§aShown" : "§cHidden", Arrays.asList("§eClick to toggle"), false, clickType -> { + showOthers = !showOthers; + openSettings(); + })); + + swInventory.setItem(13, new SWItem(Material.PLAYER_HEAD, "§fTeam", clickType -> {})); + swInventory.setItem(22, new SWItem(SWItem.getDye(showTeam ? 10 : 1), showTeam ? "§aShown" : "§cHidden", Arrays.asList("§eClick to toggle"), false, clickType -> { + showTeam = !showTeam; + openSettings(); + })); + + swInventory.setItem(15, new SWItem(Material.DRAGON_HEAD, "§fServerteam", clickType -> {})); + swInventory.setItem(24, new SWItem(SWItem.getDye(showServerteam ? 10 : 1), showServerteam ? "§aShown" : "§cHidden", Arrays.asList("§eClick to toggle"), false, clickType -> { + showServerteam = !showServerteam; + openSettings(); + })); + swInventory.open(); + } +} diff --git a/src/de/steamwar/lobby/particlenew/SpawnBehaviour.java b/src/de/steamwar/lobby/particlenew/SpawnBehaviour.java new file mode 100644 index 0000000..52cfe04 --- /dev/null +++ b/src/de/steamwar/lobby/particlenew/SpawnBehaviour.java @@ -0,0 +1,28 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.particlenew; + +public enum SpawnBehaviour { + OFF, + FLOOR, + NOT_FLOOR, + FLYING, + NOT_FLYING, +} diff --git a/src/de/steamwar/lobby/particlenew/elements/SimpleParticleElement.java b/src/de/steamwar/lobby/particlenew/elements/SimpleParticleElement.java new file mode 100644 index 0000000..8bb24a9 --- /dev/null +++ b/src/de/steamwar/lobby/particlenew/elements/SimpleParticleElement.java @@ -0,0 +1,63 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.particlenew.elements; + +import de.steamwar.inventory.SWItem; +import de.steamwar.lobby.particlenew.ParticleElement; +import de.steamwar.lobby.particlenew.settings.ParticleSetting; +import de.steamwar.lobby.particlenew.settings.TimeSetting; +import de.steamwar.lobby.particlenew.settings.VelocitySetting; +import de.steamwar.lobby.particlenew.settings.YOffsetSetting; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +public class SimpleParticleElement extends ParticleElement { + + private Particle particle = Particle.ASH; // particle.getDataType() + private double yOffset = 0.0; + private Vector velocity = new Vector(0.0, 0.0, 0.0); + private double time = 0.0; + + @Override + public void spawn(Player player, double deg, boolean isMoving) { + Location location = player.getLocation().clone().add(0, yOffset, 0); + display(player, isMoving, other -> { + other.spawnParticle(particle, location, 1, velocity.getX(), velocity.getY(), velocity.getZ(), time); + }); + } + + @Override + public SWItem toItem(Player player) { + return new SWItem(Material.BONE_MEAL, "§7Simple"); + } + + @Override + public SWItem[] items(Player player, Runnable back) { + return new SWItem[] { + ParticleSetting.item(player, back, particle, selected -> particle = selected), + YOffsetSetting.item(player, back, yOffset, value -> yOffset = value), + VelocitySetting.item(player, back, velocity, value -> velocity = value), + TimeSetting.item(player, back, time, value -> time = value), + }; + } +} diff --git a/src/de/steamwar/lobby/particlenew/settings/ParticleSetting.java b/src/de/steamwar/lobby/particlenew/settings/ParticleSetting.java new file mode 100644 index 0000000..437558f --- /dev/null +++ b/src/de/steamwar/lobby/particlenew/settings/ParticleSetting.java @@ -0,0 +1,147 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.particlenew.settings; + +import de.steamwar.inventory.SWItem; +import de.steamwar.inventory.SWListInv; +import lombok.experimental.UtilityClass; +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.entity.Player; + +import java.util.*; +import java.util.function.Consumer; + +@UtilityClass +public class ParticleSetting { + + private static final Map TO_ITEM_MAP = new HashMap<>(); + + static { + TO_ITEM_MAP.put(Particle.EXPLOSION_NORMAL, Material.TNT); + TO_ITEM_MAP.put(Particle.EXPLOSION_LARGE, Material.TNT_MINECART); + TO_ITEM_MAP.put(Particle.EXPLOSION_HUGE, Material.END_CRYSTAL); + TO_ITEM_MAP.put(Particle.FIREWORKS_SPARK, Material.FIREWORK_STAR); + TO_ITEM_MAP.put(Particle.WATER_BUBBLE, Material.PRISMARINE_CRYSTALS); + TO_ITEM_MAP.put(Particle.WATER_SPLASH, Material.SPLASH_POTION); + TO_ITEM_MAP.put(Particle.WATER_WAKE, Material.WARPED_BUTTON); + TO_ITEM_MAP.put(Particle.SUSPENDED, Material.POLISHED_BLACKSTONE_BUTTON); + TO_ITEM_MAP.put(Particle.SUSPENDED_DEPTH, Material.POLISHED_BLACKSTONE_BUTTON); + TO_ITEM_MAP.put(Particle.CRIT, Material.GOLDEN_SWORD); + TO_ITEM_MAP.put(Particle.CRIT_MAGIC, Material.DIAMOND_SWORD); + TO_ITEM_MAP.put(Particle.SMOKE_NORMAL, Material.COAL); + TO_ITEM_MAP.put(Particle.SMOKE_LARGE, Material.FIRE_CHARGE); + TO_ITEM_MAP.put(Particle.SPELL, Material.ENCHANTED_BOOK); + TO_ITEM_MAP.put(Particle.SPELL_INSTANT, Material.ENCHANTED_BOOK); + TO_ITEM_MAP.put(Particle.SPELL_MOB, Material.ENCHANTED_BOOK); + TO_ITEM_MAP.put(Particle.SPELL_MOB_AMBIENT, Material.ENCHANTED_BOOK); + TO_ITEM_MAP.put(Particle.SPELL_WITCH, Material.ENCHANTED_BOOK); + TO_ITEM_MAP.put(Particle.DRIP_WATER, Material.WATER_BUCKET); + TO_ITEM_MAP.put(Particle.DRIP_LAVA, Material.LAVA_BUCKET); + TO_ITEM_MAP.put(Particle.VILLAGER_ANGRY, Material.BONE); + TO_ITEM_MAP.put(Particle.VILLAGER_HAPPY, Material.EMERALD); + TO_ITEM_MAP.put(Particle.TOWN_AURA, Material.MYCELIUM); + TO_ITEM_MAP.put(Particle.NOTE, Material.NOTE_BLOCK); + TO_ITEM_MAP.put(Particle.PORTAL, Material.OBSERVER); + TO_ITEM_MAP.put(Particle.ENCHANTMENT_TABLE, Material.ENCHANTING_TABLE); + TO_ITEM_MAP.put(Particle.FLAME, Material.FLINT_AND_STEEL); + TO_ITEM_MAP.put(Particle.LAVA, Material.LAVA_BUCKET); + TO_ITEM_MAP.put(Particle.CLOUD, Material.BONE_MEAL); + // TODO: Redstone + TO_ITEM_MAP.put(Particle.SNOWBALL, Material.SNOWBALL); + TO_ITEM_MAP.put(Particle.SNOW_SHOVEL, Material.IRON_SHOVEL); + TO_ITEM_MAP.put(Particle.SLIME, Material.SLIME_BALL); + TO_ITEM_MAP.put(Particle.HEART, Material.GOLDEN_APPLE); + // TODO: ItemCrack + // TODO: BlockCrack + // TODO: BlockDust + TO_ITEM_MAP.put(Particle.WATER_DROP, Material.WATER_BUCKET); + TO_ITEM_MAP.put(Particle.MOB_APPEARANCE, Material.GHAST_SPAWN_EGG); + TO_ITEM_MAP.put(Particle.DRAGON_BREATH, Material.DRAGON_BREATH); + TO_ITEM_MAP.put(Particle.END_ROD, Material.END_ROD); + TO_ITEM_MAP.put(Particle.DAMAGE_INDICATOR, Material.IRON_SWORD); + TO_ITEM_MAP.put(Particle.SWEEP_ATTACK, Material.IRON_SWORD); + // TODO: FallingDust + TO_ITEM_MAP.put(Particle.TOTEM, Material.TOTEM_OF_UNDYING); + TO_ITEM_MAP.put(Particle.SPIT, Material.GHAST_TEAR); + TO_ITEM_MAP.put(Particle.SQUID_INK, Material.INK_SAC); + TO_ITEM_MAP.put(Particle.BUBBLE_POP, Material.PRISMARINE_CRYSTALS); + TO_ITEM_MAP.put(Particle.CURRENT_DOWN, Material.PRISMARINE_CRYSTALS); + TO_ITEM_MAP.put(Particle.BUBBLE_COLUMN_UP, Material.SOUL_SAND); + TO_ITEM_MAP.put(Particle.NAUTILUS, Material.NAUTILUS_SHELL); + TO_ITEM_MAP.put(Particle.DOLPHIN, Material.DOLPHIN_SPAWN_EGG); + TO_ITEM_MAP.put(Particle.SNEEZE, Material.GHAST_TEAR); + TO_ITEM_MAP.put(Particle.CAMPFIRE_COSY_SMOKE, Material.CAMPFIRE); + TO_ITEM_MAP.put(Particle.CAMPFIRE_SIGNAL_SMOKE, Material.CAMPFIRE); + TO_ITEM_MAP.put(Particle.COMPOSTER, Material.COMPOSTER); + TO_ITEM_MAP.put(Particle.FALLING_LAVA, Material.LAVA_BUCKET); + TO_ITEM_MAP.put(Particle.LANDING_LAVA, Material.LAVA_BUCKET); + TO_ITEM_MAP.put(Particle.FALLING_WATER, Material.WATER_BUCKET); + TO_ITEM_MAP.put(Particle.DRIPPING_HONEY, Material.HONEY_BOTTLE); + TO_ITEM_MAP.put(Particle.FALLING_HONEY, Material.HONEY_BOTTLE); + TO_ITEM_MAP.put(Particle.LANDING_HONEY, Material.HONEY_BOTTLE); + TO_ITEM_MAP.put(Particle.FALLING_NECTAR, Material.BEEHIVE); + TO_ITEM_MAP.put(Particle.SOUL_FIRE_FLAME, Material.SOUL_CAMPFIRE); + TO_ITEM_MAP.put(Particle.ASH, Material.COAL); + TO_ITEM_MAP.put(Particle.CRIMSON_SPORE, Material.CRIMSON_FUNGUS); + TO_ITEM_MAP.put(Particle.WARPED_SPORE, Material.WARPED_FUNGUS); + TO_ITEM_MAP.put(Particle.SOUL, Material.SOUL_SAND); + TO_ITEM_MAP.put(Particle.DRIPPING_OBSIDIAN_TEAR, Material.CRYING_OBSIDIAN); + TO_ITEM_MAP.put(Particle.FALLING_OBSIDIAN_TEAR, Material.CRYING_OBSIDIAN); + TO_ITEM_MAP.put(Particle.LANDING_OBSIDIAN_TEAR, Material.CRYING_OBSIDIAN); + TO_ITEM_MAP.put(Particle.REVERSE_PORTAL, Material.OBSERVER); + TO_ITEM_MAP.put(Particle.WHITE_ASH, Material.SUGAR); + // TODO: DustColorTransition + // TODO: Vibration + TO_ITEM_MAP.put(Particle.FALLING_SPORE_BLOSSOM, Material.SPORE_BLOSSOM); + TO_ITEM_MAP.put(Particle.SPORE_BLOSSOM_AIR, Material.SPORE_BLOSSOM); + TO_ITEM_MAP.put(Particle.SMALL_FLAME, Material.TORCH); + TO_ITEM_MAP.put(Particle.SNOWFLAKE, Material.SNOWBALL); + TO_ITEM_MAP.put(Particle.DRIPPING_DRIPSTONE_LAVA, Material.POINTED_DRIPSTONE); + TO_ITEM_MAP.put(Particle.FALLING_DRIPSTONE_LAVA, Material.POINTED_DRIPSTONE); + TO_ITEM_MAP.put(Particle.DRIPPING_DRIPSTONE_WATER, Material.POINTED_DRIPSTONE); + TO_ITEM_MAP.put(Particle.FALLING_DRIPSTONE_WATER, Material.POINTED_DRIPSTONE); + TO_ITEM_MAP.put(Particle.GLOW_SQUID_INK, Material.GLOW_INK_SAC); + TO_ITEM_MAP.put(Particle.GLOW, Material.GLOWSTONE_DUST); + TO_ITEM_MAP.put(Particle.WAX_ON, Material.HONEYCOMB); + TO_ITEM_MAP.put(Particle.WAX_OFF, Material.IRON_AXE); + TO_ITEM_MAP.put(Particle.ELECTRIC_SPARK, Material.LIGHTNING_ROD); + TO_ITEM_MAP.put(Particle.SCRAPE, Material.IRON_AXE); + TO_ITEM_MAP.put(Particle.SCULK_SOUL, Material.SCULK); + // TODO: SculkCharge + TO_ITEM_MAP.put(Particle.SCULK_CHARGE_POP, Material.SCULK); + // TODO: Shriek + } + + public SWItem item(Player player, Runnable back, Particle current, Consumer selector) { + return new SWItem(TO_ITEM_MAP.get(current), "§7Particle: " + current.name(), Arrays.asList("§eClick to change"), false, clickType -> { + List> particles = new ArrayList<>(); + TO_ITEM_MAP.forEach((particle, material) -> { + particles.add(new SWListInv.SWListEntry<>(new SWItem(material, "§7" + particle.name()), particle)); + }); + SWListInv listInv = new SWListInv<>(player, "§0Particle - Select Particle", particles, (clickType1, particle) -> { + selector.accept(particle); + back.run(); + }); + listInv.addCloseCallback(clickType1 -> back.run()); + listInv.open(); + }); + } +} diff --git a/src/de/steamwar/lobby/particlenew/settings/TimeSetting.java b/src/de/steamwar/lobby/particlenew/settings/TimeSetting.java new file mode 100644 index 0000000..16eb1cc --- /dev/null +++ b/src/de/steamwar/lobby/particlenew/settings/TimeSetting.java @@ -0,0 +1,48 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.particlenew.settings; + +import de.steamwar.inventory.SWAnvilInv; +import de.steamwar.inventory.SWItem; +import lombok.experimental.UtilityClass; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.function.Consumer; + +@UtilityClass +public class TimeSetting { + + public SWItem item(Player player, Runnable back, double current, Consumer selector) { + return new SWItem(Material.CLOCK, "§7Time: " + current, Arrays.asList("§eClick to change"), false, clickType -> { + SWAnvilInv anvilInv = new SWAnvilInv(player, "§0Particle - Select Time", current + ""); + anvilInv.addCloseCallback(back); + anvilInv.setCallback(s -> { + double value = Double.parseDouble(s); + if (value < 0.0) value = 0.0; + if (value > 1.0) value = 1.0; + selector.accept(value); + back.run(); + }); + anvilInv.open(); + }); + } +} diff --git a/src/de/steamwar/lobby/particlenew/settings/VelocitySetting.java b/src/de/steamwar/lobby/particlenew/settings/VelocitySetting.java new file mode 100644 index 0000000..9e28c3e --- /dev/null +++ b/src/de/steamwar/lobby/particlenew/settings/VelocitySetting.java @@ -0,0 +1,39 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.particlenew.settings; + +import de.steamwar.inventory.SWItem; +import lombok.experimental.UtilityClass; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import java.util.Arrays; +import java.util.function.Consumer; + +@UtilityClass +public class VelocitySetting { + + public SWItem item(Player player, Runnable back, Vector current, Consumer selector) { + return new SWItem(Material.FIREWORK_ROCKET, "§7Velocity - xz: " + current.getX() + " y: " + current.getY(), Arrays.asList("§eClick to change"), false, clickType -> { + // TODO: Implement menu! + }); + } +} diff --git a/src/de/steamwar/lobby/particlenew/settings/YOffsetSetting.java b/src/de/steamwar/lobby/particlenew/settings/YOffsetSetting.java new file mode 100644 index 0000000..dec7991 --- /dev/null +++ b/src/de/steamwar/lobby/particlenew/settings/YOffsetSetting.java @@ -0,0 +1,48 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.particlenew.settings; + +import de.steamwar.inventory.SWAnvilInv; +import de.steamwar.inventory.SWItem; +import lombok.experimental.UtilityClass; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.function.Consumer; + +@UtilityClass +public class YOffsetSetting { + + public SWItem item(Player player, Runnable back, double current, Consumer selector) { + return new SWItem(Material.MAP, "§7Y-Offset: " + current, Arrays.asList("§eClick to change"), false, clickType -> { + SWAnvilInv anvilInv = new SWAnvilInv(player, "§0Particle - Select Y-Offset", current + ""); + anvilInv.addCloseCallback(back); + anvilInv.setCallback(s -> { + double value = Double.parseDouble(s); + if (value < 0.5) value = 0.5; + if (value > 2.2) value = 2.2; + selector.accept(value); + back.run(); + }); + anvilInv.open(); + }); + } +}