From fa9a359270089e18df4667c38f3303c12e1ce2c1 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Mar 2022 10:09:03 +0100 Subject: [PATCH 01/38] Update some stuff --- .../lobby/listener/ParticleListener.java | 8 +++-- .../steamwar/lobby/particle/BaseParticle.java | 36 +++++++++++++++++++ .../lobby/particle/SpecialParticle.java | 1 - 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/BaseParticle.java diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index 9d37e92..9b408e2 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -38,6 +38,12 @@ public class ParticleListener extends BasicListener { Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { deg += 0.1; if (deg > 360) deg = 0; + Bukkit.getOnlinePlayers().forEach(player -> { + LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); + SpecialParticle particle = lobbyPlayer.getParticle(); + if (particle == null) return; + particle.execute(player.getWorld(), player, deg); + }); }, 0, 1); } @@ -58,6 +64,4 @@ public class ParticleListener extends BasicListener { if (particle == null) return; particle.execute(player.getWorld(), player, deg); } - - } diff --git a/src/de/steamwar/lobby/particle/BaseParticle.java b/src/de/steamwar/lobby/particle/BaseParticle.java new file mode 100644 index 0000000..8bf9162 --- /dev/null +++ b/src/de/steamwar/lobby/particle/BaseParticle.java @@ -0,0 +1,36 @@ +package de.steamwar.lobby.particle; + +import de.steamwar.inventory.SWItem; +import org.bukkit.Color; +import org.bukkit.Particle; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public interface BaseParticle { + List EMPTY_LORE = new ArrayList<>(); + 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()); + } + + SWItem getItem(); + + default boolean tickable() { + return false; + } + + void particle(World world, Player player, double deg); +} diff --git a/src/de/steamwar/lobby/particle/SpecialParticle.java b/src/de/steamwar/lobby/particle/SpecialParticle.java index 6ba8e21..3a81325 100644 --- a/src/de/steamwar/lobby/particle/SpecialParticle.java +++ b/src/de/steamwar/lobby/particle/SpecialParticle.java @@ -80,5 +80,4 @@ public abstract class SpecialParticle { } public abstract void particle(World world, Player player, double deg); - } From 52d61ccd7994452251bf5bd36a997b3310b53ce7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Mar 2022 15:09:05 +0100 Subject: [PATCH 02/38] Update some stuff --- src/de/steamwar/lobby/LobbySystem.properties | 14 ++- .../steamwar/lobby/particle/BaseParticle.java | 12 +-- .../lobby/particle/CircleParticle.java | 87 ------------------- .../lobby/particle/CloudCircleParticle.java | 44 ---------- .../lobby/particle/CloudParticle.java | 44 ---------- .../lobby/particle/FunctionalParticle.java | 43 --------- .../steamwar/lobby/particle/ParticleData.java | 53 +++++++++++ .../lobby/particle/ParticleFunction.java | 29 ------- .../steamwar/lobby/particle/ParticleItem.java | 66 ++++++++++++++ .../lobby/particle/SimpleParticle.java | 67 +++++++------- .../lobby/particle/SpecialParticle.java | 83 ------------------ .../particle/decorator/CircleParticle.java | 75 ++++++++++++++++ .../particle/decorator/CloudParticle.java | 58 +++++++++++++ .../particle/decorator/NonFloorParticle.java | 46 ++++++++++ .../particle/decorator/TickParticle.java | 49 +++++++++++ .../lobby/particle/group/ParticleGroup.java | 47 ++++++++++ .../mutator/LocationParticleMutator.java | 54 ++++++++++++ 17 files changed, 500 insertions(+), 371 deletions(-) delete mode 100644 src/de/steamwar/lobby/particle/CircleParticle.java delete mode 100644 src/de/steamwar/lobby/particle/CloudCircleParticle.java delete mode 100644 src/de/steamwar/lobby/particle/CloudParticle.java delete mode 100644 src/de/steamwar/lobby/particle/FunctionalParticle.java create mode 100644 src/de/steamwar/lobby/particle/ParticleData.java delete mode 100644 src/de/steamwar/lobby/particle/ParticleFunction.java create mode 100644 src/de/steamwar/lobby/particle/ParticleItem.java delete mode 100644 src/de/steamwar/lobby/particle/SpecialParticle.java create mode 100644 src/de/steamwar/lobby/particle/decorator/CircleParticle.java create mode 100644 src/de/steamwar/lobby/particle/decorator/CloudParticle.java create mode 100644 src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java create mode 100644 src/de/steamwar/lobby/particle/decorator/TickParticle.java create mode 100644 src/de/steamwar/lobby/particle/group/ParticleGroup.java create mode 100644 src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index a157b1b..a08edb6 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -9,4 +9,16 @@ PORTAL_COMMAND_ADD_HELP = §8/§7portal §ecreate §8[§7PortalType§8] §8[§7P PORTAL_COMMAND_REMOVE_HELP = §8/§7portal §eremove §8[§7PortalName§8] §8- §7Entfernt ein Portal PORTAL_COMMAND_LIST_SHORT_INFO = §e{0} §8- §7{1} §7Pos1§8(§7{2}§8) §7Pos2§8(§7{3}§8) -PORTAL_NO_WORLDEDIT_SELECTION = §cKeine WorldEdit Selection \ No newline at end of file +PORTAL_NO_WORLDEDIT_SELECTION = §cKeine WorldEdit Selection + +# Particle +PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring +PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Doppel Ring +PARTICLE_ATTRIBUTE_CLOUD = §8-§f Wolke +PARTICLE_ATTRIBUTE_TICK = §8-§f Immer aktiv +PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f in Luft +PARTICLE_ATTRIBUTE = §eAttribute§7: + +PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch + +PARTICLE_SELECT = §eKlicken zum auswählen diff --git a/src/de/steamwar/lobby/particle/BaseParticle.java b/src/de/steamwar/lobby/particle/BaseParticle.java index 8bf9162..9545282 100644 --- a/src/de/steamwar/lobby/particle/BaseParticle.java +++ b/src/de/steamwar/lobby/particle/BaseParticle.java @@ -1,17 +1,11 @@ package de.steamwar.lobby.particle; -import de.steamwar.inventory.SWItem; import org.bukkit.Color; import org.bukkit.Particle; -import org.bukkit.World; -import org.bukkit.entity.Player; -import java.util.ArrayList; -import java.util.List; import java.util.Random; public interface BaseParticle { - List EMPTY_LORE = new ArrayList<>(); Random RANDOM = new Random(); default Color randomColor() { @@ -26,11 +20,11 @@ public interface BaseParticle { return new Particle.DustOptions(randomColor(), randomSize()); } - SWItem getItem(); + ParticleItem getItem(); - default boolean tickable() { + default boolean needsTick() { return false; } - void particle(World world, Player player, double deg); + void particle(ParticleData particleData); } diff --git a/src/de/steamwar/lobby/particle/CircleParticle.java b/src/de/steamwar/lobby/particle/CircleParticle.java deleted file mode 100644 index 1c76092..0000000 --- a/src/de/steamwar/lobby/particle/CircleParticle.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.Location; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import java.util.List; -import java.util.function.Function; -import java.util.function.UnaryOperator; - -public class CircleParticle extends SpecialParticle { - - private Particle particle; - private Particle particle2; - private Function locationShift; - private boolean customVelocity = false; - private float vx; - private float vy; - private float vz; - private double time = 1; - - public CircleParticle(Material material, String name, List lore, Particle particle, Particle particle2, UnaryOperator locationShift) { - super(material, name, lore); - this.particle = particle; - this.particle2 = particle2; - this.locationShift = locationShift; - } - - public CircleParticle(Material material, String name, List lore, Particle particle, Particle particle2, UnaryOperator locationShift, float vx, float vy, float vz, double time) { - super(material, name, lore); - this.particle = particle; - this.particle2 = particle2; - this.locationShift = locationShift; - customVelocity = true; - this.vx = vx; - this.vy = vy; - this.vz = vz; - this.time = time; - } - - @Override - public void particle(World world, Player player, double deg) { - Vector vector = new Vector(1, 0, 0); - vector.rotateAroundY(deg); - if (customVelocity) { - world.spawnParticle(particle, locationShift.apply(player.getLocation().add(vector)), 1, vx, vy, vz, time); - } else { - world.spawnParticle(particle, locationShift.apply(player.getLocation().add(vector)), 1); - } - - if (particle2 == null) { - return; - } - - vector.setX(-vector.getX()); - vector.setZ(-vector.getZ()); - if (customVelocity) { - world.spawnParticle(particle2, locationShift.apply(player.getLocation().add(vector)), 1, vx, vy, vz, time); - } else { - world.spawnParticle(particle2, locationShift.apply(player.getLocation().add(vector)), 1); - } - } - -} diff --git a/src/de/steamwar/lobby/particle/CloudCircleParticle.java b/src/de/steamwar/lobby/particle/CloudCircleParticle.java deleted file mode 100644 index 80f9ed7..0000000 --- a/src/de/steamwar/lobby/particle/CloudCircleParticle.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.Location; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.World; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.function.UnaryOperator; - -public class CloudCircleParticle extends CircleParticle { - - public CloudCircleParticle(Material material, String name, List lore, Particle particle, UnaryOperator locationShift) { - super(material, name, lore, particle, null, locationShift, 0.0F, 0.0F, 0.0F, 0.01); - asCloud = true; - } - - @Override - public void particle(World world, Player player, double deg) { - super.particle(world, player, deg); - } - -} diff --git a/src/de/steamwar/lobby/particle/CloudParticle.java b/src/de/steamwar/lobby/particle/CloudParticle.java deleted file mode 100644 index 706c071..0000000 --- a/src/de/steamwar/lobby/particle/CloudParticle.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.Material; -import org.bukkit.Particle; -import org.bukkit.World; -import org.bukkit.entity.Player; - -import java.util.List; - -public class CloudParticle extends SpecialParticle { - - private Particle particle; - - public CloudParticle(Material material, String name, List lore, Particle particle) { - super(material, name, lore); - asCloud = true; - this.particle = particle; - } - - @Override - public void particle(World world, Player player, double deg) { - world.spawnParticle(particle, player.getLocation().subtract(0, -0.2, 0), 5, 0.5F, 0.02F, 0.5F, 0.01); - } -} diff --git a/src/de/steamwar/lobby/particle/FunctionalParticle.java b/src/de/steamwar/lobby/particle/FunctionalParticle.java deleted file mode 100644 index 2e11da0..0000000 --- a/src/de/steamwar/lobby/particle/FunctionalParticle.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; - -import java.util.List; - -public class FunctionalParticle extends SpecialParticle { - - private ParticleFunction particleFunction; - - public FunctionalParticle(Material material, String name, List lore, ParticleFunction particleFunction) { - super(material, name, lore); - this.particleFunction = particleFunction; - } - - @Override - public void particle(World world, Player player, double deg) { - particleFunction.accept(world, player, deg); - } - -} diff --git a/src/de/steamwar/lobby/particle/ParticleData.java b/src/de/steamwar/lobby/particle/ParticleData.java new file mode 100644 index 0000000..df9afcb --- /dev/null +++ b/src/de/steamwar/lobby/particle/ParticleData.java @@ -0,0 +1,53 @@ +/* + * 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 lombok.Getter; +import lombok.RequiredArgsConstructor; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; + +@RequiredArgsConstructor +@AllArgsConstructor +@Getter +public class ParticleData { + private final World world; + private final Player player; + private Location location; + private final double deg; + + public ParticleData withLocation(Location location) { + this.location = location; + return this; + } + + public Location getLocation() { + if (location == null) { + return player.getLocation(); + } + return location; + } + + public ParticleData clone() { + return new ParticleData(world, player, location, deg); + } +} diff --git a/src/de/steamwar/lobby/particle/ParticleFunction.java b/src/de/steamwar/lobby/particle/ParticleFunction.java deleted file mode 100644 index ab210ec..0000000 --- a/src/de/steamwar/lobby/particle/ParticleFunction.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.World; -import org.bukkit.entity.Player; - -@FunctionalInterface -public interface ParticleFunction { - void accept(World world, Player player, double time); -} diff --git a/src/de/steamwar/lobby/particle/ParticleItem.java b/src/de/steamwar/lobby/particle/ParticleItem.java new file mode 100644 index 0000000..3634d17 --- /dev/null +++ b/src/de/steamwar/lobby/particle/ParticleItem.java @@ -0,0 +1,66 @@ +/* + * 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 lombok.Setter; +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 { + + private final Material material; + private final String name; + private final Set attributes = new LinkedHashSet<>(); + + @Setter + private String 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/SimpleParticle.java b/src/de/steamwar/lobby/particle/SimpleParticle.java index 52c0b1d..416ea79 100644 --- a/src/de/steamwar/lobby/particle/SimpleParticle.java +++ b/src/de/steamwar/lobby/particle/SimpleParticle.java @@ -1,48 +1,49 @@ /* + * This file is a part of the SteamWar software. * - * This file is a part of the SteamWar software. + * Copyright (C) 2022 SteamWar.de-Serverteam * - * Copyright (C) 2020 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 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. * - * 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 . + * 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.*; -import org.bukkit.entity.Player; +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.Particle; -import java.util.List; +public class SimpleParticle implements BaseParticle { -public class SimpleParticle extends SpecialParticle { - - private Particle particle; + 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; - public SimpleParticle(Material material, String name, List lore, Particle particle) { - super(material, name, lore); + public SimpleParticle(ParticleItem particleItem, Particle particle) { + this.particleItem = particleItem; this.particle = particle; } - public SimpleParticle(Material material, String name, List lore, Particle particle, float vx, float vy, float vz, double time) { - super(material, name, lore); + public SimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time) { + this.particleItem = particleItem; this.particle = particle; - customVelocity = true; + this.customVelocity = true; this.vx = vx; this.vy = vy; this.vz = vz; @@ -50,13 +51,17 @@ public class SimpleParticle extends SpecialParticle { } @Override - public void particle(World world, Player player, double deg) { - Location location = player.getLocation().add(0.0, 0.2, 0.0); - if (customVelocity) { - world.spawnParticle(particle, location, 5, vx, vy, vz, time); - } else { - world.spawnParticle(particle, location, 5); - } + public ParticleItem getItem() { + return particleItem; } + @Override + public void particle(ParticleData particleData) { + Location location = particleData.getLocation().add(0.0, 0.2, 0.0); + if (customVelocity) { + particleData.getWorld().spawnParticle(particle, location, 5, vx, vy, vz, time); + } else { + particleData.getWorld().spawnParticle(particle, location, 5); + } + } } diff --git a/src/de/steamwar/lobby/particle/SpecialParticle.java b/src/de/steamwar/lobby/particle/SpecialParticle.java deleted file mode 100644 index 3a81325..0000000 --- a/src/de/steamwar/lobby/particle/SpecialParticle.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 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 org.bukkit.Color; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -public abstract class SpecialParticle { - - private static final List EMPTY_LORE = new ArrayList<>(); - private static Random random = new Random(); - - public static Color randomColor() { - return Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256)); - } - - public static float randomSize() { - return random.nextFloat() / 2 + 1; - } - - public static Particle.DustOptions getParticleDust() { - return new Particle.DustOptions(randomColor(), randomSize()); - } - - private Material material; - private String name; - private List lore; - protected boolean asCloud = false; - - protected SpecialParticle(Material material, String name, List lore) { - if (lore == null) { - lore = EMPTY_LORE; - } - this.material = material; - this.name = name; - this.lore = lore; - } - - public final SWItem getItem() { - return new SWItem(material, name, lore, false, clickType -> {}); - } - - public final void execute(World world, Player player, double deg) { - if (asCloud) { - if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) { - player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false)); - } else { - player.removePotionEffect(PotionEffectType.SLOW_FALLING); - return; - } - } - particle(world, player, deg); - } - - public abstract void particle(World world, Player player, double deg); -} diff --git a/src/de/steamwar/lobby/particle/decorator/CircleParticle.java b/src/de/steamwar/lobby/particle/decorator/CircleParticle.java new file mode 100644 index 0000000..bc3fb1b --- /dev/null +++ b/src/de/steamwar/lobby/particle/decorator/CircleParticle.java @@ -0,0 +1,75 @@ +/* + * 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.withLocation(location.clone().add(vector)); + particle.particle(particleData); + + if (particle2 == null) { + return; + } + vector.setX(-vector.getX()); + vector.setZ(-vector.getZ()); + + particleData.withLocation(location.clone().add(vector)); + particle2.particle(particleData); + } +} diff --git a/src/de/steamwar/lobby/particle/decorator/CloudParticle.java b/src/de/steamwar/lobby/particle/decorator/CloudParticle.java new file mode 100644 index 0000000..c3d6747 --- /dev/null +++ b/src/de/steamwar/lobby/particle/decorator/CloudParticle.java @@ -0,0 +1,58 @@ +/* + * 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; + } + particle.particle(particleData); + } +} diff --git a/src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java b/src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java new file mode 100644 index 0000000..f0a090a --- /dev/null +++ b/src/de/steamwar/lobby/particle/decorator/NonFloorParticle.java @@ -0,0 +1,46 @@ +/* + * 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 new file mode 100644 index 0000000..1eee74e --- /dev/null +++ b/src/de/steamwar/lobby/particle/decorator/TickParticle.java @@ -0,0 +1,49 @@ +/* + * 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/group/ParticleGroup.java b/src/de/steamwar/lobby/particle/group/ParticleGroup.java new file mode 100644 index 0000000..f2c4272 --- /dev/null +++ b/src/de/steamwar/lobby/particle/group/ParticleGroup.java @@ -0,0 +1,47 @@ +/* + * 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.clone()); + } + } +} diff --git a/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java b/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java new file mode 100644 index 0000000..d91f850 --- /dev/null +++ b/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java @@ -0,0 +1,54 @@ +/* + * 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.withLocation(mutator.apply(particleData.getLocation())); + particle.particle(particleData); + } +} From 4dfb865353f37f954e7d4a19281205962093d3f4 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Mar 2022 15:25:41 +0100 Subject: [PATCH 03/38] Add PlayerParticle --- src/de/steamwar/lobby/LobbySystem.properties | 15 ++++++ .../lobby/particle/DustSimpleParticle.java | 53 +++++++++++++++++++ .../lobby/particle/PlayerParticle.java | 48 +++++++++++++++++ .../lobby/particle/SimpleParticle.java | 3 -- 4 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/DustSimpleParticle.java create mode 100644 src/de/steamwar/lobby/particle/PlayerParticle.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index a08edb6..7f97e1d 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -22,3 +22,18 @@ PARTICLE_ATTRIBUTE = §eAttribute§7: PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch PARTICLE_SELECT = §eKlicken zum auswählen + +PARTICLE_SNEEZE = §aSneeze +PARTICLE_SMOKE = §7Smoke +PARTICLE_FIRE = §cFeuer +PARTICLE_WATER = §bWasser +PARTICLE_HEART = §cHerzen +PARTICLE_NOTES = §eNoten +PARTICLE_NAUTILUS = §aNautilus +PARTICLE_SNOWBALL = §fSnowball +PARTICLE_EFFECT = §5Effekt +PARTICLE_CAMPFIRE = §7Rauch +PARTICLE_MAGIC = §5Magie +PARTICLE_ANGRY = §4Wut +PARTICLE_SLIME = §aSchleim +PARTICLE_MOB = §7Mob \ No newline at end of file diff --git a/src/de/steamwar/lobby/particle/DustSimpleParticle.java b/src/de/steamwar/lobby/particle/DustSimpleParticle.java new file mode 100644 index 0000000..bf77930 --- /dev/null +++ b/src/de/steamwar/lobby/particle/DustSimpleParticle.java @@ -0,0 +1,53 @@ +/* + * 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.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; + + 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); + particleData.getWorld().spawnParticle(particle, location, 5, vx, vy, vz, time, getParticleDust()); + } +} diff --git a/src/de/steamwar/lobby/particle/PlayerParticle.java b/src/de/steamwar/lobby/particle/PlayerParticle.java new file mode 100644 index 0000000..ea10ac0 --- /dev/null +++ b/src/de/steamwar/lobby/particle/PlayerParticle.java @@ -0,0 +1,48 @@ +/* + * 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.lobby.particle.mutator.LocationParticleMutator; +import lombok.AllArgsConstructor; +import org.bukkit.Material; +import org.bukkit.Particle; + +import static org.bukkit.Material.*; + +@AllArgsConstructor +public enum PlayerParticle { + + 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)), +; + private BaseParticle particle; +} diff --git a/src/de/steamwar/lobby/particle/SimpleParticle.java b/src/de/steamwar/lobby/particle/SimpleParticle.java index 416ea79..e59fe40 100644 --- a/src/de/steamwar/lobby/particle/SimpleParticle.java +++ b/src/de/steamwar/lobby/particle/SimpleParticle.java @@ -19,9 +19,6 @@ package de.steamwar.lobby.particle; -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.Particle; From baf31eb3f2d1e20651f34d8f7913a867a8d72632 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Mar 2022 15:27:37 +0100 Subject: [PATCH 04/38] Update some stuff --- .../steamwar/lobby/particle/ParticleEnum.java | 24 +++++++++++++++++++ .../lobby/particle/PlayerParticle.java | 6 ++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/de/steamwar/lobby/particle/ParticleEnum.java diff --git a/src/de/steamwar/lobby/particle/ParticleEnum.java b/src/de/steamwar/lobby/particle/ParticleEnum.java new file mode 100644 index 0000000..1fb2174 --- /dev/null +++ b/src/de/steamwar/lobby/particle/ParticleEnum.java @@ -0,0 +1,24 @@ +/* + * 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; + +public interface ParticleEnum { + BaseParticle getParticle(); +} diff --git a/src/de/steamwar/lobby/particle/PlayerParticle.java b/src/de/steamwar/lobby/particle/PlayerParticle.java index ea10ac0..c67bb75 100644 --- a/src/de/steamwar/lobby/particle/PlayerParticle.java +++ b/src/de/steamwar/lobby/particle/PlayerParticle.java @@ -21,13 +21,14 @@ package de.steamwar.lobby.particle; import de.steamwar.lobby.particle.mutator.LocationParticleMutator; import lombok.AllArgsConstructor; +import lombok.Getter; import org.bukkit.Material; import org.bukkit.Particle; import static org.bukkit.Material.*; @AllArgsConstructor -public enum PlayerParticle { +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)), @@ -44,5 +45,8 @@ public enum PlayerParticle { SLIME(new SimpleParticle(new ParticleItem(SLIME_BALL, "PARTICLE_SLIME"), Particle.SLIME)), MOB(new SimpleParticle(new ParticleItem(ZOMBIE_HEAD, "PARTICLE_MOB"), Particle.SPELL_MOB)), ; + public static ParticleEnum[] particles = values(); + + @Getter private BaseParticle particle; } From 38cb38a1a16a9cdb42629f0487de8636089945f0 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Mar 2022 15:40:56 +0100 Subject: [PATCH 05/38] Add TeamParticle --- src/de/steamwar/lobby/LobbySystem.properties | 11 ++++- .../lobby/particle/SimpleParticle.java | 16 +++++- .../steamwar/lobby/particle/TeamParticle.java | 49 +++++++++++++++++++ 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/TeamParticle.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 7f97e1d..9a51358 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -36,4 +36,13 @@ PARTICLE_CAMPFIRE = §7Rauch PARTICLE_MAGIC = §5Magie PARTICLE_ANGRY = §4Wut PARTICLE_SLIME = §aSchleim -PARTICLE_MOB = §7Mob \ No newline at end of file +PARTICLE_MOB = §7Mob + +PARTICLE_SQUID = §8Squid +PARTICLE_BUBBLE = §aBubble +PARTICLE_HONEY = §6Honey +PARTICLE_NECTAR = §6Nectar +PARTICLE_FIREWORK = §7Firework +PARTICLE_DRAGON_BREATH = §5Dragon Breath +PARTICLE_DAMAGE = §5Damage +PARTICLE_DOLPHIN = §dDolphin \ No newline at end of file diff --git a/src/de/steamwar/lobby/particle/SimpleParticle.java b/src/de/steamwar/lobby/particle/SimpleParticle.java index e59fe40..5b9d657 100644 --- a/src/de/steamwar/lobby/particle/SimpleParticle.java +++ b/src/de/steamwar/lobby/particle/SimpleParticle.java @@ -31,6 +31,7 @@ public class SimpleParticle implements BaseParticle { private float vy; private float vz; private double time = 1; + private int count = 5; public SimpleParticle(ParticleItem particleItem, Particle particle) { this.particleItem = particleItem; @@ -47,6 +48,17 @@ public class SimpleParticle implements BaseParticle { 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; @@ -56,9 +68,9 @@ public class SimpleParticle implements BaseParticle { public void particle(ParticleData particleData) { Location location = particleData.getLocation().add(0.0, 0.2, 0.0); if (customVelocity) { - particleData.getWorld().spawnParticle(particle, location, 5, vx, vy, vz, time); + particleData.getWorld().spawnParticle(particle, location, count, vx, vy, vz, time); } else { - particleData.getWorld().spawnParticle(particle, location, 5); + particleData.getWorld().spawnParticle(particle, location, count); } } } diff --git a/src/de/steamwar/lobby/particle/TeamParticle.java b/src/de/steamwar/lobby/particle/TeamParticle.java new file mode 100644 index 0000000..ab94c01 --- /dev/null +++ b/src/de/steamwar/lobby/particle/TeamParticle.java @@ -0,0 +1,49 @@ +/* + * 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.lobby.particle.decorator.CircleParticle; +import de.steamwar.lobby.particle.decorator.NonFloorParticle; +import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +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.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)), + BUBBLE(new SimpleParticle(new ParticleItem(TUBE_CORAL, "PARTICLE_BUBBLE"), Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)), + HONEY(new SimpleParticle(new ParticleItem(HONEY_BOTTLE, "PARTICLE_HONEY"), Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)), + NECTAR(new SimpleParticle(new ParticleItem(HONEYCOMB, "PARTICLE_NECTAR"), Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)), + FIREWORK(new LocationParticleMutator(new NonFloorParticle(new SimpleParticle(new ParticleItem(FIRE_CHARGE, "PARTICLE_FIREWORK"), 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.DRAGON_BREATH, 1F, 0.2F, 1F, 0.01)), + DAMAGE(new SimpleParticle(new ParticleItem(SPIDER_EYE, "PARTICLE_DAMAGE"), Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)), + DOLPHIN(new SimpleParticle(new ParticleItem(BLUE_DYE, "PARTICLE_DOLPHIN"), Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01)), + HEART(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(RED_CONCRETE, "PARTICLE_HEART"), Particle.HEART), location -> location.add(0, 2.2, 0)))) +; + public static ParticleEnum[] particles = values(); + + @Getter + private BaseParticle particle; +} From 84b04b11982976f8e655a7fa1e88b31676d6f125 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Mar 2022 16:54:29 +0100 Subject: [PATCH 06/38] Add ServerTeamParticle --- src/de/steamwar/lobby/LobbySystem.properties | 14 ++- .../lobby/particle/ParticleInventory.java | 100 +----------------- .../lobby/particle/ServerTeamParticle.java | 62 +++++++++++ .../particle/decorator/CloudParticle.java | 1 + 4 files changed, 77 insertions(+), 100 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/ServerTeamParticle.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 9a51358..2330fe5 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -37,7 +37,6 @@ PARTICLE_MAGIC = §5Magie PARTICLE_ANGRY = §4Wut PARTICLE_SLIME = §aSchleim PARTICLE_MOB = §7Mob - PARTICLE_SQUID = §8Squid PARTICLE_BUBBLE = §aBubble PARTICLE_HONEY = §6Honey @@ -45,4 +44,15 @@ PARTICLE_NECTAR = §6Nectar PARTICLE_FIREWORK = §7Firework PARTICLE_DRAGON_BREATH = §5Dragon Breath PARTICLE_DAMAGE = §5Damage -PARTICLE_DOLPHIN = §dDolphin \ No newline at end of file +PARTICLE_DOLPHIN = §dDolphin +PARTICLE_WITCH = §5Hexe +PARTICLE_ENCHANTING = §eZauber +PARTICLE_HAPPY = §2Freude +PARTICLE_FLAME = §7Flammen +PARTICLE_END_ROD = §fEnd Rod +PARTICLE_CLOUD = §7Cloud +PARTICLE_TOTEM = §aTotem +PARTICLE_TOWN = §5Town +PARTICLE_ENCHANTING_CIRCLE = §fEnchanted +PARTICLE_WATER_FIRE = §bWater§7/§cFire +PARTICLE_MAGIC_ENCHANTING = §5Magic§7/§eZauber \ No newline at end of file diff --git a/src/de/steamwar/lobby/particle/ParticleInventory.java b/src/de/steamwar/lobby/particle/ParticleInventory.java index 33a7771..b95c73e 100644 --- a/src/de/steamwar/lobby/particle/ParticleInventory.java +++ b/src/de/steamwar/lobby/particle/ParticleInventory.java @@ -22,6 +22,8 @@ package de.steamwar.lobby.particle; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; +import de.steamwar.lobby.particle.decorator.CircleParticle; +import de.steamwar.lobby.particle.decorator.CloudParticle; import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.sql.Event; import de.steamwar.sql.SteamwarUser; @@ -42,84 +44,6 @@ public class ParticleInventory { private ParticleInventory() { } - private static final List PLAYER_PARTICLES = new ArrayList<>(); - private static final List TEAM_PARTICLES = new ArrayList<>(); - private static final List SERVERTEAM_PARTICLES = new ArrayList<>(); - - private static final List> PLAYER_PARTICLES_ENTRIES = new ArrayList<>(); - private static final List> TEAM_PARTICLES_ENTRIES = new ArrayList<>(); - private static final List> SERVERTEAM_PARTICLES_ENTRIES = new ArrayList<>(); - - static { - List defaultLore = loreBuilder(null, null); - List teamLore = loreBuilder(null, "Teambeitritt"); - List serverTeamLore = loreBuilder(null, "Serverteam"); - List serverTeamLore_C = loreBuilder(new String[]{"Wolke"}, "Serverteam"); - List serverTeamLore_R = loreBuilder(new String[]{"Ring"}, "Serverteam"); - List serverTeamLore_2R = loreBuilder(new String[]{"doppel Ring"}, "Serverteam"); - List serverTeamLore_CR = loreBuilder(new String[]{"Wolke", "Ring"}, "Serverteam"); - - PLAYER_PARTICLES.add(new SimpleParticle(Material.SLIME_BLOCK, "§aSneeze", defaultLore, Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)); - PLAYER_PARTICLES.add(new SimpleParticle(Material.COBWEB, "§7Smoke", defaultLore, Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)); - PLAYER_PARTICLES.add(new SimpleParticle(Material.LAVA_BUCKET, "§cFeuer", defaultLore, Particle.DRIP_LAVA)); - PLAYER_PARTICLES.add(new SimpleParticle(Material.WATER_BUCKET, "§bWasser", defaultLore, Particle.DRIP_WATER)); - PLAYER_PARTICLES.add(new FunctionalParticle(Material.RED_DYE, "§cHerzen", defaultLore, (world, player, integer) -> world.spawnParticle(Particle.HEART, player.getLocation().add(0, 2.2, 0), 5))); - PLAYER_PARTICLES.add(new FunctionalParticle(Material.NOTE_BLOCK, "§eNoten", defaultLore, (world, player, integer) -> world.spawnParticle(Particle.NOTE, player.getLocation().add(0, 2.2, 0), 5))); - PLAYER_PARTICLES.add(new SimpleParticle(Material.NAUTILUS_SHELL, "§aNautilis", defaultLore, Particle.NAUTILUS, 0.2F, 0F, 0.2F, 0.01)); - PLAYER_PARTICLES.add(new SimpleParticle(Material.SNOWBALL, "§fSnowball", defaultLore, Particle.SNOWBALL, 0.2F, 0F, 0.2F, 0.01)); - PLAYER_PARTICLES.add(new FunctionalParticle(Material.GLASS_BOTTLE, "§5Effekt", defaultLore, (world, player, time) -> { - world.spawnParticle(Particle.REDSTONE, player.getLocation().add(0.0, 0.2, 0.0), 5, 0F, 0.2F, 0F, 0.01, SpecialParticle.getParticleDust()); - })); - PLAYER_PARTICLES.add(new SimpleParticle(Material.CAMPFIRE, "§7Rauch", defaultLore, Particle.CAMPFIRE_COSY_SMOKE, 0.0F, 0.2F, 0F, 0.01)); - PLAYER_PARTICLES.add(new SimpleParticle(Material.CAULDRON, "§5Magie", defaultLore, Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)); - PLAYER_PARTICLES.add(new SimpleParticle(Material.REDSTONE_BLOCK, "§4Wut", defaultLore, Particle.VILLAGER_ANGRY, 0.2F, 0.02F, 0.2F, 0.01)); - PLAYER_PARTICLES.add(new SimpleParticle(Material.SLIME_BALL, "§aSchleim", defaultLore, Particle.SLIME)); - PLAYER_PARTICLES.add(new SimpleParticle(Material.ZOMBIE_HEAD, "§7Mob", defaultLore, Particle.SPELL_MOB)); - - TEAM_PARTICLES.addAll(PLAYER_PARTICLES); - TEAM_PARTICLES.add(new SimpleParticle(Material.INK_SAC, "§8Squid", teamLore, Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)); - TEAM_PARTICLES.add(new SimpleParticle(Material.TUBE_CORAL, "§aBubble", teamLore, Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)); - TEAM_PARTICLES.add(new SimpleParticle(Material.HONEY_BOTTLE, "§6Honey", teamLore, Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)); - TEAM_PARTICLES.add(new SimpleParticle(Material.HONEYCOMB, "§6Nectar", teamLore, Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)); - TEAM_PARTICLES.add(new FunctionalParticle(Material.FIRE_CHARGE, "§7Firework", loreBuilder(new String[]{"in Luft"}, "Team beitritt"), (world, player, time) -> { - if (world.getBlockAt(player.getLocation().subtract(0, 1, 0)).getType() == Material.AIR) { - world.spawnParticle(Particle.FIREWORKS_SPARK, player.getLocation().subtract(0, -0.2, 0), 2, 0.1F, 0.1F, 0.1F, 0.2); - } - })); - TEAM_PARTICLES.add(new SimpleParticle(Material.DRAGON_BREATH, "§5Dragon Breath", teamLore, Particle.DRAGON_BREATH, 1F, 0.02F, 1F, 0.01)); - TEAM_PARTICLES.add(new SimpleParticle(Material.SPIDER_EYE, "§5Damage", teamLore, Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)); - TEAM_PARTICLES.add(new SimpleParticle(Material.BLUE_DYE, "§dDolphin", teamLore, Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01)); - TEAM_PARTICLES.add(new CircleParticle(Material.RED_CONCRETE, "§cHerzen", loreBuilder(new String[]{"Ring"}, "Team beitritt"), Particle.HEART, null, location -> location.add(0, 2.2, 0))); - - SERVERTEAM_PARTICLES.addAll(TEAM_PARTICLES); - SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.EXPERIENCE_BOTTLE, "§5Hexe", serverTeamLore, Particle.SPELL_WITCH)); - SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.ENCHANTING_TABLE, "§eZauber", serverTeamLore, Particle.ENCHANTMENT_TABLE)); - SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.EMERALD_BLOCK, "§2Freude", serverTeamLore, Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)); - SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.FLINT_AND_STEEL, "§7Flammen", serverTeamLore, Particle.FLAME, 0F, 0.2F, 0F, 0.01)); - SERVERTEAM_PARTICLES.add(new SimpleParticle(Material.END_ROD, "§fEnd Rod", serverTeamLore, Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)); - SERVERTEAM_PARTICLES.add(new CloudParticle(Material.WHITE_WOOL, "§fCloud", serverTeamLore_C, Particle.CLOUD)); - SERVERTEAM_PARTICLES.add(new CloudParticle(Material.TOTEM_OF_UNDYING, "§aTotem", serverTeamLore_C, Particle.TOTEM)); - SERVERTEAM_PARTICLES.add(new CloudParticle(Material.WHITE_DYE, "§eZauber", serverTeamLore_C, Particle.ENCHANTMENT_TABLE)); - SERVERTEAM_PARTICLES.add(new CloudParticle(Material.FIRE_CORAL_BLOCK, "§cFlammen", serverTeamLore_C, Particle.FLAME)); - SERVERTEAM_PARTICLES.add(new CloudParticle(Material.LIME_SHULKER_BOX, "§aSneeze", serverTeamLore_C, Particle.SNEEZE)); - SERVERTEAM_PARTICLES.add(new CloudParticle(Material.GREEN_SHULKER_BOX, "§aSchleim", serverTeamLore_C, Particle.SLIME)); - SERVERTEAM_PARTICLES.add(new CloudParticle(Material.DEAD_BRAIN_CORAL_BLOCK, "§8Smoke", serverTeamLore_C, Particle.CAMPFIRE_COSY_SMOKE)); - SERVERTEAM_PARTICLES.add(new CloudParticle(Material.FIREWORK_STAR, "§5Town", serverTeamLore_C, Particle.TOWN_AURA)); - SERVERTEAM_PARTICLES.add(new CircleParticle(Material.MAGMA_BLOCK, "§cFlammen", serverTeamLore_R, Particle.FLAME, null, location -> location.add(0, 1.1, 0), 0F, 0.0F, 0F, 0.01)); - SERVERTEAM_PARTICLES.add(new CircleParticle(Material.ENCHANTED_BOOK, "§fEnchanted", serverTeamLore_R, Particle.ENCHANTMENT_TABLE, null, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01)); - SERVERTEAM_PARTICLES.add(new CircleParticle(Material.NOTE_BLOCK, "§eNoten", serverTeamLore_R, Particle.NOTE, null, location -> location.add(0, 2.2, 0), 0.0F, 0.0F, 0.0F, 0.01)); - SERVERTEAM_PARTICLES.add(new CircleParticle(Material.GUARDIAN_SPAWN_EGG, "§bWater§7/§cFire", serverTeamLore_2R, Particle.DRIP_WATER, Particle.DRIP_LAVA, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01)); - SERVERTEAM_PARTICLES.add(new CircleParticle(Material.DIAMOND_SWORD, "§5Magic§7/§eZauber", serverTeamLore_2R, Particle.CRIT_MAGIC, Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0), 0.0F, 0.0F, 0.0F, 0.01)); - SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.GLOWSTONE_DUST, "§5Magic", serverTeamLore_CR, Particle.CRIT_MAGIC, location -> location.add(0, 1.1, 0))); - SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.FIRE_CORAL, "§cFlammen", serverTeamLore_CR, Particle.FLAME, location -> location.add(0, 1.1, 0))); - SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.FIREWORK_ROCKET, "§7Firework", serverTeamLore_CR, Particle.FIREWORKS_SPARK, location -> location.add(0, 1.1, 0))); - SERVERTEAM_PARTICLES.add(new CloudCircleParticle(Material.CYAN_DYE, "§aWater", serverTeamLore_CR, Particle.WATER_WAKE, location -> location.add(0, 1.1, 0))); - - PLAYER_PARTICLES.forEach(specialParticle -> PLAYER_PARTICLES_ENTRIES.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); - TEAM_PARTICLES.forEach(specialParticle -> TEAM_PARTICLES_ENTRIES.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); - SERVERTEAM_PARTICLES.forEach(specialParticle -> SERVERTEAM_PARTICLES_ENTRIES.add(new SWListInv.SWListEntry<>(specialParticle.getItem(), specialParticle))); - } - private static SWInventory createInventory(Player player) { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); @@ -182,25 +106,5 @@ public class ParticleInventory { public static void openParticleInventory(Player player) { createInventory(player).open(); } - - public static List loreBuilder(String[] attribute, String unlocked) { - List lore = new ArrayList<>(); - lore.add(""); - if (attribute != null && attribute.length > 0) { - lore.add("§eAttribute§7:"); - for (String s : attribute) { - lore.add("§7- §f" + s); - } - lore.add(""); - } - if (unlocked != null) { - lore.add("§eFreigeschaltet durch"); - lore.add("§f" + unlocked); - lore.add(""); - } - lore.add("§eKlicken zum auswählen"); - return lore; - } - } diff --git a/src/de/steamwar/lobby/particle/ServerTeamParticle.java b/src/de/steamwar/lobby/particle/ServerTeamParticle.java new file mode 100644 index 0000000..bab253b --- /dev/null +++ b/src/de/steamwar/lobby/particle/ServerTeamParticle.java @@ -0,0 +1,62 @@ +/* + * 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.lobby.particle.decorator.CircleParticle; +import de.steamwar.lobby.particle.decorator.CloudParticle; +import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +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.SPELL_WITCH)), + ENCHANTING(new SimpleParticle(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_ENCHANTING"), Particle.ENCHANTMENT_TABLE)), + HAPPY(new SimpleParticle(new ParticleItem(EMERALD_BLOCK, "PARTICLE_HAPPY"), Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)), + FLAME(new SimpleParticle(new ParticleItem(FLINT_AND_STEEL, "PARTICLE_FLAME"), Particle.FLAME, 0F, 0.2F, 0F, 0.01)), + END_ROD(new SimpleParticle(new ParticleItem(Material.END_ROD, "PARTICLE_END_ROD"), Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)), + CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(WHITE_WOOL, "PARTICLE_CLOUD"), Particle.CLOUD))), + TOTEM(new CloudParticle(new SimpleParticle(new ParticleItem(TOTEM_OF_UNDYING, "PARTICLE_TOTEM"), Particle.TOTEM))), + ENCHANTING_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(WHITE_DYE, "PARTICLE_ENCHANTING"), Particle.ENCHANTMENT_TABLE))), + FLAME_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(FIRE_CORAL_BLOCK, "PARTICLE_FLAME"), Particle.FLAME))), + SNEEZE_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(LIME_SHULKER_BOX, "PARTICLE_SNEEZE"), Particle.SNEEZE))), + SLIME_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(GREEN_SHULKER_BOX, "PARTICLE_SLIME"), Particle.SLIME))), + SMOKE_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(DEAD_BRAIN_CORAL_BLOCK, "PARTICLE_SMOKE"), Particle.CAMPFIRE_COSY_SMOKE))), + TOWN_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(FIREWORK_STAR, "PARTICLE_TOWN"), Particle.TOWN_AURA))), + FLAME_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(MAGMA_BLOCK, "PARTICLE_FLAME"), 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.ENCHANTMENT_TABLE, 0F, 0F, 0F, 0.01), location -> location.add(0, 1.1, 0)))), + NOTES_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(NOTE_BLOCK, "PARTICLE_NOTES"), 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"), 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"), 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.CRIT_MAGIC), 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.FLAME), 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.FIREWORKS_SPARK), 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.WATER_WAKE), location -> location.add(0, 1.1, 0))))), +; + public static ParticleEnum[] particles = values(); + + @Getter + private BaseParticle particle; +} diff --git a/src/de/steamwar/lobby/particle/decorator/CloudParticle.java b/src/de/steamwar/lobby/particle/decorator/CloudParticle.java index c3d6747..4aa2b5c 100644 --- a/src/de/steamwar/lobby/particle/decorator/CloudParticle.java +++ b/src/de/steamwar/lobby/particle/decorator/CloudParticle.java @@ -53,6 +53,7 @@ public class CloudParticle implements BaseParticle { particleData.getPlayer().removePotionEffect(PotionEffectType.SLOW_FALLING); return; } + particleData.withLocation(particleData.getLocation().subtract(0, -0.2, 0)); particle.particle(particleData); } } From 7c16a7a315e46aed6ce2f580380d0582964c12c0 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Mar 2022 17:01:47 +0100 Subject: [PATCH 07/38] Update ParticleListener Update LobbyPlayer Update ParticleInventory --- .../lobby/listener/ParticleListener.java | 13 ++++---- .../lobby/particle/EventParticle.java | 9 +++--- .../lobby/particle/ParticleInventory.java | 30 +++++++++---------- src/de/steamwar/lobby/util/LobbyPlayer.java | 14 ++++----- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index 9b408e2..d9b6688 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -20,8 +20,9 @@ package de.steamwar.lobby.listener; import de.steamwar.lobby.LobbySystem; +import de.steamwar.lobby.particle.BaseParticle; +import de.steamwar.lobby.particle.ParticleData; import de.steamwar.lobby.particle.ParticleInventory; -import de.steamwar.lobby.particle.SpecialParticle; import de.steamwar.lobby.util.LobbyPlayer; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -40,9 +41,11 @@ public class ParticleListener extends BasicListener { if (deg > 360) deg = 0; Bukkit.getOnlinePlayers().forEach(player -> { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - SpecialParticle particle = lobbyPlayer.getParticle(); + BaseParticle particle = lobbyPlayer.getParticle(); if (particle == null) return; - particle.execute(player.getWorld(), player, deg); + if (particle.needsTick()) { + particle.particle(new ParticleData(player.getWorld(), player, deg)); + } }); }, 0, 1); } @@ -59,9 +62,9 @@ public class ParticleListener extends BasicListener { public void handlePlayerMove(PlayerMoveEvent event) { Player player = event.getPlayer(); LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - SpecialParticle particle = lobbyPlayer.getParticle(); + BaseParticle particle = lobbyPlayer.getParticle(); if (particle == null) return; - particle.execute(player.getWorld(), player, deg); + particle.particle(new ParticleData(player.getWorld(), player, deg)); } } diff --git a/src/de/steamwar/lobby/particle/EventParticle.java b/src/de/steamwar/lobby/particle/EventParticle.java index 2268766..e5e6ea8 100644 --- a/src/de/steamwar/lobby/particle/EventParticle.java +++ b/src/de/steamwar/lobby/particle/EventParticle.java @@ -19,6 +19,8 @@ package de.steamwar.lobby.particle; +import de.steamwar.lobby.particle.decorator.CircleParticle; +import de.steamwar.lobby.particle.decorator.CloudParticle; import org.bukkit.Material; import org.bukkit.Particle; @@ -31,16 +33,15 @@ public enum EventParticle { public static EventParticle[] eventParticles = values(); - EventParticle(int event, int[] placementTeams, SpecialParticle placementParticle, SpecialParticle participationParticles) { + EventParticle(int event, int[] placementTeams, BaseParticle placementParticle, BaseParticle participationParticles) { this.event = event; this.placementTeams = placementTeams; this.placementParticle = placementParticle; this.participationParticles = participationParticles; - } public final int event; public final int[] placementTeams; - public final SpecialParticle placementParticle; - public final SpecialParticle participationParticles; + public final BaseParticle placementParticle; + public final BaseParticle participationParticles; } diff --git a/src/de/steamwar/lobby/particle/ParticleInventory.java b/src/de/steamwar/lobby/particle/ParticleInventory.java index b95c73e..bed37dc 100644 --- a/src/de/steamwar/lobby/particle/ParticleInventory.java +++ b/src/de/steamwar/lobby/particle/ParticleInventory.java @@ -22,15 +22,12 @@ package de.steamwar.lobby.particle; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; -import de.steamwar.lobby.particle.decorator.CircleParticle; -import de.steamwar.lobby.particle.decorator.CloudParticle; 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 org.bukkit.Material; -import org.bukkit.Particle; import org.bukkit.entity.Player; import java.util.ArrayList; @@ -44,23 +41,24 @@ public class ParticleInventory { private ParticleInventory() { } + 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.getParticle())); + } + } + private static SWInventory createInventory(Player player) { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); UserGroup userGroup = steamwarUser.getUserGroup(); - List> particleList; - if (userGroup == UserGroup.Member) { - if (steamwarUser.getTeam() != 0) { - particleList = new ArrayList<>(TEAM_PARTICLES_ENTRIES); - } else { - if (TEAM_PARTICLES.contains(lobbyPlayer.getParticle())) { - lobbyPlayer.setParticle(null); - } - particleList = new ArrayList<>(PLAYER_PARTICLES_ENTRIES); - } - } else { - particleList = new ArrayList<>(SERVERTEAM_PARTICLES_ENTRIES); + 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()); @@ -84,7 +82,7 @@ public class ParticleInventory { } } - SWListInv particleSWListInv = new SWListInv<>(player, "§6Partikel", false, particleList, (clickType, particle) -> { + SWListInv particleSWListInv = new SWListInv<>(player, "§6Partikel", false, particleList, (clickType, particle) -> { if (particle == null) return; lobbyPlayer.setParticle(particle); player.closeInventory(); diff --git a/src/de/steamwar/lobby/util/LobbyPlayer.java b/src/de/steamwar/lobby/util/LobbyPlayer.java index ed0a018..a3d5ba1 100644 --- a/src/de/steamwar/lobby/util/LobbyPlayer.java +++ b/src/de/steamwar/lobby/util/LobbyPlayer.java @@ -19,7 +19,7 @@ package de.steamwar.lobby.util; -import de.steamwar.lobby.particle.SpecialParticle; +import de.steamwar.lobby.particle.BaseParticle; import org.bukkit.entity.Player; import java.util.HashMap; @@ -30,13 +30,13 @@ public class LobbyPlayer { private static Map cache = new HashMap<>(); - private SpecialParticle specialParticle; + private BaseParticle particle; private boolean fly; private LobbyPlayer(UUID uuid) { cache.put(uuid, this); - specialParticle = null; + particle = null; } public boolean isFlying() { @@ -47,12 +47,12 @@ public class LobbyPlayer { this.fly = fly; } - public SpecialParticle getParticle() { - return specialParticle; + public BaseParticle getParticle() { + return particle; } - public void setParticle(SpecialParticle specialParticle) { - this.specialParticle = specialParticle; + public void setParticle(BaseParticle specialParticle) { + this.particle = specialParticle; } public static LobbyPlayer getLobbyPlayer(UUID uuid) { From 86612ef7f28bc85ea078a4a0685ac9d415210990 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Mar 2022 17:07:39 +0100 Subject: [PATCH 08/38] Make stuff multilingual --- src/de/steamwar/lobby/LobbySystem.properties | 4 ++++ src/de/steamwar/lobby/particle/ParticleInventory.java | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 2330fe5..e4d16bd 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -12,6 +12,10 @@ PORTAL_COMMAND_LIST_SHORT_INFO = §e{0} §8- §7{1} §7Pos1§8(§7{2}§8) §7Pos PORTAL_NO_WORLDEDIT_SELECTION = §cKeine WorldEdit Selection # Particle +PARTICLE_INVENTORY = §6Partikel +PARTICLE_DESELECT = §8Keine Partikel +PARTICLE_LOCKED = {0} §8- §c§lGesperrt + PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Doppel Ring PARTICLE_ATTRIBUTE_CLOUD = §8-§f Wolke diff --git a/src/de/steamwar/lobby/particle/ParticleInventory.java b/src/de/steamwar/lobby/particle/ParticleInventory.java index bed37dc..6bc99cd 100644 --- a/src/de/steamwar/lobby/particle/ParticleInventory.java +++ b/src/de/steamwar/lobby/particle/ParticleInventory.java @@ -22,6 +22,7 @@ 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.util.LobbyPlayer; import de.steamwar.sql.Event; import de.steamwar.sql.SteamwarUser; @@ -82,12 +83,12 @@ public class ParticleInventory { } } - SWListInv particleSWListInv = new SWListInv<>(player, "§6Partikel", false, particleList, (clickType, particle) -> { + SWListInv particleSWListInv = new SWListInv<>(player, LobbySystem.getMessage().parse("PARTICLE_INVENTORY", player), false, particleList, (clickType, particle) -> { if (particle == null) return; lobbyPlayer.setParticle(particle); player.closeInventory(); }); - particleSWListInv.setItem(49, Material.BARRIER, "§8Keine Partikel", new ArrayList<>(), false, clickType -> { + particleSWListInv.setItem(49, Material.BARRIER, LobbySystem.getMessage().parse("PARTICLE_DESELECT", player), new ArrayList<>(), false, clickType -> { lobbyPlayer.setParticle(null); }); From 94c6fc934b3d618d09b39676a6cd6ac7871d5dee Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 24 Mar 2022 17:33:29 +0100 Subject: [PATCH 09/38] Update EventParticle --- src/de/steamwar/lobby/LobbySystem.properties | 19 +++++++- .../lobby/particle/EventParticle.java | 25 ++++++++-- .../steamwar/lobby/particle/ParticleData.java | 7 +-- .../lobby/particle/ParticleInventory.java | 12 ++--- .../steamwar/lobby/particle/ParticleItem.java | 9 ++-- .../lobby/particle/PlayerParticle.java | 2 +- .../lobby/particle/ServerTeamParticle.java | 46 +++++++++---------- .../steamwar/lobby/particle/TeamParticle.java | 20 ++++---- .../particle/decorator/CircleParticle.java | 8 ++-- .../particle/decorator/CloudParticle.java | 4 +- .../lobby/particle/group/ParticleGroup.java | 2 +- .../mutator/LocationParticleMutator.java | 4 +- 12 files changed, 97 insertions(+), 61 deletions(-) diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index e4d16bd..241c96d 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -16,6 +16,9 @@ PARTICLE_INVENTORY = §6Partikel PARTICLE_DESELECT = §8Keine Partikel PARTICLE_LOCKED = {0} §8- §c§lGesperrt +PARTICLE_UNLOCKED_BY_TEAM = §eTeam Beitritt +PARTICLE_UNLOCKED_BY_SERVER_TEAM = §eServer Team + PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Doppel Ring PARTICLE_ATTRIBUTE_CLOUD = §8-§f Wolke @@ -59,4 +62,18 @@ PARTICLE_TOTEM = §aTotem PARTICLE_TOWN = §5Town PARTICLE_ENCHANTING_CIRCLE = §fEnchanted PARTICLE_WATER_FIRE = §bWater§7/§cFire -PARTICLE_MAGIC_ENCHANTING = §5Magic§7/§eZauber \ No newline at end of file +PARTICLE_MAGIC_ENCHANTING = §5Magic§7/§eZauber + +PARTICLE_UNLOCKED_BY_WGS_PLACEMENT = WarGearSeason 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_WGS = WarGearSeason +PARTICLE_UNLOCKED_BY_AIRSHIPEVENT_PLACEMENT = AirshipEvent 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_AIRSHIPEVENT = AirshipEvent +PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT = HellsBells 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_HELLSBELLS = HellsBells +PARTICLE_UNLOCKED_BY_UNDERWATER_PLACEMENT = Underwater 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_UNDERWATER = Underwater + +PARTICLE_EVENT_ENCHANTING = §cVerzaubert +PARTICLE_EVENT_CLOUD = §fCloud +PARTICLE_EVENT_SMOKE = §7Smoke +PARTICLE_EVENT_WATER = §bWasser \ No newline at end of file diff --git a/src/de/steamwar/lobby/particle/EventParticle.java b/src/de/steamwar/lobby/particle/EventParticle.java index e5e6ea8..b5ae3e2 100644 --- a/src/de/steamwar/lobby/particle/EventParticle.java +++ b/src/de/steamwar/lobby/particle/EventParticle.java @@ -21,15 +21,30 @@ package de.steamwar.lobby.particle; import de.steamwar.lobby.particle.decorator.CircleParticle; import de.steamwar.lobby.particle.decorator.CloudParticle; -import org.bukkit.Material; +import de.steamwar.lobby.particle.mutator.LocationParticleMutator; import org.bukkit.Particle; +import static org.bukkit.Material.*; + public enum EventParticle { - WarGearSeason(22, new int[]{12, 285, 54}, new CloudCircleParticle(Material.ENCHANTING_TABLE, "§cVerzaubert", ParticleInventory.loreBuilder(new String[]{"Wolke", "Ring"}, "WarGearSeason 1., 2. oder 3. Platz"), Particle.ENCHANTMENT_TABLE, location -> location.add(0, 1.1, 0)), new SimpleParticle(Material.BOOK, "§5Verzaubert", ParticleInventory.loreBuilder(new String[0], "WarGearSeason"), Particle.ENCHANTMENT_TABLE)), - AirshipEvent(26, new int[]{205, 9, 54, 120, 292}, new CircleParticle(Material.SNOWBALL, "§fCloud", ParticleInventory.loreBuilder(new String[]{"Ring"}, "AirshipEvent 1., 2. oder 3. Platz"), Particle.CLOUD, null, location -> location.add(0, 2.2, 0)), new SimpleParticle(Material.SNOW_BLOCK, "§fCloud", ParticleInventory.loreBuilder(new String[0], "AirshipEvent"), Particle.CLOUD)), - HellsBellsWs(28, new int[]{205, 9, 11}, new CloudCircleParticle(Material.TNT_MINECART, "§7Smoke", ParticleInventory.loreBuilder(new String[]{"Wolke", "Ring"}, "HellsBells 1., 2. oder 3. Platz"), Particle.CAMPFIRE_COSY_SMOKE, location -> location.add(0, 2.2, 0)), new CircleParticle(Material.TNT, "§8Smoke", ParticleInventory.loreBuilder(new String[]{"Ring"}, "HellsBells"), Particle.CAMPFIRE_COSY_SMOKE, null, location -> location, 0, 0, 0, 0.01)), - Underwater(31, new int[]{9, 210, 520}, new CloudParticle(Material.PRISMARINE_CRYSTALS, "§bWasser", ParticleInventory.loreBuilder(new String[]{"Wolke"}, "Underwater 1., 2. oder 3. Platz"), Particle.DRIP_WATER), new SimpleParticle(Material.PRISMARINE_BRICKS, "§bWasser", ParticleInventory.loreBuilder(new String[0], "Underwater"), Particle.DRIP_WATER)); + WarGearSeason(22, new int[]{12, 285, 54}, + new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS_PLACEMENT"), Particle.ENCHANTMENT_TABLE), location -> location.add(0, 1.1, 0)))), + new SimpleParticle(new ParticleItem(BOOK, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS"), Particle.ENCHANTMENT_TABLE) + ), + AirshipEvent(26, new int[]{205, 9, 54, 120, 292}, + new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(SNOWBALL, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT_PLACEMENT"), Particle.CLOUD), location -> location.add(0, 2.2, 0))), + new SimpleParticle(new ParticleItem(SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT"), Particle.CLOUD) + ), + HellsBellsWs(28, new int[]{205, 9, 11}, + new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(TNT_MINECART, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT"), Particle.CAMPFIRE_COSY_SMOKE), location -> location.add(0, 2.2, 0)))), + new CircleParticle(new SimpleParticle(new ParticleItem(TNT, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS"), Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01)) + ), + Underwater(31, new int[]{9, 210, 520}, + new CloudParticle(new SimpleParticle(new ParticleItem(PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER_PLACEMENT"), Particle.DRIP_WATER)), + new SimpleParticle(new ParticleItem(PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER"), Particle.DRIP_WATER) + ), + ; public static EventParticle[] eventParticles = values(); diff --git a/src/de/steamwar/lobby/particle/ParticleData.java b/src/de/steamwar/lobby/particle/ParticleData.java index df9afcb..8a4523b 100644 --- a/src/de/steamwar/lobby/particle/ParticleData.java +++ b/src/de/steamwar/lobby/particle/ParticleData.java @@ -36,8 +36,9 @@ public class ParticleData { private final double deg; public ParticleData withLocation(Location location) { - this.location = location; - return this; + ParticleData particleData = copy(); + particleData.location = location; + return particleData; } public Location getLocation() { @@ -47,7 +48,7 @@ public class ParticleData { return location; } - public ParticleData clone() { + public ParticleData copy() { return new ParticleData(world, player, location, deg); } } diff --git a/src/de/steamwar/lobby/particle/ParticleInventory.java b/src/de/steamwar/lobby/particle/ParticleInventory.java index 6bc99cd..9d5a944 100644 --- a/src/de/steamwar/lobby/particle/ParticleInventory.java +++ b/src/de/steamwar/lobby/particle/ParticleInventory.java @@ -67,18 +67,18 @@ public class ParticleInventory { boolean clickablePlacement = userGroup.isTeamGroup(); clickablePlacement |= (steamwarUser.getTeam() != 0 && contains(eventParticle.placementTeams, steamwarUser.getTeam())); if (clickablePlacement) { - particleList.add(new SWListInv.SWListEntry<>(eventParticle.placementParticle.getItem(), eventParticle.placementParticle)); + particleList.add(new SWListInv.SWListEntry<>(eventParticle.placementParticle.getItem().toSWItem(player), eventParticle.placementParticle)); } else { - SWItem swItem = eventParticle.placementParticle.getItem(); - swItem.setName(swItem.getItemMeta().getDisplayName() + " §8- §c§lGesperrt"); + SWItem swItem = eventParticle.placementParticle.getItem().toSWItem(player); + swItem.setName(LobbySystem.getMessage().parse("PARTICLE_LOCKED", player, swItem.getItemMeta().getDisplayName())); particleList.add(new SWListInv.SWListEntry<>(swItem, null)); } if (eventParticle.placementTeams.length != 0 && (userGroup.isTeamGroup() || events.contains(eventParticle.event))) { - particleList.add(new SWListInv.SWListEntry<>(eventParticle.participationParticles.getItem(), eventParticle.participationParticles)); + particleList.add(new SWListInv.SWListEntry<>(eventParticle.participationParticles.getItem().toSWItem(player), eventParticle.participationParticles)); } else { - SWItem swItem = eventParticle.participationParticles.getItem(); - swItem.setName(swItem.getItemMeta().getDisplayName() + " §8- §c§lGesperrt"); + SWItem swItem = eventParticle.participationParticles.getItem().toSWItem(player); + swItem.setName(LobbySystem.getMessage().parse("PARTICLE_LOCKED", player, swItem.getItemMeta().getDisplayName())); particleList.add(new SWListInv.SWListEntry<>(swItem, null)); } } diff --git a/src/de/steamwar/lobby/particle/ParticleItem.java b/src/de/steamwar/lobby/particle/ParticleItem.java index 3634d17..e6638d1 100644 --- a/src/de/steamwar/lobby/particle/ParticleItem.java +++ b/src/de/steamwar/lobby/particle/ParticleItem.java @@ -22,7 +22,6 @@ package de.steamwar.lobby.particle; import de.steamwar.inventory.SWItem; import de.steamwar.lobby.LobbySystem; import lombok.RequiredArgsConstructor; -import lombok.Setter; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -37,10 +36,14 @@ public class ParticleItem { private final Material material; private final String name; private final Set attributes = new LinkedHashSet<>(); - - @Setter private 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; diff --git a/src/de/steamwar/lobby/particle/PlayerParticle.java b/src/de/steamwar/lobby/particle/PlayerParticle.java index c67bb75..d15cc54 100644 --- a/src/de/steamwar/lobby/particle/PlayerParticle.java +++ b/src/de/steamwar/lobby/particle/PlayerParticle.java @@ -44,7 +44,7 @@ public enum PlayerParticle implements ParticleEnum { 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)), -; + ; public static ParticleEnum[] particles = values(); @Getter diff --git a/src/de/steamwar/lobby/particle/ServerTeamParticle.java b/src/de/steamwar/lobby/particle/ServerTeamParticle.java index bab253b..e9b8c43 100644 --- a/src/de/steamwar/lobby/particle/ServerTeamParticle.java +++ b/src/de/steamwar/lobby/particle/ServerTeamParticle.java @@ -32,29 +32,29 @@ import static org.bukkit.Material.*; @AllArgsConstructor public enum ServerTeamParticle implements ParticleEnum { - WITCH(new SimpleParticle(new ParticleItem(EXPERIENCE_BOTTLE, "PARTICLE_WITCH"), Particle.SPELL_WITCH)), - ENCHANTING(new SimpleParticle(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_ENCHANTING"), Particle.ENCHANTMENT_TABLE)), - HAPPY(new SimpleParticle(new ParticleItem(EMERALD_BLOCK, "PARTICLE_HAPPY"), Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)), - FLAME(new SimpleParticle(new ParticleItem(FLINT_AND_STEEL, "PARTICLE_FLAME"), Particle.FLAME, 0F, 0.2F, 0F, 0.01)), - END_ROD(new SimpleParticle(new ParticleItem(Material.END_ROD, "PARTICLE_END_ROD"), Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)), - CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(WHITE_WOOL, "PARTICLE_CLOUD"), Particle.CLOUD))), - TOTEM(new CloudParticle(new SimpleParticle(new ParticleItem(TOTEM_OF_UNDYING, "PARTICLE_TOTEM"), Particle.TOTEM))), - ENCHANTING_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(WHITE_DYE, "PARTICLE_ENCHANTING"), Particle.ENCHANTMENT_TABLE))), - FLAME_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(FIRE_CORAL_BLOCK, "PARTICLE_FLAME"), Particle.FLAME))), - SNEEZE_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(LIME_SHULKER_BOX, "PARTICLE_SNEEZE"), Particle.SNEEZE))), - SLIME_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(GREEN_SHULKER_BOX, "PARTICLE_SLIME"), Particle.SLIME))), - SMOKE_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(DEAD_BRAIN_CORAL_BLOCK, "PARTICLE_SMOKE"), Particle.CAMPFIRE_COSY_SMOKE))), - TOWN_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(FIREWORK_STAR, "PARTICLE_TOWN"), Particle.TOWN_AURA))), - FLAME_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(MAGMA_BLOCK, "PARTICLE_FLAME"), 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.ENCHANTMENT_TABLE, 0F, 0F, 0F, 0.01), location -> location.add(0, 1.1, 0)))), - NOTES_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(NOTE_BLOCK, "PARTICLE_NOTES"), 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"), 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"), 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.CRIT_MAGIC), 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.FLAME), 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.FIREWORKS_SPARK), 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.WATER_WAKE), location -> location.add(0, 1.1, 0))))), -; + 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))), + 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))), + 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, 0F, 0F, 0F, 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))), + 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_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(GLOWSTONE_DUST, "PARTICLE_MAGIC", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.CRIT_MAGIC), 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), 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), 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), location -> location.add(0, 1.1, 0))))), + ; public static ParticleEnum[] particles = values(); @Getter diff --git a/src/de/steamwar/lobby/particle/TeamParticle.java b/src/de/steamwar/lobby/particle/TeamParticle.java index ab94c01..22da761 100644 --- a/src/de/steamwar/lobby/particle/TeamParticle.java +++ b/src/de/steamwar/lobby/particle/TeamParticle.java @@ -32,16 +32,16 @@ import static org.bukkit.Material.*; @AllArgsConstructor public enum TeamParticle implements ParticleEnum { - SQUID(new SimpleParticle(new ParticleItem(INK_SAC, "PARTICLE_SQUID"), Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)), - BUBBLE(new SimpleParticle(new ParticleItem(TUBE_CORAL, "PARTICLE_BUBBLE"), Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)), - HONEY(new SimpleParticle(new ParticleItem(HONEY_BOTTLE, "PARTICLE_HONEY"), Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)), - NECTAR(new SimpleParticle(new ParticleItem(HONEYCOMB, "PARTICLE_NECTAR"), Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)), - FIREWORK(new LocationParticleMutator(new NonFloorParticle(new SimpleParticle(new ParticleItem(FIRE_CHARGE, "PARTICLE_FIREWORK"), 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.DRAGON_BREATH, 1F, 0.2F, 1F, 0.01)), - DAMAGE(new SimpleParticle(new ParticleItem(SPIDER_EYE, "PARTICLE_DAMAGE"), Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)), - DOLPHIN(new SimpleParticle(new ParticleItem(BLUE_DYE, "PARTICLE_DOLPHIN"), Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01)), - HEART(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(RED_CONCRETE, "PARTICLE_HEART"), Particle.HEART), location -> location.add(0, 2.2, 0)))) -; + 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)))), + ; public static ParticleEnum[] particles = values(); @Getter diff --git a/src/de/steamwar/lobby/particle/decorator/CircleParticle.java b/src/de/steamwar/lobby/particle/decorator/CircleParticle.java index bc3fb1b..f46a09c 100644 --- a/src/de/steamwar/lobby/particle/decorator/CircleParticle.java +++ b/src/de/steamwar/lobby/particle/decorator/CircleParticle.java @@ -60,8 +60,8 @@ public class CircleParticle implements BaseParticle { Vector vector = new Vector(1, 0, 0); vector.rotateAroundY(particleData.getDeg()); - particleData.withLocation(location.clone().add(vector)); - particle.particle(particleData); + ParticleData nData = particleData.withLocation(location.clone().add(vector)); + particle.particle(nData); if (particle2 == null) { return; @@ -69,7 +69,7 @@ public class CircleParticle implements BaseParticle { vector.setX(-vector.getX()); vector.setZ(-vector.getZ()); - particleData.withLocation(location.clone().add(vector)); - particle2.particle(particleData); + 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 index 4aa2b5c..773f741 100644 --- a/src/de/steamwar/lobby/particle/decorator/CloudParticle.java +++ b/src/de/steamwar/lobby/particle/decorator/CloudParticle.java @@ -53,7 +53,7 @@ public class CloudParticle implements BaseParticle { particleData.getPlayer().removePotionEffect(PotionEffectType.SLOW_FALLING); return; } - particleData.withLocation(particleData.getLocation().subtract(0, -0.2, 0)); - particle.particle(particleData); + ParticleData nData = particleData.withLocation(particleData.getLocation().subtract(0, -0.2, 0)); + particle.particle(nData); } } diff --git a/src/de/steamwar/lobby/particle/group/ParticleGroup.java b/src/de/steamwar/lobby/particle/group/ParticleGroup.java index f2c4272..1d837c4 100644 --- a/src/de/steamwar/lobby/particle/group/ParticleGroup.java +++ b/src/de/steamwar/lobby/particle/group/ParticleGroup.java @@ -41,7 +41,7 @@ public class ParticleGroup implements BaseParticle { @Override public void particle(ParticleData particleData) { for (BaseParticle particle : particles) { - particle.particle(particleData.clone()); + particle.particle(particleData.copy()); } } } diff --git a/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java b/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java index d91f850..602fd85 100644 --- a/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java +++ b/src/de/steamwar/lobby/particle/mutator/LocationParticleMutator.java @@ -48,7 +48,7 @@ public class LocationParticleMutator implements BaseParticle { @Override public void particle(ParticleData particleData) { - particleData.withLocation(mutator.apply(particleData.getLocation())); - particle.particle(particleData); + ParticleData nData = particleData.withLocation(mutator.apply(particleData.getLocation())); + particle.particle(nData); } } From 291b4b883a563dc6aede25d38fb0c2c793bbc225 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 09:51:04 +0100 Subject: [PATCH 10/38] Update stuff --- .../lobby/listener/ParticleListener.java | 15 +++-- .../lobby/particle/EventParticle.java | 62 ------------------- .../particle/EventParticleParticipation.java | 42 +++++++++++++ .../particle/EventParticlePlacement.java | 45 ++++++++++++++ .../lobby/particle/ParticleInventory.java | 46 +++++++------- src/de/steamwar/lobby/util/LobbyPlayer.java | 9 +-- 6 files changed, 125 insertions(+), 94 deletions(-) delete mode 100644 src/de/steamwar/lobby/particle/EventParticle.java create mode 100644 src/de/steamwar/lobby/particle/EventParticleParticipation.java create mode 100644 src/de/steamwar/lobby/particle/EventParticlePlacement.java diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index d9b6688..ea3b5f0 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -22,6 +22,7 @@ package de.steamwar.lobby.listener; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.particle.BaseParticle; import de.steamwar.lobby.particle.ParticleData; +import de.steamwar.lobby.particle.ParticleEnum; import de.steamwar.lobby.particle.ParticleInventory; import de.steamwar.lobby.util.LobbyPlayer; import org.bukkit.Bukkit; @@ -41,10 +42,11 @@ public class ParticleListener extends BasicListener { if (deg > 360) deg = 0; Bukkit.getOnlinePlayers().forEach(player -> { LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - BaseParticle particle = lobbyPlayer.getParticle(); + ParticleEnum particle = lobbyPlayer.getParticle(); if (particle == null) return; - if (particle.needsTick()) { - particle.particle(new ParticleData(player.getWorld(), player, deg)); + BaseParticle baseParticle = particle.getParticle(); + if (baseParticle.needsTick()) { + baseParticle.particle(new ParticleData(player.getWorld(), player, deg)); } }); }, 0, 1); @@ -62,9 +64,10 @@ public class ParticleListener extends BasicListener { public void handlePlayerMove(PlayerMoveEvent event) { Player player = event.getPlayer(); LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); - BaseParticle particle = lobbyPlayer.getParticle(); - + ParticleEnum particle = lobbyPlayer.getParticle(); if (particle == null) return; - particle.particle(new ParticleData(player.getWorld(), player, deg)); + + BaseParticle baseParticle = particle.getParticle(); + baseParticle.particle(new ParticleData(player.getWorld(), player, deg)); } } diff --git a/src/de/steamwar/lobby/particle/EventParticle.java b/src/de/steamwar/lobby/particle/EventParticle.java deleted file mode 100644 index b5ae3e2..0000000 --- a/src/de/steamwar/lobby/particle/EventParticle.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.lobby.particle.decorator.CircleParticle; -import de.steamwar.lobby.particle.decorator.CloudParticle; -import de.steamwar.lobby.particle.mutator.LocationParticleMutator; -import org.bukkit.Particle; - -import static org.bukkit.Material.*; - -public enum EventParticle { - - WarGearSeason(22, new int[]{12, 285, 54}, - new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS_PLACEMENT"), Particle.ENCHANTMENT_TABLE), location -> location.add(0, 1.1, 0)))), - new SimpleParticle(new ParticleItem(BOOK, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS"), Particle.ENCHANTMENT_TABLE) - ), - AirshipEvent(26, new int[]{205, 9, 54, 120, 292}, - new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(SNOWBALL, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT_PLACEMENT"), Particle.CLOUD), location -> location.add(0, 2.2, 0))), - new SimpleParticle(new ParticleItem(SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT"), Particle.CLOUD) - ), - HellsBellsWs(28, new int[]{205, 9, 11}, - new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(TNT_MINECART, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT"), Particle.CAMPFIRE_COSY_SMOKE), location -> location.add(0, 2.2, 0)))), - new CircleParticle(new SimpleParticle(new ParticleItem(TNT, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS"), Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01)) - ), - Underwater(31, new int[]{9, 210, 520}, - new CloudParticle(new SimpleParticle(new ParticleItem(PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER_PLACEMENT"), Particle.DRIP_WATER)), - new SimpleParticle(new ParticleItem(PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER"), Particle.DRIP_WATER) - ), - ; - - public static EventParticle[] eventParticles = values(); - - EventParticle(int event, int[] placementTeams, BaseParticle placementParticle, BaseParticle participationParticles) { - this.event = event; - this.placementTeams = placementTeams; - this.placementParticle = placementParticle; - this.participationParticles = participationParticles; - } - - public final int event; - public final int[] placementTeams; - public final BaseParticle placementParticle; - public final BaseParticle participationParticles; -} diff --git a/src/de/steamwar/lobby/particle/EventParticleParticipation.java b/src/de/steamwar/lobby/particle/EventParticleParticipation.java new file mode 100644 index 0000000..bf6ae48 --- /dev/null +++ b/src/de/steamwar/lobby/particle/EventParticleParticipation.java @@ -0,0 +1,42 @@ +/* + * 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.lobby.particle.decorator.CircleParticle; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.bukkit.Particle; + +import static org.bukkit.Material.*; + +@AllArgsConstructor +@Getter +public enum EventParticleParticipation implements ParticleEnum { + + WarGearSeason(22, new SimpleParticle(new ParticleItem(BOOK, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS"), Particle.ENCHANTMENT_TABLE)), + AirshipEvent(26, new SimpleParticle(new ParticleItem(SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT"), Particle.CLOUD)), + HellsBellsWs(28, new CircleParticle(new SimpleParticle(new ParticleItem(TNT, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS"), Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))), + Underwater(31, new SimpleParticle(new ParticleItem(PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER"), Particle.DRIP_WATER)), + ; + public static EventParticleParticipation[] particles = values(); + + private int event; + private BaseParticle particle; +} diff --git a/src/de/steamwar/lobby/particle/EventParticlePlacement.java b/src/de/steamwar/lobby/particle/EventParticlePlacement.java new file mode 100644 index 0000000..5480151 --- /dev/null +++ b/src/de/steamwar/lobby/particle/EventParticlePlacement.java @@ -0,0 +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; + +import de.steamwar.lobby.particle.decorator.CircleParticle; +import de.steamwar.lobby.particle.decorator.CloudParticle; +import de.steamwar.lobby.particle.mutator.LocationParticleMutator; +import lombok.AllArgsConstructor; +import lombok.Getter; +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(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS_PLACEMENT"), Particle.ENCHANTMENT_TABLE), location -> location.add(0, 1.1, 0))))), + AirshipEvent(26, new int[]{205, 9, 54, 120, 292}, new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(SNOWBALL, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT_PLACEMENT"), Particle.CLOUD), location -> location.add(0, 2.2, 0)))), + HellsBellsWs(28, new int[]{205, 9, 11}, new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(TNT_MINECART, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT"), Particle.CAMPFIRE_COSY_SMOKE), location -> location.add(0, 2.2, 0))))), + Underwater(31, new int[]{9, 210, 520}, new CloudParticle(new SimpleParticle(new ParticleItem(PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER_PLACEMENT"), Particle.DRIP_WATER))), + ; + public static EventParticlePlacement[] particles = values(); + + private int event; + private int[] placementTeams; + private BaseParticle particle; +} diff --git a/src/de/steamwar/lobby/particle/ParticleInventory.java b/src/de/steamwar/lobby/particle/ParticleInventory.java index 9d5a944..fa13171 100644 --- a/src/de/steamwar/lobby/particle/ParticleInventory.java +++ b/src/de/steamwar/lobby/particle/ParticleInventory.java @@ -30,6 +30,7 @@ import de.steamwar.sql.TeamTeilnahme; import de.steamwar.sql.UserGroup; import org.bukkit.Material; import org.bukkit.entity.Player; +import sun.util.resources.ext.CalendarData_da; import java.util.ArrayList; import java.util.HashSet; @@ -42,9 +43,9 @@ public class ParticleInventory { private ParticleInventory() { } - private static void calculateParticles(ParticleEnum[] particles, Player player, List> particleList) { + 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.getParticle())); + particleList.add(new SWListInv.SWListEntry<>(particle.getParticle().getItem().toSWItem(player), particle)); } } @@ -53,7 +54,7 @@ public class ParticleInventory { SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); UserGroup userGroup = steamwarUser.getUserGroup(); - List> particleList = new ArrayList<>(); + List> particleList = new ArrayList<>(); calculateParticles(PlayerParticle.particles, player, particleList); if (steamwarUser.getTeam() != 0 || userGroup != UserGroup.Member) { calculateParticles(TeamParticle.particles, player, particleList); @@ -63,27 +64,18 @@ public class ParticleInventory { } Set events = steamwarUser.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(steamwarUser.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet()); - for (EventParticle eventParticle : EventParticle.eventParticles) { - boolean clickablePlacement = userGroup.isTeamGroup(); - clickablePlacement |= (steamwarUser.getTeam() != 0 && contains(eventParticle.placementTeams, steamwarUser.getTeam())); - if (clickablePlacement) { - particleList.add(new SWListInv.SWListEntry<>(eventParticle.placementParticle.getItem().toSWItem(player), eventParticle.placementParticle)); - } else { - SWItem swItem = eventParticle.placementParticle.getItem().toSWItem(player); - swItem.setName(LobbySystem.getMessage().parse("PARTICLE_LOCKED", player, swItem.getItemMeta().getDisplayName())); - particleList.add(new SWListInv.SWListEntry<>(swItem, null)); - } - - if (eventParticle.placementTeams.length != 0 && (userGroup.isTeamGroup() || events.contains(eventParticle.event))) { - particleList.add(new SWListInv.SWListEntry<>(eventParticle.participationParticles.getItem().toSWItem(player), eventParticle.participationParticles)); - } else { - SWItem swItem = eventParticle.participationParticles.getItem().toSWItem(player); - swItem.setName(LobbySystem.getMessage().parse("PARTICLE_LOCKED", player, swItem.getItemMeta().getDisplayName())); - particleList.add(new SWListInv.SWListEntry<>(swItem, null)); - } + 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); } - SWListInv particleSWListInv = new SWListInv<>(player, LobbySystem.getMessage().parse("PARTICLE_INVENTORY", player), false, particleList, (clickType, particle) -> { + SWListInv particleSWListInv = new SWListInv<>(player, LobbySystem.getMessage().parse("PARTICLE_INVENTORY", player), false, particleList, (clickType, particle) -> { if (particle == null) return; lobbyPlayer.setParticle(particle); player.closeInventory(); @@ -95,6 +87,16 @@ public class ParticleInventory { return particleSWListInv; } + 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 static boolean contains(int[] ints, int element) { for (int i : ints) { if (i == element) return true; diff --git a/src/de/steamwar/lobby/util/LobbyPlayer.java b/src/de/steamwar/lobby/util/LobbyPlayer.java index a3d5ba1..3d9d8aa 100644 --- a/src/de/steamwar/lobby/util/LobbyPlayer.java +++ b/src/de/steamwar/lobby/util/LobbyPlayer.java @@ -20,6 +20,7 @@ package de.steamwar.lobby.util; import de.steamwar.lobby.particle.BaseParticle; +import de.steamwar.lobby.particle.ParticleEnum; import org.bukkit.entity.Player; import java.util.HashMap; @@ -30,7 +31,7 @@ public class LobbyPlayer { private static Map cache = new HashMap<>(); - private BaseParticle particle; + private ParticleEnum particle; private boolean fly; @@ -47,12 +48,12 @@ public class LobbyPlayer { this.fly = fly; } - public BaseParticle getParticle() { + public ParticleEnum getParticle() { return particle; } - public void setParticle(BaseParticle specialParticle) { - this.particle = specialParticle; + public void setParticle(ParticleEnum particle) { + this.particle = particle; } public static LobbyPlayer getLobbyPlayer(UUID uuid) { From bb86bed319a9e072db6192a5ace60cee7ac8b8dc Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 09:57:38 +0100 Subject: [PATCH 11/38] Update stuff --- src/de/steamwar/lobby/listener/ParticleListener.java | 2 +- src/de/steamwar/lobby/particle/ParticleInventory.java | 2 +- .../{ => particles}/EventParticleParticipation.java | 5 ++++- .../particle/{ => particles}/EventParticlePlacement.java | 5 ++++- .../lobby/particle/{ => particles}/ParticleEnum.java | 4 +++- .../lobby/particle/{ => particles}/PlayerParticle.java | 6 +++++- .../lobby/particle/{ => particles}/ServerTeamParticle.java | 5 ++++- .../lobby/particle/{ => particles}/TeamParticle.java | 5 ++++- src/de/steamwar/lobby/util/LobbyPlayer.java | 3 +-- 9 files changed, 27 insertions(+), 10 deletions(-) rename src/de/steamwar/lobby/particle/{ => particles}/EventParticleParticipation.java (90%) rename src/de/steamwar/lobby/particle/{ => particles}/EventParticlePlacement.java (92%) rename src/de/steamwar/lobby/particle/{ => particles}/ParticleEnum.java (89%) rename src/de/steamwar/lobby/particle/{ => particles}/PlayerParticle.java (92%) rename src/de/steamwar/lobby/particle/{ => particles}/ServerTeamParticle.java (96%) rename src/de/steamwar/lobby/particle/{ => particles}/TeamParticle.java (93%) diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index ea3b5f0..3236610 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -22,7 +22,7 @@ package de.steamwar.lobby.listener; import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.particle.BaseParticle; import de.steamwar.lobby.particle.ParticleData; -import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.particles.ParticleEnum; import de.steamwar.lobby.particle.ParticleInventory; import de.steamwar.lobby.util.LobbyPlayer; import org.bukkit.Bukkit; diff --git a/src/de/steamwar/lobby/particle/ParticleInventory.java b/src/de/steamwar/lobby/particle/ParticleInventory.java index fa13171..2db6cc1 100644 --- a/src/de/steamwar/lobby/particle/ParticleInventory.java +++ b/src/de/steamwar/lobby/particle/ParticleInventory.java @@ -23,6 +23,7 @@ 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.util.LobbyPlayer; import de.steamwar.sql.Event; import de.steamwar.sql.SteamwarUser; @@ -30,7 +31,6 @@ import de.steamwar.sql.TeamTeilnahme; import de.steamwar.sql.UserGroup; import org.bukkit.Material; import org.bukkit.entity.Player; -import sun.util.resources.ext.CalendarData_da; import java.util.ArrayList; import java.util.HashSet; diff --git a/src/de/steamwar/lobby/particle/EventParticleParticipation.java b/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java similarity index 90% rename from src/de/steamwar/lobby/particle/EventParticleParticipation.java rename to src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java index bf6ae48..e3ff5ce 100644 --- a/src/de/steamwar/lobby/particle/EventParticleParticipation.java +++ b/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java @@ -17,8 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.particle; +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 lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/de/steamwar/lobby/particle/EventParticlePlacement.java b/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java similarity index 92% rename from src/de/steamwar/lobby/particle/EventParticlePlacement.java rename to src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java index 5480151..8d5139b 100644 --- a/src/de/steamwar/lobby/particle/EventParticlePlacement.java +++ b/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java @@ -17,8 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.particle; +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.mutator.LocationParticleMutator; diff --git a/src/de/steamwar/lobby/particle/ParticleEnum.java b/src/de/steamwar/lobby/particle/particles/ParticleEnum.java similarity index 89% rename from src/de/steamwar/lobby/particle/ParticleEnum.java rename to src/de/steamwar/lobby/particle/particles/ParticleEnum.java index 1fb2174..db97369 100644 --- a/src/de/steamwar/lobby/particle/ParticleEnum.java +++ b/src/de/steamwar/lobby/particle/particles/ParticleEnum.java @@ -17,7 +17,9 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.particle; +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/PlayerParticle.java b/src/de/steamwar/lobby/particle/particles/PlayerParticle.java similarity index 92% rename from src/de/steamwar/lobby/particle/PlayerParticle.java rename to src/de/steamwar/lobby/particle/particles/PlayerParticle.java index d15cc54..9bbbe1f 100644 --- a/src/de/steamwar/lobby/particle/PlayerParticle.java +++ b/src/de/steamwar/lobby/particle/particles/PlayerParticle.java @@ -17,8 +17,12 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.particle; +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 lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/de/steamwar/lobby/particle/ServerTeamParticle.java b/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java similarity index 96% rename from src/de/steamwar/lobby/particle/ServerTeamParticle.java rename to src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java index e9b8c43..ce0d6c0 100644 --- a/src/de/steamwar/lobby/particle/ServerTeamParticle.java +++ b/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java @@ -17,8 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.particle; +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.mutator.LocationParticleMutator; diff --git a/src/de/steamwar/lobby/particle/TeamParticle.java b/src/de/steamwar/lobby/particle/particles/TeamParticle.java similarity index 93% rename from src/de/steamwar/lobby/particle/TeamParticle.java rename to src/de/steamwar/lobby/particle/particles/TeamParticle.java index 22da761..9efc748 100644 --- a/src/de/steamwar/lobby/particle/TeamParticle.java +++ b/src/de/steamwar/lobby/particle/particles/TeamParticle.java @@ -17,8 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.lobby.particle; +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; diff --git a/src/de/steamwar/lobby/util/LobbyPlayer.java b/src/de/steamwar/lobby/util/LobbyPlayer.java index 3d9d8aa..031cade 100644 --- a/src/de/steamwar/lobby/util/LobbyPlayer.java +++ b/src/de/steamwar/lobby/util/LobbyPlayer.java @@ -19,8 +19,7 @@ package de.steamwar.lobby.util; -import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleEnum; +import de.steamwar.lobby.particle.particles.ParticleEnum; import org.bukkit.entity.Player; import java.util.HashMap; From 62163b7296db4e49b44ab63542a65e5fd2922f75 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 10:10:55 +0100 Subject: [PATCH 12/38] Add LobbyPlayer save and load particle via DB --- src/de/steamwar/lobby/util/LobbyPlayer.java | 36 ++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/lobby/util/LobbyPlayer.java b/src/de/steamwar/lobby/util/LobbyPlayer.java index 031cade..44f01c7 100644 --- a/src/de/steamwar/lobby/util/LobbyPlayer.java +++ b/src/de/steamwar/lobby/util/LobbyPlayer.java @@ -19,7 +19,9 @@ package de.steamwar.lobby.util; -import de.steamwar.lobby.particle.particles.ParticleEnum; +import de.steamwar.lobby.particle.particles.*; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserConfig; import org.bukkit.entity.Player; import java.util.HashMap; @@ -31,12 +33,37 @@ public class LobbyPlayer { private static Map cache = new HashMap<>(); private ParticleEnum particle; + private int userId; private boolean fly; private LobbyPlayer(UUID uuid) { + userId = SteamwarUser.get(uuid).getId(); cache.put(uuid, this); particle = null; + String saved = UserConfig.getConfig(userId, "lobby-particle"); + if (saved != null) { + 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 "EventParticleParticipation": + particle = EventParticleParticipation.valueOf(strings[1]); + break; + case "EventParticlePlacement": + particle = EventParticlePlacement.valueOf(strings[1]); + break; + default: + break; + } + } } public boolean isFlying() { @@ -52,6 +79,13 @@ public class LobbyPlayer { } public void setParticle(ParticleEnum particle) { + if (particle == null) { + UserConfig.removePlayerConfig(userId, "lobby-particle"); + } else { + Class clazz = particle.getClass(); + String saved = clazz.getSimpleName() + "@" + ((Enum) particle).name(); + UserConfig.updatePlayerConfig(userId, "lobby-particle", saved); + } this.particle = particle; } From 54ad572e0633d17e723625aa3a106f3f4502b075 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 10:12:12 +0100 Subject: [PATCH 13/38] Update stuff --- src/de/steamwar/lobby/util/LobbyPlayer.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/de/steamwar/lobby/util/LobbyPlayer.java b/src/de/steamwar/lobby/util/LobbyPlayer.java index 44f01c7..7e292cd 100644 --- a/src/de/steamwar/lobby/util/LobbyPlayer.java +++ b/src/de/steamwar/lobby/util/LobbyPlayer.java @@ -82,8 +82,7 @@ public class LobbyPlayer { if (particle == null) { UserConfig.removePlayerConfig(userId, "lobby-particle"); } else { - Class clazz = particle.getClass(); - String saved = clazz.getSimpleName() + "@" + ((Enum) particle).name(); + String saved = particle.getClass().getSimpleName() + "@" + ((Enum) particle).name(); UserConfig.updatePlayerConfig(userId, "lobby-particle", saved); } this.particle = particle; From af273ab2e1864abeeb212e4ab65167a3bd5d3d8c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 10:16:22 +0100 Subject: [PATCH 14/38] Update stuff --- src/de/steamwar/lobby/util/LobbyPlayer.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/de/steamwar/lobby/util/LobbyPlayer.java b/src/de/steamwar/lobby/util/LobbyPlayer.java index 7e292cd..d7a441e 100644 --- a/src/de/steamwar/lobby/util/LobbyPlayer.java +++ b/src/de/steamwar/lobby/util/LobbyPlayer.java @@ -96,5 +96,4 @@ public class LobbyPlayer { public static LobbyPlayer getLobbyPlayer(Player player) { return getLobbyPlayer(player.getUniqueId()); } - } From 88e03a09a9caea5a01a0d1c3acca4a9864c99a21 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 10:23:49 +0100 Subject: [PATCH 15/38] Add EventParticle --- src/de/steamwar/lobby/LobbySystem.properties | 1 + .../lobby/particle/ParticleInventory.java | 3 ++ .../particle/particles/EventParticle.java | 46 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/de/steamwar/lobby/particle/particles/EventParticle.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 241c96d..887e90d 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -17,6 +17,7 @@ PARTICLE_DESELECT = §8Keine Partikel PARTICLE_LOCKED = {0} §8- §c§lGesperrt PARTICLE_UNLOCKED_BY_TEAM = §eTeam Beitritt +PARTICLE_UNLOCKED_BY_EVENT = §eEvent teilnahme PARTICLE_UNLOCKED_BY_SERVER_TEAM = §eServer Team PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring diff --git a/src/de/steamwar/lobby/particle/ParticleInventory.java b/src/de/steamwar/lobby/particle/ParticleInventory.java index 2db6cc1..551e6db 100644 --- a/src/de/steamwar/lobby/particle/ParticleInventory.java +++ b/src/de/steamwar/lobby/particle/ParticleInventory.java @@ -64,6 +64,9 @@ public class ParticleInventory { } 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())); diff --git a/src/de/steamwar/lobby/particle/particles/EventParticle.java b/src/de/steamwar/lobby/particle/particles/EventParticle.java new file mode 100644 index 0000000..016ac02 --- /dev/null +++ b/src/de/steamwar/lobby/particle/particles/EventParticle.java @@ -0,0 +1,46 @@ +/* + * 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 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))))), + ; + public static ParticleEnum[] particles = values(); + + @Getter + private BaseParticle particle; +} From 28d84f436f5883dfb89e612d78c093d420f47bd3 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 10:44:37 +0100 Subject: [PATCH 16/38] Fix ServerTeamParticle and add 2 new ones --- src/de/steamwar/lobby/LobbySystem.properties | 22 +++++++++---------- .../lobby/listener/ParticleListener.java | 1 + .../particles/ServerTeamParticle.java | 11 ++++++---- src/de/steamwar/lobby/util/LobbyPlayer.java | 2 ++ 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 887e90d..7b10d12 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -16,9 +16,9 @@ PARTICLE_INVENTORY = §6Partikel PARTICLE_DESELECT = §8Keine Partikel PARTICLE_LOCKED = {0} §8- §c§lGesperrt -PARTICLE_UNLOCKED_BY_TEAM = §eTeam Beitritt -PARTICLE_UNLOCKED_BY_EVENT = §eEvent teilnahme -PARTICLE_UNLOCKED_BY_SERVER_TEAM = §eServer Team +PARTICLE_UNLOCKED_BY_TEAM = §fTeam Beitritt +PARTICLE_UNLOCKED_BY_EVENT = §fEvent teilnahme +PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServer Team PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Doppel Ring @@ -65,14 +65,14 @@ PARTICLE_ENCHANTING_CIRCLE = §fEnchanted PARTICLE_WATER_FIRE = §bWater§7/§cFire PARTICLE_MAGIC_ENCHANTING = §5Magic§7/§eZauber -PARTICLE_UNLOCKED_BY_WGS_PLACEMENT = WarGearSeason 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_WGS = WarGearSeason -PARTICLE_UNLOCKED_BY_AIRSHIPEVENT_PLACEMENT = AirshipEvent 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_AIRSHIPEVENT = AirshipEvent -PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT = HellsBells 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_HELLSBELLS = HellsBells -PARTICLE_UNLOCKED_BY_UNDERWATER_PLACEMENT = Underwater 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_UNDERWATER = Underwater +PARTICLE_UNLOCKED_BY_WGS_PLACEMENT = §fWarGearSeason 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_WGS = §fWarGearSeason +PARTICLE_UNLOCKED_BY_AIRSHIPEVENT_PLACEMENT = §fAirshipEvent 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_AIRSHIPEVENT = §fAirshipEvent +PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT = §fHellsBells 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_HELLSBELLS = §fHellsBells +PARTICLE_UNLOCKED_BY_UNDERWATER_PLACEMENT = §fUnderwater 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_UNDERWATER = §fUnderwater PARTICLE_EVENT_ENCHANTING = §cVerzaubert PARTICLE_EVENT_CLOUD = §fCloud diff --git a/src/de/steamwar/lobby/listener/ParticleListener.java b/src/de/steamwar/lobby/listener/ParticleListener.java index 3236610..c504f74 100644 --- a/src/de/steamwar/lobby/listener/ParticleListener.java +++ b/src/de/steamwar/lobby/listener/ParticleListener.java @@ -68,6 +68,7 @@ public class ParticleListener extends BasicListener { if (particle == null) return; BaseParticle baseParticle = particle.getParticle(); + if (baseParticle.needsTick()) return; baseParticle.particle(new ParticleData(player.getWorld(), player, deg)); } } diff --git a/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java b/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java index ce0d6c0..4a0214a 100644 --- a/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java +++ b/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java @@ -24,6 +24,7 @@ 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.mutator.LocationParticleMutator; import lombok.AllArgsConstructor; import lombok.Getter; @@ -52,11 +53,13 @@ public enum ServerTeamParticle implements ParticleEnum { ENCHANTING_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(WHITE_DYE, "PARTICLE_ENCHANTING_CIRCLE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.ENCHANTMENT_TABLE, 0F, 0F, 0F, 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_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(GLOWSTONE_DUST, "PARTICLE_MAGIC", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.CRIT_MAGIC), 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), 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), 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), 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))))), ; public static ParticleEnum[] particles = values(); diff --git a/src/de/steamwar/lobby/util/LobbyPlayer.java b/src/de/steamwar/lobby/util/LobbyPlayer.java index d7a441e..03927ba 100644 --- a/src/de/steamwar/lobby/util/LobbyPlayer.java +++ b/src/de/steamwar/lobby/util/LobbyPlayer.java @@ -54,6 +54,8 @@ public class LobbyPlayer { case "ServerTeamParticle": particle = ServerTeamParticle.valueOf(strings[1]); break; + case "EventParticle": + particle = EventParticle.valueOf(strings[1]); case "EventParticleParticipation": particle = EventParticleParticipation.valueOf(strings[1]); break; From 4c82c898690ea01b4c10653fcc9c45cfc6100624 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 13:22:24 +0100 Subject: [PATCH 17/38] Update stuff --- src/de/steamwar/lobby/LobbySystem.properties | 2 +- .../steamwar/lobby/particle/particles/ServerTeamParticle.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 7b10d12..49f4da7 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -17,7 +17,7 @@ PARTICLE_DESELECT = §8Keine Partikel PARTICLE_LOCKED = {0} §8- §c§lGesperrt PARTICLE_UNLOCKED_BY_TEAM = §fTeam Beitritt -PARTICLE_UNLOCKED_BY_EVENT = §fEvent teilnahme +PARTICLE_UNLOCKED_BY_EVENT = §fEvent Teilnahme PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServer Team PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring diff --git a/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java b/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java index 4a0214a..86fa05b 100644 --- a/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java +++ b/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java @@ -60,6 +60,7 @@ public enum ServerTeamParticle implements ParticleEnum { 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)))), ; public static ParticleEnum[] particles = values(); From dfb7e63df998a85dcb8549a49f858fa7262311b8 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 17:28:32 +0100 Subject: [PATCH 18/38] Update Event particles --- src/de/steamwar/lobby/LobbySystem.properties | 20 +++- .../lobby/particle/DustSimpleParticle.java | 13 ++- .../particle/decorator/WingParticle.java | 110 ++++++++++++++++++ .../lobby/particle/decorator/WingSW.png | Bin 0 -> 205 bytes .../lobby/particle/decorator/WingSimple2.png | Bin 0 -> 746 bytes .../lobby/particle/decorator/WingSimple4.png | Bin 0 -> 511 bytes .../lobby/particle/decorator/WingSword.png | Bin 0 -> 188 bytes .../particle/decorator/WingSwordCrossed.png | Bin 0 -> 855 bytes .../lobby/particle/decorator/WingWGS.png | Bin 0 -> 184 bytes .../particles/EventParticleParticipation.java | 10 ++ .../particles/EventParticlePlacement.java | 15 ++- .../particles/ServerTeamParticle.java | 8 +- 12 files changed, 168 insertions(+), 8 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/decorator/WingParticle.java create mode 100644 src/de/steamwar/lobby/particle/decorator/WingSW.png create mode 100644 src/de/steamwar/lobby/particle/decorator/WingSimple2.png create mode 100644 src/de/steamwar/lobby/particle/decorator/WingSimple4.png create mode 100644 src/de/steamwar/lobby/particle/decorator/WingSword.png create mode 100644 src/de/steamwar/lobby/particle/decorator/WingSwordCrossed.png create mode 100644 src/de/steamwar/lobby/particle/decorator/WingWGS.png diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 49f4da7..79006d0 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -25,6 +25,7 @@ PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Doppel Ring PARTICLE_ATTRIBUTE_CLOUD = §8-§f Wolke PARTICLE_ATTRIBUTE_TICK = §8-§f Immer aktiv PARTICLE_ATTRIBUTE_NON_FLOOR = §8-§f in Luft +PARTICLE_ATTRIBUTE_WING = §8-§f Flügel PARTICLE_ATTRIBUTE = §eAttribute§7: PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch @@ -64,6 +65,7 @@ PARTICLE_TOWN = §5Town PARTICLE_ENCHANTING_CIRCLE = §fEnchanted PARTICLE_WATER_FIRE = §bWater§7/§cFire PARTICLE_MAGIC_ENCHANTING = §5Magic§7/§eZauber +PARTICLE_WINGS_EVIL = §5Lila Flügel PARTICLE_UNLOCKED_BY_WGS_PLACEMENT = §fWarGearSeason 1., 2. oder 3. Platz PARTICLE_UNLOCKED_BY_WGS = §fWarGearSeason @@ -73,8 +75,24 @@ PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT = §fHellsBells 1., 2. oder 3. Platz PARTICLE_UNLOCKED_BY_HELLSBELLS = §fHellsBells PARTICLE_UNLOCKED_BY_UNDERWATER_PLACEMENT = §fUnderwater 1., 2. oder 3. Platz PARTICLE_UNLOCKED_BY_UNDERWATER = §fUnderwater +PARTICLE_UNLOCKED_BY_ADVENTWARSHIP_PLACEMENT = §fAdvent-WarShip 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_ADVENTWARSHIP = §fAdvent-WarShip +PARTICLE_UNLOCKED_BY_MWGL_PLACEMENT = §fMiniWarGearLiga 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_MWGL = §fMiniWarGearLiga +PARTICLE_UNLOCKED_BY_ABSTURZ_PLACEMENT = §fAbsturz 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_ABSTURZ = §fAbsturz +PARTICLE_UNLOCKED_BY_UNDERWATERMWG_PLACEMENT = §fUnderwaterMWG 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_UNDERWATERMWG = §fUnderwaterMWG +PARTICLE_UNLOCKED_BY_WGS22_PLACEMENT = §fWarGearSeason 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_WGS22 = §fWarGearSeason +PARTICLE_UNLOCKED_BY_WARGEARCLASH_PLACEMENT = §fWargearClash 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_WARGEARCLASH = §fWargearClash PARTICLE_EVENT_ENCHANTING = §cVerzaubert PARTICLE_EVENT_CLOUD = §fCloud PARTICLE_EVENT_SMOKE = §7Smoke -PARTICLE_EVENT_WATER = §bWasser \ No newline at end of file +PARTICLE_EVENT_WATER = §bWasser +PARTICLE_EVENT_WINGS = §fWings +PARTICLE_EVENT_RAIN_CLOUD = §fRegenwolke +PARTICLE_EVENT_WGS = §fWGS +PARTICLE_EVENT_WARGEARCLASH = §fClash \ No newline at end of file diff --git a/src/de/steamwar/lobby/particle/DustSimpleParticle.java b/src/de/steamwar/lobby/particle/DustSimpleParticle.java index bf77930..533b889 100644 --- a/src/de/steamwar/lobby/particle/DustSimpleParticle.java +++ b/src/de/steamwar/lobby/particle/DustSimpleParticle.java @@ -30,6 +30,7 @@ public class DustSimpleParticle implements BaseParticle { 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; @@ -40,6 +41,16 @@ public class DustSimpleParticle implements BaseParticle { this.time = time; } + public DustSimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time, int count) { + this.particleItem = particleItem; + this.particle = particle; + this.vx = vx; + this.vy = vy; + this.vz = vz; + this.time = time; + this.count = count; + } + @Override public ParticleItem getItem() { return particleItem; @@ -48,6 +59,6 @@ public class DustSimpleParticle implements BaseParticle { @Override public void particle(ParticleData particleData) { Location location = particleData.getLocation().add(0.0, 0.2, 0.0); - particleData.getWorld().spawnParticle(particle, location, 5, vx, vy, vz, time, getParticleDust()); + particleData.getWorld().spawnParticle(particle, location, count, vx, vy, vz, time, getParticleDust()); } } diff --git a/src/de/steamwar/lobby/particle/decorator/WingParticle.java b/src/de/steamwar/lobby/particle/decorator/WingParticle.java new file mode 100644 index 0000000..ba07190 --- /dev/null +++ b/src/de/steamwar/lobby/particle/decorator/WingParticle.java @@ -0,0 +1,110 @@ +/* + * 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.SneakyThrows; +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"), + ; + + 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; + } + + @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/particle/decorator/WingSW.png b/src/de/steamwar/lobby/particle/decorator/WingSW.png new file mode 100644 index 0000000000000000000000000000000000000000..3f5dc5a86a78d41a86d81fedc16279d011f1195b GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^oIotf!3HF!v>y2Yq!^2X+?^QKos)S9a~60+7BevL9R^{>Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0)I(FK~y+TwUob0 zvQZSrAAe+nRDyzKwMT>w;$Wad;_RYe|3DZ)YX~8wVK@q|nvUX9kb{a1P9lOt4hDjQ zR7(ZfkHLP}r}sX@OFqQAyx-w^?m6Fc?mge-9?i2bD^tTCJ)V78aJ4 zmeguBuDiQC5qo)g!Rd55FE1~J=XXGZObUs@GZ+k5r>3TGa)dM*jrRBV%jNRZ)04?$ z((CoHSPUbPNPK*J5CzZA&%zkTcL?&)(b3Av3h5LHg+jyOkg^mf`gIH_6be3{uib9v za=C+pgMPnnx7*oHOiY}gpA&-9YPAGeKx_#?fCiZq5=o~>uh%0)SwYt9?d{Rs^73-G z+r7WPN4NF$b-&+_j41H>`bw8(vw3Z8ZFY9{@bJ*(a>0+sPwBiTs?(VW8U3{{QSkmMKBno1VXcFwc7XhcR@xXR-8JW zZhCqe8h7HxR0rvFy3^?hrhtl$Wb-f33jHoFE}os8p$VUNdwZMC5JzT6lGrAb$$GtR zwOVNx#b}Wms8lMM^bMii50pwJRxX7I7|muAl`@&kpP&r3I0<1xgNz{($Dw=-*xK4U zIXSt$zUJ0!QKncdijctR=_yVO2+$ytB0}T%dM=7crBV+M4+ewb`1n|((J(xGhR4T8 z5yhCCoXlpkgdjkJOp1t(L!LB6*lae`X9&^SVzDs64u=EjxjwT%b!Lx|+1%WO23by1 zg7OIb0CUV+W72MJZg{zPZf|er=H|qtg~MS%`vw1W41gAmM%`|=_(L)pjkQ`W5{W1b c)i@;S6Jl#6C32W@{Qv*}07*qoM6N<$g5|tiJOBUy literal 0 HcmV?d00001 diff --git a/src/de/steamwar/lobby/particle/decorator/WingSimple4.png b/src/de/steamwar/lobby/particle/decorator/WingSimple4.png new file mode 100644 index 0000000000000000000000000000000000000000..09b3803034f7e411fe63e11ffcef88c0f2668a21 GIT binary patch literal 511 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0hCEZK~y+Tos+*y z0&y6|-*c`;CmR&8ttS5pX|PR5griLyDh!tjZ1)earOVdpPjC=ZiHclYQUV+F&M3^x zlz6-6?M_ZqHDCzA(UtJS1O#SCzV?mx!={b_Q! z3#wKhN!NAKG|k!)#bPmXyWOa~60+7BevL9R^{>gv%S$I4eCQh8l=-biA>Ghb^ zB#5Pm--wr)`K4M6!#WO20Y{TfkJ+~#{@57k>Krbp@pIv`Or3_VYl_pgPISueOj%eg fa3NHXnVI27im2;?2kZX>4QKFl^>bP0l+XkKo^?1c literal 0 HcmV?d00001 diff --git a/src/de/steamwar/lobby/particle/decorator/WingSwordCrossed.png b/src/de/steamwar/lobby/particle/decorator/WingSwordCrossed.png new file mode 100644 index 0000000000000000000000000000000000000000..d0bd2355ff8a81ce6b8b125ab15d0831d52e02e4 GIT binary patch literal 855 zcmV-d1E~CoP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0_;gdK~zXft(84b zVnGy!N5MiH3qVCpq(GyE#t``xBpPd>5u(M)hb9`WjBCX&(Go(a#7+eT1f?)yh_R3# zU}CZY3;V)53~)iSYxXH_&YW}RxpU_Z7cnr> zrl+Udx2VI20?Lf_dOfbcK1%EBKk`pch~MAec|V|ZV`F1CH#dxlc8wPo7Y2iYu}-I} zR;!gt1-HR8rBeZP*VosK6?z&f-$!+JcJ}e{k;&E?A08fXk{iN0N@ug#_-2#IT0=Mu4h;vkPZ(I%a+DU@n-Q`W)-ATsfmdR##pKB6JlXu0h`8rhY=qo+0x|j z@KDy8q|<49lMu)bA+U%-p};C=8QXR3D-DOkvZF~b7?iap__oTLGHz~e%AyeX-@rCw zvk}kF&p$suvxl6YpR*0L-x&V_Y^WPGIu>vsR#sLtI`I1Xy0o-}PK(8o%jNLD#ED>S zZ4C|L;NUNn{1`ISV`@iy0XB4ude`@%$AjKtW$m7sn8d;JJOCObiMfOk4l|-)Yh%_V!W? zOOdC;+zU< location.subtract(0, 0.2, 0))), location -> location.add(0, 2.2, 0)))), + WarGearSeason2022(37, new TickParticle(new WingParticle(new SimpleParticle(new ParticleItem(DIAMOND_SWORD, "PARTICLE_EVENT_WINGS", "PARTICLE_UNLOCKED_BY_WGS22"), Particle.DRAGON_BREATH, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.COMPLEX))), + // WargearClash(38, null), ; public static EventParticleParticipation[] particles = values(); diff --git a/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java b/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java index 8d5139b..73e934c 100644 --- a/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java +++ b/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java @@ -24,6 +24,9 @@ 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.group.ParticleGroup; import de.steamwar.lobby.particle.mutator.LocationParticleMutator; import lombok.AllArgsConstructor; import lombok.Getter; @@ -35,10 +38,16 @@ import static org.bukkit.Material.*; @Getter public enum EventParticlePlacement implements ParticleEnum { - WarGearSeason(22, new int[]{12, 285, 54}, new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS_PLACEMENT"), Particle.ENCHANTMENT_TABLE), location -> location.add(0, 1.1, 0))))), - AirshipEvent(26, new int[]{205, 9, 54, 120, 292}, new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(SNOWBALL, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT_PLACEMENT"), Particle.CLOUD), location -> location.add(0, 2.2, 0)))), - HellsBellsWs(28, new int[]{205, 9, 11}, new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(TNT_MINECART, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT"), Particle.CAMPFIRE_COSY_SMOKE), location -> location.add(0, 2.2, 0))))), + WarGearSeason(22, new int[]{12, 285, 54}, new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS_PLACEMENT"), 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(new ParticleItem(SNOWBALL, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT_PLACEMENT"), 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(new ParticleItem(TNT_MINECART, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT"), 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(new ParticleItem(PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER_PLACEMENT"), Particle.DRIP_WATER))), + AdventWarShip(32, new int[]{9, 205, 210}, new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleGroup(new ParticleItem(PRISMARINE_CRYSTALS, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_ADVENTWARSHIP"), 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(new ParticleItem(IRON_SWORD, "PARTICLE_EVENT_WINGS", "PARTICLE_UNLOCKED_BY_MWGL_PLACEMENT"), Particle.WATER_WAKE, 0, 0, 0, 0, 1), 0.05, WingParticle.WingDesign.SWORD))), + Absturz(34, new int[]{210, 205, 527, 286}, new TickParticle(new WingParticle(new SimpleParticle(new ParticleItem(FEATHER, "PARTICLE_EVENT_WINGS", "PARTICLE_UNLOCKED_BY_ABSTURZ_PLACEMENT"), 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(new ParticleItem(CYAN_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", "PARTICLE_UNLOCKED_BY_UNDERWATERMWG_PLACEMENT"), Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.SW))), + WarGearSeason2022(37, new int[]{}, new TickParticle(new WingParticle(new SimpleParticle(new ParticleItem(DIAMOND_HELMET, "PARTICLE_EVENT_WGS", "PARTICLE_UNLOCKED_BY_WGS22_PLACEMENT"), 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(new ParticleItem(GOLDEN_SWORD, "PARTICLE_EVENT_WARGEARCLASH", "PARTICLE_UNLOCKED_BY_WARGEARCLASH_PLACEMENT"), Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.1, WingParticle.WingDesign.SWORD_CROSSED))), ; public static EventParticlePlacement[] particles = values(); diff --git a/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java b/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java index 86fa05b..fc9d000 100644 --- a/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java +++ b/src/de/steamwar/lobby/particle/particles/ServerTeamParticle.java @@ -25,6 +25,7 @@ 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 lombok.AllArgsConstructor; import lombok.Getter; @@ -42,15 +43,15 @@ public enum ServerTeamParticle implements ParticleEnum { 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))), + 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))), + 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, 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)))), @@ -61,6 +62,7 @@ public enum ServerTeamParticle implements ParticleEnum { 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))), ; public static ParticleEnum[] particles = values(); From 67d094a2b11246d201104799b46b599899b81298 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 17:36:58 +0100 Subject: [PATCH 19/38] Optimize stuff client side --- .../lobby/particle/DustSimpleParticle.java | 18 +++++++----------- .../lobby/particle/SimpleParticle.java | 16 +++++++++++----- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/de/steamwar/lobby/particle/DustSimpleParticle.java b/src/de/steamwar/lobby/particle/DustSimpleParticle.java index 533b889..417b6ad 100644 --- a/src/de/steamwar/lobby/particle/DustSimpleParticle.java +++ b/src/de/steamwar/lobby/particle/DustSimpleParticle.java @@ -19,6 +19,7 @@ package de.steamwar.lobby.particle; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Particle; @@ -41,16 +42,6 @@ public class DustSimpleParticle implements BaseParticle { this.time = time; } - public DustSimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time, int count) { - this.particleItem = particleItem; - this.particle = particle; - this.vx = vx; - this.vy = vy; - this.vz = vz; - this.time = time; - this.count = count; - } - @Override public ParticleItem getItem() { return particleItem; @@ -59,6 +50,11 @@ public class DustSimpleParticle implements BaseParticle { @Override public void particle(ParticleData particleData) { Location location = particleData.getLocation().add(0.0, 0.2, 0.0); - particleData.getWorld().spawnParticle(particle, location, count, vx, vy, vz, time, getParticleDust()); + 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/SimpleParticle.java b/src/de/steamwar/lobby/particle/SimpleParticle.java index 5b9d657..0f42271 100644 --- a/src/de/steamwar/lobby/particle/SimpleParticle.java +++ b/src/de/steamwar/lobby/particle/SimpleParticle.java @@ -19,6 +19,7 @@ package de.steamwar.lobby.particle; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Particle; @@ -67,10 +68,15 @@ public class SimpleParticle implements BaseParticle { @Override public void particle(ParticleData particleData) { Location location = particleData.getLocation().add(0.0, 0.2, 0.0); - if (customVelocity) { - particleData.getWorld().spawnParticle(particle, location, count, vx, vy, vz, time); - } else { - particleData.getWorld().spawnParticle(particle, location, count); - } + 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); + } + } + }); } } From 9891dcc21476002991f5d9140a74e5643f9cbb74 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 22:18:04 +0100 Subject: [PATCH 20/38] Add initial TeamPlayer --- src/de/steamwar/lobby/LobbySystem.java | 6 + .../steamwar/lobby/display/Displayable.java | 22 +++- src/de/steamwar/lobby/display/NPC.java | 31 ++++- src/de/steamwar/lobby/team/TeamPlayer.java | 117 ++++++++++++++++++ 4 files changed, 169 insertions(+), 7 deletions(-) create mode 100644 src/de/steamwar/lobby/team/TeamPlayer.java diff --git a/src/de/steamwar/lobby/LobbySystem.java b/src/de/steamwar/lobby/LobbySystem.java index 977188a..0655238 100644 --- a/src/de/steamwar/lobby/LobbySystem.java +++ b/src/de/steamwar/lobby/LobbySystem.java @@ -24,6 +24,7 @@ import de.steamwar.lobby.command.FlyCommand; import de.steamwar.lobby.command.HologramCommand; import de.steamwar.lobby.command.PortalCommand; import de.steamwar.lobby.listener.*; +import de.steamwar.lobby.team.TeamPlayer; import de.steamwar.message.Message; import org.bukkit.plugin.java.JavaPlugin; @@ -56,6 +57,7 @@ public class LobbySystem extends JavaPlugin { new ParticleListener(); new InventoryInteraction(); new WorldInteraction(); + new TeamPlayer(); new AlphaWall(l -> l.getX() > 1199, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X); @@ -64,6 +66,10 @@ public class LobbySystem extends JavaPlugin { } + @Override + public void onDisable() { + TeamPlayer.cleanup(); + } public static LobbySystem getPlugin() { return plugin; diff --git a/src/de/steamwar/lobby/display/Displayable.java b/src/de/steamwar/lobby/display/Displayable.java index 0d7b272..327b83d 100644 --- a/src/de/steamwar/lobby/display/Displayable.java +++ b/src/de/steamwar/lobby/display/Displayable.java @@ -38,24 +38,34 @@ public class Displayable extends BasicListener { private final Set visible = new HashSet<>(); - private final int chunkX; - private final int chunkZ; + private int chunkX; + private int chunkZ; private final Consumer show; private final Consumer hide; + private final Consumer move; private final Function playerFilter; - public Displayable(Location location, Consumer show, Consumer hide) { - this(location, show, hide, player -> true); + public Displayable(Location location, Consumer show, Consumer hide, Consumer move) { + this(location, show, hide, move, player -> true); } public Displayable(Location location, Consumer show, Consumer hide, Function playerFilter) { - this.chunkX = posToChunk(location.getX()); - this.chunkZ = posToChunk(location.getZ()); + this(location, show, hide, player -> {}, playerFilter); + } + + public Displayable(Location location, Consumer show, Consumer hide, Consumer move, Function playerFilter) { this.show = show; this.hide = hide; + this.move = move; this.playerFilter = playerFilter; + setLocation(location); + } + public void setLocation(Location location) { + chunkX = posToChunk(location.getX()); + chunkZ = posToChunk(location.getZ()); Bukkit.getOnlinePlayers().forEach(this::checkLocation); + visible.forEach(move); } public Set getVisitors() { diff --git a/src/de/steamwar/lobby/display/NPC.java b/src/de/steamwar/lobby/display/NPC.java index 4a56d02..e24c3f2 100644 --- a/src/de/steamwar/lobby/display/NPC.java +++ b/src/de/steamwar/lobby/display/NPC.java @@ -62,6 +62,15 @@ public class NPC { private static final Reflection.ConstructorInvoker headRotationConstructor = Reflection.getConstructor(headRotationPacket); private static final Reflection.FieldAccessor headRotationEntity = Reflection.getField(headRotationPacket, int.class, 0); private static final Reflection.FieldAccessor headRotationYaw = Reflection.getField(headRotationPacket, byte.class, 0); + private static final Class movePacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport"); + private static final Reflection.ConstructorInvoker movePacketConstructor = Reflection.getConstructor(movePacket); + private static final Reflection.FieldAccessor movePacketEntity = Reflection.getField(movePacket, int.class, 0); + private static final Reflection.FieldAccessor movePacketX = Reflection.getField(movePacket, double.class, 0); + private static final Reflection.FieldAccessor movePacketY = Reflection.getField(movePacket, double.class, 1); + private static final Reflection.FieldAccessor movePacketZ = Reflection.getField(movePacket, double.class, 2); + private static final Reflection.FieldAccessor movePacketYaw = Reflection.getField(movePacket, byte.class, 0); + private static final Reflection.FieldAccessor movePacketPitch = Reflection.getField(movePacket, byte.class, 1); + private static final Reflection.FieldAccessor movePacketOnGround = Reflection.getField(movePacket, boolean.class, 0); private final Displayable display; @@ -75,6 +84,7 @@ public class NPC { private final Object headRotation; private final Object removePlayerInfo; private final Object destroy; + private Object move; public NPC(Location location, UUID uuid, String name) { this.entityId = Hologram.createEntityId(); @@ -101,7 +111,21 @@ public class NPC { headRotationEntity.set(headRotation, entityId); headRotationYaw.set(headRotation, yaw); - display = new Displayable(location, this::show, this::hide); + display = new Displayable(location, this::show, this::hide, this::move); + } + + public void setLocation(Location location) { + byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0); + headRotationYaw.set(headRotation, yaw); + move = movePacketConstructor.invoke(); + movePacketEntity.set(move, entityId); + movePacketX.set(move, location.getX()); + movePacketY.set(move, location.getY()); + movePacketZ.set(move, location.getZ()); + movePacketYaw.set(move, yaw); + movePacketPitch.set(move, (byte)(int)(location.getPitch() * 256.0 / 360.0)); + movePacketOnGround.set(move, true); + display.setLocation(location); } public Location getLocation() { @@ -123,6 +147,11 @@ public class NPC { TinyProtocol.instance.sendPacket(player, destroy); } + private void move(Player player) { + TinyProtocol.instance.sendPacket(player, headRotation); + TinyProtocol.instance.sendPacket(player, move); + } + public void delete() { display.delete(); } diff --git a/src/de/steamwar/lobby/team/TeamPlayer.java b/src/de/steamwar/lobby/team/TeamPlayer.java new file mode 100644 index 0000000..047c69a --- /dev/null +++ b/src/de/steamwar/lobby/team/TeamPlayer.java @@ -0,0 +1,117 @@ +/* + * 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.team; + +import de.steamwar.lobby.LobbySystem; +import de.steamwar.lobby.display.NPC; +import de.steamwar.lobby.listener.BasicListener; +import de.steamwar.sql.SteamwarUser; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Villager; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityInteractEvent; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import java.util.HashMap; +import java.util.Map; + +public class TeamPlayer extends BasicListener { + + private static Map entities = new HashMap<>(); + + public static void spawnTeamPlayer(World world, String name) { + Location location = new Location(world, 1524.5, 52, 1493.5); + NPC npc = new NPC(location, SteamwarUser.get(name).getUUID(), name); + Villager villager = (Villager) world.spawnEntity(location, EntityType.VILLAGER); + villager.setSilent(true); + villager.setInvulnerable(true); + villager.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false, false)); + villager.setCustomName(name); + villager.setProfession(Villager.Profession.NITWIT); + entities.put(villager, npc); + } + + public static void cleanup() { + entities.forEach((entity, npc) -> entity.remove()); + } + + { + World world = Bukkit.getWorld("Lobby"); + for (int x = -10; x < 10; x++) { + for (int z = -10; z < 10; z++) { + world.setChunkForceLoaded(95 + x , 93 + z, true); + } + } + world.getEntitiesByClasses(Villager.class).forEach(Entity::remove); + for (int x = -10; x < 10; x++) { + for (int z = -10; z < 10; z++) { + world.setChunkForceLoaded(95 + x , 93 + z, true); + } + } + spawnTeamPlayer(world, "AdmiralSeekrank"); + spawnTeamPlayer(world, "SalzgehaltSensei"); + spawnTeamPlayer(world, "Sehfxhler"); + spawnTeamPlayer(world, "Tim7077"); + spawnTeamPlayer(world, "LordMainex"); + spawnTeamPlayer(world, "Lixi266"); + spawnTeamPlayer(world, "PxlPain"); + spawnTeamPlayer(world, "KopFilme"); + spawnTeamPlayer(world, "Lixfel"); + spawnTeamPlayer(world, "Chaoscaot"); + spawnTeamPlayer(world, "YoyoNow"); + spawnTeamPlayer(world, "Zeanon"); + spawnTeamPlayer(world, "zOnlyKroks"); + spawnTeamPlayer(world, "Legula"); + spawnTeamPlayer(world, "xJoul"); + spawnTeamPlayer(world, "Maybe_Creative"); + spawnTeamPlayer(world, "Tim16227"); + spawnTeamPlayer(world, "FoehnX"); + spawnTeamPlayer(world, "_Noerf_"); + spawnTeamPlayer(world, "Edmund_Strong"); + spawnTeamPlayer(world, "TheBreadBeard"); + spawnTeamPlayer(world, "Basic_Redstone"); + + Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { + entities.forEach((entity, npc) -> { + npc.setLocation(entity.getLocation()); + }); + }, 1L, 1L); + } + + @EventHandler + public void onEntityInteract(EntityInteractEvent event) { + if (event.getEntityType() == EntityType.VILLAGER) { + event.setCancelled(true); + } + } + + @EventHandler + public void onEntityDamage(EntityDamageEvent event) { + if (event.getEntityType() == EntityType.VILLAGER) { + event.setCancelled(true); + } + } +} From 5ae38b6d3e91ddb2dc28b915f0734f3669ba7429 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 22:48:30 +0100 Subject: [PATCH 21/38] Fix NPC.hide --- src/de/steamwar/lobby/display/NPC.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/lobby/display/NPC.java b/src/de/steamwar/lobby/display/NPC.java index e24c3f2..8e0e6e5 100644 --- a/src/de/steamwar/lobby/display/NPC.java +++ b/src/de/steamwar/lobby/display/NPC.java @@ -22,6 +22,8 @@ package de.steamwar.lobby.display; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import com.mojang.authlib.GameProfile; +import de.steamwar.lobby.LobbySystem; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -143,7 +145,9 @@ public class NPC { } private void hide(Player player) { - TinyProtocol.instance.sendPacket(player, removePlayerInfo); + if (Bukkit.getOnlinePlayers().stream().noneMatch(p -> p.getUniqueId().equals(uuid))) { + TinyProtocol.instance.sendPacket(player, removePlayerInfo); + } TinyProtocol.instance.sendPacket(player, destroy); } From 1cca911153c1d9c2afa45082ad63d9753ef6b33b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 25 Mar 2022 23:11:35 +0100 Subject: [PATCH 22/38] Implement skinparts (not working) --- src/de/steamwar/lobby/display/NPC.java | 42 +++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/lobby/display/NPC.java b/src/de/steamwar/lobby/display/NPC.java index 8e0e6e5..9907f16 100644 --- a/src/de/steamwar/lobby/display/NPC.java +++ b/src/de/steamwar/lobby/display/NPC.java @@ -22,11 +22,12 @@ package de.steamwar.lobby.display; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import com.mojang.authlib.GameProfile; -import de.steamwar.lobby.LobbySystem; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; import java.util.Collections; import java.util.List; import java.util.UUID; @@ -74,6 +75,41 @@ public class NPC { private static final Reflection.FieldAccessor movePacketPitch = Reflection.getField(movePacket, byte.class, 1); private static final Reflection.FieldAccessor movePacketOnGround = Reflection.getField(movePacket, boolean.class, 0); + private static final Class dataWatcherObject = Reflection.getClass("{nms.network.syncher}.DataWatcherObject"); + private static final Class dataWatcherRegistry = Reflection.getClass("{nms.network.syncher}.DataWatcherRegistry"); + private static final Class dataWatcherSerializer = Reflection.getClass("{nms.network.syncher}.DataWatcherSerializer"); + private static final Reflection.ConstructorInvoker dataWatcherObjectConstructor = Reflection.getConstructor(dataWatcherObject, int.class, dataWatcherSerializer); + private static Object getDataWatcherObject(int index, Class type) { + for(Field field : dataWatcherRegistry.getFields()) { + if(dataWatcherSerializer.isAssignableFrom(field.getType()) && type.equals(((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0])) { + try { + return dataWatcherObjectConstructor.invoke(index, field.get(null)); + } catch (IllegalAccessException e) { + throw new SecurityException("Could not get field", e); + } + } + } + throw new SecurityException("Could not find Serializer for " + type.getName()); + } + + private static final Class item = Reflection.getClass("{nms.network.syncher}.DataWatcher$Item"); + private static final Reflection.ConstructorInvoker itemConstructor = Reflection.getConstructor(item, dataWatcherObject, Object.class); + private static Object getDataWatcherItem(Object dwo, Object value) { + return itemConstructor.invoke(dwo, value); + } + + private static final Class metadataPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityMetadata"); + private static final Reflection.FieldAccessor metadataEntity = Reflection.getField(metadataPacket, int.class, 0); + private static final Reflection.FieldAccessor metadataMetadata = Reflection.getField(metadataPacket, List.class, 0); + private Object getDataWatcherPacket(Object dataWatcherObject, Object value) { + Object packet = Reflection.newInstance(metadataPacket); + metadataEntity.set(packet, entityId); + metadataMetadata.set(packet, Collections.singletonList(getDataWatcherItem(dataWatcherObject, value))); + return packet; + } + + private static Object skinPartsDataWatcherObject = getDataWatcherObject(17, Byte.class); + private final Displayable display; private final int entityId; @@ -83,6 +119,7 @@ public class NPC { private final Object addPlayerInfo; private final Object namedSpawn; + private final Object skinParts; private final Object headRotation; private final Object removePlayerInfo; private final Object destroy; @@ -100,6 +137,8 @@ public class NPC { removePlayerInfo = playerInfoPacket(removePlayer, profile); destroy = Hologram.destroyPacket(entityId); + skinParts = getDataWatcherPacket(skinPartsDataWatcherObject, (byte) 0xFF); + namedSpawn = namedSpawnConstructor.invoke(); namedSpawnEntity.set(namedSpawn, entityId); namedSpawnUUID.set(namedSpawn, uuid); @@ -142,6 +181,7 @@ public class NPC { TinyProtocol.instance.sendPacket(player, addPlayerInfo); TinyProtocol.instance.sendPacket(player, namedSpawn); TinyProtocol.instance.sendPacket(player, headRotation); + TinyProtocol.instance.sendPacket(player, skinParts); } private void hide(Player player) { From deac3a2b40a0270bf4e70508a34869470cf79aa7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 08:30:39 +0100 Subject: [PATCH 23/38] Fix NPC --- src/de/steamwar/lobby/display/NPC.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/lobby/display/NPC.java b/src/de/steamwar/lobby/display/NPC.java index 9907f16..a3b9de8 100644 --- a/src/de/steamwar/lobby/display/NPC.java +++ b/src/de/steamwar/lobby/display/NPC.java @@ -137,7 +137,7 @@ public class NPC { removePlayerInfo = playerInfoPacket(removePlayer, profile); destroy = Hologram.destroyPacket(entityId); - skinParts = getDataWatcherPacket(skinPartsDataWatcherObject, (byte) 0xFF); + skinParts = getDataWatcherPacket(skinPartsDataWatcherObject, (byte) 0x7F); namedSpawn = namedSpawnConstructor.invoke(); namedSpawnEntity.set(namedSpawn, entityId); From 1fb0b119aafba92a5a4cb0ecf4c30939d6602844 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 11:02:58 +0100 Subject: [PATCH 24/38] Update stuff --- src/de/steamwar/lobby/LobbySystem.properties | 42 +++++++++---------- .../steamwar/lobby/particle/BaseParticle.java | 19 +++++++++ 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 79006d0..9988ce6 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -16,12 +16,12 @@ PARTICLE_INVENTORY = §6Partikel PARTICLE_DESELECT = §8Keine Partikel PARTICLE_LOCKED = {0} §8- §c§lGesperrt -PARTICLE_UNLOCKED_BY_TEAM = §fTeam Beitritt -PARTICLE_UNLOCKED_BY_EVENT = §fEvent Teilnahme -PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServer Team +PARTICLE_UNLOCKED_BY_TEAM = §fTeambeitritt +PARTICLE_UNLOCKED_BY_EVENT = §fEventteilnahme +PARTICLE_UNLOCKED_BY_SERVER_TEAM = §fServerteam PARTICLE_ATTRIBUTE_CIRCLE = §8-§f Ring -PARTICLE_ATTRIBUTE_BI_CIRCLE = §8-§f Doppel 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 @@ -30,7 +30,7 @@ PARTICLE_ATTRIBUTE = §eAttribute§7: PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch -PARTICLE_SELECT = §eKlicken zum auswählen +PARTICLE_SELECT = §eZum Auswählen klicken PARTICLE_SNEEZE = §aSneeze PARTICLE_SMOKE = §7Smoke @@ -39,32 +39,32 @@ PARTICLE_WATER = §bWasser PARTICLE_HEART = §cHerzen PARTICLE_NOTES = §eNoten PARTICLE_NAUTILUS = §aNautilus -PARTICLE_SNOWBALL = §fSnowball +PARTICLE_SNOWBALL = §fSchneeball PARTICLE_EFFECT = §5Effekt PARTICLE_CAMPFIRE = §7Rauch PARTICLE_MAGIC = §5Magie PARTICLE_ANGRY = §4Wut PARTICLE_SLIME = §aSchleim PARTICLE_MOB = §7Mob -PARTICLE_SQUID = §8Squid -PARTICLE_BUBBLE = §aBubble -PARTICLE_HONEY = §6Honey -PARTICLE_NECTAR = §6Nectar -PARTICLE_FIREWORK = §7Firework -PARTICLE_DRAGON_BREATH = §5Dragon Breath -PARTICLE_DAMAGE = §5Damage -PARTICLE_DOLPHIN = §dDolphin +PARTICLE_SQUID = §8Tintenfisch +PARTICLE_BUBBLE = §aBlasen +PARTICLE_HONEY = §6Honig +PARTICLE_NECTAR = §6Nekter +PARTICLE_FIREWORK = §7Feuerwerk +PARTICLE_DRAGON_BREATH = §5Drachen Atem +PARTICLE_DAMAGE = §5Schaden +PARTICLE_DOLPHIN = §dDelphin PARTICLE_WITCH = §5Hexe PARTICLE_ENCHANTING = §eZauber PARTICLE_HAPPY = §2Freude PARTICLE_FLAME = §7Flammen PARTICLE_END_ROD = §fEnd Rod -PARTICLE_CLOUD = §7Cloud +PARTICLE_CLOUD = §7Wolke PARTICLE_TOTEM = §aTotem PARTICLE_TOWN = §5Town -PARTICLE_ENCHANTING_CIRCLE = §fEnchanted -PARTICLE_WATER_FIRE = §bWater§7/§cFire -PARTICLE_MAGIC_ENCHANTING = §5Magic§7/§eZauber +PARTICLE_ENCHANTING_CIRCLE = §fVerzaubert +PARTICLE_WATER_FIRE = §bWasser§7/§cFeuer +PARTICLE_MAGIC_ENCHANTING = §5Magie§7/§eZauber PARTICLE_WINGS_EVIL = §5Lila Flügel PARTICLE_UNLOCKED_BY_WGS_PLACEMENT = §fWarGearSeason 1., 2. oder 3. Platz @@ -89,10 +89,10 @@ PARTICLE_UNLOCKED_BY_WARGEARCLASH_PLACEMENT = §fWargearClash 1., 2. oder 3. Pla PARTICLE_UNLOCKED_BY_WARGEARCLASH = §fWargearClash PARTICLE_EVENT_ENCHANTING = §cVerzaubert -PARTICLE_EVENT_CLOUD = §fCloud -PARTICLE_EVENT_SMOKE = §7Smoke +PARTICLE_EVENT_CLOUD = §fWolken +PARTICLE_EVENT_SMOKE = §7Rauch PARTICLE_EVENT_WATER = §bWasser -PARTICLE_EVENT_WINGS = §fWings +PARTICLE_EVENT_WINGS = §fFlügel PARTICLE_EVENT_RAIN_CLOUD = §fRegenwolke PARTICLE_EVENT_WGS = §fWGS PARTICLE_EVENT_WARGEARCLASH = §fClash \ No newline at end of file diff --git a/src/de/steamwar/lobby/particle/BaseParticle.java b/src/de/steamwar/lobby/particle/BaseParticle.java index 9545282..9d1a183 100644 --- a/src/de/steamwar/lobby/particle/BaseParticle.java +++ b/src/de/steamwar/lobby/particle/BaseParticle.java @@ -1,3 +1,22 @@ +/* + * 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; From 0f293773d80676a27c5ec00edaf871b5c5d22d9b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 11:14:55 +0100 Subject: [PATCH 25/38] Add EventParticleItem --- src/de/steamwar/lobby/LobbySystem.properties | 22 +----- .../lobby/particle/EventParticleItem.java | 74 +++++++++++++++++++ .../steamwar/lobby/particle/ParticleItem.java | 8 +- .../particles/EventParticleParticipation.java | 17 +++-- .../particles/EventParticlePlacement.java | 22 +++--- 5 files changed, 100 insertions(+), 43 deletions(-) create mode 100644 src/de/steamwar/lobby/particle/EventParticleItem.java diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 9988ce6..3308f32 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -67,26 +67,8 @@ PARTICLE_WATER_FIRE = §bWasser§7/§cFeuer PARTICLE_MAGIC_ENCHANTING = §5Magie§7/§eZauber PARTICLE_WINGS_EVIL = §5Lila Flügel -PARTICLE_UNLOCKED_BY_WGS_PLACEMENT = §fWarGearSeason 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_WGS = §fWarGearSeason -PARTICLE_UNLOCKED_BY_AIRSHIPEVENT_PLACEMENT = §fAirshipEvent 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_AIRSHIPEVENT = §fAirshipEvent -PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT = §fHellsBells 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_HELLSBELLS = §fHellsBells -PARTICLE_UNLOCKED_BY_UNDERWATER_PLACEMENT = §fUnderwater 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_UNDERWATER = §fUnderwater -PARTICLE_UNLOCKED_BY_ADVENTWARSHIP_PLACEMENT = §fAdvent-WarShip 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_ADVENTWARSHIP = §fAdvent-WarShip -PARTICLE_UNLOCKED_BY_MWGL_PLACEMENT = §fMiniWarGearLiga 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_MWGL = §fMiniWarGearLiga -PARTICLE_UNLOCKED_BY_ABSTURZ_PLACEMENT = §fAbsturz 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_ABSTURZ = §fAbsturz -PARTICLE_UNLOCKED_BY_UNDERWATERMWG_PLACEMENT = §fUnderwaterMWG 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_UNDERWATERMWG = §fUnderwaterMWG -PARTICLE_UNLOCKED_BY_WGS22_PLACEMENT = §fWarGearSeason 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_WGS22 = §fWarGearSeason -PARTICLE_UNLOCKED_BY_WARGEARCLASH_PLACEMENT = §fWargearClash 1., 2. oder 3. Platz -PARTICLE_UNLOCKED_BY_WARGEARCLASH = §fWargearClash +PARTICLE_UNLOCKED_BY_EVENT_PLACEMENT = §f{0} 1., 2. oder 3. Platz +PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION = §f{0} PARTICLE_EVENT_ENCHANTING = §cVerzaubert PARTICLE_EVENT_CLOUD = §fWolken diff --git a/src/de/steamwar/lobby/particle/EventParticleItem.java b/src/de/steamwar/lobby/particle/EventParticleItem.java new file mode 100644 index 0000000..2c679b9 --- /dev/null +++ b/src/de/steamwar/lobby/particle/EventParticleItem.java @@ -0,0 +1,74 @@ +/* + * 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/ParticleItem.java b/src/de/steamwar/lobby/particle/ParticleItem.java index e6638d1..50744d9 100644 --- a/src/de/steamwar/lobby/particle/ParticleItem.java +++ b/src/de/steamwar/lobby/particle/ParticleItem.java @@ -33,10 +33,10 @@ import java.util.Set; @RequiredArgsConstructor public class ParticleItem { - private final Material material; - private final String name; - private final Set attributes = new LinkedHashSet<>(); - private String unlockedBy; + 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; diff --git a/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java b/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java index 925c357..83689ac 100644 --- a/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java +++ b/src/de/steamwar/lobby/particle/particles/EventParticleParticipation.java @@ -20,6 +20,7 @@ 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; @@ -37,15 +38,15 @@ import static org.bukkit.Material.*; @Getter public enum EventParticleParticipation implements ParticleEnum { - WarGearSeason(22, new SimpleParticle(new ParticleItem(BOOK, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS"), Particle.ENCHANTMENT_TABLE)), - AirshipEvent(26, new SimpleParticle(new ParticleItem(SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT"), Particle.CLOUD)), - HellsBellsWs(28, new CircleParticle(new SimpleParticle(new ParticleItem(TNT, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS"), Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))), - Underwater(31, new SimpleParticle(new ParticleItem(PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER"), Particle.DRIP_WATER)), - AdventWarShip(32, new ParticleGroup(new ParticleItem(PRISMARINE_WALL, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_ADVENTWARSHIP_PLACEMENT"), 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(new ParticleItem(PRISMARINE_SLAB, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_MWGL"), Particle.WATER_WAKE, 0, 0, 0, 0))), + 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(new ParticleItem(BLUE_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", "PARTICLE_UNLOCKED_BY_UNDERWATERMWG"), 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(new ParticleItem(DIAMOND_SWORD, "PARTICLE_EVENT_WINGS", "PARTICLE_UNLOCKED_BY_WGS22"), Particle.DRAGON_BREATH, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.COMPLEX))), + 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), ; public static EventParticleParticipation[] particles = values(); diff --git a/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java b/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java index 73e934c..662db20 100644 --- a/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java +++ b/src/de/steamwar/lobby/particle/particles/EventParticlePlacement.java @@ -20,7 +20,7 @@ package de.steamwar.lobby.particle.particles; import de.steamwar.lobby.particle.BaseParticle; -import de.steamwar.lobby.particle.ParticleItem; +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; @@ -38,16 +38,16 @@ import static org.bukkit.Material.*; @Getter public enum EventParticlePlacement implements ParticleEnum { - WarGearSeason(22, new int[]{12, 285, 54}, new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_EVENT_ENCHANTING", "PARTICLE_UNLOCKED_BY_WGS_PLACEMENT"), 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(new ParticleItem(SNOWBALL, "PARTICLE_EVENT_CLOUD", "PARTICLE_UNLOCKED_BY_AIRSHIPEVENT_PLACEMENT"), 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(new ParticleItem(TNT_MINECART, "PARTICLE_EVENT_SMOKE", "PARTICLE_UNLOCKED_BY_HELLSBELLS_PLACEMENT"), 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(new ParticleItem(PRISMARINE_SHARD, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_UNDERWATER_PLACEMENT"), Particle.DRIP_WATER))), - AdventWarShip(32, new int[]{9, 205, 210}, new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleGroup(new ParticleItem(PRISMARINE_CRYSTALS, "PARTICLE_EVENT_WATER", "PARTICLE_UNLOCKED_BY_ADVENTWARSHIP"), 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(new ParticleItem(IRON_SWORD, "PARTICLE_EVENT_WINGS", "PARTICLE_UNLOCKED_BY_MWGL_PLACEMENT"), Particle.WATER_WAKE, 0, 0, 0, 0, 1), 0.05, WingParticle.WingDesign.SWORD))), - Absturz(34, new int[]{210, 205, 527, 286}, new TickParticle(new WingParticle(new SimpleParticle(new ParticleItem(FEATHER, "PARTICLE_EVENT_WINGS", "PARTICLE_UNLOCKED_BY_ABSTURZ_PLACEMENT"), 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(new ParticleItem(CYAN_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", "PARTICLE_UNLOCKED_BY_UNDERWATERMWG_PLACEMENT"), Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.SW))), - WarGearSeason2022(37, new int[]{}, new TickParticle(new WingParticle(new SimpleParticle(new ParticleItem(DIAMOND_HELMET, "PARTICLE_EVENT_WGS", "PARTICLE_UNLOCKED_BY_WGS22_PLACEMENT"), 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(new ParticleItem(GOLDEN_SWORD, "PARTICLE_EVENT_WARGEARCLASH", "PARTICLE_UNLOCKED_BY_WARGEARCLASH_PLACEMENT"), Particle.CRIT_MAGIC, 0, 0, 0, 0, 1), 0.1, WingParticle.WingDesign.SWORD_CROSSED))), + 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.05, WingParticle.WingDesign.SWORD))), + 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[]{}, 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))), ; public static EventParticlePlacement[] particles = values(); From 4ac8aebaa73017095f6a764a3e252c75da13030f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 11:38:22 +0100 Subject: [PATCH 26/38] Fix NPC Fix TeamPlayer spawnlocation --- src/de/steamwar/lobby/display/NPC.java | 4 +++- src/de/steamwar/lobby/team/TeamPlayer.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/lobby/display/NPC.java b/src/de/steamwar/lobby/display/NPC.java index a3b9de8..6c0b563 100644 --- a/src/de/steamwar/lobby/display/NPC.java +++ b/src/de/steamwar/lobby/display/NPC.java @@ -178,7 +178,9 @@ public class NPC { } private void show(Player player) { - TinyProtocol.instance.sendPacket(player, addPlayerInfo); + if (Bukkit.getOnlinePlayers().stream().noneMatch(p -> p.getUniqueId().equals(uuid))) { + TinyProtocol.instance.sendPacket(player, addPlayerInfo); + } TinyProtocol.instance.sendPacket(player, namedSpawn); TinyProtocol.instance.sendPacket(player, headRotation); TinyProtocol.instance.sendPacket(player, skinParts); diff --git a/src/de/steamwar/lobby/team/TeamPlayer.java b/src/de/steamwar/lobby/team/TeamPlayer.java index 047c69a..3b37196 100644 --- a/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/src/de/steamwar/lobby/team/TeamPlayer.java @@ -43,7 +43,7 @@ public class TeamPlayer extends BasicListener { private static Map entities = new HashMap<>(); public static void spawnTeamPlayer(World world, String name) { - Location location = new Location(world, 1524.5, 52, 1493.5); + Location location = new Location(world, 1524.5, 52, 1481.5); NPC npc = new NPC(location, SteamwarUser.get(name).getUUID(), name); Villager villager = (Villager) world.spawnEntity(location, EntityType.VILLAGER); villager.setSilent(true); From 55b1a26b6a3d030db72b1fd8e4305d5cfabfcf93 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 12:02:03 +0100 Subject: [PATCH 27/38] Update TeamPlayer --- src/de/steamwar/lobby/team/TeamPlayer.java | 48 +++++++--------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/src/de/steamwar/lobby/team/TeamPlayer.java b/src/de/steamwar/lobby/team/TeamPlayer.java index 3b37196..cad19f6 100644 --- a/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/src/de/steamwar/lobby/team/TeamPlayer.java @@ -58,41 +58,23 @@ public class TeamPlayer extends BasicListener { entities.forEach((entity, npc) -> entity.remove()); } + private void forceLoad(World world, boolean setTo) { + for (int x = -10; x < 10; x++) { + for (int z = -10; z < 10; z++) { + world.setChunkForceLoaded(95 + x , 93 + z, setTo); + } + } + } + { - World world = Bukkit.getWorld("Lobby"); - for (int x = -10; x < 10; x++) { - for (int z = -10; z < 10; z++) { - world.setChunkForceLoaded(95 + x , 93 + z, true); - } - } + World world = Bukkit.getWorlds().get(0); + forceLoad(world, true); world.getEntitiesByClasses(Villager.class).forEach(Entity::remove); - for (int x = -10; x < 10; x++) { - for (int z = -10; z < 10; z++) { - world.setChunkForceLoaded(95 + x , 93 + z, true); - } - } - spawnTeamPlayer(world, "AdmiralSeekrank"); - spawnTeamPlayer(world, "SalzgehaltSensei"); - spawnTeamPlayer(world, "Sehfxhler"); - spawnTeamPlayer(world, "Tim7077"); - spawnTeamPlayer(world, "LordMainex"); - spawnTeamPlayer(world, "Lixi266"); - spawnTeamPlayer(world, "PxlPain"); - spawnTeamPlayer(world, "KopFilme"); - spawnTeamPlayer(world, "Lixfel"); - spawnTeamPlayer(world, "Chaoscaot"); - spawnTeamPlayer(world, "YoyoNow"); - spawnTeamPlayer(world, "Zeanon"); - spawnTeamPlayer(world, "zOnlyKroks"); - spawnTeamPlayer(world, "Legula"); - spawnTeamPlayer(world, "xJoul"); - spawnTeamPlayer(world, "Maybe_Creative"); - spawnTeamPlayer(world, "Tim16227"); - spawnTeamPlayer(world, "FoehnX"); - spawnTeamPlayer(world, "_Noerf_"); - spawnTeamPlayer(world, "Edmund_Strong"); - spawnTeamPlayer(world, "TheBreadBeard"); - spawnTeamPlayer(world, "Basic_Redstone"); + forceLoad(world, false); + + SteamwarUser.getServerTeam().forEach(user -> { + spawnTeamPlayer(world, user.getUserName()); + }); Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { entities.forEach((entity, npc) -> { From 14c3be143df5778899ea24cca28772ca9be00934 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 13:33:44 +0100 Subject: [PATCH 28/38] Fix skin overlays --- src/de/steamwar/lobby/display/NPC.java | 14 ++++++---- src/de/steamwar/lobby/team/TeamPlayer.java | 30 ++++++++++++++-------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/de/steamwar/lobby/display/NPC.java b/src/de/steamwar/lobby/display/NPC.java index 6c0b563..39c7dc1 100644 --- a/src/de/steamwar/lobby/display/NPC.java +++ b/src/de/steamwar/lobby/display/NPC.java @@ -22,8 +22,13 @@ package de.steamwar.lobby.display; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import com.mojang.authlib.GameProfile; +import net.minecraft.server.v1_15_R1.DataWatcher; +import net.minecraft.server.v1_15_R1.DataWatcherRegistry; +import net.minecraft.server.v1_15_R1.EntityHuman; +import net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata; import org.bukkit.Bukkit; import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import java.lang.reflect.Field; @@ -108,14 +113,14 @@ public class NPC { return packet; } - private static Object skinPartsDataWatcherObject = getDataWatcherObject(17, Byte.class); + private static Object skinPartsDataWatcherObject = getDataWatcherObject(16, Byte.class); private final Displayable display; private final int entityId; private final UUID uuid; private final String name; - private final Location location; + private Location location; private final Object addPlayerInfo; private final Object namedSpawn; @@ -156,6 +161,7 @@ public class NPC { } public void setLocation(Location location) { + this.location = location; byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0); headRotationYaw.set(headRotation, yaw); move = movePacketConstructor.invoke(); @@ -178,9 +184,7 @@ public class NPC { } private void show(Player player) { - if (Bukkit.getOnlinePlayers().stream().noneMatch(p -> p.getUniqueId().equals(uuid))) { - TinyProtocol.instance.sendPacket(player, addPlayerInfo); - } + TinyProtocol.instance.sendPacket(player, addPlayerInfo); TinyProtocol.instance.sendPacket(player, namedSpawn); TinyProtocol.instance.sendPacket(player, headRotation); TinyProtocol.instance.sendPacket(player, skinParts); diff --git a/src/de/steamwar/lobby/team/TeamPlayer.java b/src/de/steamwar/lobby/team/TeamPlayer.java index cad19f6..b45ed6e 100644 --- a/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/src/de/steamwar/lobby/team/TeamPlayer.java @@ -37,28 +37,33 @@ import org.bukkit.potion.PotionEffectType; import java.util.HashMap; import java.util.Map; +import java.util.logging.Level; public class TeamPlayer extends BasicListener { - private static Map entities = new HashMap<>(); + private static final World world = Bukkit.getWorlds().get(0); + private static final Map entities = new HashMap<>(); - public static void spawnTeamPlayer(World world, String name) { - Location location = new Location(world, 1524.5, 52, 1481.5); - NPC npc = new NPC(location, SteamwarUser.get(name).getUUID(), name); + public static void spawnTeamPlayer(World world, SteamwarUser steamwarUser) { + Location location = new Location(world, 1524.5, 52, 1484.5); + String name = steamwarUser.getUserName(); + NPC npc = new NPC(location, steamwarUser.getUUID(), name); Villager villager = (Villager) world.spawnEntity(location, EntityType.VILLAGER); villager.setSilent(true); villager.setInvulnerable(true); villager.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false, false)); villager.setCustomName(name); villager.setProfession(Villager.Profession.NITWIT); - entities.put(villager, npc); + entities.put(name, npc); } public static void cleanup() { - entities.forEach((entity, npc) -> entity.remove()); + forceLoad(world, true); + world.getEntitiesByClasses(Villager.class).forEach(Entity::remove); + forceLoad(world, false); } - private void forceLoad(World world, boolean setTo) { + private static void forceLoad(World world, boolean setTo) { for (int x = -10; x < 10; x++) { for (int z = -10; z < 10; z++) { world.setChunkForceLoaded(95 + x , 93 + z, setTo); @@ -67,18 +72,21 @@ public class TeamPlayer extends BasicListener { } { - World world = Bukkit.getWorlds().get(0); forceLoad(world, true); world.getEntitiesByClasses(Villager.class).forEach(Entity::remove); forceLoad(world, false); SteamwarUser.getServerTeam().forEach(user -> { - spawnTeamPlayer(world, user.getUserName()); + spawnTeamPlayer(world, user); }); + LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players"); Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { - entities.forEach((entity, npc) -> { - npc.setLocation(entity.getLocation()); + world.getEntitiesByClasses(Villager.class).forEach(entity -> { + NPC npc = entities.get(entity.getName()); + if (npc != null) { + npc.setLocation(entity.getLocation()); + } }); }, 1L, 1L); } From be861b6bbf0cd8fb5f881670149c73b3dffef6a2 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 13:57:30 +0100 Subject: [PATCH 29/38] Fix packet stuff --- src/de/steamwar/lobby/display/NPC.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/de/steamwar/lobby/display/NPC.java b/src/de/steamwar/lobby/display/NPC.java index 39c7dc1..58b49ee 100644 --- a/src/de/steamwar/lobby/display/NPC.java +++ b/src/de/steamwar/lobby/display/NPC.java @@ -161,6 +161,9 @@ public class NPC { } public void setLocation(Location location) { + if (isSimilarLocation(location)) { + return; + } this.location = location; byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0); headRotationYaw.set(headRotation, yaw); @@ -175,6 +178,25 @@ public class NPC { display.setLocation(location); } + private boolean isSimilarLocation(Location location) { + if (Location.normalizeYaw(this.location.getYaw()) != Location.normalizeYaw(location.getYaw())) { + return false; + } + if (Location.normalizePitch(this.location.getPitch()) != Location.normalizePitch(location.getPitch())) { + return false; + } + if (Math.abs(this.location.getX() - location.getX()) > 0.1) { + return false; + } + if (Math.abs(this.location.getY() - location.getY()) > 0.1) { + return false; + } + if (Math.abs(this.location.getZ() - location.getZ()) > 0.1) { + return false; + } + return true; + } + public Location getLocation() { return location; } From c6beebed05c17484e43d16026ca4437735464038 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 14:38:39 +0100 Subject: [PATCH 30/38] Fix NPE --- src/de/steamwar/lobby/display/NPC.java | 4 ++- src/de/steamwar/lobby/team/TeamPlayer.java | 41 +++++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/lobby/display/NPC.java b/src/de/steamwar/lobby/display/NPC.java index 58b49ee..2040d5f 100644 --- a/src/de/steamwar/lobby/display/NPC.java +++ b/src/de/steamwar/lobby/display/NPC.java @@ -221,7 +221,9 @@ public class NPC { private void move(Player player) { TinyProtocol.instance.sendPacket(player, headRotation); - TinyProtocol.instance.sendPacket(player, move); + if (move != null) { + TinyProtocol.instance.sendPacket(player, move); + } } public void delete() { diff --git a/src/de/steamwar/lobby/team/TeamPlayer.java b/src/de/steamwar/lobby/team/TeamPlayer.java index b45ed6e..41fefb1 100644 --- a/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/src/de/steamwar/lobby/team/TeamPlayer.java @@ -23,6 +23,7 @@ import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.display.NPC; import de.steamwar.lobby.listener.BasicListener; import de.steamwar.sql.SteamwarUser; +import lombok.AllArgsConstructor; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; @@ -35,12 +36,37 @@ import org.bukkit.event.entity.EntityInteractEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.logging.Level; public class TeamPlayer extends BasicListener { + @AllArgsConstructor + private static class Cuboid { + private double x1; + private double y1; + private double z1; + private double x2; + private double y2; + private double z2; + + public boolean contains(Location location) { + return location.getX() >= x1 && location.getX() <= x2 && location.getY() >= y1 && location.getY() <= y2 && location.getZ() >= z1 && location.getZ() <= z2; + } + } + + private static final List cuboids = new ArrayList<>(); + static { + cuboids.add(new Cuboid(1509, 52, 1464, 1510, 58, 1469)); + cuboids.add(new Cuboid(1538, 52, 1464, 1539, 58, 1469)); + cuboids.add(new Cuboid(1518, 55, 1433, 1530, 60, 1434)); + cuboids.add(new Cuboid(1587, 52, 1471, 1588, 56, 1475)); + cuboids.add(new Cuboid(1479, 52, 1461, 1478, 56, 1463)); + } + private static final World world = Bukkit.getWorlds().get(0); private static final Map entities = new HashMap<>(); @@ -53,7 +79,7 @@ public class TeamPlayer extends BasicListener { villager.setInvulnerable(true); villager.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false, false, false)); villager.setCustomName(name); - villager.setProfession(Villager.Profession.NITWIT); + villager.setProfession(Villager.Profession.NONE); entities.put(name, npc); } @@ -85,12 +111,25 @@ public class TeamPlayer extends BasicListener { world.getEntitiesByClasses(Villager.class).forEach(entity -> { NPC npc = entities.get(entity.getName()); if (npc != null) { + if (illegalLocation(entity.getLocation())) { + entity.teleport(npc.getLocation()); + return; + } npc.setLocation(entity.getLocation()); } }); }, 1L, 1L); } + private boolean illegalLocation(Location location) { + for (Cuboid cuboid : cuboids) { + if (cuboid.contains(location)) { + return true; + } + } + return false; + } + @EventHandler public void onEntityInteract(EntityInteractEvent event) { if (event.getEntityType() == EntityType.VILLAGER) { From 1de921b7ffb7f12347f2302afd98e2f579eea28b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 15:40:51 +0100 Subject: [PATCH 31/38] Update TeamPlayer on DB update ever hour --- src/de/steamwar/lobby/display/NPC.java | 3 ++ src/de/steamwar/lobby/team/TeamPlayer.java | 37 ++++++++++++++++++---- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/lobby/display/NPC.java b/src/de/steamwar/lobby/display/NPC.java index 2040d5f..de0abfc 100644 --- a/src/de/steamwar/lobby/display/NPC.java +++ b/src/de/steamwar/lobby/display/NPC.java @@ -172,6 +172,9 @@ public class NPC { movePacketX.set(move, location.getX()); movePacketY.set(move, location.getY()); movePacketZ.set(move, location.getZ()); + namedSpawnX.set(namedSpawn, location.getX()); + namedSpawnY.set(namedSpawn, location.getY()); + namedSpawnZ.set(namedSpawn, location.getZ()); movePacketYaw.set(move, yaw); movePacketPitch.set(move, (byte)(int)(location.getPitch() * 256.0 / 360.0)); movePacketOnGround.set(move, true); diff --git a/src/de/steamwar/lobby/team/TeamPlayer.java b/src/de/steamwar/lobby/team/TeamPlayer.java index 41fefb1..56fbe46 100644 --- a/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/src/de/steamwar/lobby/team/TeamPlayer.java @@ -36,11 +36,10 @@ import org.bukkit.event.entity.EntityInteractEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; +import java.util.stream.Collectors; public class TeamPlayer extends BasicListener { @@ -59,12 +58,13 @@ public class TeamPlayer extends BasicListener { } private static final List cuboids = new ArrayList<>(); + static { cuboids.add(new Cuboid(1509, 52, 1464, 1510, 58, 1469)); cuboids.add(new Cuboid(1538, 52, 1464, 1539, 58, 1469)); cuboids.add(new Cuboid(1518, 55, 1433, 1530, 60, 1434)); cuboids.add(new Cuboid(1587, 52, 1471, 1588, 56, 1475)); - cuboids.add(new Cuboid(1479, 52, 1461, 1478, 56, 1463)); + cuboids.add(new Cuboid(1478, 52, 1461, 1479, 56, 1463)); } private static final World world = Bukkit.getWorlds().get(0); @@ -92,7 +92,7 @@ public class TeamPlayer extends BasicListener { private static void forceLoad(World world, boolean setTo) { for (int x = -10; x < 10; x++) { for (int z = -10; z < 10; z++) { - world.setChunkForceLoaded(95 + x , 93 + z, setTo); + world.setChunkForceLoaded(95 + x, 93 + z, setTo); } } } @@ -106,8 +106,33 @@ public class TeamPlayer extends BasicListener { spawnTeamPlayer(world, user); }); + AtomicInteger count = new AtomicInteger(); LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players"); Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { + count.incrementAndGet(); + if (count.get() % 20 * 60 * 60 == 0) { + count.set(0); + List steamwarUsers = SteamwarUser.getServerTeam(); + AtomicInteger added = new AtomicInteger(); + steamwarUsers.forEach(user -> { + if (!entities.containsKey(user.getUserName())) { + spawnTeamPlayer(world, user); + added.incrementAndGet(); + } + }); + AtomicInteger removed = new AtomicInteger(); + List names = steamwarUsers.stream().map(SteamwarUser::getUserName).collect(Collectors.toList()); + new HashSet<>(entities.keySet()).stream().filter(name -> !names.contains(name)).forEach(name -> { + world.getEntitiesByClasses(Villager.class).forEach(entity -> { + if (entity.getName().equals(name)) { + entity.remove(); + } + }); + entities.remove(name).delete(); + removed.incrementAndGet(); + }); + LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + added.get() + " team players, removed " + removed.get() + " team players"); + } world.getEntitiesByClasses(Villager.class).forEach(entity -> { NPC npc = entities.get(entity.getName()); if (npc != null) { From 6e1b0f70dd614c3abb4b13e61505ebd94352ab91 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 15:42:57 +0100 Subject: [PATCH 32/38] Fix last NPC stuff --- src/de/steamwar/lobby/display/NPC.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/lobby/display/NPC.java b/src/de/steamwar/lobby/display/NPC.java index de0abfc..3d7e058 100644 --- a/src/de/steamwar/lobby/display/NPC.java +++ b/src/de/steamwar/lobby/display/NPC.java @@ -166,18 +166,21 @@ public class NPC { } this.location = location; byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0); + byte pitch = (byte)(int)(location.getPitch() * 256.0 / 360.0); headRotationYaw.set(headRotation, yaw); move = movePacketConstructor.invoke(); movePacketEntity.set(move, entityId); movePacketX.set(move, location.getX()); movePacketY.set(move, location.getY()); movePacketZ.set(move, location.getZ()); + movePacketYaw.set(move, yaw); + movePacketPitch.set(move, pitch); + movePacketOnGround.set(move, true); namedSpawnX.set(namedSpawn, location.getX()); namedSpawnY.set(namedSpawn, location.getY()); namedSpawnZ.set(namedSpawn, location.getZ()); - movePacketYaw.set(move, yaw); - movePacketPitch.set(move, (byte)(int)(location.getPitch() * 256.0 / 360.0)); - movePacketOnGround.set(move, true); + namedSpawnYaw.set(namedSpawn, yaw); + namedSpawnPitch.set(namedSpawn, pitch); display.setLocation(location); } From 4b0f4328157fc0d22509830650741d73018b1b1b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 15:49:29 +0100 Subject: [PATCH 33/38] Optimize stuff --- src/de/steamwar/lobby/display/NPC.java | 37 +++++++++------------- src/de/steamwar/lobby/team/TeamPlayer.java | 6 ++-- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/de/steamwar/lobby/display/NPC.java b/src/de/steamwar/lobby/display/NPC.java index 3d7e058..3672e3a 100644 --- a/src/de/steamwar/lobby/display/NPC.java +++ b/src/de/steamwar/lobby/display/NPC.java @@ -22,13 +22,8 @@ package de.steamwar.lobby.display; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import com.mojang.authlib.GameProfile; -import net.minecraft.server.v1_15_R1.DataWatcher; -import net.minecraft.server.v1_15_R1.DataWatcherRegistry; -import net.minecraft.server.v1_15_R1.EntityHuman; -import net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import java.lang.reflect.Field; @@ -135,7 +130,6 @@ public class NPC { this.uuid = uuid; this.name = name; this.location = location; - byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0); GameProfile profile = new GameProfile(uuid, name); addPlayerInfo = playerInfoPacket(addPlayer, profile); @@ -147,15 +141,14 @@ public class NPC { namedSpawn = namedSpawnConstructor.invoke(); namedSpawnEntity.set(namedSpawn, entityId); namedSpawnUUID.set(namedSpawn, uuid); - namedSpawnX.set(namedSpawn, location.getX()); - namedSpawnY.set(namedSpawn, location.getY()); - namedSpawnZ.set(namedSpawn, location.getZ()); - namedSpawnYaw.set(namedSpawn, yaw); - namedSpawnPitch.set(namedSpawn, (byte)(int)(location.getPitch() * 256.0 / 360.0)); headRotation = headRotationConstructor.invoke(); headRotationEntity.set(headRotation, entityId); - headRotationYaw.set(headRotation, yaw); + + move = movePacketConstructor.invoke(); + movePacketEntity.set(move, entityId); + + setPackets(location); display = new Displayable(location, this::show, this::hide, this::move); } @@ -165,11 +158,14 @@ public class NPC { return; } this.location = location; + setPackets(location); + display.setLocation(location); + } + + private void setPackets(Location location) { byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0); byte pitch = (byte)(int)(location.getPitch() * 256.0 / 360.0); headRotationYaw.set(headRotation, yaw); - move = movePacketConstructor.invoke(); - movePacketEntity.set(move, entityId); movePacketX.set(move, location.getX()); movePacketY.set(move, location.getY()); movePacketZ.set(move, location.getZ()); @@ -181,10 +177,12 @@ public class NPC { namedSpawnZ.set(namedSpawn, location.getZ()); namedSpawnYaw.set(namedSpawn, yaw); namedSpawnPitch.set(namedSpawn, pitch); - display.setLocation(location); } private boolean isSimilarLocation(Location location) { + if (this.location == null) { + return false; + } if (Location.normalizeYaw(this.location.getYaw()) != Location.normalizeYaw(location.getYaw())) { return false; } @@ -197,10 +195,7 @@ public class NPC { if (Math.abs(this.location.getY() - location.getY()) > 0.1) { return false; } - if (Math.abs(this.location.getZ() - location.getZ()) > 0.1) { - return false; - } - return true; + return !(Math.abs(this.location.getZ() - location.getZ()) > 0.1); } public Location getLocation() { @@ -227,9 +222,7 @@ public class NPC { private void move(Player player) { TinyProtocol.instance.sendPacket(player, headRotation); - if (move != null) { - TinyProtocol.instance.sendPacket(player, move); - } + TinyProtocol.instance.sendPacket(player, move); } public void delete() { diff --git a/src/de/steamwar/lobby/team/TeamPlayer.java b/src/de/steamwar/lobby/team/TeamPlayer.java index 56fbe46..ea44726 100644 --- a/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/src/de/steamwar/lobby/team/TeamPlayer.java @@ -110,7 +110,7 @@ public class TeamPlayer extends BasicListener { LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players"); Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { count.incrementAndGet(); - if (count.get() % 20 * 60 * 60 == 0) { + if (count.get() % (20 * 60 * 60) == 0) { count.set(0); List steamwarUsers = SteamwarUser.getServerTeam(); AtomicInteger added = new AtomicInteger(); @@ -131,7 +131,9 @@ public class TeamPlayer extends BasicListener { entities.remove(name).delete(); removed.incrementAndGet(); }); - LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + added.get() + " team players, removed " + removed.get() + " team players"); + if (added.get() > 0 || removed.get() > 0) { + LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + added.get() + " team players, removed " + removed.get() + " team players"); + } } world.getEntitiesByClasses(Villager.class).forEach(entity -> { NPC npc = entities.get(entity.getName()); From 7d150d24e1e2270b065a197d42b3a8faf300b5af Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 16:09:49 +0100 Subject: [PATCH 34/38] Add clickable messages --- src/de/steamwar/lobby/LobbySystem.properties | 4 ++ src/de/steamwar/lobby/team/TeamPlayer.java | 59 +++++++++++++++----- 2 files changed, 49 insertions(+), 14 deletions(-) diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index a157b1b..84304c5 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -3,6 +3,10 @@ TIME = HH:mm:ss DATE=........ COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===--- +# ServerTeamNPC's +NPC_CHAT_1 = §fHallo, ich bin {0} und habe den Rang {1}. +NPC_CHAT_2 = §fWillkommen auf §eSteam§8War§f, viel Spaß dir. + # Portal Command PORTAL_COMMAND_LIST_HELP = §8/§7portal §elist §8- §7Listet alle Portale auf PORTAL_COMMAND_ADD_HELP = §8/§7portal §ecreate §8[§7PortalType§8] §8[§7PortalName§8] §8- §7Fügt ein Portal hinzu diff --git a/src/de/steamwar/lobby/team/TeamPlayer.java b/src/de/steamwar/lobby/team/TeamPlayer.java index ea44726..6c79212 100644 --- a/src/de/steamwar/lobby/team/TeamPlayer.java +++ b/src/de/steamwar/lobby/team/TeamPlayer.java @@ -29,10 +29,13 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityInteractEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -43,20 +46,6 @@ import java.util.stream.Collectors; public class TeamPlayer extends BasicListener { - @AllArgsConstructor - private static class Cuboid { - private double x1; - private double y1; - private double z1; - private double x2; - private double y2; - private double z2; - - public boolean contains(Location location) { - return location.getX() >= x1 && location.getX() <= x2 && location.getY() >= y1 && location.getY() <= y2 && location.getZ() >= z1 && location.getZ() <= z2; - } - } - private static final List cuboids = new ArrayList<>(); static { @@ -70,6 +59,15 @@ public class TeamPlayer extends BasicListener { private static final World world = Bukkit.getWorlds().get(0); private static final Map entities = new HashMap<>(); + private Set players = new HashSet<>(); + + private Random random = new Random(); + private List strings = new ArrayList<>(); + { + strings.add("NPC_CHAT_1"); + strings.add("NPC_CHAT_2"); + } + public static void spawnTeamPlayer(World world, SteamwarUser steamwarUser) { Location location = new Location(world, 1524.5, 52, 1484.5); String name = steamwarUser.getUserName(); @@ -157,6 +155,25 @@ public class TeamPlayer extends BasicListener { return false; } + @EventHandler + public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { + if (!(event.getRightClicked() instanceof Villager)) { + return; + } + if (!players.add(event.getPlayer())) { + players.remove(event.getPlayer()); + return; + } + SteamwarUser user = SteamwarUser.get(event.getRightClicked().getName()); + String message = strings.get(random.nextInt(strings.size())); + LobbySystem.getMessage().send(message, event.getPlayer(), event.getRightClicked().getName(), user.getUserGroup().getColorCode() + user.getUserGroup().name()); + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + players.remove(event.getPlayer()); + } + @EventHandler public void onEntityInteract(EntityInteractEvent event) { if (event.getEntityType() == EntityType.VILLAGER) { @@ -170,4 +187,18 @@ public class TeamPlayer extends BasicListener { event.setCancelled(true); } } + + @AllArgsConstructor + private static class Cuboid { + private double x1; + private double y1; + private double z1; + private double x2; + private double y2; + private double z2; + + public boolean contains(Location location) { + return location.getX() >= x1 && location.getX() <= x2 && location.getY() >= y1 && location.getY() <= y2 && location.getZ() >= z1 && location.getZ() <= z2; + } + } } From eda49e0c915ed2974f2472c459d2e6a24ddc3806 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 16:11:13 +0100 Subject: [PATCH 35/38] Update messages --- src/de/steamwar/lobby/LobbySystem.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/lobby/LobbySystem.properties b/src/de/steamwar/lobby/LobbySystem.properties index 3308f32..2c54623 100644 --- a/src/de/steamwar/lobby/LobbySystem.properties +++ b/src/de/steamwar/lobby/LobbySystem.properties @@ -33,7 +33,7 @@ PARTICLE_UNLOCKED_BY = §eFreigeschaltet durch PARTICLE_SELECT = §eZum Auswählen klicken PARTICLE_SNEEZE = §aSneeze -PARTICLE_SMOKE = §7Smoke +PARTICLE_SMOKE = §7Rauch PARTICLE_FIRE = §cFeuer PARTICLE_WATER = §bWasser PARTICLE_HEART = §cHerzen @@ -49,9 +49,9 @@ PARTICLE_MOB = §7Mob PARTICLE_SQUID = §8Tintenfisch PARTICLE_BUBBLE = §aBlasen PARTICLE_HONEY = §6Honig -PARTICLE_NECTAR = §6Nekter +PARTICLE_NECTAR = §6Nektar PARTICLE_FIREWORK = §7Feuerwerk -PARTICLE_DRAGON_BREATH = §5Drachen Atem +PARTICLE_DRAGON_BREATH = §5Drachenatem PARTICLE_DAMAGE = §5Schaden PARTICLE_DOLPHIN = §dDelphin PARTICLE_WITCH = §5Hexe From c304e775478173de365fd5677dfffc4da577f8a8 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 16:22:28 +0100 Subject: [PATCH 36/38] Fix WorldInteraction --- .../lobby/listener/WorldInteraction.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/de/steamwar/lobby/listener/WorldInteraction.java b/src/de/steamwar/lobby/listener/WorldInteraction.java index 52c7463..51771f6 100644 --- a/src/de/steamwar/lobby/listener/WorldInteraction.java +++ b/src/de/steamwar/lobby/listener/WorldInteraction.java @@ -26,6 +26,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; @@ -71,5 +72,31 @@ public class WorldInteraction extends BasicListener { Player player = event.getPlayer(); player.setVelocity(player.getLocation().getDirection().multiply(5).add(new Vector(0, 1, 0))); } + + @EventHandler + public void onBlockPhysics(BlockPhysicsEvent event) { + if (event.getSourceBlock().getType().name().endsWith("_PRESSURE_PLATE")) { + event.setCancelled(true); + } + if (event.getSourceBlock().getType().name().endsWith("_BUTTON")) { + event.setCancelled(true); + } + if (event.getSourceBlock().getType() == Material.LEVER) { + event.setCancelled(true); + } + } + + @EventHandler + public void onPlayerInteract(PlayerInteractEvent event) { + if(ModifyCommand.modifying(event.getPlayer())) { + return; + } + if (event.getClickedBlock() == null) { + return; + } + if (event.getClickedBlock().getType().name().endsWith("_DOOR")) { + event.setCancelled(true); + } + } } From f3874cf9de82f161ba3593d6588393b150028a20 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 16:25:12 +0100 Subject: [PATCH 37/38] Fix WorldInteraction --- .../lobby/listener/WorldInteraction.java | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/de/steamwar/lobby/listener/WorldInteraction.java b/src/de/steamwar/lobby/listener/WorldInteraction.java index 51771f6..8bef3fc 100644 --- a/src/de/steamwar/lobby/listener/WorldInteraction.java +++ b/src/de/steamwar/lobby/listener/WorldInteraction.java @@ -75,28 +75,7 @@ public class WorldInteraction extends BasicListener { @EventHandler public void onBlockPhysics(BlockPhysicsEvent event) { - if (event.getSourceBlock().getType().name().endsWith("_PRESSURE_PLATE")) { - event.setCancelled(true); - } - if (event.getSourceBlock().getType().name().endsWith("_BUTTON")) { - event.setCancelled(true); - } - if (event.getSourceBlock().getType() == Material.LEVER) { - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerInteract(PlayerInteractEvent event) { - if(ModifyCommand.modifying(event.getPlayer())) { - return; - } - if (event.getClickedBlock() == null) { - return; - } - if (event.getClickedBlock().getType().name().endsWith("_DOOR")) { - event.setCancelled(true); - } + event.setCancelled(true); } } From ed4acbad3f572619a100355bf7c1d40834bf0fbf Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 26 Mar 2022 16:27:37 +0100 Subject: [PATCH 38/38] Update messages --- 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 84304c5..576f1aa 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 = §fHallo, ich bin {0} und habe den Rang {1}. +NPC_CHAT_1 = §fHallo, ich bin {0} und bin ein {1}. NPC_CHAT_2 = §fWillkommen auf §eSteam§8War§f, viel Spaß dir. # Portal Command