Update ParticleListener
Update LobbyPlayer Update ParticleInventory
Dieser Commit ist enthalten in:
Ursprung
84b04b1198
Commit
7c16a7a315
@ -20,8 +20,9 @@
|
||||
package de.steamwar.lobby.listener;
|
||||
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.lobby.particle.BaseParticle;
|
||||
import de.steamwar.lobby.particle.ParticleData;
|
||||
import de.steamwar.lobby.particle.ParticleInventory;
|
||||
import de.steamwar.lobby.particle.SpecialParticle;
|
||||
import de.steamwar.lobby.util.LobbyPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -40,9 +41,11 @@ public class ParticleListener extends BasicListener {
|
||||
if (deg > 360) deg = 0;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
SpecialParticle particle = lobbyPlayer.getParticle();
|
||||
BaseParticle particle = lobbyPlayer.getParticle();
|
||||
if (particle == null) return;
|
||||
particle.execute(player.getWorld(), player, deg);
|
||||
if (particle.needsTick()) {
|
||||
particle.particle(new ParticleData(player.getWorld(), player, deg));
|
||||
}
|
||||
});
|
||||
}, 0, 1);
|
||||
}
|
||||
@ -59,9 +62,9 @@ public class ParticleListener extends BasicListener {
|
||||
public void handlePlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
SpecialParticle particle = lobbyPlayer.getParticle();
|
||||
BaseParticle particle = lobbyPlayer.getParticle();
|
||||
|
||||
if (particle == null) return;
|
||||
particle.execute(player.getWorld(), player, deg);
|
||||
particle.particle(new ParticleData(player.getWorld(), player, deg));
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
package de.steamwar.lobby.particle;
|
||||
|
||||
import de.steamwar.lobby.particle.decorator.CircleParticle;
|
||||
import de.steamwar.lobby.particle.decorator.CloudParticle;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
|
||||
@ -31,16 +33,15 @@ public enum EventParticle {
|
||||
|
||||
public static EventParticle[] eventParticles = values();
|
||||
|
||||
EventParticle(int event, int[] placementTeams, SpecialParticle placementParticle, SpecialParticle participationParticles) {
|
||||
EventParticle(int event, int[] placementTeams, BaseParticle placementParticle, BaseParticle participationParticles) {
|
||||
this.event = event;
|
||||
this.placementTeams = placementTeams;
|
||||
this.placementParticle = placementParticle;
|
||||
this.participationParticles = participationParticles;
|
||||
|
||||
}
|
||||
|
||||
public final int event;
|
||||
public final int[] placementTeams;
|
||||
public final SpecialParticle placementParticle;
|
||||
public final SpecialParticle participationParticles;
|
||||
public final BaseParticle placementParticle;
|
||||
public final BaseParticle participationParticles;
|
||||
}
|
||||
|
@ -22,15 +22,12 @@ package de.steamwar.lobby.particle;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.steamwar.lobby.particle.decorator.CircleParticle;
|
||||
import de.steamwar.lobby.particle.decorator.CloudParticle;
|
||||
import de.steamwar.lobby.util.LobbyPlayer;
|
||||
import de.steamwar.sql.Event;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.TeamTeilnahme;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -44,23 +41,24 @@ public class ParticleInventory {
|
||||
private ParticleInventory() {
|
||||
}
|
||||
|
||||
private static void calculateParticles(ParticleEnum[] particles, Player player, List<SWListInv.SWListEntry<BaseParticle>> particleList) {
|
||||
for (ParticleEnum particle : particles) {
|
||||
particleList.add(new SWListInv.SWListEntry<>(particle.getParticle().getItem().toSWItem(player), particle.getParticle()));
|
||||
}
|
||||
}
|
||||
|
||||
private static SWInventory createInventory(Player player) {
|
||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
||||
|
||||
List<SWListInv.SWListEntry<SpecialParticle>> particleList;
|
||||
if (userGroup == UserGroup.Member) {
|
||||
if (steamwarUser.getTeam() != 0) {
|
||||
particleList = new ArrayList<>(TEAM_PARTICLES_ENTRIES);
|
||||
} else {
|
||||
if (TEAM_PARTICLES.contains(lobbyPlayer.getParticle())) {
|
||||
lobbyPlayer.setParticle(null);
|
||||
List<SWListInv.SWListEntry<BaseParticle>> particleList = new ArrayList<>();
|
||||
calculateParticles(PlayerParticle.particles, player, particleList);
|
||||
if (steamwarUser.getTeam() != 0 || userGroup != UserGroup.Member) {
|
||||
calculateParticles(TeamParticle.particles, player, particleList);
|
||||
}
|
||||
particleList = new ArrayList<>(PLAYER_PARTICLES_ENTRIES);
|
||||
}
|
||||
} else {
|
||||
particleList = new ArrayList<>(SERVERTEAM_PARTICLES_ENTRIES);
|
||||
if (userGroup != UserGroup.Member) {
|
||||
calculateParticles(ServerTeamParticle.particles, player, particleList);
|
||||
}
|
||||
|
||||
Set<Integer> events = steamwarUser.getTeam() == 0 ? new HashSet<>() : TeamTeilnahme.getEvents(steamwarUser.getTeam()).stream().map(Event::getEventID).collect(Collectors.toSet());
|
||||
@ -84,7 +82,7 @@ public class ParticleInventory {
|
||||
}
|
||||
}
|
||||
|
||||
SWListInv<SpecialParticle> particleSWListInv = new SWListInv<>(player, "§6Partikel", false, particleList, (clickType, particle) -> {
|
||||
SWListInv<BaseParticle> particleSWListInv = new SWListInv<>(player, "§6Partikel", false, particleList, (clickType, particle) -> {
|
||||
if (particle == null) return;
|
||||
lobbyPlayer.setParticle(particle);
|
||||
player.closeInventory();
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package de.steamwar.lobby.util;
|
||||
|
||||
import de.steamwar.lobby.particle.SpecialParticle;
|
||||
import de.steamwar.lobby.particle.BaseParticle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -30,13 +30,13 @@ public class LobbyPlayer {
|
||||
|
||||
private static Map<UUID, LobbyPlayer> cache = new HashMap<>();
|
||||
|
||||
private SpecialParticle specialParticle;
|
||||
private BaseParticle particle;
|
||||
|
||||
private boolean fly;
|
||||
|
||||
private LobbyPlayer(UUID uuid) {
|
||||
cache.put(uuid, this);
|
||||
specialParticle = null;
|
||||
particle = null;
|
||||
}
|
||||
|
||||
public boolean isFlying() {
|
||||
@ -47,12 +47,12 @@ public class LobbyPlayer {
|
||||
this.fly = fly;
|
||||
}
|
||||
|
||||
public SpecialParticle getParticle() {
|
||||
return specialParticle;
|
||||
public BaseParticle getParticle() {
|
||||
return particle;
|
||||
}
|
||||
|
||||
public void setParticle(SpecialParticle specialParticle) {
|
||||
this.specialParticle = specialParticle;
|
||||
public void setParticle(BaseParticle specialParticle) {
|
||||
this.particle = specialParticle;
|
||||
}
|
||||
|
||||
public static LobbyPlayer getLobbyPlayer(UUID uuid) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren