UUID cache changes

This commit is contained in:
Jesse Boyd 2016-07-25 07:44:47 +10:00
parent 76bce7c0ef
commit 07977ac2ce
3 changed files with 40 additions and 29 deletions

View File

@ -168,6 +168,8 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
} else { } else {
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit"); NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
String name = (String) bukkit.get("lastKnownName"); String name = (String) bukkit.get("lastKnownName");
StringWrapper wrap = new StringWrapper(name);
if (!toAdd.containsKey(wrap)) {
long last = (long) bukkit.get("lastPlayed"); long last = (long) bukkit.get("lastPlayed");
if (Settings.UUID.OFFLINE) { if (Settings.UUID.OFFLINE) {
if (Settings.UUID.FORCE_LOWERCASE && !name.toLowerCase().equals(name)) { if (Settings.UUID.FORCE_LOWERCASE && !name.toLowerCase().equals(name)) {
@ -181,7 +183,8 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
if (ExpireManager.IMP != null) { if (ExpireManager.IMP != null) {
ExpireManager.IMP.storeDate(uuid, last); ExpireManager.IMP.storeDate(uuid, last);
} }
toAdd.put(new StringWrapper(name), uuid); toAdd.put(wrap, uuid);
}
} }
} catch (Exception ignored) { } catch (Exception ignored) {
PS.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat"); PS.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat");
@ -199,6 +202,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
if (last != 0) { if (last != 0) {
String name = op.getName(); String name = op.getName();
StringWrapper wrap = new StringWrapper(name); StringWrapper wrap = new StringWrapper(name);
if (!toAdd.containsKey(wrap)) {
UUID uuid = FileUUIDHandler.this.uuidWrapper.getUUID(op); UUID uuid = FileUUIDHandler.this.uuidWrapper.getUUID(op);
toAdd.put(wrap, uuid); toAdd.put(wrap, uuid);
if (ExpireManager.IMP != null) { if (ExpireManager.IMP != null) {
@ -207,6 +211,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
} }
} }
} }
}
add(toAdd); add(toAdd);
if (whenDone != null) { if (whenDone != null) {
whenDone.run(); whenDone.run();

View File

@ -370,13 +370,16 @@ public class PS {
@Override @Override
public void run() { public void run() {
UUIDHandler.add(new StringWrapper("*"), DBFunc.everyone); UUIDHandler.add(new StringWrapper("*"), DBFunc.everyone);
for (Plot plot : getPlots()) { foreachPlotRaw(new RunnableVal<Plot>() {
@Override
public void run(Plot plot) {
if (plot.hasOwner() && plot.temp != -1) { if (plot.hasOwner() && plot.temp != -1) {
if (UUIDHandler.getName(plot.owner) == null) { if (UUIDHandler.getName(plot.owner) == null) {
UUIDHandler.implementation.unknown.add(plot.owner); UUIDHandler.implementation.unknown.add(plot.owner);
} }
} }
} }
});
startExpiryTasks(); startExpiryTasks();
startPlotMeConversion(); startPlotMeConversion();
} }

View File

@ -59,8 +59,10 @@ public class UUIDHandler {
} }
public static HashSet<UUID> getAllUUIDS() { public static HashSet<UUID> getAllUUIDS() {
HashSet<UUID> uuids = new HashSet<>(); final HashSet<UUID> uuids = new HashSet<>();
for (Plot plot : PS.get().getPlots()) { PS.get().foreachPlotRaw(new RunnableVal<Plot>() {
@Override
public void run(Plot plot) {
if (plot.hasOwner()) { if (plot.hasOwner()) {
uuids.add(plot.owner); uuids.add(plot.owner);
uuids.addAll(plot.getTrusted()); uuids.addAll(plot.getTrusted());
@ -68,6 +70,7 @@ public class UUIDHandler {
uuids.addAll(plot.getDenied()); uuids.addAll(plot.getDenied());
} }
} }
});
return uuids; return uuids;
} }