mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Seems to work for 1.7.2 (which doesn't have UUIDs)
This commit is contained in:
parent
7b203261a3
commit
760041607e
@ -52,6 +52,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class PlotMain extends JavaPlugin {
|
public class PlotMain extends JavaPlugin {
|
||||||
|
private static PlotMain main = null;
|
||||||
/**
|
/**
|
||||||
* Permission that allows for "everything"
|
* Permission that allows for "everything"
|
||||||
*/
|
*/
|
||||||
@ -681,7 +682,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* @return (this class)
|
* @return (this class)
|
||||||
*/
|
*/
|
||||||
public static PlotMain getMain() {
|
public static PlotMain getMain() {
|
||||||
return JavaPlugin.getPlugin(PlotMain.class);
|
return PlotMain.main;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -718,7 +719,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
OfflinePlayer player;
|
OfflinePlayer player;
|
||||||
if (((player = Bukkit.getOfflinePlayer(uuid)) == null) || !player.hasPlayedBefore()) {
|
if (((player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid)) == null) || !player.hasPlayedBefore()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return player.getLastPlayed();
|
return player.getLastPlayed();
|
||||||
@ -1388,6 +1389,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
final public void onEnable() {
|
final public void onEnable() {
|
||||||
|
PlotMain.main = this;
|
||||||
// Setup the logger mechanics
|
// Setup the logger mechanics
|
||||||
setupLogger();
|
setupLogger();
|
||||||
// Setup translations
|
// Setup translations
|
||||||
|
@ -124,7 +124,7 @@ public class PlotAPI {
|
|||||||
* @see com.intellectualcrafters.plot.PlotMain
|
* @see com.intellectualcrafters.plot.PlotMain
|
||||||
*/
|
*/
|
||||||
public PlotAPI(@NotNull final JavaPlugin plugin) {
|
public PlotAPI(@NotNull final JavaPlugin plugin) {
|
||||||
this.plotMain = JavaPlugin.getPlugin(PlotMain.class);
|
this.plotMain = PlotMain.getMain();
|
||||||
if (plotMain == null) {
|
if (plotMain == null) {
|
||||||
throw new PlotSquaredException(PlotSquaredException.PlotError.PLOTMAIN_NULL, "Failed to fetch the plotmain instance, Plot API for " + plugin.getName() + " will be disabled");
|
throw new PlotSquaredException(PlotSquaredException.PlotError.PLOTMAIN_NULL, "Failed to fetch the plotmain instance, Plot API for " + plugin.getName() + " will be disabled");
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import com.intellectualcrafters.plot.database.SQLManager;
|
|||||||
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.StringComparison;
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -36,7 +38,7 @@ public class Database extends SubCommand {
|
|||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
PlotMain.sendConsoleSenderMessage(msg);
|
PlotMain.sendConsoleSenderMessage(msg);
|
||||||
} else {
|
} else {
|
||||||
Player p = Bukkit.getPlayer(uuid);
|
Player p = UUIDHandler.uuidWrapper.getPlayer(uuid);
|
||||||
if (p != null && p.isOnline())
|
if (p != null && p.isOnline())
|
||||||
return PlayerFunctions.sendMessage(p, msg);
|
return PlayerFunctions.sendMessage(p, msg);
|
||||||
else
|
else
|
||||||
@ -46,7 +48,7 @@ public class Database extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void insertPlots(final SQLManager manager, final UUID requester, final Connection c) {
|
public static void insertPlots(final SQLManager manager, final UUID requester, final Connection c) {
|
||||||
Plugin p = PlotMain.getPlugin(PlotMain.class);
|
Plugin p = PlotMain.getMain();
|
||||||
final java.util.Set<Plot> plots = PlotMain.getPlots();
|
final java.util.Set<Plot> plots = PlotMain.getPlots();
|
||||||
p.getServer().getScheduler().runTaskAsynchronously(p, new Runnable() {
|
p.getServer().getScheduler().runTaskAsynchronously(p, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -100,7 +102,7 @@ public class Database extends SubCommand {
|
|||||||
Connection n;
|
Connection n;
|
||||||
try {
|
try {
|
||||||
n = new MySQL(
|
n = new MySQL(
|
||||||
PlotMain.getPlugin(PlotMain.class),
|
PlotMain.getMain(),
|
||||||
host,
|
host,
|
||||||
port,
|
port,
|
||||||
database,
|
database,
|
||||||
|
@ -30,6 +30,7 @@ import com.intellectualcrafters.plot.util.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -70,13 +71,18 @@ public class Denied extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
|
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
OfflinePlayer player = null;
|
||||||
if (plot.trusted.contains(uuid)) {
|
if (plot.trusted.contains(uuid)) {
|
||||||
plot.trusted.remove(uuid);
|
plot.trusted.remove(uuid);
|
||||||
DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
|
player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||||
|
DBFunc.removeTrusted(plr.getWorld().getName(), plot, player);
|
||||||
}
|
}
|
||||||
if (plot.helpers.contains(uuid)) {
|
if (plot.helpers.contains(uuid)) {
|
||||||
plot.helpers.remove(uuid);
|
plot.helpers.remove(uuid);
|
||||||
DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
|
if (player == null) {
|
||||||
|
player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||||
|
}
|
||||||
|
DBFunc.removeHelper(plr.getWorld().getName(), plot, player);
|
||||||
}
|
}
|
||||||
plot.addDenied(uuid);
|
plot.addDenied(uuid);
|
||||||
DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
||||||
@ -86,11 +92,12 @@ public class Denied extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
|
PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!uuid.equals(DBFunc.everyone) && (Bukkit.getPlayer(uuid) != null) && Bukkit.getPlayer(uuid).isOnline()) {
|
Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
|
||||||
final Plot pl = PlayerFunctions.getCurrentPlot(Bukkit.getPlayer((uuid)));
|
if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) {
|
||||||
|
final Plot pl = PlayerFunctions.getCurrentPlot(player);
|
||||||
if ((pl != null) && pl.id.equals(plot.id)) {
|
if ((pl != null) && pl.id.equals(plot.id)) {
|
||||||
PlayerFunctions.sendMessage(Bukkit.getPlayer(uuid), C.YOU_BE_DENIED);
|
PlayerFunctions.sendMessage(player, C.YOU_BE_DENIED);
|
||||||
Bukkit.getPlayer(uuid).teleport(Bukkit.getPlayer(uuid).getWorld().getSpawnLocation());
|
player.teleport(player.getWorld().getSpawnLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED);
|
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED);
|
||||||
|
@ -30,6 +30,7 @@ import com.intellectualcrafters.plot.util.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -68,13 +69,18 @@ public class Helpers extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
|
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
OfflinePlayer player = null;
|
||||||
if (plot.trusted.contains(uuid)) {
|
if (plot.trusted.contains(uuid)) {
|
||||||
plot.trusted.remove(uuid);
|
plot.trusted.remove(uuid);
|
||||||
DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
|
player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||||
|
DBFunc.removeTrusted(plr.getWorld().getName(), plot, player);
|
||||||
}
|
}
|
||||||
if (plot.denied.contains(uuid)) {
|
if (plot.denied.contains(uuid)) {
|
||||||
plot.denied.remove(uuid);
|
plot.denied.remove(uuid);
|
||||||
DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
|
if (player == null) {
|
||||||
|
player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||||
|
}
|
||||||
|
DBFunc.removeDenied(plr.getWorld().getName(), plot, player);
|
||||||
}
|
}
|
||||||
plot.addHelper(uuid);
|
plot.addHelper(uuid);
|
||||||
DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
||||||
|
@ -115,7 +115,7 @@ public class Info extends SubCommand {
|
|||||||
|
|
||||||
String owner = "none";
|
String owner = "none";
|
||||||
if (plot.owner != null) {
|
if (plot.owner != null) {
|
||||||
owner = Bukkit.getOfflinePlayer(plot.owner).getName();
|
owner = UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner).getName();
|
||||||
}
|
}
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
owner = plot.owner.toString();
|
owner = plot.owner.toString();
|
||||||
@ -179,7 +179,7 @@ public class Info extends SubCommand {
|
|||||||
|
|
||||||
String owner = "none";
|
String owner = "none";
|
||||||
if (plot.owner != null) {
|
if (plot.owner != null) {
|
||||||
owner = Bukkit.getOfflinePlayer(plot.owner).getName();
|
owner = UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner).getName();
|
||||||
}
|
}
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
owner = plot.owner.toString();
|
owner = plot.owner.toString();
|
||||||
|
@ -30,6 +30,7 @@ import com.intellectualcrafters.plot.util.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -69,13 +70,18 @@ public class Trusted extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
|
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
OfflinePlayer player = null;
|
||||||
if (plot.helpers.contains(uuid)) {
|
if (plot.helpers.contains(uuid)) {
|
||||||
plot.helpers.remove(uuid);
|
plot.helpers.remove(uuid);
|
||||||
DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
|
player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||||
|
DBFunc.removeHelper(plr.getWorld().getName(), plot, player);
|
||||||
}
|
}
|
||||||
if (plot.denied.contains(uuid)) {
|
if (plot.denied.contains(uuid)) {
|
||||||
plot.denied.remove(uuid);
|
plot.denied.remove(uuid);
|
||||||
DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
|
if (player == null) {
|
||||||
|
player = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||||
|
}
|
||||||
|
DBFunc.removeDenied(plr.getWorld().getName(), plot, player);
|
||||||
}
|
}
|
||||||
plot.addTrusted(uuid);
|
plot.addTrusted(uuid);
|
||||||
DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
||||||
|
@ -91,7 +91,7 @@ public class plugin extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final Player plr, final String... args) {
|
public boolean execute(final Player plr, final String... args) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(PlotMain.getMain(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final ArrayList<String> strings = new ArrayList<String>() {
|
final ArrayList<String> strings = new ArrayList<String>() {
|
||||||
|
@ -439,7 +439,7 @@ public enum C {
|
|||||||
manager = new TranslationManager();
|
manager = new TranslationManager();
|
||||||
}
|
}
|
||||||
if (defaultFile == null) {
|
if (defaultFile == null) {
|
||||||
defaultFile = new YamlTranslationFile(BukkitTranslation.getParent(PlotMain.getPlugin(PlotMain.class)), lang, "PlotSquared", manager)
|
defaultFile = new YamlTranslationFile(BukkitTranslation.getParent(PlotMain.getMain()), lang, "PlotSquared", manager)
|
||||||
.read();
|
.read();
|
||||||
}
|
}
|
||||||
// register everything in this class
|
// register everything in this class
|
||||||
|
@ -177,7 +177,8 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
if (booleanFlag(plot, "notify-enter")) {
|
if (booleanFlag(plot, "notify-enter")) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
final Player player = Bukkit.getPlayer(plot.getOwner());
|
|
||||||
|
final Player player = UUIDHandler.uuidWrapper.getPlayer(plot.getOwner());
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -216,7 +217,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
if (booleanFlag(plot, "notify-leave")) {
|
if (booleanFlag(plot, "notify-leave")) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
final Player player = Bukkit.getPlayer(plot.getOwner());
|
final Player player = UUIDHandler.uuidWrapper.getPlayer(plot.getOwner());
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
|||||||
import com.intellectualcrafters.plot.util.PWE;
|
import com.intellectualcrafters.plot.util.PWE;
|
||||||
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 com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
@ -77,7 +78,7 @@ public class WorldEditListener implements Listener {
|
|||||||
if ((plot == null) || (plot.owner == null)) {
|
if ((plot == null) || (plot.owner == null)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Player player = Bukkit.getPlayer(plot.owner);
|
final Player player = UUIDHandler.uuidWrapper.getPlayer(plot.owner);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,10 @@ public class WorldGuardListener implements Listener {
|
|||||||
// requester.setOp(true);
|
// requester.setOp(true);
|
||||||
|
|
||||||
// 10 ticks should be enough
|
// 10 ticks should be enough
|
||||||
final PermissionAttachment add = requester.addAttachment(JavaPlugin.getPlugin(PlotMain.class), 10);
|
final PermissionAttachment add = requester.addAttachment(PlotMain.getMain(), 10);
|
||||||
add.setPermission("worldguard.region.addowner.own.*", true);
|
add.setPermission("worldguard.region.addowner.own.*", true);
|
||||||
|
|
||||||
final PermissionAttachment remove = requester.addAttachment(JavaPlugin.getPlugin(PlotMain.class), 10);
|
final PermissionAttachment remove = requester.addAttachment(PlotMain.getMain(), 10);
|
||||||
remove.setPermission("worldguard.region.removeowner.own.*", true);
|
remove.setPermission("worldguard.region.removeowner.own.*", true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -214,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(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)));
|
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) && (UUIDHandler.uuidWrapper.getPlayer(this.owner) != null) && (this.trusted.contains(UUIDHandler.getUUID(player)) || this.trusted.contains(DBFunc.everyone)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.util;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -17,4 +18,14 @@ public class DefaultUUIDWrapper extends UUIDWrapper {
|
|||||||
return player.getUniqueId();
|
return player.getUniqueId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OfflinePlayer getOfflinePlayer(UUID uuid) {
|
||||||
|
return Bukkit.getOfflinePlayer(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Player getPlayer(UUID uuid) {
|
||||||
|
return Bukkit.getPlayer(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,13 @@ package com.intellectualcrafters.plot.util;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
import com.google.common.collect.BiMap;
|
||||||
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||||
|
|
||||||
public class OfflineUUIDWrapper extends UUIDWrapper {
|
public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||||
|
|
||||||
@ -19,4 +22,33 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
|||||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
|
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OfflinePlayer getOfflinePlayer(UUID uuid) {
|
||||||
|
BiMap<UUID, StringWrapper> map = UUIDHandler.getUuidMap().inverse();
|
||||||
|
String name = map.get(uuid).value;
|
||||||
|
if (name != null) {
|
||||||
|
return Bukkit.getOfflinePlayer(name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||||
|
if (getUUID(player).equals(uuid)) {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Bukkit.getOfflinePlayer(uuid.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Player getPlayer(UUID uuid) {
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (getUUID(player).equals(uuid)) {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public class PlayerFunctions {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean hasExpired(final Plot plot) {
|
public static boolean hasExpired(final Plot plot) {
|
||||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(plot.owner);
|
final OfflinePlayer player = UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner);
|
||||||
final long lp = player.getLastPlayed();
|
final long lp = player.getLastPlayed();
|
||||||
final long cu = System.currentTimeMillis();
|
final long cu = System.currentTimeMillis();
|
||||||
return (lp - cu) > 30l;
|
return (lp - cu) > 30l;
|
||||||
|
@ -273,7 +273,7 @@ public class PlotHelper {
|
|||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
final OfflinePlayer plr = Bukkit.getOfflinePlayer(uuid);
|
final OfflinePlayer plr = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||||
if (plr == null) {
|
if (plr == null) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
@ -122,14 +122,14 @@ public class SchematicHandler {
|
|||||||
*/
|
*/
|
||||||
public static Schematic getSchematic(final String name) {
|
public static Schematic getSchematic(final String name) {
|
||||||
{
|
{
|
||||||
final File parent = new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics");
|
final File parent = new File(PlotMain.getMain().getDataFolder() + File.separator + "schematics");
|
||||||
if (!parent.exists()) {
|
if (!parent.exists()) {
|
||||||
if (!parent.mkdir()) {
|
if (!parent.mkdir()) {
|
||||||
throw new RuntimeException("Could not create schematic parent directory");
|
throw new RuntimeException("Could not create schematic parent directory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final File file = new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics" + File.separator + name + ".schematic");
|
final File file = new File(PlotMain.getMain().getDataFolder() + File.separator + "schematics" + File.separator + name + ".schematic");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
PlotMain.sendConsoleSenderMessage(file.toString() + " doesn't exist");
|
PlotMain.sendConsoleSenderMessage(file.toString() + " doesn't exist");
|
||||||
return null;
|
return null;
|
||||||
|
@ -194,7 +194,7 @@ public class UUIDHandler {
|
|||||||
if ((name = getNameOfflinePlayer(uuid)) != null) {
|
if ((name = getNameOfflinePlayer(uuid)) != null) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
if (online) {
|
if (online && !Settings.OFFLINE_MODE) {
|
||||||
if (!Settings.CUSTOM_API) {
|
if (!Settings.CUSTOM_API) {
|
||||||
try {
|
try {
|
||||||
final NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid));
|
final NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid));
|
||||||
@ -251,7 +251,7 @@ public class UUIDHandler {
|
|||||||
* @return String - name
|
* @return String - name
|
||||||
*/
|
*/
|
||||||
private static String getNameOnlinePlayer(final UUID uuid) {
|
private static String getNameOnlinePlayer(final UUID uuid) {
|
||||||
final Player player = Bukkit.getPlayer(uuid);
|
final Player player = uuidWrapper.getPlayer(uuid);
|
||||||
if ((player == null) || !player.isOnline()) {
|
if ((player == null) || !player.isOnline()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -260,12 +260,14 @@ public class UUIDHandler {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uuid to use as key
|
* @param uuid to use as key
|
||||||
* @return String - name
|
* @return String - name
|
||||||
*/
|
*/
|
||||||
private static String getNameOfflinePlayer(final UUID uuid) {
|
private static String getNameOfflinePlayer(final UUID uuid) {
|
||||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
|
final OfflinePlayer player = uuidWrapper.getOfflinePlayer(uuid);
|
||||||
if ((player == null) || !player.hasPlayedBefore()) {
|
if ((player == null) || !player.hasPlayedBefore()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -9,4 +9,8 @@ public abstract class UUIDWrapper {
|
|||||||
public abstract UUID getUUID(Player player);
|
public abstract UUID getUUID(Player player);
|
||||||
|
|
||||||
public abstract UUID getUUID(OfflinePlayer player);
|
public abstract UUID getUUID(OfflinePlayer player);
|
||||||
|
|
||||||
|
public abstract OfflinePlayer getOfflinePlayer(UUID uuid);
|
||||||
|
|
||||||
|
public abstract Player getPlayer(UUID uuid);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class PlotUUIDSaver implements UUIDSaver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void globalPopulate() {
|
public void globalPopulate() {
|
||||||
JavaPlugin.getPlugin(PlotMain.class).getServer().getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() {
|
Bukkit.getServer().getScheduler().runTaskAsynchronously(PlotMain.getMain(), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers();
|
final OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers();
|
||||||
|
Loading…
Reference in New Issue
Block a user