mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Various minor
Fix download world spawnpoint Fix regenallroads on augmented world Ensure all chunks have unloaded before unloading a world
This commit is contained in:
parent
ce90b36d28
commit
d97ff94465
@ -218,7 +218,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
List<PlotPlayer> players = plot.getPlayersInPlot();
|
List<PlotPlayer> players = plot.getPlayersInPlot();
|
||||||
if (players.isEmpty() && PlotPlayer.wrap(plot.owner) == null) {
|
if (players.isEmpty() && PlotPlayer.wrap(plot.owner) == null) {
|
||||||
for (Chunk chunk : world.getLoadedChunks()) {
|
for (Chunk chunk : world.getLoadedChunks()) {
|
||||||
chunk.unload(true, false);
|
if (!chunk.unload(true, false)) return;
|
||||||
if (System.currentTimeMillis() - start > 20) {
|
if (System.currentTimeMillis() - start > 20) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
@ -41,7 +39,7 @@ public class RegenAllRoads extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotArea area = PS.get().getPlotAreaByString(args[0]);
|
PlotArea area = PS.get().getPlotAreaByString(args[0]);
|
||||||
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
|
if (area == null) {
|
||||||
C.NOT_VALID_PLOT_WORLD.send(player, args[0]);
|
C.NOT_VALID_PLOT_WORLD.send(player, args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author DPOH-VAR
|
* @author DPOH-VAR
|
||||||
@ -32,6 +33,18 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T, V> Map<T, V> getMap(Map<T, V> map) {
|
||||||
|
try {
|
||||||
|
Class<? extends Map> clazz = map.getClass();
|
||||||
|
Field m = clazz.getDeclaredField("m");
|
||||||
|
m.setAccessible(true);
|
||||||
|
return (Map<T, V>) m.get(map);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Method findMethod(Class<?> clazz, boolean isStatic, Class<?> returnType, Class... types) {
|
public static Method findMethod(Class<?> clazz, boolean isStatic, Class<?> returnType, Class... types) {
|
||||||
loop:
|
loop:
|
||||||
for (Method method : clazz.getMethods()) {
|
for (Method method : clazz.getMethods()) {
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.intellectualcrafters.plot.util;
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||||
|
import com.intellectualcrafters.jnbt.IntTag;
|
||||||
|
import com.intellectualcrafters.jnbt.NBTInputStream;
|
||||||
|
import com.intellectualcrafters.jnbt.NBTOutputStream;
|
||||||
|
import com.intellectualcrafters.jnbt.Tag;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
@ -9,14 +14,17 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
import java.util.zip.GZIPOutputStream;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
@ -70,15 +78,22 @@ public abstract class WorldUtil {
|
|||||||
try (final ZipOutputStream zos = new ZipOutputStream(output)) {
|
try (final ZipOutputStream zos = new ZipOutputStream(output)) {
|
||||||
File dat = getDat(plot.getWorldName());
|
File dat = getDat(plot.getWorldName());
|
||||||
Location spawn = getSpawn(plot.getWorldName());
|
Location spawn = getSpawn(plot.getWorldName());
|
||||||
setSpawn(home);
|
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
if (dat != null) {
|
if (dat != null) {
|
||||||
ZipEntry ze = new ZipEntry("world" + File.separator + dat.getName());
|
ZipEntry ze = new ZipEntry("world" + File.separator + dat.getName());
|
||||||
zos.putNextEntry(ze);
|
zos.putNextEntry(ze);
|
||||||
FileInputStream in = new FileInputStream(dat);
|
try (NBTInputStream nis = new NBTInputStream(new GZIPInputStream(new FileInputStream(dat)))) {
|
||||||
int len;
|
CompoundTag tag = (CompoundTag) nis.readTag();
|
||||||
while ((len = in.read(buffer)) > 0) {
|
CompoundTag data = (CompoundTag) tag.getValue().get("Data");
|
||||||
zos.write(buffer, 0, len);
|
Map<String, Tag> map = ReflectionUtils.getMap(data.getValue());
|
||||||
|
map.put("SpawnX", new IntTag("SpawnX", home.getX()));
|
||||||
|
map.put("SpawnY", new IntTag("SpawnY", home.getY()));
|
||||||
|
map.put("SpawnZ", new IntTag("SpawnZ", home.getZ()));
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
try (NBTOutputStream out = new NBTOutputStream(new GZIPOutputStream(baos, true))) {
|
||||||
|
out.writeTag(tag);
|
||||||
|
}
|
||||||
|
zos.write(baos.toByteArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setSpawn(spawn);
|
setSpawn(spawn);
|
||||||
|
Loading…
Reference in New Issue
Block a user