Dieser Commit ist enthalten in:
Ursprung
950f7716b3
Commit
cbc97f81e4
@ -9,6 +9,7 @@ import de.steamwar.sql.internal.Statement;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
@ -60,11 +61,11 @@ public class Leaderboard implements Listener {
|
|||||||
entity.setInvisible(true);
|
entity.setInvisible(true);
|
||||||
}
|
}
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
updatePlayerPlacement(SteamwarUser.get(player.getUniqueId()));
|
updatePlayerPlacement(player, SteamwarUser.get(player.getUniqueId()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePlayerPlacement(SteamwarUser steamwarUser) {
|
private void updatePlayerPlacement(Player player, SteamwarUser steamwarUser) {
|
||||||
if (server.getEntities().isEmpty()) return;
|
if (server.getEntities().isEmpty()) return;
|
||||||
int placement = getPlayerPlacement(steamwarUser);
|
int placement = getPlayerPlacement(steamwarUser);
|
||||||
if (placement < 5) {
|
if (placement < 5) {
|
||||||
@ -73,11 +74,15 @@ public class Leaderboard implements Listener {
|
|||||||
entityServer.getEntities().forEach(rEntity -> rEntity.hide(true));
|
entityServer.getEntities().forEach(rEntity -> rEntity.hide(true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
REntityServer entityServer = playerPlacements.computeIfAbsent(steamwarUser.getId(), ignore -> new REntityServer());
|
REntityServer entityServer = playerPlacements.computeIfAbsent(steamwarUser.getId(), ignore -> {
|
||||||
|
REntityServer server = new REntityServer();
|
||||||
|
server.addPlayer(player);
|
||||||
|
return server;
|
||||||
|
});
|
||||||
List<REntity> entities = entityServer.getEntities();
|
List<REntity> entities = entityServer.getEntities();
|
||||||
RArmorStand entity;
|
RArmorStand entity;
|
||||||
if (entities.isEmpty()) {
|
if (entities.isEmpty()) {
|
||||||
entity = new RArmorStand(server, location.clone().add(0, -2 * 0.32, 0), RArmorStand.Size.MARKER);
|
entity = new RArmorStand(entityServer, location.clone().add(0, -2 * 0.32, 0), RArmorStand.Size.MARKER);
|
||||||
entity.setInvisible(true);
|
entity.setInvisible(true);
|
||||||
} else {
|
} else {
|
||||||
entity = (RArmorStand) entities.get(0);
|
entity = (RArmorStand) entities.get(0);
|
||||||
@ -149,7 +154,7 @@ public class Leaderboard implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(event.getPlayer().getUniqueId());
|
SteamwarUser steamwarUser = SteamwarUser.get(event.getPlayer().getUniqueId());
|
||||||
updatePlayerPlacement(steamwarUser);
|
updatePlayerPlacement(event.getPlayer(), steamwarUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren