13
0

Hotfix TeamPlayer infinite Villager glitch
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2023-04-06 20:02:06 +02:00
Ursprung 93933ec92c
Commit 64d9068d3d
2 geänderte Dateien mit 8 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -84,7 +84,6 @@ public class LobbySystem extends JavaPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
TeamPlayer.cleanup();
} }
public static LobbySystem getPlugin() { public static LobbySystem getPlugin() {

Datei anzeigen

@ -79,11 +79,6 @@ public class TeamPlayer extends BasicListener {
entities.put(name, npc); entities.put(name, npc);
} }
public static void cleanup() {
villagers.values().forEach(Entity::remove);
entities.values().forEach(NPC::delete);
}
{ {
SteamwarUser.getServerTeam().forEach(user -> { SteamwarUser.getServerTeam().forEach(user -> {
spawnTeamPlayer(world, user); spawnTeamPlayer(world, user);
@ -92,6 +87,14 @@ public class TeamPlayer extends BasicListener {
AtomicInteger count = new AtomicInteger(); AtomicInteger count = new AtomicInteger();
LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players"); LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players");
Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> { Bukkit.getScheduler().runTaskTimer(LobbySystem.getPlugin(), () -> {
Collection<Villager> active = world.getEntitiesByClass(Villager.class);
if (active.size() > entities.size()) {
Set<String> duplicates = new HashSet<>();
active.stream()
.filter(villager -> !duplicates.add(villager.getCustomName()))
.forEach(Entity::remove);
}
count.incrementAndGet(); count.incrementAndGet();
if (count.get() % (20 * 60 * 60) == 0) { if (count.get() % (20 * 60 * 60) == 0) {
count.set(0); count.set(0);