Finish updating UUID system

This commit is contained in:
boy0001 2014-12-31 00:09:11 +11:00
parent bb4e91e943
commit d505329134
21 changed files with 57 additions and 52 deletions

View File

@ -1523,11 +1523,17 @@ import java.util.concurrent.TimeUnit;
}
// Handle UUIDS
{
boolean checkVersion = checkVersion();
if (!checkVersion && Settings.TITLES) {
sendConsoleSenderMessage(C.PREFIX.s()+" &c[WARN] Titles are enabled - please update your version of Bukkit to support this feature.");
Settings.TITLES = false;
FlagManager.removeFlag(FlagManager.getFlag("titles"));
}
if (Settings.OFFLINE_MODE) {
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
Settings.OFFLINE_MODE = true;
}
else if (checkVersion() && Bukkit.getOnlineMode()) {
else if (checkVersion && Bukkit.getOnlineMode()) {
UUIDHandler.uuidWrapper = new DefaultUUIDWrapper();
Settings.OFFLINE_MODE = false;
}
@ -1536,7 +1542,7 @@ import java.util.concurrent.TimeUnit;
Settings.OFFLINE_MODE = true;
}
if (Settings.OFFLINE_MODE) {
sendConsoleSenderMessage(C.PREFIX.s()+" &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because of the version of the Bukkit API");
sendConsoleSenderMessage(C.PREFIX.s()+" &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of Bukkit");
}
else {
sendConsoleSenderMessage(C.PREFIX.s()+" &6PlotSquared is using online UUIDs");

View File

@ -27,6 +27,8 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotSelection;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.entity.Player;
public class Copy extends SubCommand {
@ -42,7 +44,7 @@ public class Copy extends SubCommand {
return false;
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}

View File

@ -122,7 +122,7 @@ public class Database extends SubCommand {
}
UUID requester = null;
if (plr != null) {
requester = plr.getUniqueId();
requester = UUIDHandler.getUUID(plr);
}
insertPlots(manager, requester, n);
break;

View File

@ -27,6 +27,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.entity.Player;
@ -45,12 +46,14 @@ public class Delete extends SubCommand {
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
return !sendMessage(plr, C.UNLINK_REQUIRED);
}
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))) && !PlotMain.hasPermission(plr, "plots.admin")) {
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !PlotMain.hasPermission(plr, "plots.admin")) {
System.out.print(UUIDHandler.uuidWrapper.getUUID(plr));
System.out.print(plot.getOwner());
return !sendMessage(plr, C.NO_PLOT_PERMS);
}
assert plot != null;
final PlotWorld pWorld = PlotMain.getWorldSettings(plot.getWorld());
if (PlotMain.useEconomy && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(plr.getUniqueId())) {
if (PlotMain.useEconomy && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) {
final double c = pWorld.SELL_PRICE;
if (c > 0d) {
final Economy economy = PlotMain.economy;

View File

@ -51,7 +51,7 @@ import java.util.UUID;
return true;
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot.owner == null) || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
if (((plot.owner == null) || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return true;
}
@ -115,18 +115,6 @@ import java.util.UUID;
PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED);
return true;
}
/*
* if (!hasBeenOnServer(args[1])) {
* PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
* return true; } UUID uuid = null; if
* (Bukkit.getPlayer(args[1])!=null) { uuid =
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid =
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if
* (!plot.denied.contains(uuid)) {
* PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); return
* true; } if (uuid == null) { PlayerFunctions.sendMessage(plr,
* C.PLAYER_HAS_NOT_BEEN_ON); return true; }
*/
final UUID uuid = UUIDHandler.getUUID(args[1]);
plot.removeDenied(uuid);
DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));

View File

@ -51,7 +51,7 @@ import java.util.UUID;
return true;
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot.owner == null) || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
if (((plot.owner == null) || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return true;
}

View File

@ -25,6 +25,8 @@ import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.entity.Player;
/**
@ -62,7 +64,7 @@ public class Home extends SubCommand {
Plot temp;
if ((temp = isAlias(args[0])) != null) {
if (temp.hasOwner()) {
if (temp.getOwner().equals(plr.getUniqueId())) {
if (temp.getOwner().equals(UUIDHandler.getUUID(plr))) {
PlotMain.teleportPlayer(plr, plr.getLocation(), temp);
return true;
}

View File

@ -27,6 +27,8 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotComment;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -54,7 +56,7 @@ public class Inbox extends SubCommand {
}
Integer tier;
final UUID uuid = plr.getUniqueId();
final UUID uuid = UUIDHandler.getUUID(plr);
if (PlotMain.hasPermission(plr, "plots.admin")) {
tier = 0;
} else if (plot.owner == uuid) {

View File

@ -25,6 +25,8 @@ import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -41,7 +43,7 @@ import org.bukkit.entity.Player;
return false;
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}

View File

@ -30,7 +30,10 @@ import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.SetBlockFast;
import com.intellectualcrafters.plot.util.UUIDHandler;
import net.milkbowl.vault.economy.Economy;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.World;
@ -83,7 +86,7 @@ public class Merge extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}
if (!plot.getOwner().equals(plr.getUniqueId())) {
if (!plot.getOwner().equals(UUIDHandler.getUUID(plr))) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}
@ -126,7 +129,7 @@ public class Merge extends SubCommand {
}
for (final PlotId myid : plots) {
final Plot myplot = PlotMain.getPlots(world).get(myid);
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(plr.getUniqueId()))) {
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(plr)))) {
PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
return false;
}

View File

@ -27,6 +27,8 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotSelection;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.entity.Player;
public class Paste extends SubCommand {
@ -42,7 +44,7 @@ public class Paste extends SubCommand {
return false;
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}

View File

@ -25,6 +25,8 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.entity.Player;
@SuppressWarnings({"unused", "deprecated", "javadoc"}) public class Rate extends SubCommand {
@ -53,7 +55,7 @@ import org.bukkit.entity.Player;
sendMessage(plr, C.RATING_NOT_OWNED);
return true;
}
if (plot.getOwner().equals(plr.getUniqueId())) {
if (plot.getOwner().equals(UUIDHandler.getUUID(plr))) {
sendMessage(plr, C.RATING_NOT_YOUR_OWN);
return true;
}

View File

@ -29,6 +29,8 @@ import com.intellectualcrafters.plot.object.PlotSelection;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.SetBlockFast;
import com.intellectualcrafters.plot.util.UUIDHandler;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -55,7 +57,7 @@ public class Swap extends SubCommand {
return false;
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}
@ -69,7 +71,7 @@ public class Swap extends SubCommand {
try {
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
final Plot plot2 = PlotMain.getPlots(world).get(plotid);
if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString());
return false;
}

View File

@ -51,7 +51,7 @@ import java.util.UUID;
return true;
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot.owner == null) || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
if (((plot.owner == null) || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return true;
}
@ -107,19 +107,6 @@ import java.util.UUID;
PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED);
return true;
}
/*
* if (!hasBeenOnServer(args[1])) {
* PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
* return true; } UUID uuid = null; if
* (Bukkit.getPlayer(args[1]) != null) { uuid =
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid =
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid ==
* null) { PlayerFunctions.sendMessage(plr,
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } if
* (!plot.trusted.contains(uuid)) {
* PlayerFunctions.sendMessage(plr, C.T_WAS_NOT_ADDED); return
* true; }
*/
final UUID uuid = UUIDHandler.getUUID(args[1]);
plot.removeTrusted(uuid);
DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));

View File

@ -27,7 +27,10 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.entity.Player;
public class Unclaim extends SubCommand {
@ -45,7 +48,7 @@ public class Unclaim extends SubCommand {
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
return !sendMessage(plr, C.UNLINK_REQUIRED);
}
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))) && !PlotMain.hasPermission(plr, "plots.admin")) {
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !PlotMain.hasPermission(plr, "plots.admin")) {
return !sendMessage(plr, C.NO_PLOT_PERMS);
}
assert plot != null;

View File

@ -56,7 +56,7 @@ public class Unlink extends SubCommand {
return sendMessage(plr, C.NOT_IN_PLOT);
}
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !PlotMain.hasPermission(plr, "plots.admin")) {
return sendMessage(plr, C.NO_PLOT_PERMS);
}
if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {

View File

@ -86,7 +86,7 @@ public class list extends SubCommand {
final StringBuilder string = new StringBuilder();
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all")).append("\n");
for (final Plot p : PlotMain.getPlotsSorted()) {
if (p.helpers.contains(plr.getUniqueId())) {
if (p.helpers.contains(UUIDHandler.getUUID(plr))) {
string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n");
}
}

View File

@ -180,7 +180,7 @@ import java.util.*;
if (player == null) {
return;
}
if (UUIDHandler.getUUID(player).equals(event.getPlayer().getUniqueId())) {
if (UUIDHandler.getUUID(player).equals(UUIDHandler.getUUID(event.getPlayer()))) {
return;
}
if (player.isOnline()) {
@ -219,7 +219,7 @@ import java.util.*;
if (player == null) {
return;
}
if (UUIDHandler.getUUID(player).equals(event.getPlayer().getUniqueId())) {
if (UUIDHandler.getUUID(player).equals(UUIDHandler.getUUID(event.getPlayer()))) {
return;
}
if (player.isOnline()) {

View File

@ -124,7 +124,7 @@ import java.util.Set;
}
final Plot plot = PlotHelper.getCurrentPlot(b.getLocation());
if (plot != null) {
if (plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
if (plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)))) {
PWE.setMask(p, l);
}
}
@ -143,7 +143,7 @@ import java.util.Set;
}
if (this.restrictedcmds.contains(cmd)) {
final Plot plot = PlayerFunctions.getCurrentPlot(p);
if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)))) {
e.setCancelled(true);
}
return;

View File

@ -33,6 +33,7 @@ import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.RegionMask;
import com.sk89q.worldedit.regions.CuboidRegion;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -57,7 +58,7 @@ import org.bukkit.entity.Player;
final Plot plot = PlotMain.getPlots(l.getWorld()).get(id);
if (plot != null) {
boolean r;
r = ((plot.getOwner() != null) && plot.getOwner().equals(p.getUniqueId())) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId());
r = ((plot.getOwner() != null) && plot.getOwner().equals(UUIDHandler.getUUID(p))) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p));
if (!r) {
if (p.hasPermission("plots.worldedit.bypass")) {
removeMask(p, s);

View File

@ -220,7 +220,7 @@ import java.util.*;
* @return
*/
public static int getPlayerPlotCount(final World world, final Player plr) {
final UUID uuid = plr.getUniqueId();
final UUID uuid = UUIDHandler.getUUID(plr);
int count = 0;
for (final Plot plot : PlotMain.getPlots(world).values()) {
if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) {