diff --git a/src/de/steamwar/lobby/util/LobbyPlayer.java b/src/de/steamwar/lobby/util/LobbyPlayer.java index 031cade..44f01c7 100644 --- a/src/de/steamwar/lobby/util/LobbyPlayer.java +++ b/src/de/steamwar/lobby/util/LobbyPlayer.java @@ -19,7 +19,9 @@ package de.steamwar.lobby.util; -import de.steamwar.lobby.particle.particles.ParticleEnum; +import de.steamwar.lobby.particle.particles.*; +import de.steamwar.sql.SteamwarUser; +import de.steamwar.sql.UserConfig; import org.bukkit.entity.Player; import java.util.HashMap; @@ -31,12 +33,37 @@ public class LobbyPlayer { private static Map cache = new HashMap<>(); private ParticleEnum particle; + private int userId; private boolean fly; private LobbyPlayer(UUID uuid) { + userId = SteamwarUser.get(uuid).getId(); cache.put(uuid, this); particle = null; + String saved = UserConfig.getConfig(userId, "lobby-particle"); + if (saved != null) { + String[] strings = saved.split("@"); + switch (strings[0]) { + case "PlayerParticle": + particle = PlayerParticle.valueOf(strings[1]); + break; + case "TeamParticle": + particle = TeamParticle.valueOf(strings[1]); + break; + case "ServerTeamParticle": + particle = ServerTeamParticle.valueOf(strings[1]); + break; + case "EventParticleParticipation": + particle = EventParticleParticipation.valueOf(strings[1]); + break; + case "EventParticlePlacement": + particle = EventParticlePlacement.valueOf(strings[1]); + break; + default: + break; + } + } } public boolean isFlying() { @@ -52,6 +79,13 @@ public class LobbyPlayer { } public void setParticle(ParticleEnum particle) { + if (particle == null) { + UserConfig.removePlayerConfig(userId, "lobby-particle"); + } else { + Class clazz = particle.getClass(); + String saved = clazz.getSimpleName() + "@" + ((Enum) particle).name(); + UserConfig.updatePlayerConfig(userId, "lobby-particle", saved); + } this.particle = particle; }