mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-27 10:31:51 +01:00
Fixed thread safety
This commit is contained in:
parent
d4bf3bd2ec
commit
cc203b1a1a
@ -11,10 +11,9 @@ public class EntityManager {
|
|||||||
|
|
||||||
private Set<LivingEntity> livingEntities = Collections.synchronizedSet(new HashSet<>());
|
private Set<LivingEntity> livingEntities = Collections.synchronizedSet(new HashSet<>());
|
||||||
|
|
||||||
private ExecutorService pool = Executors.newFixedThreadPool(5);
|
private ExecutorService pool = Executors.newFixedThreadPool(50);
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
|
|
||||||
livingEntities.removeIf(livingEntity -> livingEntity.shouldRemove());
|
livingEntities.removeIf(livingEntity -> livingEntity.shouldRemove());
|
||||||
|
|
||||||
synchronized (livingEntities) {
|
synchronized (livingEntities) {
|
||||||
|
@ -11,7 +11,6 @@ public class ChickenCreature extends EntityCreature {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
//System.out.println("Update poulet");
|
|
||||||
onGround = true;
|
onGround = true;
|
||||||
|
|
||||||
double speed = 0.01;
|
double speed = 0.01;
|
||||||
|
@ -3,12 +3,14 @@ package fr.themode.minestom.net;
|
|||||||
import fr.themode.minestom.entity.Player;
|
import fr.themode.minestom.entity.Player;
|
||||||
import fr.themode.minestom.net.player.PlayerConnection;
|
import fr.themode.minestom.net.player.PlayerConnection;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ConnectionManager {
|
public class ConnectionManager {
|
||||||
|
|
||||||
private Set<PlayerConnection> connections = new HashSet<>();
|
private volatile Map<PlayerConnection, Player> connectionPlayerMap = new HashMap<>();
|
||||||
private Map<PlayerConnection, Player> connectionPlayerMap = new HashMap<>();
|
|
||||||
|
|
||||||
public Player getPlayer(PlayerConnection connection) {
|
public Player getPlayer(PlayerConnection connection) {
|
||||||
return connectionPlayerMap.get(connection);
|
return connectionPlayerMap.get(connection);
|
||||||
|
Loading…
Reference in New Issue
Block a user