Added wrapping of PlotPlayer from OfflinePlayer

This commit is contained in:
boy0001 2015-06-23 21:13:48 +10:00
parent 345b4599b9
commit 4f7de9bf13
4 changed files with 27 additions and 1 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>2.11.21</version> <version>2.11.22</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>

View File

@ -177,4 +177,16 @@ public class BukkitPlayer implements PlotPlayer {
key = "plotsquared_user_attributes." + key; key = "plotsquared_user_attributes." + key;
EconHandler.manager.setPermission(this, key, false); EconHandler.manager.setPermission(this, key, false);
} }
@Override
public void loadData() {
if (!player.isOnline()) {
player.loadData();
}
}
@Override
public void saveData() {
player.saveData();
}
} }

View File

@ -31,6 +31,10 @@ public interface PlotPlayer {
public void setCompassTarget(Location loc); public void setCompassTarget(Location loc);
public void loadData();
public void saveData();
/** /**
* Set player data that will persist restarts * Set player data that will persist restarts
* - Please note that this is not intended to store large values * - Please note that this is not intended to store large values

View File

@ -7,6 +7,7 @@ import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -46,6 +47,15 @@ public class BukkitUtil extends BlockManager {
return getWorld(world) != null; 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) { public static PlotPlayer getPlayer(final Player player) {
if (player == lastPlayer) { if (player == lastPlayer) {
return lastPlotPlayer; return lastPlotPlayer;