mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-01-07 19:17:57 +01:00
UUID
This commit is contained in:
parent
406ae58391
commit
dc025839f5
@ -57,7 +57,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@EventHandler
|
||||
public static void worldLoad(final WorldLoadEvent event) {
|
||||
UUIDHandler.cacheAll();
|
||||
UUIDHandler.cacheAll(event.getWorld().getName());
|
||||
}
|
||||
|
||||
public static boolean checkVersion(final int major, final int minor, final int minor2) {
|
||||
|
@ -32,6 +32,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
|
||||
@ -138,7 +139,7 @@ public class Auto extends SubCommand {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
return true;
|
||||
}
|
||||
EconHandler.withdrawPlayer(plr.getName(), cost);
|
||||
EconHandler.withdrawPlayer(plr, cost);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
|
@ -70,13 +70,14 @@ public class Buy extends SubCommand {
|
||||
if (plot == null) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (BukkitPlayerFunctions.getPlayerPlotCount(world, plr) >= BukkitPlayerFunctions.getAllowedPlots(plr)) {
|
||||
int currentPlots = MainUtil.getPlayerPlotCount(world, plr);
|
||||
if (currentPlots >= MainUtil.getAllowedPlots(plr, currentPlots)) {
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
return sendMessage(plr, C.PLOT_UNOWNED);
|
||||
}
|
||||
if (plot.owner.equals(UUIDHandler.getUUID(plr))) {
|
||||
if (plot.owner.equals(plr.getUUID())) {
|
||||
return sendMessage(plr, C.CANNOT_BUY_OWN);
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlag(plot, "price");
|
||||
@ -86,8 +87,8 @@ public class Buy extends SubCommand {
|
||||
double initPrice = (double) flag.getValue();
|
||||
double price = initPrice;
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id2 = BukkitPlayerFunctions.getTopPlot(world, plot).id;
|
||||
final int size = BukkitPlayerFunctions.getPlotSelectionIds(id, id2).size();
|
||||
final PlotId id2 = MainUtil.getTopPlot(world, plot).id;
|
||||
final int size = MainUtil.getPlotSelectionIds(id, id2).size();
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
if (plotworld.USE_ECONOMY) {
|
||||
price += plotworld.PLOT_PRICE * size;
|
||||
@ -100,14 +101,14 @@ public class Buy extends SubCommand {
|
||||
}
|
||||
EconHandler.withdrawPlayer(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
||||
economy.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice);
|
||||
EconHandler.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice);
|
||||
final Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner);
|
||||
if (owner != null) {
|
||||
sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + "");
|
||||
}
|
||||
FlagManager.removePlotFlag(plot, "price");
|
||||
}
|
||||
plot.owner = UUIDHandler.getUUID(plr);
|
||||
plot.owner = plr.getUUID();
|
||||
DBFunc.setOwner(plot, plot.owner);
|
||||
MainUtil.sendMessage(plr, C.CLAIMED);
|
||||
return true;
|
||||
|
@ -67,7 +67,7 @@ public class Clear extends SubCommand {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
return sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
}
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) {
|
||||
|
@ -97,7 +97,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||
final ArrayList<Plot> plots = new ArrayList<>();
|
||||
for (final PlotId id : BukkitPlayerFunctions.getPlotSelectionIds(min, max)) {
|
||||
for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
|
||||
final Plot plot = MainUtil.getPlot(world, id);
|
||||
final boolean contains = PlotSquared.getPlots(world).containsKey(plot.id);
|
||||
if (contains) {
|
||||
|
@ -85,7 +85,7 @@ public class DebugClear extends SubCommand {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
return sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
}
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) {
|
||||
|
@ -43,7 +43,7 @@ public class Delete extends SubCommand {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
return !sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
}
|
||||
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
|
||||
|
@ -163,8 +163,8 @@ public class Info extends SubCommand {
|
||||
|
||||
private String format(String info, final World world, final Plot plot, final Player player) {
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id2 = BukkitPlayerFunctions.getTopPlot(world, plot).id;
|
||||
final int num = BukkitPlayerFunctions.getPlotSelectionIds(id, id2).size();
|
||||
final PlotId id2 = MainUtil.getTopPlot(world, plot).id;
|
||||
final int num = MainUtil.getPlotSelectionIds(id, id2).size();
|
||||
final String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none";
|
||||
final String biome = getBiomeAt(plot).toString();
|
||||
final String helpers = getPlayerList(plot.helpers);
|
||||
|
@ -107,7 +107,7 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
final World world = plr.getWorld();
|
||||
PlotId bot = BukkitPlayerFunctions.getBottomPlot(world, plot).id;
|
||||
PlotId top = BukkitPlayerFunctions.getTopPlot(world, plot).id;
|
||||
PlotId top = MainUtil.getTopPlot(world, plot).id;
|
||||
ArrayList<PlotId> plots;
|
||||
switch (direction) {
|
||||
case 0: // north = -y
|
||||
@ -129,8 +129,8 @@ public class Merge extends SubCommand {
|
||||
final PlotId topId = plots.get(plots.size() - 1);
|
||||
final PlotId bot1 = BukkitPlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, botId)).id;
|
||||
final PlotId bot2 = BukkitPlayerFunctions.getBottomPlot(world, MainUtil.getPlot(world, topId)).id;
|
||||
final PlotId top1 = BukkitPlayerFunctions.getTopPlot(world, MainUtil.getPlot(world, topId)).id;
|
||||
final PlotId top2 = BukkitPlayerFunctions.getTopPlot(world, MainUtil.getPlot(world, botId)).id;
|
||||
final PlotId top1 = MainUtil.getTopPlot(world, MainUtil.getPlot(world, topId)).id;
|
||||
final PlotId top2 = MainUtil.getTopPlot(world, MainUtil.getPlot(world, botId)).id;
|
||||
bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y));
|
||||
top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y));
|
||||
plots = BukkitPlayerFunctions.getMaxPlotSelectionIds(world, bot, top);
|
||||
|
@ -43,7 +43,7 @@ public class Paste extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
MainUtil.sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
return false;
|
||||
}
|
||||
|
@ -66,8 +66,8 @@ public class SetOwner extends SubCommand {
|
||||
}
|
||||
final World world = plr.getWorld();
|
||||
final PlotId bot = BukkitPlayerFunctions.getBottomPlot(world, plot).id;
|
||||
final PlotId top = BukkitPlayerFunctions.getTopPlot(world, plot).id;
|
||||
final ArrayList<PlotId> plots = BukkitPlayerFunctions.getPlotSelectionIds(bot, top);
|
||||
final PlotId top = MainUtil.getTopPlot(world, plot).id;
|
||||
final ArrayList<PlotId> plots = MainUtil.getPlotSelectionIds(bot, top);
|
||||
for (final PlotId id : plots) {
|
||||
final Plot current = PlotSquared.getPlots(world).get(id);
|
||||
final UUID uuid = getUUID(args[0]);
|
||||
|
@ -45,7 +45,7 @@ public class Unclaim extends SubCommand {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
if (!MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
return !sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
}
|
||||
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.unclaim")) {
|
||||
|
@ -58,7 +58,7 @@ public class Unlink extends SubCommand {
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) {
|
||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
if (BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
if (MainUtil.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
return sendMessage(plr, C.UNLINK_IMPOSSIBLE);
|
||||
}
|
||||
final World world = plr.getWorld();
|
||||
@ -82,8 +82,8 @@ public class Unlink extends SubCommand {
|
||||
|
||||
public static boolean unlinkPlot(final World world, final Plot plot) {
|
||||
final PlotId pos1 = BukkitPlayerFunctions.getBottomPlot(world, plot).id;
|
||||
final PlotId pos2 = BukkitPlayerFunctions.getTopPlot(world, plot).id;
|
||||
final ArrayList<PlotId> ids = BukkitPlayerFunctions.getPlotSelectionIds(pos1, pos2);
|
||||
final PlotId pos2 = MainUtil.getTopPlot(world, plot).id;
|
||||
final ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(pos1, pos2);
|
||||
final PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
|
@ -78,14 +78,14 @@ public class WorldEditListener implements Listener {
|
||||
if ((plot == null) || (plot.owner == null)) {
|
||||
return;
|
||||
}
|
||||
final Player player = UUIDHandler.uuidWrapper.getPlayer(plot.owner);
|
||||
final PlotPlayer player = UUIDHandler.getPlayer(plot.owner);
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
if (!world.equals(player.getWorld().getName())) {
|
||||
if (!world.equals(player.getLocation().getWorld())) {
|
||||
return;
|
||||
}
|
||||
if (Permissions.hasPermission(BukkitUtil.getPlayer(player), "plots.worldedit.bypass")) {
|
||||
if (Permissions.hasPermission(player, "plots.worldedit.bypass")) {
|
||||
return;
|
||||
}
|
||||
PWE.setNoMask(player);
|
||||
|
@ -0,0 +1,38 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
public class BukkitOfflinePlayer implements OfflinePlotPlayer {
|
||||
|
||||
public final OfflinePlayer player;
|
||||
|
||||
/**
|
||||
* Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects.
|
||||
* @param player
|
||||
*/
|
||||
public BukkitOfflinePlayer(OfflinePlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return player.getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastPlayed() {
|
||||
return player.getLastPlayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return player.isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return player.getName();
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ public class BukkitPlayer implements PlotPlayer {
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
if (this.uuid == null) {
|
||||
this.uuid = UUIDHandler.getUUID(this.player);
|
||||
this.uuid = UUIDHandler.getUUID(this);
|
||||
}
|
||||
return this.uuid;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
/**
|
||||
@ -50,7 +51,7 @@ public class InfoInventory implements InventoryHolder {
|
||||
}
|
||||
|
||||
public InfoInventory build() {
|
||||
UUID uuid = UUIDHandler.getUUID(player);
|
||||
UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(player));
|
||||
final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.getOwner()), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.isAdded(uuid), "&cIs Denied: &6" + this.plot.isDenied(uuid));
|
||||
final ItemStack helpers = getItem(Material.EMERALD, "&cHelpers", "&cAmount: &6" + this.plot.helpers.size(), "&8Click to view a list of the plot helpers");
|
||||
final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.size(), "&8Click to view a list of trusted players");
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created 2015-02-20 for PlotSquared
|
||||
*
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public interface OfflinePlotPlayer {
|
||||
public UUID getUUID();
|
||||
|
||||
public long getLastPlayed();
|
||||
|
||||
public boolean isOnline();
|
||||
|
||||
public String getName();
|
||||
}
|
@ -147,7 +147,7 @@ public class Plot implements Cloneable {
|
||||
* @return true if the player is added as a helper or is the owner
|
||||
*/
|
||||
public boolean isAdded(final UUID uuid) {
|
||||
return ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(uuid)) || ((this.owner != null) && this.owner.equals(uuid)) || ((this.owner != null) && (this.trusted != null) && (UUIDHandler.uuidWrapper.getPlayer(this.owner) != null) && (this.trusted.contains(uuid) || this.trusted.contains(DBFunc.everyone)));
|
||||
return ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(uuid)) || ((this.owner != null) && this.owner.equals(uuid)) || ((this.owner != null) && (this.trusted != null) && (UUIDHandler.getPlayer(this.owner) != null) && (this.trusted.contains(uuid) || this.trusted.contains(DBFunc.everyone)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,7 @@ import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotClusterId;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.SetBlockManager;
|
||||
@ -258,9 +259,9 @@ public class ClusterManager {
|
||||
@Override
|
||||
public void run() {
|
||||
ClusterManager.regenerating.remove(cluster.world + ":" + cluster.getName());
|
||||
final Player owner = UUIDHandler.uuidWrapper.getPlayer(cluster.owner);
|
||||
final PlotPlayer owner = UUIDHandler.getPlayer(cluster.owner);
|
||||
if (owner != null) {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(owner), C.CLEARING_DONE);
|
||||
MainUtil.sendMessage(owner, C.CLEARING_DONE);
|
||||
}
|
||||
}
|
||||
}, (interval * chunks.size()) + 20);
|
||||
|
@ -10,6 +10,10 @@ public class EconHandler {
|
||||
}
|
||||
|
||||
public static void withdrawPlayer(PlotPlayer player, double amount) {
|
||||
EconHandler.withdrawPlayer(player.getName(), amount);
|
||||
PlotSquared.economy.withdrawPlayer(player.getName(), amount);
|
||||
}
|
||||
|
||||
public static void depositPlayer(PlotPlayer player, double amount) {
|
||||
PlotSquared.economy.depositPlayer(player.getName(), amount);
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,10 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
||||
import com.intellectualcrafters.plot.object.BukkitOfflinePlayer;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
@ -86,7 +88,7 @@ public class ExpireManager {
|
||||
}
|
||||
final Plot plot = plots.iterator().next();
|
||||
if (plot.owner != null) {
|
||||
if (UUIDHandler.uuidWrapper.getPlayer(plot.owner) != null) {
|
||||
if (UUIDHandler.getPlayer(plot.owner) != null) {
|
||||
expiredPlots.get(world).remove(plot);
|
||||
return;
|
||||
}
|
||||
@ -102,9 +104,9 @@ public class ExpireManager {
|
||||
return;
|
||||
}
|
||||
for (final UUID helper : plot.helpers) {
|
||||
final Player player = UUIDHandler.uuidWrapper.getPlayer(helper);
|
||||
final PlotPlayer player = UUIDHandler.getPlayer(helper);
|
||||
if (player != null) {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_REMOVED_HELPER, plot.id.toString());
|
||||
MainUtil.sendMessage(player, C.PLOT_REMOVED_HELPER, plot.id.toString());
|
||||
}
|
||||
}
|
||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||
@ -165,13 +167,13 @@ public class ExpireManager {
|
||||
if (keep.contains(uuid)) {
|
||||
continue;
|
||||
}
|
||||
final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
|
||||
final PlotPlayer player = UUIDHandler.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
keep.add(uuid);
|
||||
continue;
|
||||
}
|
||||
final OfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||
if ((op == null) || !op.hasPlayedBefore()) {
|
||||
final BukkitOfflinePlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||
if ((op == null) || op.getLastPlayed() == 0) {
|
||||
continue;
|
||||
}
|
||||
long last = op.getLastPlayed();
|
||||
@ -184,7 +186,7 @@ public class ExpireManager {
|
||||
if (BukkitMain.checkVersion(1, 7, 5)) {
|
||||
foldername = "playerdata";
|
||||
try {
|
||||
filename = op.getUniqueId() + ".dat";
|
||||
filename = op.getUUID() + ".dat";
|
||||
} catch (final Throwable e) {
|
||||
filename = uuid.toString() + ".dat";
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
/**
|
||||
@ -88,7 +89,7 @@ public class BukkitPlayerFunctions {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost);
|
||||
return false;
|
||||
}
|
||||
EconHandler.withdrawPlayer(plr, cost);
|
||||
EconHandler.withdrawPlayer(BukkitUtil.getPlayer(plr), cost);
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
@ -99,11 +100,11 @@ public class BukkitPlayerFunctions {
|
||||
if (uuid == null) {
|
||||
return "unknown";
|
||||
}
|
||||
final OfflinePlayer plr = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||
if (!plr.hasPlayedBefore()) {
|
||||
final String name = UUIDHandler.getName(uuid);
|
||||
if (name == null) {
|
||||
return "unknown";
|
||||
}
|
||||
return plr.getName();
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,6 @@ public class BukkitUtil extends BlockManager {
|
||||
private static String lastString = null;
|
||||
private static World lastWorld = null;
|
||||
|
||||
private static HashMap<String, PlotPlayer> players = new HashMap<>();
|
||||
private static Player lastPlayer = null;
|
||||
private static PlotPlayer lastPlotPlayer = null;
|
||||
|
||||
@ -36,7 +35,7 @@ public class BukkitUtil extends BlockManager {
|
||||
lastPlayer = null;
|
||||
lastPlotPlayer = null;
|
||||
}
|
||||
players.remove(plr);
|
||||
UUIDHandler.players.remove(plr);
|
||||
}
|
||||
|
||||
public static PlotPlayer getPlayer(Player player) {
|
||||
@ -44,7 +43,7 @@ public class BukkitUtil extends BlockManager {
|
||||
return lastPlotPlayer;
|
||||
}
|
||||
lastPlotPlayer = new BukkitPlayer(player);
|
||||
players.put(lastPlotPlayer.getName(), lastPlotPlayer);
|
||||
UUIDHandler.players.put(lastPlotPlayer.getName(), lastPlotPlayer);
|
||||
lastPlayer = player;
|
||||
return lastPlotPlayer;
|
||||
}
|
||||
|
@ -86,13 +86,8 @@ public class PWE {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasMask(final Player p) {
|
||||
LocalSession s;
|
||||
if (PlotSquared.worldEdit == null) {
|
||||
s = WorldEdit.getInstance().getSession(p.getName());
|
||||
} else {
|
||||
s = PlotSquared.worldEdit.getSession(p);
|
||||
}
|
||||
public static boolean hasMask(final PlotPlayer p) {
|
||||
LocalSession s = WorldEdit.getInstance().getSession(p.getName());
|
||||
return !noMask(s);
|
||||
}
|
||||
|
||||
@ -101,14 +96,9 @@ public class PWE {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setNoMask(final Player p) {
|
||||
public static void setNoMask(final PlotPlayer p) {
|
||||
try {
|
||||
LocalSession s;
|
||||
if (PlotSquared.worldEdit == null) {
|
||||
s = WorldEdit.getInstance().getSession(p.getName());
|
||||
} else {
|
||||
s = PlotSquared.worldEdit.getSession(p);
|
||||
}
|
||||
LocalSession s = WorldEdit.getInstance().getSession(p.getName());
|
||||
final com.sk89q.worldedit.bukkit.BukkitPlayer plr = PlotSquared.worldEdit.wrapPlayer(((BukkitPlayer) p).player);
|
||||
final Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
|
||||
s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
|
||||
|
@ -6,16 +6,14 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.BukkitOfflinePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||
@ -24,6 +22,8 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
public class UUIDHandler {
|
||||
public static boolean CACHED = false;
|
||||
public static UUIDWrapper uuidWrapper = null;
|
||||
public static HashMap<String, PlotPlayer> players = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Map containing names and UUIDs
|
||||
*
|
||||
@ -77,14 +77,14 @@ public class UUIDHandler {
|
||||
return uuidMap.containsKey(name);
|
||||
}
|
||||
|
||||
public static void cacheAll() {
|
||||
public static void cacheAll(String world) {
|
||||
if (CACHED) {
|
||||
return;
|
||||
}
|
||||
PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching");
|
||||
UUIDHandler.CACHED = true;
|
||||
final HashSet<String> worlds = new HashSet<>();
|
||||
worlds.add(Bukkit.getWorlds().get(0).getName());
|
||||
worlds.add(world);
|
||||
worlds.add("world");
|
||||
final HashSet<UUID> uuids = new HashSet<>();
|
||||
final HashSet<String> names = new HashSet<>();
|
||||
@ -125,7 +125,7 @@ public class UUIDHandler {
|
||||
final UUIDWrapper wrapper = new DefaultUUIDWrapper();
|
||||
for (UUID uuid : uuids) {
|
||||
try {
|
||||
final OfflinePlayer player = wrapper.getOfflinePlayer(uuid);
|
||||
final BukkitOfflinePlayer player = wrapper.getOfflinePlayer(uuid);
|
||||
uuid = UUIDHandler.uuidWrapper.getUUID(player);
|
||||
final StringWrapper name = new StringWrapper(player.getName());
|
||||
add(name, uuid);
|
||||
@ -134,8 +134,7 @@ public class UUIDHandler {
|
||||
}
|
||||
}
|
||||
for (final String name : names) {
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
final UUID uuid = UUIDHandler.uuidWrapper.getUUID(player);
|
||||
final UUID uuid = uuidWrapper.getUUID(name);
|
||||
final StringWrapper nameWrap = new StringWrapper(name);
|
||||
add(nameWrap, uuid);
|
||||
}
|
||||
@ -144,11 +143,11 @@ public class UUIDHandler {
|
||||
PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs");
|
||||
}
|
||||
|
||||
public static UUID getUUID(final Player player) {
|
||||
public static UUID getUUID(final PlotPlayer player) {
|
||||
return UUIDHandler.uuidWrapper.getUUID(player);
|
||||
}
|
||||
|
||||
public static UUID getUUID(final OfflinePlayer player) {
|
||||
public static UUID getUUID(final BukkitOfflinePlayer player) {
|
||||
return UUIDHandler.uuidWrapper.getUUID(player);
|
||||
}
|
||||
|
||||
@ -157,7 +156,7 @@ public class UUIDHandler {
|
||||
return null;
|
||||
}
|
||||
// check online
|
||||
final Player player = uuidWrapper.getPlayer(uuid);
|
||||
final PlotPlayer player = UUIDHandler.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
return player.getName();
|
||||
}
|
||||
@ -169,16 +168,27 @@ public class UUIDHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PlotPlayer getPlayer(UUID uuid) {
|
||||
for (PlotPlayer player : players.values()) {
|
||||
if (player.getUUID().equals(uuid)) {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PlotPlayer getPlayer(String name) {
|
||||
return players.get(name);
|
||||
}
|
||||
|
||||
public static UUID getUUID(final String name) {
|
||||
if ((name == null) || (name.length() == 0)) {
|
||||
return null;
|
||||
}
|
||||
// check online
|
||||
final Player player = Bukkit.getPlayer(name);
|
||||
final PlotPlayer player = getPlayer(name);
|
||||
if (player != null) {
|
||||
final UUID uuid = UUIDHandler.uuidWrapper.getUUID(player);
|
||||
add(new StringWrapper(name), uuid);
|
||||
return uuid;
|
||||
return player.getUUID();
|
||||
}
|
||||
// check cache
|
||||
final StringWrapper wrap = new StringWrapper(name);
|
||||
|
@ -3,28 +3,24 @@ package com.intellectualcrafters.plot.uuid;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.intellectualcrafters.plot.object.BukkitOfflinePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.BukkitPlayer;;
|
||||
|
||||
public class DefaultUUIDWrapper extends UUIDWrapper {
|
||||
@Override
|
||||
public UUID getUUID(final Player player) {
|
||||
return player.getUniqueId();
|
||||
public UUID getUUID(final PlotPlayer player) {
|
||||
return ((BukkitPlayer) player).player.getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(final OfflinePlayer player) {
|
||||
return player.getUniqueId();
|
||||
public UUID getUUID(final BukkitOfflinePlayer player) {
|
||||
return player.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlayer getOfflinePlayer(final UUID uuid) {
|
||||
return Bukkit.getOfflinePlayer(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer(final UUID uuid) {
|
||||
return Bukkit.getPlayer(uuid);
|
||||
public BukkitOfflinePlayer getOfflinePlayer(final UUID uuid) {
|
||||
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(uuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,6 +11,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.intellectualcrafters.plot.object.BukkitOfflinePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
@ -29,17 +31,21 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(final Player player) {
|
||||
public UUID getUUID(final PlotPlayer player) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(final BukkitOfflinePlayer player) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
public UUID getUUID(final OfflinePlayer player) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlayer getOfflinePlayer(final UUID uuid) {
|
||||
public BukkitOfflinePlayer getOfflinePlayer(final UUID uuid) {
|
||||
final BiMap<UUID, StringWrapper> map = UUIDHandler.getUuidMap().inverse();
|
||||
String name;
|
||||
try {
|
||||
@ -50,12 +56,12 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
if (name != null) {
|
||||
final OfflinePlayer op = Bukkit.getOfflinePlayer(name);
|
||||
if (op.hasPlayedBefore()) {
|
||||
return op;
|
||||
return new BukkitOfflinePlayer(op);
|
||||
}
|
||||
}
|
||||
for (final OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||
if (getUUID(player).equals(uuid)) {
|
||||
return player;
|
||||
return new BukkitOfflinePlayer(player);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -81,16 +87,6 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer(final UUID uuid) {
|
||||
for (final Player player : getOnlinePlayers()) {
|
||||
if (getUUID(player).equals(uuid)) {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(final String name) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
|
||||
|
@ -2,17 +2,15 @@ package com.intellectualcrafters.plot.uuid;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.intellectualcrafters.plot.object.BukkitOfflinePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
public abstract class UUIDWrapper {
|
||||
public abstract UUID getUUID(Player player);
|
||||
public abstract UUID getUUID(PlotPlayer player);
|
||||
|
||||
public abstract UUID getUUID(OfflinePlayer player);
|
||||
public abstract UUID getUUID(BukkitOfflinePlayer player);
|
||||
|
||||
public abstract UUID getUUID(String name);
|
||||
|
||||
public abstract OfflinePlayer getOfflinePlayer(UUID uuid);
|
||||
|
||||
public abstract Player getPlayer(UUID uuid);
|
||||
public abstract BukkitOfflinePlayer getOfflinePlayer(UUID uuid);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user