Move tick call responsibility to EntityServer owner
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Dieser Commit ist enthalten in:
Ursprung
81a77fd1de
Commit
c340f11666
@ -29,7 +29,6 @@ import org.bukkit.event.HandlerList;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -46,11 +45,8 @@ public class REntityServer implements Listener {
|
|||||||
private final HashMap<Long, HashSet<Player>> players = new HashMap<>();
|
private final HashMap<Long, HashSet<Player>> players = new HashMap<>();
|
||||||
private final HashMap<Player, Location> lastLocation = new HashMap<>();
|
private final HashMap<Player, Location> lastLocation = new HashMap<>();
|
||||||
|
|
||||||
private final BukkitTask tickTask;
|
|
||||||
|
|
||||||
public REntityServer() {
|
public REntityServer() {
|
||||||
Core.getInstance().getServer().getPluginManager().registerEvents(this, Core.getInstance());
|
Core.getInstance().getServer().getPluginManager().registerEvents(this, Core.getInstance());
|
||||||
tickTask = Core.getInstance().getServer().getScheduler().runTaskTimer(Core.getInstance(), this::tick, 1, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(Player player) {
|
public void addPlayer(Player player) {
|
||||||
@ -68,7 +64,6 @@ public class REntityServer implements Listener {
|
|||||||
for(Player player : lastLocation.keySet().toArray(new Player[0])) {
|
for(Player player : lastLocation.keySet().toArray(new Player[0])) {
|
||||||
removePlayer(player);
|
removePlayer(player);
|
||||||
}
|
}
|
||||||
tickTask.cancel();
|
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +181,7 @@ public class REntityServer implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tick() {
|
public void tick() {
|
||||||
for(HashSet<REntity> entitiesInChunk : entities.values()) {
|
for(HashSet<REntity> entitiesInChunk : entities.values()) {
|
||||||
for(REntity entity : entitiesInChunk) {
|
for(REntity entity : entitiesInChunk) {
|
||||||
entity.tick();
|
entity.tick();
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren