mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-28 11:44:42 +02:00
Pfft.
This commit is contained in:
@ -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();
|
||||
|
@ -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<String, UUID> uuidMap = HashBiMap.create();
|
||||
|
||||
public static BiMap<String, UUID> 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));
|
||||
|
@ -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));
|
||||
|
Reference in New Issue
Block a user