From 237a0d8b6b1b511232fa66fe05df4890600c02b6 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 5 Jun 2016 20:11:02 +1000 Subject: [PATCH] Always cache * uuid --- .../com/plotsquared/bukkit/uuid/FileUUIDHandler.java | 10 +++------- .../com/plotsquared/bukkit/uuid/SQLUUIDHandler.java | 12 ++++-------- .../main/java/com/intellectualcrafters/plot/PS.java | 3 +++ .../plotsquared/sponge/uuid/SpongeUUIDHandler.java | 5 +---- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java index ba7df80a8..f55b67175 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java @@ -6,20 +6,16 @@ import com.google.common.io.ByteSource; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.OfflinePlotPlayer; import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.util.expiry.ExpireManager; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; +import com.intellectualcrafters.plot.util.expiry.ExpireManager; import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.plotsquared.bukkit.util.NbtFactory; -import org.bukkit.Bukkit; -import org.bukkit.World; - import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -28,6 +24,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.UUID; +import org.bukkit.Bukkit; +import org.bukkit.World; public class FileUUIDHandler extends UUIDHandlerImplementation { @@ -84,7 +82,6 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { } if (Settings.UUID.NATIVE_UUID_PROVIDER) { HashBiMap toAdd = HashBiMap.create(new HashMap()); - toAdd.put(new StringWrapper("*"), DBFunc.everyone); HashSet all = UUIDHandler.getAllUUIDS(); PS.debug("&aFast mode UUID caching enabled!"); File playerDataFolder = new File(container, world + File.separator + "playerdata"); @@ -128,7 +125,6 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { } } HashBiMap toAdd = HashBiMap.create(new HashMap()); - toAdd.put(new StringWrapper("*"), DBFunc.everyone); HashSet worlds = Sets.newHashSet(world, "world"); HashSet uuids = new HashSet<>(); HashSet names = new HashSet<>(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java index c15cfe730..d8c964854 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java @@ -4,7 +4,6 @@ import com.google.common.collect.HashBiMap; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.SQLite; import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.StringWrapper; @@ -13,11 +12,6 @@ import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.uuid.UUIDWrapper; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; - import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; @@ -31,6 +25,10 @@ import java.util.ArrayDeque; import java.util.Collections; import java.util.HashMap; import java.util.UUID; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; public class SQLUUIDHandler extends UUIDHandlerImplementation { @@ -84,8 +82,6 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation { } } add(toAdd); - add(new StringWrapper("*"), DBFunc.everyone); - // This should be called as long as there are some unknown plots final ArrayDeque toFetch = new ArrayDeque<>(); for (UUID u : UUIDHandler.getAllUUIDS()) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 4d46cbf75..2034f70f8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -29,6 +29,7 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.AbstractTitle; import com.intellectualcrafters.plot.util.ChatManager; import com.intellectualcrafters.plot.util.ChunkManager; @@ -206,6 +207,7 @@ public class PS { startUuidCatching(); } else { // Start these separately + UUIDHandler.add(new StringWrapper("*"), DBFunc.everyone); startExpiryTasks(); startPlotMeConversion(); } @@ -364,6 +366,7 @@ public class PS { UUIDHandler.startCaching(new Runnable() { @Override public void run() { + UUIDHandler.add(new StringWrapper("*"), DBFunc.everyone); for (Plot plot : getPlots()) { if (plot.hasOwner() && plot.temp != -1) { if (UUIDHandler.getName(plot.owner) == null) { diff --git a/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java b/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java index 21414df33..8e66b6d48 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java @@ -1,15 +1,13 @@ package com.plotsquared.sponge.uuid; -import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.plotsquared.sponge.SpongeMain; -import org.spongepowered.api.profile.GameProfile; - import java.util.UUID; +import org.spongepowered.api.profile.GameProfile; public class SpongeUUIDHandler extends UUIDHandlerImplementation { @@ -26,7 +24,6 @@ public class SpongeUUIDHandler extends UUIDHandlerImplementation { } public boolean cache(Runnable whenDone) { - add(new StringWrapper("*"), DBFunc.everyone); for (GameProfile profile : SpongeMain.THIS.getServer().getGameProfileManager().getCache().getProfiles()) { String name = profile.getName().orElse(null); if (name != null) {