diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 92d354385..8731618f4 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.11.21 + 2.11.22 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index b4c47f206..b6db79291 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -177,4 +177,16 @@ public class BukkitPlayer implements PlotPlayer { key = "plotsquared_user_attributes." + key; EconHandler.manager.setPermission(this, key, false); } + + @Override + public void loadData() { + if (!player.isOnline()) { + player.loadData(); + } + } + + @Override + public void saveData() { + player.saveData(); + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index a4456d010..7bf848864 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -31,6 +31,10 @@ public interface PlotPlayer { public void setCompassTarget(Location loc); + public void loadData(); + + public void saveData(); + /** * Set player data that will persist restarts * - Please note that this is not intended to store large values diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index ee0cb746a..842a32e8a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -7,6 +7,7 @@ import java.util.List; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Material; +import org.bukkit.OfflinePlayer; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.block.Block; @@ -46,6 +47,15 @@ public class BukkitUtil extends BlockManager { return getWorld(world) != null; } + public static PlotPlayer getPlayer(final OfflinePlayer op) { + if (op.isOnline()) { + return getPlayer(op.getPlayer()); + } + Player player = OfflinePlayerUtil.loadPlayer(op); + player.loadData(); + return new BukkitPlayer(player); + } + public static PlotPlayer getPlayer(final Player player) { if (player == lastPlayer) { return lastPlotPlayer;