Hotfix TeamPlayer infinite Villager glitch
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Ursprung
93933ec92c
Commit
64d9068d3d
@ -84,7 +84,6 @@ public class LobbySystem extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
TeamPlayer.cleanup();
|
||||
}
|
||||
|
||||
public static LobbySystem getPlugin() {
|
||||
|
@ -79,11 +79,6 @@ public class TeamPlayer extends BasicListener {
|
||||
entities.put(name, npc);
|
||||
}
|
||||
|
||||
public static void cleanup() {
|
||||
villagers.values().forEach(Entity::remove);
|
||||
entities.values().forEach(NPC::delete);
|
||||
}
|
||||
|
||||
{
|
||||
SteamwarUser.getServerTeam().forEach(user -> {
|
||||
spawnTeamPlayer(world, user);
|
||||
@ -92,6 +87,14 @@ public class TeamPlayer extends BasicListener {
|
||||
AtomicInteger count = new AtomicInteger();
|
||||
LobbySystem.getPlugin().getLogger().log(Level.INFO, "Loaded " + entities.size() + " team players");
|
||||
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();
|
||||
if (count.get() % (20 * 60 * 60) == 0) {
|
||||
count.set(0);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren