Add LobbyPlayer save and load particle via DB
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Ursprung
bb86bed319
Commit
62163b7296
@ -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<UUID, LobbyPlayer> 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;
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren