mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 11:49:12 +00:00
Better solution than synchronization
This commit is contained in:
parent
72760096f5
commit
e90455463f
1 changed files with 5 additions and 1 deletions
|
@ -22,6 +22,8 @@ public class UUIDMap {
|
|||
private static final ScheduledExecutorService writeScheduler = Executors.newScheduledThreadPool(1);
|
||||
private final Runnable writeTaskRunnable;
|
||||
|
||||
private static boolean loading = false;
|
||||
|
||||
public UUIDMap(final net.ess3.api.IEssentials ess) {
|
||||
this.ess = ess;
|
||||
userList = new File(ess.getDataFolder(), "usermap.csv");
|
||||
|
@ -53,6 +55,7 @@ public class UUIDMap {
|
|||
|
||||
names.clear();
|
||||
history.clear();
|
||||
loading = true;
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(userList))) {
|
||||
while (true) {
|
||||
|
@ -79,6 +82,7 @@ public class UUIDMap {
|
|||
}
|
||||
}
|
||||
}
|
||||
loading = false;
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
|
@ -115,7 +119,7 @@ public class UUIDMap {
|
|||
@Override
|
||||
public void run() {
|
||||
pendingWrite = false;
|
||||
if (names.isEmpty()) {
|
||||
if (loading || names.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
File configFile = null;
|
||||
|
|
Loading…
Reference in a new issue