mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
UUIDs are now Abstract
This commit is contained in:
parent
176baa5c0d
commit
7b203261a3
@ -42,8 +42,10 @@ import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
|
|||||||
import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
import me.confuser.barapi.BarAPI;
|
import me.confuser.barapi.BarAPI;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -338,7 +340,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* @return Set Containing the players plots
|
* @return Set Containing the players plots
|
||||||
*/
|
*/
|
||||||
public static Set<Plot> getPlots(final Player player) {
|
public static Set<Plot> getPlots(final Player player) {
|
||||||
final UUID uuid = player.getUniqueId();
|
final UUID uuid = UUIDHandler.getUUID(player);
|
||||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
final ArrayList<Plot> myplots = new ArrayList<>();
|
||||||
for (final HashMap<PlotId, Plot> world : plots.values()) {
|
for (final HashMap<PlotId, Plot> world : plots.values()) {
|
||||||
for (final Plot plot : world.values()) {
|
for (final Plot plot : world.values()) {
|
||||||
@ -358,7 +360,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* @return players plots
|
* @return players plots
|
||||||
*/
|
*/
|
||||||
public static Set<Plot> getPlots(final World world, final Player player) {
|
public static Set<Plot> getPlots(final World world, final Player player) {
|
||||||
final UUID uuid = player.getUniqueId();
|
final UUID uuid = UUIDHandler.getUUID(player);
|
||||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
final ArrayList<Plot> myplots = new ArrayList<>();
|
||||||
for (final Plot plot : getPlots(world).values()) {
|
for (final Plot plot : getPlots(world).values()) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
@ -912,7 +914,10 @@ public class PlotMain extends JavaPlugin {
|
|||||||
final int config_ver = 1;
|
final int config_ver = 1;
|
||||||
config.set("version", config_ver);
|
config.set("version", config_ver);
|
||||||
final Map<String, Object> options = new HashMap<>();
|
final Map<String, Object> options = new HashMap<>();
|
||||||
|
|
||||||
options.put("auto_update", false);
|
options.put("auto_update", false);
|
||||||
|
|
||||||
|
options.put("UUID.offline", Settings.OFFLINE_MODE);
|
||||||
options.put("worldguard.enabled", Settings.WORLDGUARD);
|
options.put("worldguard.enabled", Settings.WORLDGUARD);
|
||||||
options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT);
|
options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT);
|
||||||
options.put("mob_pathfinding", Settings.MOB_PATHFINDING_DEFAULT);
|
options.put("mob_pathfinding", Settings.MOB_PATHFINDING_DEFAULT);
|
||||||
@ -953,6 +958,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
Settings.MAX_PLOTS = config.getInt("max_plots");
|
Settings.MAX_PLOTS = config.getInt("max_plots");
|
||||||
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");
|
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");
|
||||||
|
|
||||||
|
Settings.OFFLINE_MODE = config.getBoolean("UUID.offline");
|
||||||
|
|
||||||
Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask");
|
Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1597,6 +1604,9 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
// Handle UUIDS
|
// Handle UUIDS
|
||||||
{
|
{
|
||||||
|
if (Settings.OFFLINE_MODE) {
|
||||||
|
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
||||||
|
}
|
||||||
setUUIDSaver(new PlotUUIDSaver());
|
setUUIDSaver(new PlotUUIDSaver());
|
||||||
// Looks really cool xD
|
// Looks really cool xD
|
||||||
getUUIDSaver().globalPopulate();
|
getUUIDSaver().globalPopulate();
|
||||||
|
@ -35,7 +35,9 @@ import com.intellectualcrafters.plot.util.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.util.PlotSquaredException;
|
import com.intellectualcrafters.plot.util.PlotSquaredException;
|
||||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.sun.istack.internal.NotNull;
|
import com.sun.istack.internal.NotNull;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -420,7 +422,7 @@ public class PlotAPI {
|
|||||||
final ArrayList<Plot> pPlots = new ArrayList<>();
|
final ArrayList<Plot> pPlots = new ArrayList<>();
|
||||||
for (final Plot plot : PlotMain.getPlots(world).values()) {
|
for (final Plot plot : PlotMain.getPlots(world).values()) {
|
||||||
if (just_owner) {
|
if (just_owner) {
|
||||||
if ((plot.owner != null) && (plot.owner == plr.getUniqueId())) {
|
if ((plot.owner != null) && (plot.owner == UUIDHandler.getUUID(plr))) {
|
||||||
pPlots.add(plot);
|
pPlots.add(plot);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -27,6 +27,8 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -71,7 +73,7 @@ public class Clear extends SubCommand {
|
|||||||
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||||
return sendMessage(plr, C.UNLINK_REQUIRED);
|
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);
|
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
|
@ -41,7 +41,7 @@ public class SetOwner extends SubCommand {
|
|||||||
/*
|
/*
|
||||||
* private UUID getUUID(String string) { OfflinePlayer player =
|
* private UUID getUUID(String string) { OfflinePlayer player =
|
||||||
* Bukkit.getOfflinePlayer(string); return ((player != null) &&
|
* Bukkit.getOfflinePlayer(string); return ((player != null) &&
|
||||||
* player.hasPlayedBefore()) ? player.getUniqueId() : null; }
|
* player.hasPlayedBefore()) ? UUIDHandler.getUUID(player) : null; }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private UUID getUUID(final String string) {
|
private UUID getUUID(final String string) {
|
||||||
|
@ -114,7 +114,11 @@ public class Settings {
|
|||||||
* Use the custom API
|
* Use the custom API
|
||||||
*/
|
*/
|
||||||
public static boolean CUSTOM_API = true;
|
public static boolean CUSTOM_API = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use offline mode storage
|
||||||
|
*/
|
||||||
|
public static boolean OFFLINE_MODE = false;
|
||||||
/**
|
/**
|
||||||
* Database settings
|
* Database settings
|
||||||
*
|
*
|
||||||
|
@ -30,6 +30,8 @@ import com.intellectualcrafters.plot.object.PlotHomePosition;
|
|||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.util.Logger;
|
import com.intellectualcrafters.plot.util.Logger;
|
||||||
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -1009,7 +1011,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
final PreparedStatement statement = connection.prepareStatement("DELETE FROM `" + prefix + "plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
final PreparedStatement statement = connection.prepareStatement("DELETE FROM `" + prefix + "plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
||||||
statement.setInt(1, getId(world, plot.id));
|
statement.setInt(1, getId(world, plot.id));
|
||||||
statement.setString(2, player.getUniqueId().toString());
|
statement.setString(2, UUIDHandler.getUUID(player).toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
statement.close();
|
statement.close();
|
||||||
} catch (final SQLException e) {
|
} catch (final SQLException e) {
|
||||||
@ -1032,7 +1034,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
final PreparedStatement statement = connection.prepareStatement("DELETE FROM `" + prefix + "plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
final PreparedStatement statement = connection.prepareStatement("DELETE FROM `" + prefix + "plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
||||||
statement.setInt(1, getId(world, plot.id));
|
statement.setInt(1, getId(world, plot.id));
|
||||||
statement.setString(2, player.getUniqueId().toString());
|
statement.setString(2, UUIDHandler.getUUID(player).toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
statement.close();
|
statement.close();
|
||||||
} catch (final SQLException e) {
|
} catch (final SQLException e) {
|
||||||
@ -1055,7 +1057,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
final PreparedStatement statement = connection.prepareStatement("INSERT INTO `" + prefix + "plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
final PreparedStatement statement = connection.prepareStatement("INSERT INTO `" + prefix + "plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
||||||
statement.setInt(1, getId(world, plot.id));
|
statement.setInt(1, getId(world, plot.id));
|
||||||
statement.setString(2, player.getUniqueId().toString());
|
statement.setString(2, UUIDHandler.getUUID(player).toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
statement.close();
|
statement.close();
|
||||||
} catch (final SQLException e) {
|
} catch (final SQLException e) {
|
||||||
@ -1078,7 +1080,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
final PreparedStatement statement = connection.prepareStatement("INSERT INTO `" + prefix + "plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
final PreparedStatement statement = connection.prepareStatement("INSERT INTO `" + prefix + "plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
||||||
statement.setInt(1, getId(world, plot.id));
|
statement.setInt(1, getId(world, plot.id));
|
||||||
statement.setString(2, player.getUniqueId().toString());
|
statement.setString(2, UUIDHandler.getUUID(player).toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
statement.close();
|
statement.close();
|
||||||
} catch (final SQLException e) {
|
} catch (final SQLException e) {
|
||||||
@ -1101,7 +1103,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
final PreparedStatement statement = connection.prepareStatement("DELETE FROM `" + prefix + "plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
final PreparedStatement statement = connection.prepareStatement("DELETE FROM `" + prefix + "plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
||||||
statement.setInt(1, getId(world, plot.id));
|
statement.setInt(1, getId(world, plot.id));
|
||||||
statement.setString(2, player.getUniqueId().toString());
|
statement.setString(2, UUIDHandler.getUUID(player).toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
statement.close();
|
statement.close();
|
||||||
} catch (final SQLException e) {
|
} catch (final SQLException e) {
|
||||||
@ -1124,7 +1126,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
try {
|
try {
|
||||||
final PreparedStatement statement = connection.prepareStatement("INSERT INTO `" + prefix + "plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
final PreparedStatement statement = connection.prepareStatement("INSERT INTO `" + prefix + "plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
||||||
statement.setInt(1, getId(world, plot.id));
|
statement.setInt(1, getId(world, plot.id));
|
||||||
statement.setString(2, player.getUniqueId().toString());
|
statement.setString(2, UUIDHandler.getUUID(player).toString());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
statement.close();
|
statement.close();
|
||||||
} catch (final SQLException e) {
|
} catch (final SQLException e) {
|
||||||
|
@ -26,6 +26,8 @@ import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
|
|||||||
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -179,7 +181,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (player.getUniqueId().equals(event.getPlayer().getUniqueId())) {
|
if (UUIDHandler.getUUID(player).equals(event.getPlayer().getUniqueId())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
@ -218,7 +220,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (player.getUniqueId().equals(event.getPlayer().getUniqueId())) {
|
if (UUIDHandler.getUUID(player).equals(event.getPlayer().getUniqueId())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
|
@ -25,6 +25,8 @@ import com.intellectualcrafters.plot.PlotMain;
|
|||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
@ -212,7 +214,7 @@ public class Plot implements Cloneable {
|
|||||||
* @return true if the player is added as a helper or is the owner
|
* @return true if the player is added as a helper or is the owner
|
||||||
*/
|
*/
|
||||||
public boolean hasRights(final Player player) {
|
public boolean hasRights(final Player player) {
|
||||||
return PlotMain.hasPermission(player, "plots.admin") || ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(player.getUniqueId())) || ((this.owner != null) && this.owner.equals(player.getUniqueId())) || ((this.owner != null) && (this.trusted != null) && (Bukkit.getPlayer(this.owner) != null) && (this.trusted.contains(player.getUniqueId()) || this.trusted.contains(DBFunc.everyone)));
|
return PlotMain.hasPermission(player, "plots.admin") || ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(UUIDHandler.getUUID(player))) || ((this.owner != null) && this.owner.equals(UUIDHandler.getUUID(player))) || ((this.owner != null) && (this.trusted != null) && (Bukkit.getPlayer(this.owner) != null) && (this.trusted.contains(UUIDHandler.getUUID(player)) || this.trusted.contains(DBFunc.everyone)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -222,7 +224,7 @@ public class Plot implements Cloneable {
|
|||||||
* @return false if the player is allowed to enter
|
* @return false if the player is allowed to enter
|
||||||
*/
|
*/
|
||||||
public boolean deny_entry(final Player player) {
|
public boolean deny_entry(final Player player) {
|
||||||
return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.hasRights(player)) || (!this.hasRights(player) && this.denied.contains(player.getUniqueId())));
|
return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.hasRights(player)) || (!this.hasRights(player) && this.denied.contains(UUIDHandler.getUUID(player))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -238,7 +240,7 @@ public class Plot implements Cloneable {
|
|||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public void setOwner(final Player player) {
|
public void setOwner(final Player player) {
|
||||||
this.owner = player.getUniqueId();
|
this.owner = UUIDHandler.getUUID(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DefaultUUIDWrapper extends UUIDWrapper {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID(Player player) {
|
||||||
|
return player.getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID(OfflinePlayer player) {
|
||||||
|
return player.getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
|
||||||
|
public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID(Player player) {
|
||||||
|
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID(OfflinePlayer player) {
|
||||||
|
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -345,7 +345,7 @@ public class PlotHelper {
|
|||||||
if (plot.owner == null) {
|
if (plot.owner == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!plot.owner.equals(player.getUniqueId())) {
|
if (!plot.owner.equals(UUIDHandler.getUUID(player))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ public class PlotHelper {
|
|||||||
final PlotId id_max = plots.get(plots.size() - 1);
|
final PlotId id_max = plots.get(plots.size() - 1);
|
||||||
for (final PlotId myid : plots) {
|
for (final PlotId myid : plots) {
|
||||||
final Plot myplot = PlotMain.getPlots(world).get(myid);
|
final Plot myplot = PlotMain.getPlots(world).get(myid);
|
||||||
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(player.getUniqueId()))) {
|
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(player)))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotId top = PlayerFunctions.getTopPlot(world, myplot).id;
|
final PlotId top = PlayerFunctions.getTopPlot(world, myplot).id;
|
||||||
@ -420,7 +420,7 @@ public class PlotHelper {
|
|||||||
|
|
||||||
public static boolean createPlot(final Player player, final Plot plot) {
|
public static boolean createPlot(final Player player, final Plot plot) {
|
||||||
final World w = plot.getWorld();
|
final World w = plot.getWorld();
|
||||||
final Plot p = new Plot(plot.id, player.getUniqueId(), plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
|
final Plot p = new Plot(plot.id, UUIDHandler.getUUID(player), plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
|
||||||
PlotMain.updatePlot(p);
|
PlotMain.updatePlot(p);
|
||||||
DBFunc.createPlot(p);
|
DBFunc.createPlot(p);
|
||||||
DBFunc.createPlotSettings(DBFunc.getId(w.getName(), plot.id), plot);
|
DBFunc.createPlotSettings(DBFunc.getId(w.getName(), plot.id), plot);
|
||||||
|
@ -62,6 +62,8 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class UUIDHandler {
|
public class UUIDHandler {
|
||||||
|
|
||||||
|
public static UUIDWrapper uuidWrapper = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Online mode
|
* Online mode
|
||||||
@ -133,7 +135,7 @@ public class UUIDHandler {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
final Player player = Bukkit.getPlayer(name);
|
final Player player = Bukkit.getPlayer(name);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
final UUID uuid = player.getUniqueId();
|
final UUID uuid = getUUID(player);
|
||||||
add(nameWrap, uuid);
|
add(nameWrap, uuid);
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
@ -282,7 +284,7 @@ public class UUIDHandler {
|
|||||||
if (player == null) {
|
if (player == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final UUID uuid = player.getUniqueId();
|
final UUID uuid = getUUID(player);
|
||||||
add(name, uuid);
|
add(name, uuid);
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
@ -297,4 +299,30 @@ public class UUIDHandler {
|
|||||||
final UUIDSaver saver = PlotMain.getUUIDSaver();
|
final UUIDSaver saver = PlotMain.getUUIDSaver();
|
||||||
saver.globalSave(getUuidMap());
|
saver.globalSave(getUuidMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static UUID getUUID(Player player) {
|
||||||
|
if (uuidWrapper == null) {
|
||||||
|
try {
|
||||||
|
getUUID(player);
|
||||||
|
uuidWrapper = new DefaultUUIDWrapper();
|
||||||
|
}
|
||||||
|
catch (Throwable e) {
|
||||||
|
uuidWrapper = new OfflineUUIDWrapper();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return uuidWrapper.getUUID(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UUID getUUID(OfflinePlayer player) {
|
||||||
|
if (uuidWrapper == null) {
|
||||||
|
try {
|
||||||
|
getUUID(player);
|
||||||
|
uuidWrapper = new DefaultUUIDWrapper();
|
||||||
|
}
|
||||||
|
catch (Throwable e) {
|
||||||
|
uuidWrapper = new OfflineUUIDWrapper();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return uuidWrapper.getUUID(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public abstract class UUIDWrapper {
|
||||||
|
public abstract UUID getUUID(Player player);
|
||||||
|
|
||||||
|
public abstract UUID getUUID(OfflinePlayer player);
|
||||||
|
}
|
@ -56,7 +56,7 @@ public class PlotUUIDSaver implements UUIDSaver {
|
|||||||
String name;
|
String name;
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
for (final OfflinePlayer player : offlinePlayers) {
|
for (final OfflinePlayer player : offlinePlayers) {
|
||||||
uuid = player.getUniqueId();
|
uuid = UUIDHandler.getUUID(player);
|
||||||
if (!UUIDHandler.uuidExists(uuid)) {
|
if (!UUIDHandler.uuidExists(uuid)) {
|
||||||
name = player.getName();
|
name = player.getName();
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user