mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 20:00:46 +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 static final ScheduledExecutorService writeScheduler = Executors.newScheduledThreadPool(1);
|
||||||
private final Runnable writeTaskRunnable;
|
private final Runnable writeTaskRunnable;
|
||||||
|
|
||||||
|
private static boolean loading = false;
|
||||||
|
|
||||||
public UUIDMap(final net.ess3.api.IEssentials ess) {
|
public UUIDMap(final net.ess3.api.IEssentials ess) {
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
userList = new File(ess.getDataFolder(), "usermap.csv");
|
userList = new File(ess.getDataFolder(), "usermap.csv");
|
||||||
|
@ -53,6 +55,7 @@ public class UUIDMap {
|
||||||
|
|
||||||
names.clear();
|
names.clear();
|
||||||
history.clear();
|
history.clear();
|
||||||
|
loading = true;
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(new FileReader(userList))) {
|
try (BufferedReader reader = new BufferedReader(new FileReader(userList))) {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -79,6 +82,7 @@ public class UUIDMap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
loading = false;
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +119,7 @@ public class UUIDMap {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
pendingWrite = false;
|
pendingWrite = false;
|
||||||
if (names.isEmpty()) {
|
if (loading || names.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File configFile = null;
|
File configFile = null;
|
||||||
|
|
Loading…
Reference in a new issue