mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Fixes #1534 + various
Auto world loading/unloading Auto player teleporting on login
This commit is contained in:
@ -19,7 +19,7 @@ import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "remove",
|
||||
aliases = {"r","untrust", "ut", "undeny", "ud"},
|
||||
aliases = {"r","untrust", "ut", "undeny", "unban", "ud"},
|
||||
description = "Remove a player from a plot",
|
||||
usage = "/plot remove <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
|
@ -1678,7 +1678,7 @@ public class Plot {
|
||||
* @param uuid
|
||||
*/
|
||||
public boolean removeDenied(UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
if (uuid == DBFunc.everyone && !denied.contains(uuid)) {
|
||||
boolean result = false;
|
||||
for (UUID other : new HashSet<>(getDenied())) {
|
||||
result = rmvDenied(other) || result;
|
||||
@ -1705,7 +1705,7 @@ public class Plot {
|
||||
* @param uuid
|
||||
*/
|
||||
public boolean removeTrusted(UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
if (uuid == DBFunc.everyone && !trusted.contains(uuid)) {
|
||||
boolean result = false;
|
||||
for (UUID other : new HashSet<>(getTrusted())) {
|
||||
result = rmvTrusted(other) || result;
|
||||
@ -1735,7 +1735,7 @@ public class Plot {
|
||||
if (this.members == null) {
|
||||
return false;
|
||||
}
|
||||
if (uuid == DBFunc.everyone) {
|
||||
if (uuid == DBFunc.everyone && !members.contains(uuid)) {
|
||||
boolean result = false;
|
||||
for (UUID other : new HashSet<>(this.members)) {
|
||||
result = rmvMember(other) || result;
|
||||
|
@ -5,14 +5,19 @@ import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotArea;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.PlotGameMode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -401,6 +406,21 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
||||
public void unregister() {
|
||||
Plot plot = getCurrentPlot();
|
||||
if (plot != null) {
|
||||
if (Settings.Enabled_Components.PERSISTENT_META) {
|
||||
if (plot.getArea() instanceof SinglePlotArea) {
|
||||
PlotId id = plot.getId();
|
||||
int x = id.x;
|
||||
int z = id.y;
|
||||
ByteBuffer buffer = ByteBuffer.allocate(13);
|
||||
buffer.putShort((short) x);
|
||||
buffer.putShort((short) z);
|
||||
Location loc = getLocation();
|
||||
buffer.putInt(loc.getX());
|
||||
buffer.put((byte) loc.getY());
|
||||
buffer.putInt(loc.getZ());
|
||||
setPersistentMeta("quitLoc", buffer.array());
|
||||
}
|
||||
}
|
||||
EventUtil.manager.callLeave(this, plot);
|
||||
}
|
||||
if (Settings.Enabled_Components.BAN_DELETER && isBanned()) {
|
||||
@ -470,6 +490,32 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
||||
@Override
|
||||
public void run(Map<String, byte[]> value) {
|
||||
PlotPlayer.this.metaMap = value;
|
||||
if (!value.isEmpty()) {
|
||||
if (Settings.Enabled_Components.PERSISTENT_META) {
|
||||
PlotAreaManager manager = PS.get().getPlotAreaManager();
|
||||
if (manager instanceof SinglePlotAreaManager) {
|
||||
PlotArea area = ((SinglePlotAreaManager) manager).getArea();
|
||||
byte[] arr = PlotPlayer.this.getPersistentMeta("quitLoc");
|
||||
if (arr != null) {
|
||||
ByteBuffer quitWorld = ByteBuffer.wrap(arr);
|
||||
PlotId id = new PlotId(quitWorld.getShort(), quitWorld.getShort());
|
||||
int x = quitWorld.getInt();
|
||||
int y = quitWorld.get() & 0xFF;
|
||||
int z = quitWorld.getInt();
|
||||
Plot plot = area.getOwnedPlot(id);
|
||||
if (plot != null && plot.isLoaded()) {
|
||||
final Location loc = new Location(plot.getWorldName(), x, y, z);
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object o) {
|
||||
teleport(loc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -41,8 +41,20 @@ public class SinglePlotArea extends GridPlotWorld {
|
||||
setup.step = new ConfigurationNode[0];
|
||||
setup.world = worldName;
|
||||
SetupUtils.manager.setupWorld(setup);
|
||||
// String worldName = plot.getWorldName();
|
||||
// World world = Bukkit.getWorld(worldName);
|
||||
// if (world != null) {
|
||||
// return world;
|
||||
// }
|
||||
// WorldCreator wc = new WorldCreator(worldName);
|
||||
// wc.generator("PlotSquared:single");
|
||||
// wc.environment(World.Environment.NORMAL);
|
||||
// wc.type(WorldType.FLAT);
|
||||
// return AsyncWorld.create(wc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ConfigurationNode[] getSettingNodes() {
|
||||
return new ConfigurationNode[] {
|
||||
|
Reference in New Issue
Block a user