13
0

Teleporter #12

Zusammengeführt
Lixfel hat 12 Commits von Teleporter nach master 2022-03-26 16:51:55 +01:00 zusammengeführt
42 geänderte Dateien mit 1674 neuen und 568 gelöschten Zeilen
Nur Änderungen aus Commit 63b4a8ca57 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.lobby.command.FlyCommand;
import de.steamwar.lobby.command.HologramCommand; import de.steamwar.lobby.command.HologramCommand;
import de.steamwar.lobby.command.PortalCommand; import de.steamwar.lobby.command.PortalCommand;
import de.steamwar.lobby.listener.*; import de.steamwar.lobby.listener.*;
import de.steamwar.lobby.team.TeamPlayer;
import de.steamwar.message.Message; import de.steamwar.message.Message;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -59,6 +60,7 @@ public class LobbySystem extends JavaPlugin {
new PlayerSeatListener(); new PlayerSeatListener();
new MapsRotateListener(); new MapsRotateListener();
new TeleporterListener(); new TeleporterListener();
new TeamPlayer();
new AlphaWall(l -> l.getX() > 1199, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() > 1199, AlphaWall.REFLECT_X);
new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X); new AlphaWall(l -> l.getX() < 2977, AlphaWall.REFLECT_X);
@ -67,6 +69,10 @@ public class LobbySystem extends JavaPlugin {
} }
@Override
public void onDisable() {
TeamPlayer.cleanup();
}
public static LobbySystem getPlugin() { public static LobbySystem getPlugin() {
return plugin; return plugin;

Datei anzeigen

@ -3,10 +3,82 @@ TIME = HH:mm:ss
DATE=........ DATE=........
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===--- COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
# ServerTeamNPC's
NPC_CHAT_1 = §fHallo, ich bin {0} und bin ein {1}.
NPC_CHAT_2 = §fWillkommen auf §eSteam§8War§f, viel Spaß dir.
# Portal Command # Portal Command
PORTAL_COMMAND_LIST_HELP = §8/§7portal §elist §8- §7Listet alle Portale auf 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 PORTAL_COMMAND_ADD_HELP = §8/§7portal §ecreate §8[§7PortalType§8] §8[§7PortalName§8] §8- §7Fügt ein Portal hinzu
PORTAL_COMMAND_REMOVE_HELP = §8/§7portal §eremove §8[§7PortalName§8] §8- §7Entfernt ein Portal 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_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 PORTAL_NO_WORLDEDIT_SELECTION = §cKeine WorldEdit Selection
# Particle
PARTICLE_INVENTORY = §6Partikel
PARTICLE_DESELECT = §8Keine Partikel
PARTICLE_LOCKED = {0} §8- §c§lGesperrt
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 Doppelring
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
PARTICLE_SELECT = §eZum Auswählen klicken
PARTICLE_SNEEZE = §aSneeze
PARTICLE_SMOKE = §7Rauch
PARTICLE_FIRE = §cFeuer
PARTICLE_WATER = §bWasser
PARTICLE_HEART = §cHerzen
PARTICLE_NOTES = §eNoten
PARTICLE_NAUTILUS = §aNautilus
PARTICLE_SNOWBALL = §fSchneeball
PARTICLE_EFFECT = §5Effekt
PARTICLE_CAMPFIRE = §7Rauch
PARTICLE_MAGIC = §5Magie
PARTICLE_ANGRY = §4Wut
PARTICLE_SLIME = §aSchleim
PARTICLE_MOB = §7Mob
PARTICLE_SQUID = §8Tintenfisch
PARTICLE_BUBBLE = §aBlasen
PARTICLE_HONEY = §6Honig
PARTICLE_NECTAR = §6Nektar
PARTICLE_FIREWORK = §7Feuerwerk
PARTICLE_DRAGON_BREATH = §5Drachenatem
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 = §7Wolke
PARTICLE_TOTEM = §aTotem
PARTICLE_TOWN = §5Town
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_EVENT_PLACEMENT = §f{0} 1., 2. oder 3. Platz
PARTICLE_UNLOCKED_BY_EVENT_PARTICIPATION = §f{0}
PARTICLE_EVENT_ENCHANTING = §cVerzaubert
PARTICLE_EVENT_CLOUD = §fWolken
PARTICLE_EVENT_SMOKE = §7Rauch
PARTICLE_EVENT_WATER = §bWasser
PARTICLE_EVENT_WINGS = §fFlügel
PARTICLE_EVENT_RAIN_CLOUD = §fRegenwolke
PARTICLE_EVENT_WGS = §fWGS
PARTICLE_EVENT_WARGEARCLASH = §fClash

Datei anzeigen

@ -38,24 +38,34 @@ public class Displayable extends BasicListener {
private final Set<Player> visible = new HashSet<>(); private final Set<Player> visible = new HashSet<>();
private final int chunkX; private int chunkX;
private final int chunkZ; private int chunkZ;
private final Consumer<Player> show; private final Consumer<Player> show;
private final Consumer<Player> hide; private final Consumer<Player> hide;
private final Consumer<Player> move;
private final Function<Player, Boolean> playerFilter; private final Function<Player, Boolean> playerFilter;
public Displayable(Location location, Consumer<Player> show, Consumer<Player> hide) { public Displayable(Location location, Consumer<Player> show, Consumer<Player> hide, Consumer<Player> move) {
this(location, show, hide, player -> true); this(location, show, hide, move, player -> true);
} }
public Displayable(Location location, Consumer<Player> show, Consumer<Player> hide, Function<Player, Boolean> playerFilter) { public Displayable(Location location, Consumer<Player> show, Consumer<Player> hide, Function<Player, Boolean> playerFilter) {
this.chunkX = posToChunk(location.getX()); this(location, show, hide, player -> {}, playerFilter);
this.chunkZ = posToChunk(location.getZ()); }
public Displayable(Location location, Consumer<Player> show, Consumer<Player> hide, Consumer<Player> move, Function<Player, Boolean> playerFilter) {
this.show = show; this.show = show;
this.hide = hide; this.hide = hide;
this.move = move;
this.playerFilter = playerFilter; this.playerFilter = playerFilter;
setLocation(location);
}
public void setLocation(Location location) {
chunkX = posToChunk(location.getX());
chunkZ = posToChunk(location.getZ());
Bukkit.getOnlinePlayers().forEach(this::checkLocation); Bukkit.getOnlinePlayers().forEach(this::checkLocation);
visible.forEach(move);
} }
public Set<Player> getVisitors() { public Set<Player> getVisitors() {

Datei anzeigen

@ -22,9 +22,12 @@ package de.steamwar.lobby.display;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol; import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -62,46 +65,137 @@ public class NPC {
private static final Reflection.ConstructorInvoker headRotationConstructor = Reflection.getConstructor(headRotationPacket); private static final Reflection.ConstructorInvoker headRotationConstructor = Reflection.getConstructor(headRotationPacket);
private static final Reflection.FieldAccessor<Integer> headRotationEntity = Reflection.getField(headRotationPacket, int.class, 0); private static final Reflection.FieldAccessor<Integer> headRotationEntity = Reflection.getField(headRotationPacket, int.class, 0);
private static final Reflection.FieldAccessor<Byte> headRotationYaw = Reflection.getField(headRotationPacket, byte.class, 0); private static final Reflection.FieldAccessor<Byte> 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<Integer> movePacketEntity = Reflection.getField(movePacket, int.class, 0);
private static final Reflection.FieldAccessor<Double> movePacketX = Reflection.getField(movePacket, double.class, 0);
private static final Reflection.FieldAccessor<Double> movePacketY = Reflection.getField(movePacket, double.class, 1);
private static final Reflection.FieldAccessor<Double> movePacketZ = Reflection.getField(movePacket, double.class, 2);
private static final Reflection.FieldAccessor<Byte> movePacketYaw = Reflection.getField(movePacket, byte.class, 0);
private static final Reflection.FieldAccessor<Byte> movePacketPitch = Reflection.getField(movePacket, byte.class, 1);
private static final Reflection.FieldAccessor<Boolean> 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<Integer> metadataEntity = Reflection.getField(metadataPacket, int.class, 0);
private static final Reflection.FieldAccessor<List> 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(16, Byte.class);
private final Displayable display; private final Displayable display;
private final int entityId; private final int entityId;
private final UUID uuid; private final UUID uuid;
private final String name; private final String name;
private final Location location; private Location location;
private final Object addPlayerInfo; private final Object addPlayerInfo;
private final Object namedSpawn; private final Object namedSpawn;
private final Object skinParts;
private final Object headRotation; private final Object headRotation;
private final Object removePlayerInfo; private final Object removePlayerInfo;
private final Object destroy; private final Object destroy;
private Object move;
public NPC(Location location, UUID uuid, String name) { public NPC(Location location, UUID uuid, String name) {
this.entityId = Hologram.createEntityId(); this.entityId = Hologram.createEntityId();
this.uuid = uuid; this.uuid = uuid;
this.name = name; this.name = name;
this.location = location; this.location = location;
byte yaw = (byte)(int)(location.getYaw() * 256.0 / 360.0);
GameProfile profile = new GameProfile(uuid, name); GameProfile profile = new GameProfile(uuid, name);
addPlayerInfo = playerInfoPacket(addPlayer, profile); addPlayerInfo = playerInfoPacket(addPlayer, profile);
removePlayerInfo = playerInfoPacket(removePlayer, profile); removePlayerInfo = playerInfoPacket(removePlayer, profile);
destroy = Hologram.destroyPacket(entityId); destroy = Hologram.destroyPacket(entityId);
skinParts = getDataWatcherPacket(skinPartsDataWatcherObject, (byte) 0x7F);
namedSpawn = namedSpawnConstructor.invoke(); namedSpawn = namedSpawnConstructor.invoke();
namedSpawnEntity.set(namedSpawn, entityId); namedSpawnEntity.set(namedSpawn, entityId);
namedSpawnUUID.set(namedSpawn, uuid); namedSpawnUUID.set(namedSpawn, uuid);
headRotation = headRotationConstructor.invoke();
headRotationEntity.set(headRotation, entityId);
move = movePacketConstructor.invoke();
movePacketEntity.set(move, entityId);
setPackets(location);
display = new Displayable(location, this::show, this::hide, this::move);
}
public void setLocation(Location location) {
if (isSimilarLocation(location)) {
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);
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()); namedSpawnX.set(namedSpawn, location.getX());
namedSpawnY.set(namedSpawn, location.getY()); namedSpawnY.set(namedSpawn, location.getY());
namedSpawnZ.set(namedSpawn, location.getZ()); namedSpawnZ.set(namedSpawn, location.getZ());
namedSpawnYaw.set(namedSpawn, yaw); namedSpawnYaw.set(namedSpawn, yaw);
namedSpawnPitch.set(namedSpawn, (byte)(int)(location.getPitch() * 256.0 / 360.0)); namedSpawnPitch.set(namedSpawn, pitch);
}
headRotation = headRotationConstructor.invoke(); private boolean isSimilarLocation(Location location) {
headRotationEntity.set(headRotation, entityId); if (this.location == null) {
headRotationYaw.set(headRotation, yaw); return false;
}
display = new Displayable(location, this::show, this::hide); 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;
}
return !(Math.abs(this.location.getZ() - location.getZ()) > 0.1);
} }
public Location getLocation() { public Location getLocation() {
@ -116,13 +210,21 @@ public class NPC {
TinyProtocol.instance.sendPacket(player, addPlayerInfo); TinyProtocol.instance.sendPacket(player, addPlayerInfo);
TinyProtocol.instance.sendPacket(player, namedSpawn); TinyProtocol.instance.sendPacket(player, namedSpawn);
TinyProtocol.instance.sendPacket(player, headRotation); TinyProtocol.instance.sendPacket(player, headRotation);
TinyProtocol.instance.sendPacket(player, skinParts);
} }
private void hide(Player player) { 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); TinyProtocol.instance.sendPacket(player, destroy);
} }
private void move(Player player) {
TinyProtocol.instance.sendPacket(player, headRotation);
TinyProtocol.instance.sendPacket(player, move);
}
public void delete() { public void delete() {
display.delete(); display.delete();
} }

Datei anzeigen

@ -20,8 +20,10 @@
package de.steamwar.lobby.listener; package de.steamwar.lobby.listener;
import de.steamwar.lobby.LobbySystem; import de.steamwar.lobby.LobbySystem;
import de.steamwar.lobby.particle.BaseParticle;
import de.steamwar.lobby.particle.ParticleData;
import de.steamwar.lobby.particle.particles.ParticleEnum;
import de.steamwar.lobby.particle.ParticleInventory; import de.steamwar.lobby.particle.ParticleInventory;
import de.steamwar.lobby.particle.SpecialParticle;
import de.steamwar.lobby.util.LobbyPlayer; import de.steamwar.lobby.util.LobbyPlayer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -38,6 +40,15 @@ public class ParticleListener extends BasicListener {
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> {
deg += 0.1; deg += 0.1;
if (deg > 360) deg = 0; if (deg > 360) deg = 0;
Bukkit.getOnlinePlayers().forEach(player -> {
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
ParticleEnum particle = lobbyPlayer.getParticle();
if (particle == null) return;
BaseParticle baseParticle = particle.getParticle();
if (baseParticle.needsTick()) {
baseParticle.particle(new ParticleData(player.getWorld(), player, deg));
}
});
}, 0, 1); }, 0, 1);
} }
@ -53,11 +64,11 @@ public class ParticleListener extends BasicListener {
public void handlePlayerMove(PlayerMoveEvent event) { public void handlePlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
SpecialParticle particle = lobbyPlayer.getParticle(); ParticleEnum particle = lobbyPlayer.getParticle();
if (particle == null) return; if (particle == null) return;
particle.execute(player.getWorld(), player, deg);
BaseParticle baseParticle = particle.getParticle();
if (baseParticle.needsTick()) return;
baseParticle.particle(new ParticleData(player.getWorld(), player, deg));
} }
} }

Datei anzeigen

@ -26,6 +26,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
@ -71,5 +72,10 @@ public class WorldInteraction extends BasicListener {
Player player = event.getPlayer(); Player player = event.getPlayer();
player.setVelocity(player.getLocation().getDirection().multiply(5).add(new Vector(0, 1, 0))); player.setVelocity(player.getLocation().getDirection().multiply(5).add(new Vector(0, 1, 0)));
} }
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event) {
event.setCancelled(true);
}
} }

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle;
import org.bukkit.Color;
import org.bukkit.Particle;
import java.util.Random;
public interface BaseParticle {
Random RANDOM = new Random();
default Color randomColor() {
return Color.fromRGB(RANDOM.nextInt(256), RANDOM.nextInt(256), RANDOM.nextInt(256));
}
default float randomSize() {
return RANDOM.nextFloat() / 2 + 1;
}
default Particle.DustOptions getParticleDust() {
return new Particle.DustOptions(randomColor(), randomSize());
}
ParticleItem getItem();
default boolean needsTick() {
return false;
}
void particle(ParticleData particleData);
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<Location, Location> 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<String> lore, Particle particle, Particle particle2, UnaryOperator<Location> locationShift) {
super(material, name, lore);
this.particle = particle;
this.particle2 = particle2;
this.locationShift = locationShift;
}
public CircleParticle(Material material, String name, List<String> lore, Particle particle, Particle particle2, UnaryOperator<Location> 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);
}
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<String> lore, Particle particle, UnaryOperator<Location> 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);
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<String> 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);
}
}

Datei anzeigen

@ -0,0 +1,60 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Particle;
public class DustSimpleParticle implements BaseParticle {
private final ParticleItem particleItem;
private final Particle particle;
private float vx;
private float vy;
private float vz;
private double time = 1;
private int count = 5;
public DustSimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time) {
this.particleItem = particleItem;
this.particle = particle;
this.vx = vx;
this.vy = vy;
this.vz = vz;
this.time = time;
}
@Override
public ParticleItem getItem() {
return particleItem;
}
@Override
public void particle(ParticleData particleData) {
Location location = particleData.getLocation().add(0.0, 0.2, 0.0);
Bukkit.getOnlinePlayers().forEach(player -> {
int viewDistance = player.getClientViewDistance() * 16;
if (location.distanceSquared(player.getLocation()) <= viewDistance * viewDistance) {
player.spawnParticle(particle, location, count, vx, vy, vz, time, getParticleDust());
}
});
}
}

Datei anzeigen

@ -1,46 +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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle;
import org.bukkit.Material;
import org.bukkit.Particle;
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));
public static EventParticle[] eventParticles = values();
EventParticle(int event, int[] placementTeams, SpecialParticle placementParticle, SpecialParticle 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;
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<String> 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 -> {});
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<String> 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);
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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) {
ParticleData particleData = copy();
particleData.location = location;
return particleData;
}
public Location getLocation() {
if (location == null) {
return player.getLocation();
}
return location;
}
public ParticleData copy() {
return new ParticleData(world, player, location, deg);
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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);
}

Datei anzeigen

@ -22,13 +22,14 @@ package de.steamwar.lobby.particle;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv; 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.lobby.util.LobbyPlayer;
import de.steamwar.sql.Event; import de.steamwar.sql.Event;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.TeamTeilnahme; import de.steamwar.sql.TeamTeilnahme;
import de.steamwar.sql.UserGroup; import de.steamwar.sql.UserGroup;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
@ -42,82 +43,10 @@ public class ParticleInventory {
private ParticleInventory() { private ParticleInventory() {
} }
private static final List<SpecialParticle> PLAYER_PARTICLES = new ArrayList<>(); private static void calculateParticles(ParticleEnum[] particles, Player player, List<SWListInv.SWListEntry<ParticleEnum>> particleList) {
private static final List<SpecialParticle> TEAM_PARTICLES = new ArrayList<>(); for (ParticleEnum particle : particles) {
private static final List<SpecialParticle> SERVERTEAM_PARTICLES = new ArrayList<>(); particleList.add(new SWListInv.SWListEntry<>(particle.getParticle().getItem().toSWItem(player), particle));
}
private static final List<SWListInv.SWListEntry<SpecialParticle>> PLAYER_PARTICLES_ENTRIES = new ArrayList<>();
private static final List<SWListInv.SWListEntry<SpecialParticle>> TEAM_PARTICLES_ENTRIES = new ArrayList<>();
private static final List<SWListInv.SWListEntry<SpecialParticle>> SERVERTEAM_PARTICLES_ENTRIES = new ArrayList<>();
static {
List<String> defaultLore = loreBuilder(null, null);
List<String> teamLore = loreBuilder(null, "Teambeitritt");
List<String> serverTeamLore = loreBuilder(null, "Serverteam");
List<String> serverTeamLore_C = loreBuilder(new String[]{"Wolke"}, "Serverteam");
List<String> serverTeamLore_R = loreBuilder(new String[]{"Ring"}, "Serverteam");
List<String> serverTeamLore_2R = loreBuilder(new String[]{"doppel Ring"}, "Serverteam");
List<String> 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) { private static SWInventory createInventory(Player player) {
@ -125,53 +54,52 @@ public class ParticleInventory {
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId()); SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup(); UserGroup userGroup = steamwarUser.getUserGroup();
List<SWListInv.SWListEntry<SpecialParticle>> particleList; List<SWListInv.SWListEntry<ParticleEnum>> particleList = new ArrayList<>();
if (userGroup == UserGroup.Member) { calculateParticles(PlayerParticle.particles, player, particleList);
if (steamwarUser.getTeam() != 0) { if (steamwarUser.getTeam() != 0 || userGroup != UserGroup.Member) {
particleList = new ArrayList<>(TEAM_PARTICLES_ENTRIES); calculateParticles(TeamParticle.particles, player, particleList);
} else { }
if (TEAM_PARTICLES.contains(lobbyPlayer.getParticle())) { if (userGroup != UserGroup.Member) {
lobbyPlayer.setParticle(null); calculateParticles(ServerTeamParticle.particles, player, particleList);
}
particleList = new ArrayList<>(PLAYER_PARTICLES_ENTRIES);
}
} else {
particleList = new ArrayList<>(SERVERTEAM_PARTICLES_ENTRIES);
} }
Set<Integer> events = steamwarUser.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(steamwarUser.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet()); Set<Integer> events = steamwarUser.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(steamwarUser.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet());
for (EventParticle eventParticle : EventParticle.eventParticles) { if (!events.isEmpty()) {
boolean clickablePlacement = userGroup.isTeamGroup(); calculateParticles(EventParticle.particles, player, particleList);
clickablePlacement |= (steamwarUser.getTeam() != 0 && contains(eventParticle.placementTeams, steamwarUser.getTeam())); }
if (clickablePlacement) { for (EventParticlePlacement particle : EventParticlePlacement.particles) {
particleList.add(new SWListInv.SWListEntry<>(eventParticle.placementParticle.getItem(), eventParticle.placementParticle)); boolean clickable = userGroup.isTeamGroup();
} else { clickable |= (steamwarUser.getTeam() != 0 && contains(particle.getPlacementTeams(), steamwarUser.getTeam()));
SWItem swItem = eventParticle.placementParticle.getItem(); addParticle(particleList, particle, clickable, player);
swItem.setName(swItem.getItemMeta().getDisplayName() + " §8- §c§lGesperrt"); }
particleList.add(new SWListInv.SWListEntry<>(swItem, null)); for (EventParticleParticipation particle : EventParticleParticipation.particles) {
} boolean clickable = userGroup.isTeamGroup();
clickable |= events.contains(particle.getEvent());
if (eventParticle.placementTeams.length != 0 && (userGroup.isTeamGroup() || events.contains(eventParticle.event))) { addParticle(particleList, particle, clickable, player);
particleList.add(new SWListInv.SWListEntry<>(eventParticle.participationParticles.getItem(), eventParticle.participationParticles));
} else {
SWItem swItem = eventParticle.participationParticles.getItem();
swItem.setName(swItem.getItemMeta().getDisplayName() + " §8- §c§lGesperrt");
particleList.add(new SWListInv.SWListEntry<>(swItem, null));
}
} }
SWListInv<SpecialParticle> particleSWListInv = new SWListInv<>(player, "§6Partikel", false, particleList, (clickType, particle) -> { SWListInv<ParticleEnum> particleSWListInv = new SWListInv<>(player, LobbySystem.getMessage().parse("PARTICLE_INVENTORY", player), false, particleList, (clickType, particle) -> {
if (particle == null) return; if (particle == null) return;
lobbyPlayer.setParticle(particle); lobbyPlayer.setParticle(particle);
player.closeInventory(); 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); lobbyPlayer.setParticle(null);
}); });
return particleSWListInv; return particleSWListInv;
} }
private static void addParticle(List<SWListInv.SWListEntry<ParticleEnum>> 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) { private static boolean contains(int[] ints, int element) {
for (int i : ints) { for (int i : ints) {
if (i == element) return true; if (i == element) return true;
@ -182,25 +110,5 @@ public class ParticleInventory {
public static void openParticleInventory(Player player) { public static void openParticleInventory(Player player) {
createInventory(player).open(); createInventory(player).open();
} }
public static List<String> loreBuilder(String[] attribute, String unlocked) {
List<String> 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;
}
} }

Datei anzeigen

@ -0,0 +1,69 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle;
import de.steamwar.inventory.SWItem;
import de.steamwar.lobby.LobbySystem;
import lombok.RequiredArgsConstructor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@RequiredArgsConstructor
public class ParticleItem {
protected final Material material;
protected final String name;
protected final Set<String> attributes = new LinkedHashSet<>();
protected String unlockedBy;
public ParticleItem(Material material, String name, String unlockedBy) {
this.material = material;
this.name = name;
this.unlockedBy = unlockedBy;
}
public ParticleItem addAttribute(String attribute) {
this.attributes.add(attribute);
return this;
}
public SWItem toSWItem(Player player) {
String translatedName = LobbySystem.getMessage().parse(name, player);
List<String> 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 -> {});
}
}

Datei anzeigen

@ -1,62 +1,82 @@
/* /*
* 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 * This program is distributed in the hope that it will be useful,
* it under the terms of the GNU Affero General Public License as published by * but WITHOUT ANY WARRANTY; without even the implied warranty of
* the Free Software Foundation, either version 3 of the License, or * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* (at your option) any later version. * GNU Affero General Public License for more details.
* *
* This program is distributed in the hope that it will be useful, * You should have received a copy of the GNU Affero General Public License
* but WITHOUT ANY WARRANTY; without even the implied warranty of * along with this program. If not, see <https://www.gnu.org/licenses/>.
* 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 <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.lobby.particle; package de.steamwar.lobby.particle;
import org.bukkit.*; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.Location;
import org.bukkit.Particle;
import java.util.List; public class SimpleParticle implements BaseParticle {
public class SimpleParticle extends SpecialParticle { private final ParticleItem particleItem;
private final Particle particle;
private Particle particle;
private boolean customVelocity = false; private boolean customVelocity = false;
private float vx; private float vx;
private float vy; private float vy;
private float vz; private float vz;
private double time = 1; private double time = 1;
private int count = 5;
public SimpleParticle(Material material, String name, List<String> lore, Particle particle) { public SimpleParticle(ParticleItem particleItem, Particle particle) {
super(material, name, lore); this.particleItem = particleItem;
this.particle = particle; this.particle = particle;
} }
public SimpleParticle(Material material, String name, List<String> lore, Particle particle, float vx, float vy, float vz, double time) { public SimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time) {
super(material, name, lore); this.particleItem = particleItem;
this.particle = particle; this.particle = particle;
customVelocity = true; this.customVelocity = true;
this.vx = vx; this.vx = vx;
this.vy = vy; this.vy = vy;
this.vz = vz; this.vz = vz;
this.time = time; this.time = time;
} }
@Override public SimpleParticle(ParticleItem particleItem, Particle particle, float vx, float vy, float vz, double time, int count) {
public void particle(World world, Player player, double deg) { this.particleItem = particleItem;
Location location = player.getLocation().add(0.0, 0.2, 0.0); this.particle = particle;
if (customVelocity) { this.customVelocity = true;
world.spawnParticle(particle, location, 5, vx, vy, vz, time); this.vx = vx;
} else { this.vy = vy;
world.spawnParticle(particle, location, 5); this.vz = vz;
} this.time = time;
this.count = count;
} }
@Override
public ParticleItem getItem() {
return particleItem;
}
@Override
public void particle(ParticleData particleData) {
Location location = particleData.getLocation().add(0.0, 0.2, 0.0);
Bukkit.getOnlinePlayers().forEach(player -> {
int viewDistance = player.getClientViewDistance() * 16;
if (location.distanceSquared(player.getLocation()) <= viewDistance * viewDistance) {
if (customVelocity) {
player.spawnParticle(particle, location, count, vx, vy, vz, time);
} else {
player.spawnParticle(particle, location, count);
}
}
});
}
} }

Datei anzeigen

@ -1,84 +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 <https://www.gnu.org/licenses/>.
*/
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<String> 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<String> lore;
protected boolean asCloud = false;
protected SpecialParticle(Material material, String name, List<String> 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);
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle.decorator;
import de.steamwar.lobby.particle.BaseParticle;
import de.steamwar.lobby.particle.ParticleData;
import de.steamwar.lobby.particle.ParticleItem;
import org.bukkit.Location;
import org.bukkit.util.Vector;
public class CircleParticle implements BaseParticle {
private ParticleItem particleItem = null;
private BaseParticle particle;
private BaseParticle particle2;
public CircleParticle(BaseParticle particle) {
this.particle = particle;
}
public CircleParticle(ParticleItem particleItem, BaseParticle particle, BaseParticle particle2) {
this.particleItem = particleItem;
this.particle = particle;
this.particle2 = particle2;
}
@Override
public ParticleItem getItem() {
if (particleItem != null) {
return particleItem.addAttribute("PARTICLE_ATTRIBUTE_BI_CIRCLE");
}
return particle.getItem().addAttribute("PARTICLE_ATTRIBUTE_CIRCLE");
}
@Override
public boolean needsTick() {
return particle.needsTick() || (particle2 != null && particle2.needsTick());
}
@Override
public void particle(ParticleData particleData) {
Location location = particleData.getLocation();
Vector vector = new Vector(1, 0, 0);
vector.rotateAroundY(particleData.getDeg());
ParticleData nData = particleData.withLocation(location.clone().add(vector));
particle.particle(nData);
if (particle2 == null) {
return;
}
vector.setX(-vector.getX());
vector.setZ(-vector.getZ());
nData = particleData.withLocation(location.clone().add(vector));
particle2.particle(nData);
}
}

Datei anzeigen

@ -0,0 +1,59 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle.decorator;
import de.steamwar.lobby.particle.BaseParticle;
import de.steamwar.lobby.particle.ParticleData;
import de.steamwar.lobby.particle.ParticleItem;
import lombok.NonNull;
import org.bukkit.Material;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class CloudParticle implements BaseParticle {
private BaseParticle particle;
public CloudParticle(@NonNull BaseParticle particle) {
this.particle = particle;
}
@Override
public ParticleItem getItem() {
return particle.getItem().addAttribute("PARTICLE_ATTRIBUTE_CLOUD");
}
@Override
public boolean needsTick() {
return particle.needsTick();
}
@Override
public void particle(ParticleData particleData) {
if (particleData.getWorld().getBlockAt(particleData.getPlayer().getLocation().subtract(0, 0.5, 0)).getType() == Material.AIR) {
particleData.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 5, 2, false, false, false));
} else {
particleData.getPlayer().removePotionEffect(PotionEffectType.SLOW_FALLING);
return;
}
ParticleData nData = particleData.withLocation(particleData.getLocation().subtract(0, -0.2, 0));
particle.particle(nData);
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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);
}
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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);
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<Player, Integer> 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<Vector> 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);
});
}
}

Binäre Datei nicht angezeigt.

Vorher

Breite:  |  Höhe:  |  Größe: 205 B

Nachher

Breite:  |  Höhe:  |  Größe: 205 B

Binäre Datei nicht angezeigt.

Vorher

Breite:  |  Höhe:  |  Größe: 746 B

Nachher

Breite:  |  Höhe:  |  Größe: 746 B

Binäre Datei nicht angezeigt.

Vorher

Breite:  |  Höhe:  |  Größe: 511 B

Nachher

Breite:  |  Höhe:  |  Größe: 511 B

Binäre Datei nicht angezeigt.

Vorher

Breite:  |  Höhe:  |  Größe: 188 B

Nachher

Breite:  |  Höhe:  |  Größe: 188 B

Binäre Datei nicht angezeigt.

Vorher

Breite:  |  Höhe:  |  Größe: 855 B

Nachher

Breite:  |  Höhe:  |  Größe: 855 B

Binäre Datei nicht angezeigt.

Vorher

Breite:  |  Höhe:  |  Größe: 184 B

Nachher

Breite:  |  Höhe:  |  Größe: 184 B

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle.group;
import de.steamwar.lobby.particle.BaseParticle;
import de.steamwar.lobby.particle.ParticleData;
import de.steamwar.lobby.particle.ParticleItem;
public class ParticleGroup implements BaseParticle {
private ParticleItem particleItem;
private BaseParticle[] particles;
public ParticleGroup(ParticleItem particleItem, BaseParticle... particles) {
this.particleItem = particleItem;
this.particles = particles;
}
@Override
public ParticleItem getItem() {
return particleItem;
}
@Override
public void particle(ParticleData particleData) {
for (BaseParticle particle : particles) {
particle.particle(particleData.copy());
}
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<Location> mutator;
public LocationParticleMutator(BaseParticle particle, UnaryOperator<Location> mutator) {
this.particle = particle;
this.mutator = mutator;
}
@Override
public ParticleItem getItem() {
return particle.getItem();
}
@Override
public boolean needsTick() {
return particle.needsTick();
}
@Override
public void particle(ParticleData particleData) {
ParticleData nData = particleData.withLocation(mutator.apply(particleData.getLocation()));
particle.particle(nData);
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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;
}

Datei anzeigen

@ -0,0 +1,56 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle.particles;
import de.steamwar.lobby.particle.BaseParticle;
import de.steamwar.lobby.particle.EventParticleItem;
import de.steamwar.lobby.particle.ParticleItem;
import de.steamwar.lobby.particle.SimpleParticle;
import de.steamwar.lobby.particle.decorator.CircleParticle;
import de.steamwar.lobby.particle.decorator.TickParticle;
import de.steamwar.lobby.particle.decorator.WingParticle;
import de.steamwar.lobby.particle.group.ParticleGroup;
import de.steamwar.lobby.particle.mutator.LocationParticleMutator;
import 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(EventParticleItem.participation(BOOK, "PARTICLE_EVENT_ENCHANTING", 22), Particle.ENCHANTMENT_TABLE)),
AirshipEvent(26, new SimpleParticle(EventParticleItem.participation(SNOW_BLOCK, "PARTICLE_EVENT_CLOUD", 26), Particle.CLOUD)),
HellsBellsWs(28, new CircleParticle(new SimpleParticle(EventParticleItem.participation(TNT, "PARTICLE_EVENT_SMOKE", 28), Particle.CAMPFIRE_COSY_SMOKE, 0, 0, 0, 0.01))),
Underwater(31, new SimpleParticle(EventParticleItem.participation(PRISMARINE_BRICKS, "PARTICLE_EVENT_WATER", 31), Particle.DRIP_WATER)),
AdventWarShip(32, new ParticleGroup(EventParticleItem.participation(PRISMARINE_WALL, "PARTICLE_EVENT_WATER", 32), new SimpleParticle(null, Particle.DRIP_WATER), new SimpleParticle(null, Particle.WATER_WAKE, 0.2F, 0.2F, 0.2F, 0.01))),
MiniWarGearLiga(33, new CircleParticle(new SimpleParticle(EventParticleItem.participation(PRISMARINE_SLAB, "PARTICLE_EVENT_WATER", 33), Particle.WATER_WAKE, 0, 0, 0, 0))),
// Absturz(34, null),
UnderwaterMWG(35, new TickParticle(new LocationParticleMutator(new ParticleGroup(EventParticleItem.participation(BLUE_CARPET, "PARTICLE_EVENT_RAIN_CLOUD", 35), new SimpleParticle(null, Particle.CLOUD, 0.3F, 0.1F, 0.3F, 0.01), new SimpleParticle(null, Particle.WATER_WAKE, 0.3F, 0.1F, 0.3F, 0.01), new LocationParticleMutator(new SimpleParticle(null, Particle.DRIP_WATER, 0.3F, 0.0F, 0.3F, 0.01), location -> location.subtract(0, 0.2, 0))), location -> location.add(0, 2.2, 0)))),
WarGearSeason2022(37, new TickParticle(new WingParticle(new SimpleParticle(EventParticleItem.participation(DIAMOND_SWORD, "PARTICLE_EVENT_WINGS", 37), Particle.DRAGON_BREATH, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.COMPLEX))),
// WargearClash(38, null),
;
public static EventParticleParticipation[] particles = values();
private int event;
private BaseParticle particle;
}

Datei anzeigen

@ -0,0 +1,57 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle.particles;
import de.steamwar.lobby.particle.BaseParticle;
import de.steamwar.lobby.particle.EventParticleItem;
import de.steamwar.lobby.particle.SimpleParticle;
import de.steamwar.lobby.particle.decorator.CircleParticle;
import de.steamwar.lobby.particle.decorator.CloudParticle;
import de.steamwar.lobby.particle.decorator.TickParticle;
import de.steamwar.lobby.particle.decorator.WingParticle;
import de.steamwar.lobby.particle.group.ParticleGroup;
import de.steamwar.lobby.particle.mutator.LocationParticleMutator;
import 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(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();
private int event;
private int[] placementTeams;
private BaseParticle particle;
}

Datei anzeigen

@ -0,0 +1,26 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle.particles;
import de.steamwar.lobby.particle.BaseParticle;
public interface ParticleEnum {
BaseParticle getParticle();
}

Datei anzeigen

@ -0,0 +1,56 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
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;
import org.bukkit.Material;
import org.bukkit.Particle;
import static org.bukkit.Material.*;
@AllArgsConstructor
public enum PlayerParticle implements ParticleEnum {
SNEEZE(new SimpleParticle(new ParticleItem(SLIME_BLOCK, "PARTICLE_SNEEZE"), Particle.SNEEZE, 0.2F, 0.2F, 0.2F, 0.01)),
SMOKE(new SimpleParticle(new ParticleItem(COBWEB, "PARTICLE_SMOKE"), Particle.SMOKE_NORMAL, 0.2F, 0.2F, 0.2F, 0.01)),
FIRE(new SimpleParticle(new ParticleItem(LAVA_BUCKET, "PARTICLE_FIRE"), Particle.DRIP_LAVA)),
WATER(new SimpleParticle(new ParticleItem(WATER_BUCKET, "PARTICLE_WATER"), Particle.DRIP_WATER)),
HEART(new LocationParticleMutator(new SimpleParticle(new ParticleItem(RED_DYE, "PARTICLE_HEART"), Particle.HEART), location -> location.add(0, 2.2, 0))),
NOTES(new LocationParticleMutator(new SimpleParticle(new ParticleItem(NOTE_BLOCK, "PARTICLE_NOTES"), Particle.NOTE), location -> location.add(0, 2.2, 0))),
NAUTILUS(new SimpleParticle(new ParticleItem(NAUTILUS_SHELL, "PARTICLE_NAUTILUS"), Particle.NAUTILUS, 0.2F, 0.2F, 0.2F, 0.01)),
SNOWBALL(new SimpleParticle(new ParticleItem(Material.SNOWBALL, "PARTICLE_SNOWBALL"), Particle.SNOWBALL, 0.2F, 0.2F, 0.2F, 0.01)),
EFFECT(new DustSimpleParticle(new ParticleItem(GLASS_BOTTLE, "PARTICLE_EFFECT"), Particle.REDSTONE, 0F, 0.2F, 0F, 0.01)),
CAMPFIRE(new SimpleParticle(new ParticleItem(Material.CAMPFIRE, "PARTICLE_CAMPFIRE"), Particle.CAMPFIRE_COSY_SMOKE, 0F, 0.2F, 0F, 0.01)),
MAGIC(new SimpleParticle(new ParticleItem(CAULDRON, "PARTICLE_MAGIC"), Particle.CRIT_MAGIC, 0.2F, 0.2F, 0.2F, 0.01)),
ANGRY(new SimpleParticle(new ParticleItem(REDSTONE_BLOCK, "PARTICLE_ANGRY"), Particle.VILLAGER_ANGRY, 0.2F, 0.2F, 0.2F, 0.01)),
SLIME(new SimpleParticle(new ParticleItem(SLIME_BALL, "PARTICLE_SLIME"), Particle.SLIME)),
MOB(new SimpleParticle(new ParticleItem(ZOMBIE_HEAD, "PARTICLE_MOB"), Particle.SPELL_MOB)),
;
public static ParticleEnum[] particles = values();
@Getter
private BaseParticle particle;
}

Datei anzeigen

@ -0,0 +1,71 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle.particles;
import de.steamwar.lobby.particle.BaseParticle;
import de.steamwar.lobby.particle.ParticleItem;
import de.steamwar.lobby.particle.SimpleParticle;
import de.steamwar.lobby.particle.decorator.CircleParticle;
import de.steamwar.lobby.particle.decorator.CloudParticle;
import de.steamwar.lobby.particle.decorator.TickParticle;
import de.steamwar.lobby.particle.decorator.WingParticle;
import de.steamwar.lobby.particle.mutator.LocationParticleMutator;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.Material;
import org.bukkit.Particle;
import static org.bukkit.Material.*;
@AllArgsConstructor
public enum ServerTeamParticle implements ParticleEnum {
WITCH(new SimpleParticle(new ParticleItem(EXPERIENCE_BOTTLE, "PARTICLE_WITCH", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.SPELL_WITCH)),
ENCHANTING(new SimpleParticle(new ParticleItem(ENCHANTING_TABLE, "PARTICLE_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.ENCHANTMENT_TABLE)),
HAPPY(new SimpleParticle(new ParticleItem(EMERALD_BLOCK, "PARTICLE_HAPPY", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.VILLAGER_HAPPY, 0.2F, 0.2F, 0.2F, 0.01)),
FLAME(new SimpleParticle(new ParticleItem(FLINT_AND_STEEL, "PARTICLE_FLAME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FLAME, 0F, 0.2F, 0F, 0.01)),
END_ROD(new SimpleParticle(new ParticleItem(Material.END_ROD, "PARTICLE_END_ROD", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.END_ROD, 0.2F, 0.2F, 0.2F, 0.01)),
CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(WHITE_WOOL, "PARTICLE_CLOUD", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.CLOUD))),
TOTEM(new CloudParticle(new SimpleParticle(new ParticleItem(TOTEM_OF_UNDYING, "PARTICLE_TOTEM", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.TOTEM, 0.2F, 0.2F, 0.2F, 0.01))),
ENCHANTING_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(WHITE_DYE, "PARTICLE_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.ENCHANTMENT_TABLE))),
FLAME_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(FIRE_CORAL_BLOCK, "PARTICLE_FLAME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FLAME))),
SNEEZE_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(LIME_SHULKER_BOX, "PARTICLE_SNEEZE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.SNEEZE))),
SLIME_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(GREEN_SHULKER_BOX, "PARTICLE_SLIME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.SLIME))),
SMOKE_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(DEAD_BRAIN_CORAL_BLOCK, "PARTICLE_SMOKE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.CAMPFIRE_COSY_SMOKE, 0.2F, 0.2F, 0.2F, 0.01))),
TOWN_CLOUD(new CloudParticle(new SimpleParticle(new ParticleItem(FIREWORK_STAR, "PARTICLE_TOWN", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.TOWN_AURA))),
FLAME_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(MAGMA_BLOCK, "PARTICLE_FLAME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FLAME, 0F, 0F, 0F, 0.01), location -> location.add(0, 1.1, 0)))),
ENCHANTING_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(WHITE_DYE, "PARTICLE_ENCHANTING_CIRCLE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.ENCHANTMENT_TABLE, 0.2F, 0.2F, 0.2F, 0.01), location -> location.add(0, 1.1, 0)))),
NOTES_CIRCLE(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(NOTE_BLOCK, "PARTICLE_NOTES", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.NOTE, 0F, 0F, 0F, 0.01), location -> location.add(0, 2.2, 0)))),
WATER_FIRE(new LocationParticleMutator(new CircleParticle(new ParticleItem(GUARDIAN_SPAWN_EGG, "PARTICLE_WATER_FIRE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null, Particle.DRIP_WATER, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null, Particle.DRIP_LAVA, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 1.1, 0))),
WATER_FIRE_ALWAYS(new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleItem(MAGMA_CUBE_SPAWN_EGG, "PARTICLE_WATER_FIRE", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null,Particle.DRIP_WATER, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null,Particle.DRIP_LAVA, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 1.1, 0)))),
MAGIC_ENCHANTING(new LocationParticleMutator(new CircleParticle(new ParticleItem(DIAMOND_SWORD, "PARTICLE_MAGIC_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null, Particle.CRIT_MAGIC, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null, Particle.ENCHANTMENT_TABLE, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 1.1, 0))),
MAGIC_ENCHANTING_ALWAYS(new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleItem(WOODEN_SWORD, "PARTICLE_MAGIC_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null, Particle.CRIT_MAGIC, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null, Particle.ENCHANTMENT_TABLE, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 1.1, 0)))),
MAGIC_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(GLOWSTONE_DUST, "PARTICLE_MAGIC", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.CRIT_MAGIC, 0.0F, 0.0F, 0.0F, 0.01), location -> location.add(0, 1.1, 0))))),
FLAME_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(FIRE_CORAL, "PARTICLE_FLAME", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FLAME, 0.0F, 0.0F, 0.0F, 0.01), location -> location.add(0, 1.1, 0))))),
FIREWORK_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(FIREWORK_ROCKET, "PARTICLE_FIREWORK", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.FIREWORKS_SPARK, 0.0F, 0.0F, 0.0F, 0.01), location -> location.add(0, 1.1, 0))))),
WATER_CLOUD_CIRCLE(new CloudParticle(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(CYAN_DYE, "PARTICLE_WATER", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.WATER_WAKE, 0.0F, 0.0F, 0.0F, 0.01), location -> location.add(0, 1.1, 0))))),
ENCHANTING_DOUBLE_CIRCLE(new TickParticle(new LocationParticleMutator(new CircleParticle(new ParticleItem(BUBBLE_CORAL_BLOCK, "PARTICLE_ENCHANTING", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), new SimpleParticle(null, Particle.ENCHANTMENT_TABLE, 0.0F, 0.0F, 0.0F, 0.01), new SimpleParticle(null, Particle.ENCHANTMENT_TABLE, 0.0F, 0.0F, 0.0F, 0.01)), location -> location.add(0, 2.2, 0)))),
EVIL_WINGS(new TickParticle(new WingParticle(new SimpleParticle(new ParticleItem(PURPUR_SLAB, "PARTICLE_WINGS_EVIL", "PARTICLE_UNLOCKED_BY_SERVER_TEAM"), Particle.SPELL_WITCH, 0, 0, 0, 0, 1), 0.15, WingParticle.WingDesign.SIMPLE))),
;
public static ParticleEnum[] particles = values();
@Getter
private BaseParticle particle;
}

Datei anzeigen

@ -0,0 +1,52 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.lobby.particle.particles;
import de.steamwar.lobby.particle.BaseParticle;
import de.steamwar.lobby.particle.ParticleItem;
import de.steamwar.lobby.particle.SimpleParticle;
import de.steamwar.lobby.particle.decorator.CircleParticle;
import de.steamwar.lobby.particle.decorator.NonFloorParticle;
import de.steamwar.lobby.particle.mutator.LocationParticleMutator;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.Material;
import org.bukkit.Particle;
import static org.bukkit.Material.*;
@AllArgsConstructor
public enum TeamParticle implements ParticleEnum {
SQUID(new SimpleParticle(new ParticleItem(INK_SAC, "PARTICLE_SQUID", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.SQUID_INK, 0.2F, 0.2F, 0.2F, 0.01)),
BUBBLE(new SimpleParticle(new ParticleItem(TUBE_CORAL, "PARTICLE_BUBBLE", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.BUBBLE_POP, 0.2F, 0.2F, 0.2F, 0.01)),
HONEY(new SimpleParticle(new ParticleItem(HONEY_BOTTLE, "PARTICLE_HONEY", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.DRIPPING_HONEY, 0.2F, 0.2F, 0.2F, 1)),
NECTAR(new SimpleParticle(new ParticleItem(HONEYCOMB, "PARTICLE_NECTAR", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.FALLING_NECTAR, 0.2F, 0.2F, 0.2F, 1)),
FIREWORK(new LocationParticleMutator(new NonFloorParticle(new SimpleParticle(new ParticleItem(FIRE_CHARGE, "PARTICLE_FIREWORK", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.FIREWORKS_SPARK, 0.1F, 0.1F, 0.1F, 0.2, 2)), location -> location.subtract(0, -0.2, 0))),
DRAGON_BREATH(new SimpleParticle(new ParticleItem(Material.DRAGON_BREATH, "PARTICLE_DRAGON_BREATH", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.DRAGON_BREATH, 1F, 0.2F, 1F, 0.01)),
DAMAGE(new SimpleParticle(new ParticleItem(SPIDER_EYE, "PARTICLE_DAMAGE", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.DAMAGE_INDICATOR, 0.2F, 0F, 0.2F, 0.01)),
DOLPHIN(new SimpleParticle(new ParticleItem(BLUE_DYE, "PARTICLE_DOLPHIN", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.DOLPHIN, 0.2F, 0F, 0.2F, 0.01)),
HEART(new CircleParticle(new LocationParticleMutator(new SimpleParticle(new ParticleItem(RED_CONCRETE, "PARTICLE_HEART", "PARTICLE_UNLOCKED_BY_TEAM"), Particle.HEART), location -> location.add(0, 2.2, 0)))),
;
public static ParticleEnum[] particles = values();
@Getter
private BaseParticle particle;
}

Datei anzeigen

@ -0,0 +1,204 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
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 lombok.AllArgsConstructor;
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.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;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.stream.Collectors;
public class TeamPlayer extends BasicListener {
private static final List<Cuboid> 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(1478, 52, 1461, 1479, 56, 1463));
}
private static final World world = Bukkit.getWorlds().get(0);
private static final Map<String, NPC> entities = new HashMap<>();
private Set<Player> players = new HashSet<>();
private Random random = new Random();
private List<String> 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();
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.NONE);
entities.put(name, npc);
}
public static void cleanup() {
forceLoad(world, true);
world.getEntitiesByClasses(Villager.class).forEach(Entity::remove);
forceLoad(world, false);
}
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);
}
}
}
{
forceLoad(world, true);
world.getEntitiesByClasses(Villager.class).forEach(Entity::remove);
forceLoad(world, false);
SteamwarUser.getServerTeam().forEach(user -> {
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<SteamwarUser> 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<String> 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();
});
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());
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 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) {
event.setCancelled(true);
}
}
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if (event.getEntityType() == EntityType.VILLAGER) {
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;
}
}
}

Datei anzeigen

@ -19,7 +19,9 @@
package de.steamwar.lobby.util; package de.steamwar.lobby.util;
import de.steamwar.lobby.particle.SpecialParticle; import de.steamwar.lobby.particle.particles.*;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserConfig;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.HashMap; import java.util.HashMap;
@ -30,13 +32,40 @@ public class LobbyPlayer {
private static Map<UUID, LobbyPlayer> cache = new HashMap<>(); private static Map<UUID, LobbyPlayer> cache = new HashMap<>();
private SpecialParticle specialParticle; private ParticleEnum particle;
private int userId;
private boolean fly; private boolean fly;
private LobbyPlayer(UUID uuid) { private LobbyPlayer(UUID uuid) {
userId = SteamwarUser.get(uuid).getId();
cache.put(uuid, this); cache.put(uuid, this);
specialParticle = null; 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 "EventParticle":
particle = EventParticle.valueOf(strings[1]);
case "EventParticleParticipation":
particle = EventParticleParticipation.valueOf(strings[1]);
break;
case "EventParticlePlacement":
particle = EventParticlePlacement.valueOf(strings[1]);
break;
default:
break;
}
}
} }
public boolean isFlying() { public boolean isFlying() {
@ -47,12 +76,18 @@ public class LobbyPlayer {
this.fly = fly; this.fly = fly;
} }
public SpecialParticle getParticle() { public ParticleEnum getParticle() {
return specialParticle; return particle;
} }
public void setParticle(SpecialParticle specialParticle) { public void setParticle(ParticleEnum particle) {
this.specialParticle = specialParticle; if (particle == null) {
UserConfig.removePlayerConfig(userId, "lobby-particle");
} else {
String saved = particle.getClass().getSimpleName() + "@" + ((Enum<?>) particle).name();
UserConfig.updatePlayerConfig(userId, "lobby-particle", saved);
}
this.particle = particle;
} }
public static LobbyPlayer getLobbyPlayer(UUID uuid) { public static LobbyPlayer getLobbyPlayer(UUID uuid) {
@ -63,5 +98,4 @@ public class LobbyPlayer {
public static LobbyPlayer getLobbyPlayer(Player player) { public static LobbyPlayer getLobbyPlayer(Player player) {
return getLobbyPlayer(player.getUniqueId()); return getLobbyPlayer(player.getUniqueId());
} }
} }