From 8245db7a08dfe79d090926a29cee4a021215fec3 Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Sun, 12 Oct 2014 01:18:47 +0200 Subject: [PATCH] Pfft. --- .idea/workspace.xml | 559 ++++++------------ .../intellectualcrafters/plot/PlotHelper.java | 33 +- .../plot/UUIDHandler.java | 43 +- .../plot/commands/TP.java | 2 + 4 files changed, 243 insertions(+), 394 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index de6ec31d0..da181b94d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -10,6 +10,8 @@ + + @@ -34,54 +36,21 @@ - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -90,51 +59,78 @@ - - + + - - + + - - - - - - - - - - - - - - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -179,7 +175,6 @@ @@ -239,8 +236,6 @@ - - @@ -313,58 +308,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -569,8 +436,6 @@ - @@ -989,7 +860,6 @@ - @@ -1001,6 +871,7 @@ + @@ -1020,7 +891,6 @@ - @@ -1045,7 +915,8 @@ - @@ -1065,69 +936,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1167,7 +975,6 @@ - @@ -1175,7 +982,6 @@ - @@ -1183,7 +989,6 @@ - @@ -1191,7 +996,6 @@ - @@ -1199,7 +1003,6 @@ - @@ -1207,7 +1010,6 @@ - @@ -1215,7 +1017,6 @@ - @@ -1223,17 +1024,6 @@ - - - - - - - - - - - @@ -1241,7 +1031,6 @@ - @@ -1249,7 +1038,6 @@ - @@ -1257,7 +1045,6 @@ - @@ -1265,7 +1052,6 @@ - @@ -1273,7 +1059,6 @@ - @@ -1281,7 +1066,6 @@ - @@ -1289,7 +1073,6 @@ - @@ -1297,10 +1080,6 @@ - - - - @@ -1308,7 +1087,6 @@ - @@ -1316,7 +1094,6 @@ - @@ -1328,21 +1105,6 @@ - - - - - - - - - - - - - - - @@ -1355,7 +1117,6 @@ - @@ -1363,19 +1124,6 @@ - - - - - - - - - - - - - @@ -1383,9 +1131,6 @@ - - - @@ -1393,7 +1138,6 @@ - @@ -1401,7 +1145,6 @@ - @@ -1429,29 +1172,10 @@ - - - - - - - - - - - - - - - - - - - @@ -1474,12 +1198,121 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java index 4f08dc048..c77aa0b53 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java @@ -8,19 +8,9 @@ package com.intellectualcrafters.plot; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.UUID; - +import com.intellectualcrafters.plot.database.DBFunc; import net.milkbowl.vault.economy.Economy; - -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.World; +import org.bukkit.*; import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -28,7 +18,10 @@ import org.bukkit.block.Sign; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.database.DBFunc; +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.UUID; /** * plot functions @@ -749,19 +742,17 @@ public class PlotHelper { } public static Location getPlotHome(World w, PlotId plotid) { - PlotMain.getWorldSettings(w); + Location + bot = getPlotBottomLoc(w, plotid), + top = getPlotTopLoc(w, plotid); + if (getPlot(w, plotid).settings.getPosition() == PlotHomePosition.DEFAULT) { - int x = getPlotBottomLoc(w, plotid).getBlockX() + (getPlotTopLoc(w, plotid).getBlockX() - getPlotBottomLoc(w, plotid).getBlockX()); - int z = getPlotBottomLoc(w, plotid).getBlockZ() - 2; + int x = bot.getBlockX() + (top.getBlockX() - bot.getBlockX()); + int z = bot.getBlockZ() - 2; int y = w.getHighestBlockYAt(x, z); return new Location(w, x, y + 2, z); } else { - World world = w; - - Location bot, top; - bot = getPlotBottomLoc(world, plotid); - top = getPlotTopLoc(world, plotid); int x = top.getBlockX() - bot.getBlockX(); int z = top.getBlockZ() - bot.getBlockZ(); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/UUIDHandler.java b/PlotSquared/src/com/intellectualcrafters/plot/UUIDHandler.java index 9225d98f1..1b8066966 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/UUIDHandler.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/UUIDHandler.java @@ -13,12 +13,34 @@ import org.bukkit.plugin.java.JavaPlugin; import java.util.Arrays; import java.util.UUID; +/** + * This class can be used to efficiently translate UUIDs and names back and forth. + * It uses three primary methods of achieving this: + * - Read From Cache + * - Read from OfflinePlayer objects + * - Read from (if onlinemode: mojang api) (else: playername hashing) + * All UUIDs/Usernames will be stored in a map (cache) until the server is + * restarted. + * + * You can use getUuidMap() to save the uuids/names to a file (SQLite db for example). + * Primary methods: getUUID(String name) & getName(UUID uuid) <-- You should ONLY use these. + * Call startFetch(JavaPlugin plugin) in your onEnable(). + * + * Originally created by: + * @author Citymonstret + * @author Empire92 + * for PlotSquared. + */ public class UUIDHandler { private static boolean online = Bukkit.getServer().getOnlineMode(); private static BiMap uuidMap = HashBiMap.create(); + public static BiMap getUuidMap() { + return uuidMap; + } + public static boolean uuidExists(UUID uuid) { return uuidMap.containsValue(uuid); } @@ -61,8 +83,9 @@ public class UUIDHandler { ups = size / time; } - PlotMain.sendConsoleSenderMessage("&cFinished caching of offlineplayers! Took &6" + time + "&cms (&6" + ups + "&c per millisecond), &6" - + length + " &cUUID's were cached" + " and there is now a grand total of &6" + size + //Plot Squared Only... + PlotMain.sendConsoleSenderMessage("&cFinished caching of offline player UUIDs! Took &6" + time + "&cms (&6" + ups + "&c per millisecond), &6" + + length + " &cUUIDs were cached" + " and there is now a grand total of &6" + size + " &ccached."); } }); @@ -70,7 +93,7 @@ public class UUIDHandler { /** * @param name - * @return + * @return uuid */ public static UUID getUUID(String name) { if (nameExists(name)) { @@ -101,7 +124,7 @@ public class UUIDHandler { /** * @param uuid - * @return + * @return name (cache) */ private static String loopSearch(UUID uuid) { return uuidMap.inverse().get(uuid); @@ -109,7 +132,7 @@ public class UUIDHandler { /** * @param uuid - * @return + * @return Name */ public static String getName(UUID uuid) { if (uuidExists(uuid)) { @@ -141,7 +164,7 @@ public class UUIDHandler { /** * @param name - * @return + * @return UUID (name hash) */ private static UUID getUuidOfflineMode(String name) { UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)); @@ -151,7 +174,7 @@ public class UUIDHandler { /** * @param uuid - * @return + * @return String - name */ private static String getNameOnlinePlayer(UUID uuid) { Player player = Bukkit.getPlayer(uuid); @@ -165,7 +188,7 @@ public class UUIDHandler { /** * @param uuid - * @return + * @return String - name */ private static String getNameOfflinePlayer(UUID uuid) { OfflinePlayer player = Bukkit.getOfflinePlayer(uuid); @@ -179,7 +202,7 @@ public class UUIDHandler { /** * @param name - * @return + * @return UUID */ private static UUID getUuidOnlinePlayer(String name) { Player player = Bukkit.getPlayer(name); @@ -193,7 +216,7 @@ public class UUIDHandler { /** * @param name - * @return + * @return UUID (username hash) */ private static UUID getUuidOfflinePlayer(String name) { UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/TP.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/TP.java index a5bce6467..c7e506a3b 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/TP.java @@ -52,6 +52,8 @@ public class TP extends SubCommand { PlotMain.teleportPlayer(plr, plr.getLocation(), temp); return true; } + + try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); PlotMain.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid));