mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Added wrapping of PlotPlayer from OfflinePlayer
This commit is contained in:
parent
345b4599b9
commit
4f7de9bf13
@ -8,7 +8,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>2.11.21</version>
|
||||
<version>2.11.22</version>
|
||||
<name>PlotSquared</name>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user