Correction d'un bug de synchronisation dans le OnlinePlayerManager
This commit is contained in:
parent
762e33e981
commit
650f6891ea
@ -53,13 +53,13 @@ public final class OnlinePlayerManager {
|
|||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
// -------------- Evènements --------------
|
// -------------- Evènements --------------
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
public void onPlayerJoin (PlayerJoinEvent event)
|
public synchronized void onPlayerJoin (PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
players.put(event.getPlayer(), new OnlinePlayer(event.getPlayer()));
|
players.put(event.getPlayer(), new OnlinePlayer(event.getPlayer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void onPlayerQuit (PlayerQuitEvent event)
|
public synchronized void onPlayerQuit (PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
players.remove(event.getPlayer());
|
players.remove(event.getPlayer());
|
||||||
}
|
}
|
||||||
@ -74,16 +74,16 @@ public final class OnlinePlayerManager {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static OnlinePlayer get(Player p) {
|
public synchronized static OnlinePlayer get(Player p) {
|
||||||
return getInstance().players.get(p);
|
return getInstance().players.get(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<OnlinePlayer> getAll() {
|
public synchronized static Collection<OnlinePlayer> getAll() {
|
||||||
return new ArrayList<OnlinePlayer>(getInstance().players.values());
|
return new ArrayList<OnlinePlayer>(getInstance().players.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean isOnline(Player p) {
|
public synchronized static boolean isOnline(Player p) {
|
||||||
return getInstance().players.containsKey(p);
|
return getInstance().players.containsKey(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user