Fix teleportOnLogin error

This commit is contained in:
Jesse Boyd 2019-04-19 12:53:48 +10:00
parent 8ac23b92d8
commit 815e513093
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -462,8 +462,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
*/ */
public void unregister() { public void unregister() {
Plot plot = getCurrentPlot(); Plot plot = getCurrentPlot();
if (plot != null && Settings.Enabled_Components.PERSISTENT_META && plot if (plot != null && Settings.Enabled_Components.PERSISTENT_META && plot.getArea() instanceof SinglePlotArea) {
.getArea() instanceof SinglePlotArea) {
PlotId id = plot.getId(); PlotId id = plot.getId();
int x = id.x; int x = id.x;
int z = id.y; int z = id.y;
@ -538,59 +537,60 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
@Override public void run(Map<String, byte[]> value) { @Override public void run(Map<String, byte[]> value) {
try { try {
PlotPlayer.this.metaMap = value; PlotPlayer.this.metaMap = value;
if (!value.isEmpty()) { if (value.isEmpty()) {
if (Settings.Enabled_Components.PERSISTENT_META) { return;
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager(); }
if (manager instanceof SinglePlotAreaManager) {
PlotArea area = ((SinglePlotAreaManager) manager).getArea();
byte[] arr = PlotPlayer.this.getPersistentMeta("quitLoc");
if (arr != null) {
removePersistentMeta("quitLoc");
if (getMeta("teleportOnLogin", true)) { if (!Settings.Enabled_Components.PERSISTENT_META) {
ByteBuffer quitWorld = ByteBuffer.wrap(arr); return;
final int plotX = quitWorld.getShort(); }
final int plotZ = quitWorld.getShort(); PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
PlotId id = new PlotId(plotX, plotZ);
int x = quitWorld.getInt(); if (!(manager instanceof SinglePlotAreaManager)) {
int y = quitWorld.get() & 0xFF; return;
int z = quitWorld.getInt(); }
Plot plot = area.getOwnedPlot(id); PlotArea area = ((SinglePlotAreaManager) manager).getArea();
if (plot != null) { byte[] arr = PlotPlayer.this.getPersistentMeta("quitLoc");
final Location loc = if (arr == null) {
new Location(plot.getWorldName(), x, y, z); return;
if (plot.isLoaded()) { }
TaskManager.runTask(() -> { removePersistentMeta("quitLoc");
if (getMeta("teleportOnLogin", true)) {
teleport(loc); if (!getMeta("teleportOnLogin", true)) {
sendMessage( return;
Captions.TELEPORTED_TO_PLOT.f() }
+ " (quitLoc) (" + plotX + "," ByteBuffer quitWorld = ByteBuffer.wrap(arr);
+ plotZ + ")"); final int plotX = quitWorld.getShort();
} final int plotZ = quitWorld.getShort();
}); PlotId id = new PlotId(plotX, plotZ);
} else if (!PlotSquared.get() int x = quitWorld.getInt();
.isMainThread(Thread.currentThread())) { int y = quitWorld.get() & 0xFF;
if (getMeta("teleportOnLogin", true)) { int z = quitWorld.getInt();
if (plot.teleportPlayer(PlotPlayer.this)) { Plot plot = area.getOwnedPlot(id);
TaskManager.runTask(() -> {
if (getMeta("teleportOnLogin", if (plot == null) {
true)) { return;
teleport(loc); }
sendMessage(
Captions.TELEPORTED_TO_PLOT final Location loc = new Location(plot.getWorldName(), x, y, z);
.f() if (plot.isLoaded()) {
+ " (quitLoc-unloaded) (" TaskManager.runTask(() -> {
+ plotX + "," + plotZ if (getMeta("teleportOnLogin", true)) {
+ ")"); teleport(loc);
} sendMessage(Captions.TELEPORTED_TO_PLOT.f() + " (quitLoc) (" + plotX + "," + plotZ + ")");
}); }
} });
} } else if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
} if (getMeta("teleportOnLogin", true)) {
if (plot.teleportPlayer(PlotPlayer.this)) {
TaskManager.runTask(() -> {
if (getMeta("teleportOnLogin",true)) {
if (plot.isLoaded()) {
teleport(loc);
sendMessage(Captions.TELEPORTED_TO_PLOT.f() + " (quitLoc-unloaded) (" + plotX + "," + plotZ + ")");
} }
} }
} });
} }
} }
} }