13
0

Update ParticleListener

Update LobbyPlayer
Update ParticleInventory
Dieser Commit ist enthalten in:
yoyosource 2022-03-24 17:01:47 +01:00
Ursprung 84b04b1198
Commit 7c16a7a315
4 geänderte Dateien mit 34 neuen und 32 gelöschten Zeilen

Datei anzeigen

@ -20,8 +20,9 @@
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.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;
@ -40,9 +41,11 @@ public class ParticleListener extends BasicListener {
if (deg > 360) deg = 0; if (deg > 360) deg = 0;
Bukkit.getOnlinePlayers().forEach(player -> { Bukkit.getOnlinePlayers().forEach(player -> {
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
SpecialParticle particle = lobbyPlayer.getParticle(); BaseParticle particle = lobbyPlayer.getParticle();
if (particle == null) return; if (particle == null) return;
particle.execute(player.getWorld(), player, deg); if (particle.needsTick()) {
particle.particle(new ParticleData(player.getWorld(), player, deg));
}
}); });
}, 0, 1); }, 0, 1);
} }
@ -59,9 +62,9 @@ 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(); BaseParticle particle = lobbyPlayer.getParticle();
if (particle == null) return; if (particle == null) return;
particle.execute(player.getWorld(), player, deg); particle.particle(new ParticleData(player.getWorld(), player, deg));
} }
} }

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.lobby.particle; 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.Material;
import org.bukkit.Particle; import org.bukkit.Particle;
@ -31,16 +33,15 @@ public enum EventParticle {
public static EventParticle[] eventParticles = values(); 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.event = event;
this.placementTeams = placementTeams; this.placementTeams = placementTeams;
this.placementParticle = placementParticle; this.placementParticle = placementParticle;
this.participationParticles = participationParticles; this.participationParticles = participationParticles;
} }
public final int event; public final int event;
public final int[] placementTeams; public final int[] placementTeams;
public final SpecialParticle placementParticle; public final BaseParticle placementParticle;
public final SpecialParticle participationParticles; public final BaseParticle participationParticles;
} }

Datei anzeigen

@ -22,15 +22,12 @@ 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.particle.decorator.CircleParticle;
import de.steamwar.lobby.particle.decorator.CloudParticle;
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;
@ -44,23 +41,24 @@ public class ParticleInventory {
private 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) { private static SWInventory createInventory(Player player) {
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
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<BaseParticle>> 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())) {
lobbyPlayer.setParticle(null);
} }
particleList = new ArrayList<>(PLAYER_PARTICLES_ENTRIES); if (userGroup != UserGroup.Member) {
} calculateParticles(ServerTeamParticle.particles, player, particleList);
} 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());
@ -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; if (particle == null) return;
lobbyPlayer.setParticle(particle); lobbyPlayer.setParticle(particle);
player.closeInventory(); player.closeInventory();

Datei anzeigen

@ -19,7 +19,7 @@
package de.steamwar.lobby.util; package de.steamwar.lobby.util;
import de.steamwar.lobby.particle.SpecialParticle; import de.steamwar.lobby.particle.BaseParticle;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.HashMap; import java.util.HashMap;
@ -30,13 +30,13 @@ public class LobbyPlayer {
private static Map<UUID, LobbyPlayer> cache = new HashMap<>(); private static Map<UUID, LobbyPlayer> cache = new HashMap<>();
private SpecialParticle specialParticle; private BaseParticle particle;
private boolean fly; private boolean fly;
private LobbyPlayer(UUID uuid) { private LobbyPlayer(UUID uuid) {
cache.put(uuid, this); cache.put(uuid, this);
specialParticle = null; particle = null;
} }
public boolean isFlying() { public boolean isFlying() {
@ -47,12 +47,12 @@ public class LobbyPlayer {
this.fly = fly; this.fly = fly;
} }
public SpecialParticle getParticle() { public BaseParticle getParticle() {
return specialParticle; return particle;
} }
public void setParticle(SpecialParticle specialParticle) { public void setParticle(BaseParticle specialParticle) {
this.specialParticle = specialParticle; this.particle = specialParticle;
} }
public static LobbyPlayer getLobbyPlayer(UUID uuid) { public static LobbyPlayer getLobbyPlayer(UUID uuid) {