15
15
import java .util .concurrent .ConcurrentSkipListSet ;
16
16
import java .util .concurrent .ExecutionException ;
17
17
import net .ess3 .api .IEssentials ;
18
+ import org .bukkit .Bukkit ;
18
19
import org .bukkit .entity .Player ;
19
20
20
21
@@ -33,7 +34,6 @@ public UserMap(final IEssentials ess)
33
34
this .ess = ess ;
34
35
uuidMap = new UUIDMap (ess );
35
36
users = CacheBuilder .newBuilder ().maximumSize (ess .getSettings ().getMaxUserCacheCount ()).softValues ().build (this );
36
- loadAllUsersAsync (ess );
37
37
}
38
38
39
39
private void loadAllUsersAsync (final IEssentials ess )
@@ -43,33 +43,34 @@ private void loadAllUsersAsync(final IEssentials ess)
43
43
@ Override
44
44
public void run ()
45
45
{
46
- final File userdir = new File (ess .getDataFolder (), "userdata" );
47
- if (!userdir .exists ())
48
- {
49
- return ;
50
- }
51
- keys .clear ();
52
- names .clear ();
53
- users .invalidateAll ();
54
- for (String string : userdir .list ())
46
+ synchronized (users )
55
47
{
56
- if (!string .endsWith (".yml" ))
57
- {
58
- continue ;
59
- }
60
- final String name = string .substring (0 , string .length () - 4 );
61
- try
48
+ final File userdir = new File (ess .getDataFolder (), "userdata" );
49
+ if (!userdir .exists ())
62
50
{
63
- keys . add ( UUID . fromString ( name )) ;
51
+ return ;
64
52
}
65
- catch (IllegalArgumentException ex )
53
+ keys .clear ();
54
+ names .clear ();
55
+ users .invalidateAll ();
56
+ for (String string : userdir .list ())
66
57
{
67
- //Ignore these users till they rejoin.
58
+ if (!string .endsWith (".yml" ))
59
+ {
60
+ continue ;
61
+ }
62
+ final String name = string .substring (0 , string .length () - 4 );
63
+ try
64
+ {
65
+ keys .add (UUID .fromString (name ));
66
+ }
67
+ catch (IllegalArgumentException ex )
68
+ {
69
+ //Ignore these users till they rejoin.
70
+ }
68
71
}
72
+ uuidMap .loadAllUsers (names , history );
69
73
}
70
-
71
- uuidMap .loadAllUsers (names , history );
72
-
73
74
}
74
75
});
75
76
}
@@ -164,7 +165,7 @@ public User load(final UUID uuid) throws Exception
164
165
165
166
if (userFile .exists ())
166
167
{
167
- player = new OfflinePlayer (uuid , ess .getServer ());
168
+ player = new OfflinePlayer (uuid , ess .getServer ());
168
169
final User user = new User (player , ess );
169
170
((OfflinePlayer )player ).setName (user .getLastAccountName ());
170
171
trackUUID (uuid , user .getName ());
@@ -212,7 +213,7 @@ public ConcurrentSkipListMap<UUID, ArrayList<String>> getHistory()
212
213
{
213
214
return history ;
214
215
}
215
-
216
+
216
217
public List <String > getUserHistory (final UUID uuid )
217
218
{
218
219
return history .get (uuid );
0 commit comments