forked from LogBlock/LogBlock
Tidied up session management
This commit is contained in:
@@ -101,7 +101,7 @@ class LBToolListener extends PlayerListener
|
|||||||
@Override
|
@Override
|
||||||
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
|
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final Session session = logblock.getSessions().get(player.getName().hashCode());
|
final Session session = logblock.getSession(player.getName(), false);
|
||||||
if (session != null)
|
if (session != null)
|
||||||
for (final Entry<Tool, ToolData> entry : session.toolData.entrySet()) {
|
for (final Entry<Tool, ToolData> entry : session.toolData.entrySet()) {
|
||||||
final Tool tool = entry.getKey();
|
final Tool tool = entry.getKey();
|
||||||
|
@@ -41,7 +41,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
private Timer timer = null;
|
private Timer timer = null;
|
||||||
private PermissionHandler permissions = null;
|
private PermissionHandler permissions = null;
|
||||||
private boolean errorAtLoading = false;
|
private boolean errorAtLoading = false;
|
||||||
private final Map<Integer, Session> sessions = new HashMap<Integer, Session>();
|
private final Map<String, Session> sessions = new HashMap<String, Session>();
|
||||||
|
|
||||||
public Config getLBConfig() {
|
public Config getLBConfig() {
|
||||||
return config;
|
return config;
|
||||||
@@ -297,15 +297,15 @@ public class LogBlock extends JavaPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, Session> getSessions() {
|
public Session getSession(String playerName) {
|
||||||
return sessions;
|
return getSession(playerName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Session getSession(String playerName) {
|
public Session getSession(String playerName, boolean create) {
|
||||||
Session session = sessions.get(playerName.hashCode());
|
Session session = sessions.get(playerName.toLowerCase());
|
||||||
if (session == null) {
|
if (session == null && create) {
|
||||||
session = new Session(this, getServer().getPlayer(playerName));
|
session = new Session(this, getServer().getPlayer(playerName));
|
||||||
sessions.put(playerName.hashCode(), session);
|
sessions.put(playerName.toLowerCase(), session);
|
||||||
}
|
}
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user