mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 12:35:15 +01:00
Merge remote-tracking branch 'IntellectualSites/master' into testing
This commit is contained in:
commit
f16affabcc
@ -78,7 +78,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -91,8 +90,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
@ -655,25 +652,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public String getNMSPackage() {
|
||||
final Server server = Bukkit.getServer();
|
||||
final Class<?> bukkitServerClass = server.getClass();
|
||||
String[] pas = bukkitServerClass.getName().split("\\.");
|
||||
if (pas.length == 5) {
|
||||
return pas[3];
|
||||
}
|
||||
try {
|
||||
final Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle");
|
||||
final Object handle = getHandle.invoke(server);
|
||||
final Class handleServerClass = handle.getClass();
|
||||
pas = handleServerClass.getName().split("\\.");
|
||||
if (pas.length == 5) {
|
||||
return pas[3];
|
||||
}
|
||||
} catch (IllegalAccessException | InvocationTargetException | SecurityException | NoSuchMethodException | IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
PS.debug("Unknown NMS package: " + StringMan.getString(pas));
|
||||
return "1_8_R3";
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
return name.substring(name.lastIndexOf('.') + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.plotsquared.bukkit.chat;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -29,7 +29,6 @@ public final class Reflection {
|
||||
* The map maps [types to maps of [method names to maps of [parameter types to method instances]]].
|
||||
*/
|
||||
private static final Map<Class<?>, Map<String, Map<ArrayWrapper<Class<?>>, Method>>> _loadedMethods = new HashMap<>();
|
||||
private static String _versionString;
|
||||
|
||||
private Reflection() {
|
||||
|
||||
@ -41,16 +40,7 @@ public final class Reflection {
|
||||
* @return The version string of the OBC and NMS packages, <em>including the trailing dot</em>.
|
||||
*/
|
||||
public synchronized static String getVersion() {
|
||||
if (_versionString == null) {
|
||||
if (Bukkit.getServer() == null) {
|
||||
// The server hasn't started, static initializer call?
|
||||
return null;
|
||||
}
|
||||
final String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
_versionString = name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
}
|
||||
|
||||
return _versionString;
|
||||
return PS.get().IMP.getNMSPackage();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,7 +54,7 @@ public final class Reflection {
|
||||
return _loadedNMSClasses.get(className);
|
||||
}
|
||||
|
||||
final String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
final String fullName = "net.minecraft.server." + getVersion() + "." + className;
|
||||
Class<?> clazz;
|
||||
try {
|
||||
clazz = Class.forName(fullName);
|
||||
@ -90,7 +80,7 @@ public final class Reflection {
|
||||
return _loadedOBCClasses.get(className);
|
||||
}
|
||||
|
||||
final String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
||||
final String fullName = "org.bukkit.craftbukkit." + getVersion() + "." + className;
|
||||
Class<?> clazz;
|
||||
try {
|
||||
clazz = Class.forName(fullName);
|
||||
@ -162,13 +152,7 @@ public final class Reflection {
|
||||
field.setAccessible(true);
|
||||
loaded.put(name, field);
|
||||
return field;
|
||||
} catch (NoSuchFieldException e) {
|
||||
// Error loading
|
||||
e.printStackTrace();
|
||||
// Cache field as not existing
|
||||
loaded.put(name, null);
|
||||
return null;
|
||||
} catch (SecurityException e) {
|
||||
} catch (NoSuchFieldException | SecurityException e) {
|
||||
// Error loading
|
||||
e.printStackTrace();
|
||||
// Cache field as not existing
|
||||
|
@ -32,10 +32,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
@Override
|
||||
public Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder) {
|
||||
this.plugin = plugin.toLowerCase();
|
||||
prefix = plotConfig.getString("mySQLprefix");
|
||||
if (prefix == null) {
|
||||
prefix = plugin.toLowerCase();
|
||||
}
|
||||
prefix = plotConfig.getString("mySQLprefix", plugin.toLowerCase());
|
||||
try {
|
||||
if (plotConfig.getBoolean("usemySQL")) {
|
||||
final String user = plotConfig.getString("mySQLuname");
|
||||
|
@ -234,6 +234,8 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
// Set the result data
|
||||
result.cd = createChunkData(world);
|
||||
result.grid = grid;
|
||||
result.result = null;
|
||||
result.result_data = null;
|
||||
// Catch any exceptions (as exceptions usually thrown
|
||||
try {
|
||||
// Fill the result data if necessary
|
||||
@ -259,9 +261,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
// Set random seed
|
||||
this.random.state = (cx << 16) | (cz & 0xFFFF);
|
||||
// Process the chunk
|
||||
result.modified = false;
|
||||
ChunkManager.preProcessChunk(result);
|
||||
if (result.modified) {
|
||||
if (ChunkManager.preProcessChunk(result)) {
|
||||
return;
|
||||
}
|
||||
PlotArea area = PS.get().getPlotArea(world.getName(), null);
|
||||
@ -279,6 +279,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
result.result = new short[16][];
|
||||
result.result_data = new byte[16][];
|
||||
result.grid = grid;
|
||||
result.cd = null;
|
||||
// Catch any exceptions (as exceptions usually thrown
|
||||
try {
|
||||
// Fill the result data
|
||||
|
@ -1196,6 +1196,9 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BUILD_IRONGOLEM:
|
||||
case BUILD_WITHER:
|
||||
case BUILD_SNOWMAN:
|
||||
case CUSTOM:
|
||||
if (!area.SPAWN_CUSTOM && entity.getType().getTypeId() != 30) {
|
||||
event.setCancelled(true);
|
||||
@ -1505,7 +1508,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
return;
|
||||
}
|
||||
} else if (fireball.getShooter() instanceof BlockProjectileSource) {
|
||||
final Block shooter = (Block) ((BlockProjectileSource) fireball.getShooter()).getBlock();
|
||||
final Block shooter = ((BlockProjectileSource) fireball.getShooter()).getBlock();
|
||||
if (BukkitUtil.getLocation(shooter.getLocation()).getPlot() == null) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
|
@ -534,7 +534,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
final PlotLoc loc = new PlotLoc(x, z);
|
||||
final PlotLoc loc = new PlotLoc(x + offset_x, z + offset_z);
|
||||
allblocks.put(loc, ids);
|
||||
}
|
||||
|
||||
@ -633,133 +633,48 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
public boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) {
|
||||
final int relX = newPos.getX() - pos1.getX();
|
||||
final int relZ = newPos.getZ() - pos1.getZ();
|
||||
|
||||
final int relCX = relX >> 4;
|
||||
final int relCZ = relZ >> 4;
|
||||
final Location pos4 = new Location(newPos.getWorld(), newPos.getX() + relX, 256, newPos.getZ() + relZ);
|
||||
|
||||
final RegionWrapper region = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
|
||||
final World oldWorld = Bukkit.getWorld(pos1.getWorld());
|
||||
final World newWorld = Bukkit.getWorld(newPos.getWorld());
|
||||
final String newWorldname = newWorld.getName();
|
||||
final List<ChunkLoc> chunks = new ArrayList<>();
|
||||
|
||||
initMaps();
|
||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||
@Override
|
||||
public void run(int[] value) {
|
||||
initMaps();
|
||||
|
||||
final int bx = value[2];
|
||||
final int bz = value[3];
|
||||
|
||||
final int tx = value[4];
|
||||
final int tz = value[5];
|
||||
|
||||
// Load chunks
|
||||
final ChunkLoc loc1 = new ChunkLoc(value[0], value[1]);
|
||||
final ChunkLoc loc2 = new ChunkLoc(loc1.x + relCX, loc1.z + relCZ);
|
||||
final Chunk c1 = oldWorld.getChunkAt(loc1.x, loc1.z);
|
||||
final Chunk c2 = newWorld.getChunkAt(loc2.x, loc2.z);
|
||||
c1.load(true);
|
||||
c2.load(true);
|
||||
chunks.add(loc2);
|
||||
// entities
|
||||
saveEntitiesIn(c1, region);
|
||||
// copy chunk
|
||||
setChunkInPlotArea(null, new RunnableVal<PlotChunk<?>>() {
|
||||
@Override
|
||||
public void run(PlotChunk<?> value) {
|
||||
for (int x = bx & 15; x <= (tx & 15); x++) {
|
||||
for (int z = bz & 15; z <= (tz & 15); z++) {
|
||||
for (int y = 1; y < 256; y++) {
|
||||
Block block = c1.getBlock(x, y, z);
|
||||
Material id = block.getType();
|
||||
switch (id) {
|
||||
case AIR:
|
||||
case GRASS:
|
||||
case COBBLESTONE:
|
||||
case GRAVEL:
|
||||
case GOLD_ORE:
|
||||
case IRON_ORE:
|
||||
case GLASS:
|
||||
case LAPIS_ORE:
|
||||
case LAPIS_BLOCK:
|
||||
case WEB:
|
||||
case DEAD_BUSH:
|
||||
case YELLOW_FLOWER:
|
||||
case BROWN_MUSHROOM:
|
||||
case RED_MUSHROOM:
|
||||
case GOLD_BLOCK:
|
||||
case IRON_BLOCK:
|
||||
case BRICK:
|
||||
case TNT:
|
||||
case BOOKSHELF:
|
||||
case MOSSY_COBBLESTONE:
|
||||
case OBSIDIAN:
|
||||
case FIRE:
|
||||
case REDSTONE_WIRE:
|
||||
case DIAMOND_ORE:
|
||||
case DIAMOND_BLOCK:
|
||||
case WORKBENCH:
|
||||
case SOIL:
|
||||
case BEDROCK:
|
||||
case WATER:
|
||||
case STATIONARY_WATER:
|
||||
case LAVA:
|
||||
case STATIONARY_LAVA:
|
||||
case REDSTONE_ORE:
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case SNOW:
|
||||
case ICE:
|
||||
case SNOW_BLOCK:
|
||||
case CACTUS:
|
||||
case CLAY:
|
||||
case SUGAR_CANE_BLOCK:
|
||||
case FENCE:
|
||||
case NETHERRACK:
|
||||
case SOUL_SAND:
|
||||
case IRON_FENCE:
|
||||
case THIN_GLASS:
|
||||
case MELON_BLOCK:
|
||||
case MYCEL:
|
||||
case NETHER_BRICK:
|
||||
case NETHER_FENCE:
|
||||
case ENDER_STONE:
|
||||
case DRAGON_EGG:
|
||||
case EMERALD_ORE:
|
||||
case EMERALD_BLOCK:
|
||||
case SLIME_BLOCK:
|
||||
case BARRIER:
|
||||
case SEA_LANTERN:
|
||||
case HAY_BLOCK:
|
||||
case HARD_CLAY:
|
||||
case COAL_BLOCK:
|
||||
case PACKED_ICE:
|
||||
case DOUBLE_STONE_SLAB2:
|
||||
case STONE_SLAB2:
|
||||
case SPRUCE_FENCE:
|
||||
case BIRCH_FENCE:
|
||||
case JUNGLE_FENCE:
|
||||
case DARK_OAK_FENCE:
|
||||
case ACACIA_FENCE:
|
||||
value.setBlock(x, y, z, id.getId(), (byte) 0);
|
||||
break;
|
||||
default:
|
||||
value.setBlock(x, y, z, id.getId(), block.getData());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
final ChunkLoc loc = new ChunkLoc(value[0], value[1]);
|
||||
final int cxx = loc.x << 4;
|
||||
final int czz = loc.z << 4;
|
||||
final Chunk chunk = oldWorld.getChunkAt(loc.x, loc.z);
|
||||
saveEntitiesIn(chunk, region);
|
||||
for (int x = bx & 15; x <= (tx & 15); x++) {
|
||||
for (int z = bz & 15; z <= (tz & 15); z++) {
|
||||
saveBlocks(oldWorld, 256, cxx + x, czz + z, relX, relZ, true);
|
||||
}
|
||||
}, newWorldname, loc2);
|
||||
// restore chunk
|
||||
restoreBlocks(newWorld, relX, relZ);
|
||||
restoreEntities(newWorld, relX, relZ);
|
||||
}
|
||||
}
|
||||
}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SetQueue.IMP.queue.sendChunk(newWorldname, chunks);
|
||||
for (Entry<PlotLoc, PlotBlock[]> entry : allblocks.entrySet()) {
|
||||
PlotLoc loc = entry.getKey();
|
||||
PlotBlock[] blocks = entry.getValue();
|
||||
for (int y = 0; y < blocks.length; y++) {
|
||||
PlotBlock block = blocks[y];
|
||||
if (block != null) {
|
||||
SetQueue.IMP.setBlock(newWorldname, loc.x, y, loc.z, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (SetQueue.IMP.forceChunkSet());
|
||||
restoreBlocks(newWorld, 0, 0);
|
||||
restoreEntities(newWorld, relX, relZ);
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
}, 5);
|
||||
|
@ -162,6 +162,22 @@ public class BukkitUtil extends WorldUtil {
|
||||
return new Location(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ(), temp.getYaw(), temp.getPitch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpawn(Location loc) {
|
||||
World world = getWorld(loc.getWorld());
|
||||
if (world != null) {
|
||||
world.setSpawnLocation(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorld(String worldname) {
|
||||
World world = getWorld(worldname);
|
||||
if (world != null) {
|
||||
world.save();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestBlock(final String world, final int x, final int z) {
|
||||
return getWorld(world).getHighestBlockAt(x, z).getY();
|
||||
|
@ -2,31 +2,40 @@ package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class FastQueue_1_9 extends SlowQueue {
|
||||
|
||||
final Object air;
|
||||
private final SendChunk chunksender;
|
||||
private final RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
||||
private final RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||
@ -41,25 +50,24 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
|
||||
private final RefClass classBlock = getRefClass("{nms}.Block");
|
||||
private final RefClass classIBlockData = getRefClass("{nms}.IBlockData");
|
||||
private HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private RefMethod methodGetHandleChunk;
|
||||
private RefConstructor MapChunk;
|
||||
private RefMethod methodInitLighting;
|
||||
private RefConstructor classBlockPositionConstructor;
|
||||
private RefConstructor classChunkSectionConstructor;
|
||||
private RefMethod methodW;
|
||||
private RefMethod methodAreNeighborsLoaded;
|
||||
private RefField fieldSections;
|
||||
private RefField fieldWorld;
|
||||
private RefMethod methodGetBlocks;
|
||||
private RefMethod methodGetType;
|
||||
private RefMethod methodSetType;
|
||||
private RefMethod methodGetCombinedId;
|
||||
private RefMethod methodGetByCombinedId;
|
||||
final Object air;
|
||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private final RefMethod methodGetHandleChunk;
|
||||
private final RefConstructor MapChunk;
|
||||
private final RefMethod methodInitLighting;
|
||||
private final RefConstructor classBlockPositionConstructor;
|
||||
private final RefConstructor classChunkSectionConstructor;
|
||||
private final RefMethod methodW;
|
||||
private final RefMethod methodAreNeighborsLoaded;
|
||||
private final RefField fieldSections;
|
||||
private final RefField fieldWorld;
|
||||
private final RefMethod methodGetBlocks;
|
||||
private final RefMethod methodGetType;
|
||||
private final RefMethod methodSetType;
|
||||
private final RefMethod methodGetCombinedId;
|
||||
private final RefMethod methodGetByCombinedId;
|
||||
|
||||
|
||||
public FastQueue_1_9() throws NoSuchMethodException, RuntimeException {
|
||||
public FastQueue_1_9() throws RuntimeException {
|
||||
methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||
methodInitLighting = classChunk.getMethod("initLighting");
|
||||
MapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
||||
@ -106,7 +114,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
if (!MainUtil.canSendChunk) {
|
||||
for (final Chunk chunk : chunks) {
|
||||
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||
chunk.unload(true, false);
|
||||
chunk.unload(true, true);
|
||||
chunk.load();
|
||||
}
|
||||
return;
|
||||
@ -143,16 +151,15 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
final Field sf = clazz.getDeclaredField("sections");
|
||||
sf.setAccessible(true);
|
||||
final Field tf = clazz.getDeclaredField("tileEntities");
|
||||
final Field ef = clazz.getDeclaredField("entitySlices");
|
||||
final Field entitySlices = clazz.getDeclaredField("entitySlices");
|
||||
|
||||
final Object[] sections = (Object[]) sf.get(c);
|
||||
final HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
||||
final List<?>[] entities = (List<?>[]) ef.get(c);
|
||||
final Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
||||
|
||||
Method xm = null;
|
||||
Method ym = null;
|
||||
Method zm = null;
|
||||
|
||||
// Trim tiles
|
||||
final Set<Entry<?, ?>> entryset = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
|
||||
final Iterator<Entry<?, ?>> iter = entryset.iterator();
|
||||
@ -228,7 +235,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
int x = MainUtil.x_loc[j][k];
|
||||
int y = MainUtil.y_loc[j][k];
|
||||
int z = MainUtil.z_loc[j][k];
|
||||
int id = (int) n;
|
||||
int id = n;
|
||||
Object iblock = methodGetByCombinedId.call((int) n);
|
||||
setType.call(x, y & 15, z, iblock);
|
||||
continue;
|
||||
@ -292,7 +299,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
if (!chunk.isLoaded()) {
|
||||
chunk.load(false);
|
||||
} else {
|
||||
chunk.unload(true, false);
|
||||
chunk.unload(true, true);
|
||||
chunk.load(false);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ public class GenChunk extends PlotChunk<Chunk> {
|
||||
public short[][] result;
|
||||
public byte[][] result_data;
|
||||
public ChunkData cd;
|
||||
public boolean modified = false;
|
||||
public BiomeGrid grid;
|
||||
|
||||
public GenChunk(Chunk chunk, ChunkWrapper wrap) {
|
||||
@ -42,7 +41,6 @@ public class GenChunk extends PlotChunk<Chunk> {
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, int biome) {
|
||||
modified = true;
|
||||
grid.setBiome(x, z, biomes[biome]);
|
||||
}
|
||||
|
||||
@ -55,14 +53,12 @@ public class GenChunk extends PlotChunk<Chunk> {
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, int id, byte data) {
|
||||
if (result == null) {
|
||||
modified = true;
|
||||
cd.setBlock(x, y, z, id, data);
|
||||
return;
|
||||
}
|
||||
int i = MainUtil.CACHE_I[y][x][z];
|
||||
short[] v = result[i];
|
||||
if (v == null) {
|
||||
modified = true;
|
||||
result[i] = v = new short[4096];
|
||||
}
|
||||
int j = MainUtil.CACHE_J[y][x][z];
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
@ -20,6 +17,9 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public interface IPlotMain {
|
||||
|
||||
/**
|
||||
|
@ -127,8 +127,8 @@ public class PS {
|
||||
private File storageFile;
|
||||
private File FILE = null; // This file
|
||||
private int[] VERSION = null;
|
||||
private int[] LAST_VERSION;
|
||||
private String PLATFORM = null;
|
||||
private String LAST_VERSION;
|
||||
private Database database;
|
||||
private Thread thread;
|
||||
|
||||
@ -278,8 +278,11 @@ public class PS {
|
||||
final URL url = Updater.getUpdate();
|
||||
if (url != null) {
|
||||
update = url;
|
||||
} else if ((LAST_VERSION != null) && !StringMan.join(VERSION, ".").equals(LAST_VERSION)) {
|
||||
log("&aThanks for updating from: " + LAST_VERSION + " to " + StringMan.join(VERSION, "."));
|
||||
} else if (LAST_VERSION == null) {
|
||||
log("&aThanks for installing PlotSquared!");
|
||||
} else if (!PS.get().checkVersion(LAST_VERSION, VERSION)) {
|
||||
log("&aThanks for updating from " + StringMan.join(LAST_VERSION, ".") + " to " + StringMan.join(VERSION, ".") + "!");
|
||||
DBFunc.dbManager.updateTables(LAST_VERSION);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -366,16 +369,22 @@ public class PS {
|
||||
return this.thread == thread;
|
||||
}
|
||||
|
||||
public boolean checkVersion(final int[] version, final int major, final int minor, final int minor2) {
|
||||
return (version[0] > major) || ((version[0] == major) && (version[1] > minor)) || ((version[0] == major) && (version[1] == minor) && (
|
||||
version[2] >= minor2));
|
||||
/**
|
||||
* Check if `version` is >= `version2`
|
||||
* @param version
|
||||
* @param version2
|
||||
* @return true if `version` is >= `version2`
|
||||
*/
|
||||
public boolean checkVersion(final int[] version, int... version2) {
|
||||
return (version[0] > version2[0]) || ((version[0] == version2[0]) && (version[1] > version2[1])) || ((version[0] == version2[0]) && (version[1] == version2[1]) && (
|
||||
version[2] >= version2[2]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last PlotSquared version
|
||||
* @return last version in config or null
|
||||
*/
|
||||
public String getLastVersion() {
|
||||
public int[] getLastVersion() {
|
||||
return LAST_VERSION;
|
||||
}
|
||||
|
||||
@ -914,6 +923,55 @@ public class PS {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public ArrayList<Plot> sortPlotsByTimestamp(final Collection<Plot> plots) {
|
||||
List<Plot> unknown = new ArrayList<>();
|
||||
int hardmax = 256000;
|
||||
int max = 0;
|
||||
int overflowSize = 0;
|
||||
for (final Plot plot : plots) {
|
||||
final int hash = MathMan.getPositiveId(plot.hashCode());
|
||||
if (hash > max) {
|
||||
if (hash >= hardmax) {
|
||||
overflowSize++;
|
||||
} else {
|
||||
max = hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
hardmax = Math.min(hardmax, max);
|
||||
final Plot[] cache = new Plot[hardmax + 1];
|
||||
final List<Plot> overflow = new ArrayList<>(overflowSize);
|
||||
final ArrayList<Plot> extra = new ArrayList<>();
|
||||
for (final Plot plot : plots) {
|
||||
final int hash = MathMan.getPositiveId(plot.hashCode());
|
||||
if (hash < hardmax) {
|
||||
if (hash >= 0) {
|
||||
cache[hash] = plot;
|
||||
} else {
|
||||
extra.add(plot);
|
||||
}
|
||||
} else if ((Math.abs(plot.getId().x) > 15446) || (Math.abs(plot.getId().y) > 15446)) {
|
||||
extra.add(plot);
|
||||
} else {
|
||||
overflow.add(plot);
|
||||
}
|
||||
}
|
||||
final Plot[] overflowArray = overflow.toArray(new Plot[overflow.size()]);
|
||||
sortPlotsByHash(overflowArray);
|
||||
final ArrayList<Plot> result = new ArrayList<>(cache.length + overflowArray.length);
|
||||
for (final Plot plot : cache) {
|
||||
if (plot != null) {
|
||||
result.add(plot);
|
||||
}
|
||||
}
|
||||
Collections.addAll(result, overflowArray);
|
||||
for (final Plot plot : extra) {
|
||||
result.add(plot);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort plots by creation timestamp
|
||||
* @param input
|
||||
@ -921,167 +979,20 @@ public class PS {
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public ArrayList<Plot> sortPlotsByTimestamp(final Collection<Plot> input) {
|
||||
public List<Plot> sortPlotsByModified(final Collection<Plot> input) {
|
||||
List<Plot> list;
|
||||
if (input instanceof ArrayList<?>) {
|
||||
if (input instanceof List) {
|
||||
list = (List<Plot>) input;
|
||||
} else {
|
||||
list = new ArrayList<>(input);
|
||||
}
|
||||
long min = Integer.MAX_VALUE;
|
||||
long max = 0;
|
||||
final int size = list.size();
|
||||
final int limit = Math.min(1048576, size * 2);
|
||||
for (final Plot plot : list) {
|
||||
final long time = plot.getTimestamp();
|
||||
if (time < min) {
|
||||
min = time;
|
||||
Collections.sort(list, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(Plot a, Plot b) {
|
||||
return (int) Math.signum(ExpireManager.IMP.getTimestamp(a.owner) - ExpireManager.IMP.getTimestamp(b.owner));
|
||||
}
|
||||
if (time > max) {
|
||||
max = time;
|
||||
}
|
||||
}
|
||||
final long range = max - min;
|
||||
try {
|
||||
final ArrayList<Plot> overflow = new ArrayList<>();
|
||||
Plot[] plots;
|
||||
if ((range > limit) && (size > 1024)) {
|
||||
plots = new Plot[limit];
|
||||
final int factor = (int) ((range / limit));
|
||||
for (Plot plot : list) {
|
||||
int index = (int) (plot.getTimestamp() - min) / factor;
|
||||
if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
if (index >= plots.length) {
|
||||
overflow.add(plot);
|
||||
continue;
|
||||
}
|
||||
Plot current = plots[index];
|
||||
while (true) {
|
||||
if (current == null) {
|
||||
plots[index] = plot;
|
||||
break;
|
||||
}
|
||||
if (current.getTimestamp() > plot.getTimestamp()) {
|
||||
plots[index] = plot;
|
||||
plot = current;
|
||||
}
|
||||
index++;
|
||||
if (index >= plots.length) {
|
||||
overflow.add(plot);
|
||||
break;
|
||||
}
|
||||
current = plots[index];
|
||||
}
|
||||
}
|
||||
} else if ((range < size) || (size < 1024)) {
|
||||
final ArrayList<Plot> result = new ArrayList<>(list);
|
||||
Collections.sort(result, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(final Plot a, final Plot b) {
|
||||
if (a.getTimestamp() > b.getTimestamp()) {
|
||||
return -1;
|
||||
} else if (b.getTimestamp() > a.getTimestamp()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
} else if (min != 0) {
|
||||
plots = new Plot[(int) range];
|
||||
for (Plot plot : list) {
|
||||
int index = (int) (plot.getTimestamp() - min);
|
||||
if (index >= plots.length) {
|
||||
overflow.add(plot);
|
||||
continue;
|
||||
}
|
||||
Plot current = plots[index];
|
||||
while (true) {
|
||||
if (current == null) {
|
||||
plots[index] = plot;
|
||||
break;
|
||||
}
|
||||
if (current.getTimestamp() > plot.getTimestamp()) {
|
||||
plots[index] = plot;
|
||||
plot = current;
|
||||
}
|
||||
index++;
|
||||
if (index >= plots.length) {
|
||||
overflow.add(plot);
|
||||
break;
|
||||
}
|
||||
current = plots[index];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plots = new Plot[(int) range];
|
||||
for (Plot plot : list) {
|
||||
int index = (int) (plot.getTimestamp());
|
||||
if (index >= plots.length) {
|
||||
overflow.add(plot);
|
||||
continue;
|
||||
}
|
||||
Plot current = plots[index];
|
||||
// Move everything along until a free spot is found
|
||||
while (true) {
|
||||
if (current == null) {
|
||||
plots[index] = plot;
|
||||
break;
|
||||
}
|
||||
if (current.getTimestamp() > plot.getTimestamp()) {
|
||||
plots[index] = plot;
|
||||
plot = current;
|
||||
}
|
||||
index++;
|
||||
if (index >= plots.length) {
|
||||
overflow.add(plot);
|
||||
break;
|
||||
}
|
||||
current = plots[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
final ArrayList<Plot> result = new ArrayList<>(size);
|
||||
if (!overflow.isEmpty()) {
|
||||
Collections.sort(overflow, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(final Plot a, final Plot b) {
|
||||
if (a.getTimestamp() > b.getTimestamp()) {
|
||||
return -1;
|
||||
} else if (b.getTimestamp() > a.getTimestamp()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
for (final Plot plot : overflow) {
|
||||
result.add(plot);
|
||||
}
|
||||
}
|
||||
for (int i = plots.length - 1; i >= 0; i--) {
|
||||
if (plots[i] != null) {
|
||||
result.add(plots[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
final ArrayList<Plot> result = new ArrayList<>(list);
|
||||
Collections.sort(result, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(final Plot a, final Plot b) {
|
||||
if (a.getTimestamp() > b.getTimestamp()) {
|
||||
return -1;
|
||||
} else if (b.getTimestamp() > a.getTimestamp()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1170,6 +1081,8 @@ public class PS {
|
||||
case DISTANCE_FROM_ORIGIN:
|
||||
toReturn.addAll(sortPlotsByHash(map.get(area)));
|
||||
break;
|
||||
case LAST_MODIFIED:
|
||||
toReturn.addAll(sortPlotsByModified(map.get(area)));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -2039,7 +1952,12 @@ public class PS {
|
||||
* Setup the default configuration (settings.yml)
|
||||
*/
|
||||
public void setupConfig() {
|
||||
LAST_VERSION = config.getString("version");
|
||||
String lastVersionString = config.getString("version");
|
||||
if (lastVersionString != null) {
|
||||
String[] split = lastVersionString.split("\\.");
|
||||
LAST_VERSION = new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]) };
|
||||
}
|
||||
|
||||
config.set("version", StringMan.join(VERSION, "."));
|
||||
config.set("platform", PLATFORM);
|
||||
|
||||
@ -2548,6 +2466,6 @@ public class PS {
|
||||
}
|
||||
|
||||
public enum SortType {
|
||||
CREATION_DATE, CREATION_DATE_TIMESTAMP, DISTANCE_FROM_ORIGIN
|
||||
CREATION_DATE, CREATION_DATE_TIMESTAMP, LAST_MODIFIED, DISTANCE_FROM_ORIGIN
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot;
|
||||
import com.intellectualcrafters.json.JSONArray;
|
||||
import com.intellectualcrafters.json.JSONObject;
|
||||
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@ -51,13 +52,15 @@ public class Updater {
|
||||
String name = asset.getString("name");
|
||||
if (downloadURL.equals(name)) {
|
||||
try {
|
||||
String version = release.getString("name");
|
||||
String[] split = release.getString("name").split("\\.");
|
||||
int[] version = new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
|
||||
URL url = new URL(asset.getString("browser_download_url"));
|
||||
if (!PS.get().canUpdate(PS.get().config.getString("version"), version)) {
|
||||
// If current version >= update
|
||||
if (PS.get().checkVersion(PS.get().getVersion(), version)) {
|
||||
PS.debug("&7PlotSquared is already up to date!");
|
||||
return null;
|
||||
}
|
||||
log("&6PlotSquared " + version + " is available:");
|
||||
log("&6PlotSquared " + StringMan.join(split, ".") + " is available:");
|
||||
log("&8 - &3Use: &7/plot update");
|
||||
log("&8 - &3Or: &7" + downloadURL);
|
||||
return url;
|
||||
|
@ -23,7 +23,6 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
@ -40,8 +39,7 @@ public class Continue extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
final Plot plot = plr.getCurrentPlot();
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
@ -53,7 +51,8 @@ public class Continue extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.DONE_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
if (Settings.DONE_COUNTS_TOWARDS_LIMIT && (plr.getAllowedPlots() >= plr.getPlotCount())) {
|
||||
int size = plot.getConnectedPlots().size();
|
||||
if (Settings.DONE_COUNTS_TOWARDS_LIMIT && (plr.getAllowedPlots() < plr.getPlotCount() + size)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.continue");
|
||||
return false;
|
||||
}
|
||||
|
@ -8,15 +8,16 @@ import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.BO3Handler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
@CommandDeclaration(command = "download", aliases = { "dl" }, category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, description = "Download your plot", permission = "plots.download")
|
||||
@CommandDeclaration(usage = "/plot download [schematic|bo3|world]", command = "download", aliases = { "dl" }, category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, description = "Download your plot", permission = "plots.download")
|
||||
public class Download extends SubCommand {
|
||||
|
||||
@Override
|
||||
@ -41,26 +42,63 @@ public class Download extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK);
|
||||
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run(final CompoundTag value) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final URL url = SchematicHandler.manager.upload(value, null, null);
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK_FAILED);
|
||||
plot.removeRunning();
|
||||
return;
|
||||
if (args.length == 0 || (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "sch", "schem", "schematic"))) {
|
||||
plot.addRunning();
|
||||
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run(final CompoundTag value) {
|
||||
plot.removeRunning();
|
||||
SchematicHandler.manager.upload(value, null, null, new RunnableVal<URL>() {
|
||||
@Override
|
||||
public void run(URL url) {
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK_FAILED);
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, url.toString());
|
||||
}
|
||||
MainUtil.sendMessage(plr, url.toString());
|
||||
plot.removeRunning();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "bo3", "bo2", "b03", "b02")) {
|
||||
if (!Permissions.hasPermission(plr, "plots.download.bo3")) {
|
||||
C.NO_PERMISSION.send(plr, "plots.download.bo3");
|
||||
}
|
||||
});
|
||||
plot.addRunning();
|
||||
BO3Handler.upload(plot, null, null, new RunnableVal<URL>() {
|
||||
@Override
|
||||
public void run(URL url) {
|
||||
plot.removeRunning();
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK_FAILED);
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, url.toString());
|
||||
}
|
||||
});
|
||||
} else if (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "mcr", "world", "mca")) {
|
||||
if (!Permissions.hasPermission(plr, "plots.download.world")) {
|
||||
C.NO_PERMISSION.send(plr, "plots.download.world");
|
||||
}
|
||||
MainUtil.sendMessage(plr, "&cNote: The `.mca` files are 512x512");
|
||||
plot.addRunning();
|
||||
WorldUtil.IMP.upload(plot, null, null, new RunnableVal<URL>() {
|
||||
@Override
|
||||
public void run(URL url) {
|
||||
plot.removeRunning();
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK_FAILED);
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, url.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.GENERATING_LINK);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -374,13 +374,13 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
// ex. /p h:2 SomeUsername
|
||||
// > /p h SomeUsername 2
|
||||
String[] temp = label.split(":");
|
||||
label = temp[0];
|
||||
|
||||
String[] tempArgs = new String[args.length + 1];
|
||||
System.arraycopy(args, 0, tempArgs, 0, args.length);
|
||||
tempArgs[tempArgs.length - 1] = temp[1];
|
||||
|
||||
args = tempArgs;
|
||||
if (temp.length == 2) {
|
||||
label = temp[0];
|
||||
String[] tempArgs = new String[args.length + 1];
|
||||
System.arraycopy(args, 0, tempArgs, 0, args.length);
|
||||
tempArgs[tempArgs.length - 1] = temp[1];
|
||||
args = tempArgs;
|
||||
}
|
||||
}
|
||||
cmd = getInstance().commands.get(label.toLowerCase());
|
||||
} else {
|
||||
|
@ -64,19 +64,21 @@ public class Save extends SubCommand {
|
||||
final String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", "");
|
||||
final String file = time + "_" + world + "_" + id.x + "_" + id.y + "_" + size + "_" + name;
|
||||
final UUID uuid = plr.getUUID();
|
||||
|
||||
final URL url = SchematicHandler.manager.upload(value, uuid, file);
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, C.SAVE_FAILED);
|
||||
plot.removeRunning();
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SAVE_SUCCESS);
|
||||
final List<String> schematics = (List<String>) plr.getMeta("plot_schematics");
|
||||
if (schematics != null) {
|
||||
schematics.add(file);
|
||||
}
|
||||
plot.removeRunning();
|
||||
SchematicHandler.manager.upload(value, uuid, file, new RunnableVal<URL>() {
|
||||
@Override
|
||||
public void run(URL url) {
|
||||
plot.removeRunning();
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(plr, C.SAVE_FAILED);
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SAVE_SUCCESS);
|
||||
final List<String> schematics = (List<String>) plr.getMeta("plot_schematics");
|
||||
if (schematics != null) {
|
||||
schematics.add(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -30,8 +30,12 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "visit",
|
||||
@ -82,8 +86,6 @@ public class Visit extends SubCommand {
|
||||
}
|
||||
if (user != null) {
|
||||
unsorted = PS.get().getBasePlots(user);
|
||||
} else if (PS.get().getPlotAreaByString(args[0]) != null) {
|
||||
unsorted = PS.get().getPlotAreaByString(args[0]).getPlots();
|
||||
} else {
|
||||
final Plot plot = MainUtil.getPlotFromString(player, args[0], true);
|
||||
if (plot != null) {
|
||||
|
@ -23,18 +23,18 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "plugin", permission = "plots.use", description = "Show plugin information", aliases = { "version" }, category = CommandCategory.INFO)
|
||||
@CommandDeclaration(command = "plugin", permission = "plots.use", description = "Show plugin information", aliases = "version",
|
||||
category = CommandCategory.INFO)
|
||||
public class plugin extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().IMP.getPluginVersion(), ".")));
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", PS.get().IMP.getPluginVersion()));
|
||||
MainUtil.sendMessage(plr, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92");
|
||||
MainUtil.sendMessage(plr, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");
|
||||
MainUtil.sendMessage(plr, "$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? StringMan.join(PS.get().IMP.getPluginVersion(), ".") : PS.get().update));
|
||||
MainUtil.sendMessage(plr, "$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? PS.get().IMP.getPluginVersion() : PS.get().update));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -353,4 +353,6 @@ public interface AbstractDB {
|
||||
void close();
|
||||
|
||||
void replaceWorld(String oldWorld, String newWorld, PlotId min, PlotId max);
|
||||
|
||||
void updateTables(int[] oldVersion);
|
||||
}
|
||||
|
@ -173,18 +173,17 @@ public class SQLManager implements AbstractDB {
|
||||
CREATE_TIERS = "INSERT INTO `" + prefix + "plot_%tier%` (`plot_plot_id`, `user_uuid`) values ";
|
||||
CREATE_PLOT = "INSERT INTO `" + prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`, `timestamp`) VALUES(?, ?, ?, ?, ?)";
|
||||
CREATE_CLUSTER = "INSERT INTO `" + prefix + "cluster`(`pos1_x`, `pos1_z`, `pos2_x`, `pos2_z`, `owner`, `world`) VALUES(?, ?, ?, ?, ?, ?)";
|
||||
updateTables();
|
||||
createTables();
|
||||
}
|
||||
|
||||
public synchronized Queue<Runnable> getGlobalTasks() {
|
||||
return globalTasks;
|
||||
}
|
||||
|
||||
|
||||
public synchronized Queue<Runnable> getNotifyTasks() {
|
||||
return notifyTasks;
|
||||
}
|
||||
|
||||
|
||||
public synchronized void addPlotTask(Plot plot, UniqueStatement task) {
|
||||
if (plot == null) {
|
||||
plot = new Plot(null, new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE));
|
||||
@ -274,17 +273,17 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
tasks.add(task);
|
||||
}
|
||||
|
||||
|
||||
public synchronized void addGlobalTask(final Runnable task) {
|
||||
getGlobalTasks().add(task);
|
||||
}
|
||||
|
||||
|
||||
public synchronized void addNotifyTask(final Runnable task) {
|
||||
if (task != null) {
|
||||
getNotifyTasks().add(task);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean sendBatch() {
|
||||
try {
|
||||
if (!getGlobalTasks().isEmpty()) {
|
||||
@ -426,11 +425,11 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Plot owner
|
||||
*
|
||||
@ -454,7 +453,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void createPlotsAndData(final ArrayList<Plot> myList, final Runnable whenDone) {
|
||||
addGlobalTask(new Runnable() {
|
||||
@ -549,7 +548,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a plot
|
||||
*
|
||||
@ -592,7 +591,7 @@ public class SQLManager implements AbstractDB {
|
||||
};
|
||||
setBulk(myList, mod, whenDone);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a plot
|
||||
*
|
||||
@ -655,7 +654,7 @@ public class SQLManager implements AbstractDB {
|
||||
};
|
||||
setBulk(myList, mod, whenDone);
|
||||
}
|
||||
|
||||
|
||||
public <T> void setBulk(final ArrayList<T> objList, final StmtMod<T> mod, final Runnable whenDone) {
|
||||
final int size = objList.size();
|
||||
if (size == 0) {
|
||||
@ -774,7 +773,7 @@ public class SQLManager implements AbstractDB {
|
||||
whenDone.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void createSettings(final ArrayList<SettingsPair> myList, final Runnable whenDone) {
|
||||
final StmtMod<SettingsPair> mod = new StmtMod<SettingsPair>() {
|
||||
@Override
|
||||
@ -885,7 +884,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void createEmptySettings(final ArrayList<Integer> myList, final Runnable whenDone) {
|
||||
final StmtMod<Integer> mod = new StmtMod<Integer>() {
|
||||
@Override
|
||||
@ -939,7 +938,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a plot
|
||||
*
|
||||
@ -963,7 +962,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void commit() {
|
||||
try {
|
||||
if (CLOSED) {
|
||||
@ -977,7 +976,7 @@ public class SQLManager implements AbstractDB {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void createPlotAndSettings(final Plot plot, final Runnable whenDone) {
|
||||
addPlotTask(plot, new UniqueStatement("createPlotAndSettings_" + plot.hashCode()) {
|
||||
@ -1022,7 +1021,7 @@ public class SQLManager implements AbstractDB {
|
||||
});
|
||||
addNotifyTask(whenDone);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create tables
|
||||
*
|
||||
@ -1100,8 +1099,7 @@ public class SQLManager implements AbstractDB {
|
||||
+ " `flags` VARCHAR(512) DEFAULT NULL,"
|
||||
+ " `merged` INT(11) DEFAULT NULL,"
|
||||
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||
+ " PRIMARY KEY (`plot_plot_id`),"
|
||||
+ " UNIQUE KEY `unique_alias` (`alias`)"
|
||||
+ " PRIMARY KEY (`plot_plot_id`)"
|
||||
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `"
|
||||
+ prefix
|
||||
@ -1243,7 +1241,7 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.clearBatch();
|
||||
stmt.close();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteSettings(final Plot plot) {
|
||||
addPlotTask(plot, new UniqueStatement("delete_plot_settings") {
|
||||
@ -1258,7 +1256,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteHelpers(final Plot plot) {
|
||||
if (plot.getTrusted().isEmpty()) {
|
||||
@ -1276,7 +1274,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteTrusted(final Plot plot) {
|
||||
if (plot.getMembers().isEmpty()) {
|
||||
@ -1294,7 +1292,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteDenied(final Plot plot) {
|
||||
if (plot.getDenied().isEmpty()) {
|
||||
@ -1312,7 +1310,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteComments(final Plot plot) {
|
||||
addPlotTask(plot, new UniqueStatement("delete_plot_comments") {
|
||||
@ -1328,7 +1326,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteRatings(final Plot plot) {
|
||||
if (Settings.CACHE_RATINGS && plot.getSettings().getRatings().isEmpty()) {
|
||||
@ -1393,7 +1391,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getClusterId(final PlotCluster cluster) {
|
||||
if (cluster.temp > 0) {
|
||||
@ -1469,11 +1467,14 @@ public class SQLManager implements AbstractDB {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public void updateTables() {
|
||||
if (PS.get().getVersion().equals(PS.get().getLastVersion()) || (PS.get().getLastVersion() == null)) {
|
||||
return;
|
||||
}
|
||||
public void updateTables(int[] oldVersion) {
|
||||
try {
|
||||
if (MYSQL && !PS.get().checkVersion(oldVersion, 3, 3, 2)) {
|
||||
try (Statement stmt = connection.createStatement()) {
|
||||
stmt.executeUpdate("ALTER TABLE `" + prefix + "plots` DROP INDEX `unique_alias`");
|
||||
}
|
||||
catch (SQLException ignore) {}
|
||||
}
|
||||
final DatabaseMetaData data = connection.getMetaData();
|
||||
ResultSet rs = data.getColumns(null, null, prefix + "plot_comments", "plot_plot_id");
|
||||
if (rs.next()) {
|
||||
@ -1553,23 +1554,23 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void deleteRows(final ArrayList<Integer> rowIds, final String table, final String column) {
|
||||
setBulk(rowIds, new StmtMod<Integer>() {
|
||||
|
||||
@Override
|
||||
public String getCreateMySQL(int size) {
|
||||
return getCreateMySQL(1, "DELETE FROM `" + table + "` WHERE `" + prefix + column + "` IN ", size);
|
||||
return getCreateMySQL(1, "DELETE FROM `" + table + "` WHERE `" + column + "` IN ", size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreateSQLite(int size) {
|
||||
return getCreateMySQL(1, "DELETE FROM `" + table + "` WHERE `" + prefix + column + "` IN ", size);
|
||||
return getCreateMySQL(1, "DELETE FROM `" + table + "` WHERE `" + column + "` IN ", size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreateSQL() {
|
||||
return "DELETE FROM `" + table + "` WHERE `" + prefix + column + "` = ?";
|
||||
return "DELETE FROM `" + table + "` WHERE `" + column + "` = ?";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1662,7 +1663,7 @@ public class SQLManager implements AbstractDB {
|
||||
if (Settings.AUTO_PURGE) {
|
||||
toDelete.add(id);
|
||||
} else {
|
||||
PS.debug("&cPLOT " + id + " in `plot` is a duplicate. Delete this plot or set `auto-purge: true` in the settings.yml.");
|
||||
PS.debug("&cPLOT " + id + " in `" + prefix + "plot` is a duplicate. Delete this plot or set `auto-purge: true` in the settings.yml.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -1673,7 +1674,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
plots.put(id, p);
|
||||
}
|
||||
deleteRows(toDelete, "plot", "id");
|
||||
deleteRows(toDelete, prefix + "plot", "id");
|
||||
}
|
||||
if (Settings.CACHE_RATINGS) {
|
||||
try (ResultSet r = stmt.executeQuery("SELECT `plot_plot_id`, `player`, `rating` FROM `" + prefix + "plot_rating`")) {
|
||||
@ -1695,7 +1696,7 @@ public class SQLManager implements AbstractDB {
|
||||
PS.debug("&cENTRY " + id + " in `plot_rating` does not exist. Create this plot or set `auto-purge: true` in the settings.yml.");
|
||||
}
|
||||
}
|
||||
deleteRows(toDelete, "plot_rating", "plot_plot_id");
|
||||
deleteRows(toDelete, prefix + "plot_rating", "plot_plot_id");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1721,7 +1722,7 @@ public class SQLManager implements AbstractDB {
|
||||
PS.debug("&cENTRY " + id + " in `plot_helpers` does not exist. Create this plot or set `auto-purge: true` in the settings.yml.");
|
||||
}
|
||||
}
|
||||
deleteRows(toDelete, "plot_helpers", "plot_plot_id");
|
||||
deleteRows(toDelete, prefix + "plot_helpers", "plot_plot_id");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1746,7 +1747,7 @@ public class SQLManager implements AbstractDB {
|
||||
PS.debug("&cENTRY " + id + " in `plot_trusted` does not exist. Create this plot or set `auto-purge: true` in the settings.yml.");
|
||||
}
|
||||
}
|
||||
deleteRows(toDelete, "plot_trusted", "plot_plot_id");
|
||||
deleteRows(toDelete, prefix + "plot_trusted", "plot_plot_id");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1771,7 +1772,7 @@ public class SQLManager implements AbstractDB {
|
||||
PS.debug("&cENTRY " + id + " in `plot_denied` does not exist. Create this plot or set `auto-purge: true` in the settings.yml.");
|
||||
}
|
||||
}
|
||||
deleteRows(toDelete, "plot_denied", "plot_plot_id");
|
||||
deleteRows(toDelete, prefix + "plot_denied", "plot_plot_id");
|
||||
}
|
||||
|
||||
try (ResultSet r = stmt.executeQuery("SELECT * FROM `" + prefix + "plot_settings`")) {
|
||||
@ -1850,7 +1851,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
}
|
||||
stmt.close();
|
||||
deleteRows(toDelete, "plot_settings", "plot_plot_id");
|
||||
deleteRows(toDelete, prefix + "plot_settings", "plot_plot_id");
|
||||
}
|
||||
if (!plots.entrySet().isEmpty()) {
|
||||
createEmptySettings(new ArrayList<>(plots.keySet()), null);
|
||||
@ -1891,7 +1892,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void swapPlots(final Plot p1, final Plot p2) {
|
||||
final int id1 = getId(p1);
|
||||
@ -1925,7 +1926,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void movePlot(final Plot original, final Plot newPlot) {
|
||||
addPlotTask(original, new UniqueStatement("movePlot") {
|
||||
@ -1944,7 +1945,7 @@ public class SQLManager implements AbstractDB {
|
||||
});
|
||||
addPlotTask(newPlot, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setFlags(final Plot plot, final Collection<Flag> flags) {
|
||||
final String flag_string = FlagManager.toString(flags);
|
||||
@ -1961,7 +1962,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAlias(final Plot plot, final String alias) {
|
||||
addPlotTask(plot, new UniqueStatement("setAlias") {
|
||||
@ -1977,7 +1978,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Purge all plots with the following database IDs
|
||||
*/
|
||||
@ -2025,7 +2026,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void purge(final PlotArea area, final Set<PlotId> plots) {
|
||||
addGlobalTask(new Runnable() {
|
||||
@ -2058,7 +2059,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPosition(final Plot plot, final String position) {
|
||||
addPlotTask(plot, new UniqueStatement("setPosition") {
|
||||
@ -2074,7 +2075,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeComment(final Plot plot, final PlotComment comment) {
|
||||
addPlotTask(plot, new UniqueStatement("removeComment") {
|
||||
@ -2102,7 +2103,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clearInbox(final Plot plot, final String inbox) {
|
||||
addPlotTask(plot, new UniqueStatement("clearInbox") {
|
||||
@ -2126,7 +2127,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getComments(final Plot plot, final String inbox, final RunnableVal<List<PlotComment>> whenDone) {
|
||||
addPlotTask(plot, new UniqueStatement("getComments_" + plot) {
|
||||
@ -2177,7 +2178,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setComment(final Plot plot, final PlotComment comment) {
|
||||
addPlotTask(plot, new UniqueStatement("setComment") {
|
||||
@ -2197,7 +2198,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeTrusted(final Plot plot, final UUID uuid) {
|
||||
addPlotTask(plot, new UniqueStatement("removeTrusted") {
|
||||
@ -2213,7 +2214,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeMember(final Plot plot, final UUID uuid) {
|
||||
addPlotTask(plot, new UniqueStatement("removeMember") {
|
||||
@ -2229,7 +2230,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setTrusted(final Plot plot, final UUID uuid) {
|
||||
addPlotTask(plot, new UniqueStatement("setTrusted") {
|
||||
@ -2245,7 +2246,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setMember(final Plot plot, final UUID uuid) {
|
||||
addPlotTask(plot, new UniqueStatement("setMember") {
|
||||
@ -2261,7 +2262,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeDenied(final Plot plot, final UUID uuid) {
|
||||
addPlotTask(plot, new UniqueStatement("removeDenied") {
|
||||
@ -2277,7 +2278,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setDenied(final Plot plot, final UUID uuid) {
|
||||
addPlotTask(plot, new UniqueStatement("setDenied") {
|
||||
@ -2293,7 +2294,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HashMap<UUID, Integer> getRatings(final Plot plot) {
|
||||
final HashMap<UUID, Integer> map = new HashMap<>();
|
||||
@ -2313,7 +2314,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setRating(final Plot plot, final UUID rater, final int value) {
|
||||
addPlotTask(plot, new UniqueStatement("setRating") {
|
||||
@ -2330,7 +2331,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(final PlotCluster cluster) {
|
||||
final int id = getClusterId(cluster);
|
||||
@ -2666,7 +2667,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setClusterName(final PlotCluster cluster, final String name) {
|
||||
addClusterTask(cluster, new UniqueStatement("setClusterName") {
|
||||
@ -2683,7 +2684,7 @@ public class SQLManager implements AbstractDB {
|
||||
});
|
||||
cluster.settings.setAlias(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeHelper(final PlotCluster cluster, final UUID uuid) {
|
||||
addClusterTask(cluster, new UniqueStatement("removeHelper") {
|
||||
@ -2699,7 +2700,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setHelper(final PlotCluster cluster, final UUID uuid) {
|
||||
addClusterTask(cluster, new UniqueStatement("setHelper") {
|
||||
@ -2715,7 +2716,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void createCluster(final PlotCluster cluster) {
|
||||
addClusterTask(cluster, new UniqueStatement("createCluster_" + cluster.hashCode()) {
|
||||
@ -2761,7 +2762,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void resizeCluster(final PlotCluster current, PlotId min, PlotId max) {
|
||||
final PlotId pos1 = new PlotId(current.getP1().x, current.getP1().y);
|
||||
@ -2785,7 +2786,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPosition(final PlotCluster cluster, final String position) {
|
||||
addClusterTask(cluster, new UniqueStatement("setPosition") {
|
||||
@ -2801,7 +2802,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeInvited(final PlotCluster cluster, final UUID uuid) {
|
||||
addClusterTask(cluster, new UniqueStatement("removeInvited") {
|
||||
@ -2817,7 +2818,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setInvited(final PlotCluster cluster, final UUID uuid) {
|
||||
addClusterTask(cluster, new UniqueStatement("setInvited") {
|
||||
@ -2833,14 +2834,14 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean deleteTables() {
|
||||
try {
|
||||
try (Statement stmt = connection.createStatement();
|
||||
PreparedStatement statement = connection.prepareStatement("DROP TABLE `" + prefix + "plot`")) {
|
||||
close();
|
||||
CLOSED = false;
|
||||
SQLManager.this.connection = database.forceConnection();
|
||||
final Statement stmt = connection.createStatement();
|
||||
stmt.addBatch("DROP TABLE `" + prefix + "cluster_invited`");
|
||||
stmt.addBatch("DROP TABLE `" + prefix + "cluster_helpers`");
|
||||
stmt.addBatch("DROP TABLE `" + prefix + "cluster`");
|
||||
@ -2852,9 +2853,6 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.addBatch("DROP TABLE `" + prefix + "plot_denied`");
|
||||
stmt.executeBatch();
|
||||
stmt.clearBatch();
|
||||
stmt.close();
|
||||
|
||||
final PreparedStatement statement = connection.prepareStatement("DROP TABLE `" + prefix + "plot`");
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
@ -2862,7 +2860,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void validateAllPlots(final Set<Plot> toValidate) {
|
||||
try {
|
||||
@ -2990,7 +2988,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
commit();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void replaceWorld(final String oldWorld, final String newWorld, final PlotId min, final PlotId max) {
|
||||
addGlobalTask(new Runnable() {
|
||||
@ -3001,7 +2999,6 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.setString(1, newWorld);
|
||||
stmt.setString(2, oldWorld);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -3009,14 +3006,12 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.setString(1, newWorld);
|
||||
stmt.setString(2, oldWorld);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try (PreparedStatement stmt = connection.prepareStatement("UPDATE `"
|
||||
+ prefix
|
||||
+ "plot` SET `world` = ? WHERE `world` = ? AND `plot_id_x` BETWEEN ? AND ? AND `plot_id_z` BETWEEN ? AND ?")) {
|
||||
+ prefix + "plot` SET `world` = ? WHERE `world` = ? AND `plot_id_x` BETWEEN ? AND ? AND `plot_id_z` BETWEEN ? AND ?")) {
|
||||
stmt.setString(1, newWorld);
|
||||
stmt.setString(2, oldWorld);
|
||||
stmt.setInt(3, min.x);
|
||||
@ -3024,7 +3019,6 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.setInt(5, min.y);
|
||||
stmt.setInt(6, max.y);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -3038,7 +3032,6 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.setInt(5, min.x);
|
||||
stmt.setInt(6, min.y);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -3071,14 +3064,13 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.executeUpdate(
|
||||
"UPDATE `" + prefix + "plot_trusted` SET `user_uuid` = '" + now.toString() + "' WHERE `user_uuid` = '" + old.toString()
|
||||
+ "'");
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
try {
|
||||
|
@ -97,9 +97,6 @@ public class AbstractFlag {
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
package com.intellectualcrafters.plot.flag;
|
||||
|
||||
public class BooleanFlag extends Flag<Boolean> {
|
||||
|
||||
public BooleanFlag(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
@ -25,10 +25,11 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class Flag implements Cloneable {
|
||||
public class Flag<T> implements Cloneable {
|
||||
private AbstractFlag key;
|
||||
private Object value;
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Flag object used to store basic information for a Plot. Flags are a key/value pair. For a flag to be usable by a
|
||||
* player, you need to register it with PlotSquared.
|
||||
@ -59,6 +60,10 @@ public class Flag implements Cloneable {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Flag(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AbstractFlag used in creating the flag
|
||||
@ -145,4 +150,8 @@ public class Flag implements Cloneable {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,19 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import java.io.File;
|
||||
|
||||
public class BO3 {
|
||||
private final ChunkLoc chunk;
|
||||
private final String world;
|
||||
private final StringBuilder blocks;
|
||||
private final StringBuilder children;
|
||||
private final String name;
|
||||
|
||||
public BO3(final String name, final ChunkLoc loc) {
|
||||
public BO3(final String name, final String world, final ChunkLoc loc) {
|
||||
this.world = world;
|
||||
this.name = name;
|
||||
chunk = loc;
|
||||
blocks = new StringBuilder();
|
||||
@ -21,6 +28,10 @@ public class BO3 {
|
||||
public ChunkLoc getLoc() {
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public String getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
@ -42,4 +53,12 @@ public class BO3 {
|
||||
public String getChildren() {
|
||||
return children.toString();
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.BO3_SAVE_PATH + File.separator + getWorld() + File.separator + getFilename());
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return name + (((chunk.x == 0) && (chunk.z == 0)) ? "" : ("_" + chunk.x + "_" + chunk.z)) + ".bo3";
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class BlockLoc {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
return x == 0 && y == 0 && z == 0;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
@ -47,7 +47,11 @@ public class BlockLoc {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (x == 0 && y == 0 && z == 0) {
|
||||
return "";
|
||||
}
|
||||
return x + "," + y + "," + z + "," + yaw + "," + pitch;
|
||||
|
||||
}
|
||||
|
||||
public static BlockLoc fromString(final String string) {
|
||||
|
@ -564,43 +564,42 @@ public class Plot {
|
||||
* @return true if merged in that direction
|
||||
*/
|
||||
public boolean getMerged(final int direction) {
|
||||
if (isMerged()) {
|
||||
switch (direction) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
return this.getSettings().getMerged(direction);
|
||||
case 7:
|
||||
int i = direction - 4;
|
||||
int i2 = 0;
|
||||
if (this.getSettings().getMerged(i2)) {
|
||||
if (this.getSettings().getMerged(i)) {
|
||||
if (this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2)) {
|
||||
if (this.area.getPlotAbs(this.id.getRelative(i2)).getMerged(i)) {
|
||||
return true;
|
||||
}
|
||||
if (settings == null) {
|
||||
return false;
|
||||
}
|
||||
switch (direction) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
return this.getSettings().getMerged(direction);
|
||||
case 7:
|
||||
int i = direction - 4;
|
||||
int i2 = 0;
|
||||
if (this.getSettings().getMerged(i2)) {
|
||||
if (this.getSettings().getMerged(i)) {
|
||||
if (this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2)) {
|
||||
if (this.area.getPlotAbs(this.id.getRelative(i2)).getMerged(i)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
i = direction - 4;
|
||||
i2 = direction - 3;
|
||||
return this.getSettings().getMerged(i2)
|
||||
&& this.getSettings().getMerged(i)
|
||||
&& this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2)
|
||||
&& this.area.getPlotAbs(this.id.getRelative(i2)).getMerged(i);
|
||||
}
|
||||
return false;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
i = direction - 4;
|
||||
i2 = direction - 3;
|
||||
return this.getSettings().getMerged(i2)
|
||||
&& this.getSettings().getMerged(i)
|
||||
&& this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2)
|
||||
&& this.area.getPlotAbs(this.id.getRelative(i2)).getMerged(i);
|
||||
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the denied users
|
||||
* @return
|
||||
@ -1129,13 +1128,13 @@ public class Plot {
|
||||
* @param loc
|
||||
*/
|
||||
public void setHome(final BlockLoc loc) {
|
||||
final BlockLoc pos = this.getSettings().getPosition();
|
||||
if (pos.equals(new BlockLoc(0, 0, 0)) && loc == null || pos.equals(loc)) {
|
||||
final Plot plot = this.getBasePlot(false);
|
||||
final BlockLoc pos = plot.getSettings().getPosition();
|
||||
if (new BlockLoc(0, 0, 0).equals(loc)) {
|
||||
return;
|
||||
}
|
||||
final Plot plot = this.getBasePlot(false);
|
||||
plot.getSettings().setPosition(loc);
|
||||
DBFunc.setPosition(plot, this.getSettings().getPosition().toString());
|
||||
DBFunc.setPosition(plot, plot.getSettings().getPosition().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1761,27 +1760,40 @@ public class Plot {
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload the plot as a schematic to the configured web interface
|
||||
* Upload the plot as a schematic to the configured web interface<br>
|
||||
* @param whenDone value will be null if uploading fails
|
||||
*/
|
||||
public void upload(final RunnableVal<URL> whenDone) {
|
||||
SchematicHandler.manager.getCompoundTag(this, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run(final CompoundTag value) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final URL url = SchematicHandler.manager.upload(value, null, null);
|
||||
if (whenDone != null) {
|
||||
whenDone.value = url;
|
||||
}
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
});
|
||||
SchematicHandler.manager.upload(value, null, null, whenDone);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload this plot as a world file<br>
|
||||
* - The mca files are each 512x512, so depending on the plot size it may also download adjacent plots<br>
|
||||
* - Works best when (plot width + road width) % 512 == 0<br>
|
||||
* @see com.intellectualcrafters.plot.util.WorldUtil
|
||||
* @param whenDone
|
||||
*/
|
||||
public void uploadWorld(RunnableVal<URL> whenDone) {
|
||||
WorldUtil.IMP.upload(this, null, null, whenDone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload this plot as a BO3<br>
|
||||
* - May not work on non default generator<br>
|
||||
* - BO3 includes flags/ignores plot main/floor block<br>
|
||||
* @see com.intellectualcrafters.plot.util.BO3Handler
|
||||
* @param whenDone
|
||||
*/
|
||||
public void uploadBO3(RunnableVal<URL> whenDone) {
|
||||
BO3Handler.upload(this, null, null, whenDone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
@ -2308,9 +2320,6 @@ public class Plot {
|
||||
connected_cache.add(current);
|
||||
queuecache.remove(current);
|
||||
merged = current.getMerged();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
|
||||
}
|
||||
if (merged[0]) {
|
||||
tmp = current.area.getPlotAbs(current.id.getRelative(0));
|
||||
if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
@ -2780,7 +2789,7 @@ public class Plot {
|
||||
// copy data
|
||||
for (final Plot plot : plots) {
|
||||
final Plot other = plot.getRelative(offset.x, offset.y);
|
||||
other.create(other.owner, false);
|
||||
other.create(plot.owner, false);
|
||||
if (!plot.getFlags().isEmpty()) {
|
||||
other.getSettings().flags = plot.getFlags();
|
||||
DBFunc.setFlags(other, plot.getFlags().values());
|
||||
@ -2790,19 +2799,19 @@ public class Plot {
|
||||
}
|
||||
if ((plot.members != null) && !plot.members.isEmpty()) {
|
||||
other.members = plot.members;
|
||||
for (final UUID member : other.members) {
|
||||
for (final UUID member : plot.members) {
|
||||
DBFunc.setMember(other, member);
|
||||
}
|
||||
}
|
||||
if ((plot.trusted != null) && !plot.trusted.isEmpty()) {
|
||||
other.trusted = plot.trusted;
|
||||
for (final UUID trusted : other.trusted) {
|
||||
for (final UUID trusted : plot.trusted) {
|
||||
DBFunc.setTrusted(other, trusted);
|
||||
}
|
||||
}
|
||||
if ((plot.denied != null) && !plot.denied.isEmpty()) {
|
||||
other.denied = plot.denied;
|
||||
for (final UUID denied : other.denied) {
|
||||
for (final UUID denied : plot.denied) {
|
||||
DBFunc.setDenied(other, denied);
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,12 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
*/
|
||||
public class PlotBlock {
|
||||
|
||||
public static PlotBlock EVERYTHING = new PlotBlock((short) 0, (byte) 0);
|
||||
|
||||
public final static PlotBlock EVERYTHING = new PlotBlock((short) 0, (byte) 0);
|
||||
|
||||
public final short id;
|
||||
public final byte data;
|
||||
|
@ -17,7 +17,12 @@ public class PlotLoc {
|
||||
result = (prime * result) + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + "," + z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
|
@ -12,8 +12,13 @@ import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
@ -22,17 +27,29 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class BO3Handler {
|
||||
|
||||
/**
|
||||
* @see #saveBO3(PlotPlayer, Plot)
|
||||
* @see #saveBO3(PlotPlayer, Plot, RunnableVal)
|
||||
* @param plot
|
||||
* @return if successfully exported
|
||||
*/
|
||||
public static boolean saveBO3(final Plot plot) {
|
||||
return saveBO3(null, plot);
|
||||
}
|
||||
|
||||
public static boolean saveBO3(final PlotPlayer player, final Plot plot) {
|
||||
return saveBO3(player, plot, new RunnableVal<BO3>() {
|
||||
@Override
|
||||
public void run(BO3 bo3) {
|
||||
save(plot, bo3);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean contains(final PlotBlock[] blocks, final PlotBlock block) {
|
||||
for (final PlotBlock item : blocks) {
|
||||
@ -50,7 +67,10 @@ public class BO3Handler {
|
||||
* @param plot
|
||||
* @return
|
||||
*/
|
||||
public static boolean saveBO3(final PlotPlayer plr, final Plot plot) {
|
||||
public static boolean saveBO3(final PlotPlayer plr, final Plot plot, RunnableVal<BO3> saveTask) {
|
||||
if (saveTask == null) {
|
||||
throw new IllegalArgumentException("Save task cannot be null!");
|
||||
}
|
||||
final PlotArea plotworld = plot.getArea();
|
||||
if (!(plotworld instanceof ClassicPlotWorld) || (plotworld.TYPE != 0)) {
|
||||
MainUtil.sendMessage(plr, "BO3 exporting only supports type 0 classic generation.");
|
||||
@ -83,8 +103,8 @@ public class BO3Handler {
|
||||
|
||||
boolean content = false;
|
||||
for (RegionWrapper region : regions) {
|
||||
Location pos1 = new Location(plot.getArea().worldname, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plot.getArea().worldname, region.maxX, region.maxY, region.maxZ);
|
||||
Location pos1 = new Location(plotworld.worldname, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plotworld.worldname, region.maxX, region.maxY, region.maxZ);
|
||||
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||
final int X = ((x + 7) - cx) >> 4;
|
||||
final int xx = (x - cx) % 16;
|
||||
@ -97,7 +117,7 @@ public class BO3Handler {
|
||||
final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z));
|
||||
if (!contains(cpw.MAIN_BLOCK, block)) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, loc);
|
||||
bo3 = new BO3(alias, plotworld.worldname, loc);
|
||||
map.put(loc, bo3);
|
||||
content = true;
|
||||
}
|
||||
@ -107,7 +127,7 @@ public class BO3Handler {
|
||||
final PlotBlock floor = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, height, z));
|
||||
if (!contains(cpw.TOP_BLOCK, floor)) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, loc);
|
||||
bo3 = new BO3(alias, plotworld.worldname, loc);
|
||||
map.put(loc, bo3);
|
||||
content = true;
|
||||
}
|
||||
@ -117,7 +137,7 @@ public class BO3Handler {
|
||||
final PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z));
|
||||
if (block.id != 0) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, loc);
|
||||
bo3 = new BO3(alias, plotworld.worldname, loc);
|
||||
map.put(loc, bo3);
|
||||
content = true;
|
||||
}
|
||||
@ -164,14 +184,78 @@ public class BO3Handler {
|
||||
}
|
||||
|
||||
for (final Entry<ChunkLoc, BO3> entry : map.entrySet()) {
|
||||
save(plot, entry.getValue());
|
||||
saveTask.run(entry.getValue());
|
||||
}
|
||||
|
||||
MainUtil.sendMessage(plr, "BO3 exporting was successful!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void upload(final Plot plot, final UUID uuid, final String file, final RunnableVal<URL> whenDone) {
|
||||
if (plot == null) {
|
||||
throw new IllegalArgumentException("Arguments may not be null!");
|
||||
}
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try (final ZipOutputStream zos = new ZipOutputStream(baos)) {
|
||||
saveBO3(null, plot, new RunnableVal<BO3>() {
|
||||
@Override
|
||||
public void run(BO3 bo3) {
|
||||
try {
|
||||
final ZipEntry ze = new ZipEntry(bo3.getFilename());
|
||||
zos.putNextEntry(ze);
|
||||
write(zos, plot, bo3);
|
||||
zos.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
whenDone.run();
|
||||
return;
|
||||
}
|
||||
MainUtil.upload(uuid, file, "zip", new RunnableVal<OutputStream>() {
|
||||
@Override
|
||||
public void run(OutputStream output) {
|
||||
try {
|
||||
output.write(baos.toByteArray());
|
||||
baos.flush();
|
||||
baos.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, whenDone);
|
||||
}
|
||||
|
||||
public static void write(OutputStream stream, final Plot plot, BO3 bo3) throws IOException {
|
||||
File base = getBaseFile(bo3.getWorld());
|
||||
final List<String> lines = Files.readAllLines(base.toPath(), StandardCharsets.UTF_8);
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
final String line = lines.get(i).trim();
|
||||
final String result = StringMan.replaceAll(line, "%owner%", MainUtil.getName(plot.owner), "%alias%", plot.toString(), "%blocks%", bo3.getBlocks(), "%branches%", bo3.getChildren(),
|
||||
"%flags%", StringMan.join(FlagManager.getPlotFlags(plot).values(), ","));
|
||||
if (!StringMan.isEqual(result, line)) {
|
||||
lines.set(i, result);
|
||||
}
|
||||
}
|
||||
stream.write(StringMan.join(lines, System.getProperty("line.separator")).getBytes());
|
||||
}
|
||||
|
||||
public static boolean save(final Plot plot, final BO3 bo3) {
|
||||
try {
|
||||
File bo3File = bo3.getFile();
|
||||
bo3File.createNewFile();
|
||||
try (FileOutputStream fos = new FileOutputStream(bo3File)) {
|
||||
write(fos, plot, bo3);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
final File base = getBaseFile(plot.getArea().worldname);
|
||||
try {
|
||||
final List<String> lines = Files.readAllLines(base.toPath(), StandardCharsets.UTF_8);
|
||||
|
@ -49,18 +49,22 @@ public abstract class ChunkManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void preProcessChunk(PlotChunk<?> chunk) {
|
||||
public static boolean preProcessChunk(PlotChunk<?> chunk) {
|
||||
if (CURRENT_FORCE_CHUNK != null) {
|
||||
CURRENT_FORCE_CHUNK.run(chunk);
|
||||
CURRENT_FORCE_CHUNK = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void postProcessChunk(PlotChunk<?> chunk) {
|
||||
public static boolean postProcessChunk(PlotChunk<?> chunk) {
|
||||
if (CURRENT_ADD_CHUNK != null) {
|
||||
CURRENT_ADD_CHUNK.run(chunk);
|
||||
CURRENT_ADD_CHUNK = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void largeRegionTask(final String world, final RegionWrapper region, final RunnableVal<ChunkLoc> task, final Runnable whenDone) {
|
||||
|
@ -21,6 +21,7 @@ import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ExpireManager {
|
||||
|
||||
@ -45,6 +46,11 @@ public class ExpireManager {
|
||||
}
|
||||
}
|
||||
|
||||
public long getTimestamp(UUID uuid) {
|
||||
Long value = dates_cache.get(uuid);
|
||||
return value == null ? 0 : value;
|
||||
}
|
||||
|
||||
public void confirmExpiry(final PlotPlayer pp) {
|
||||
if (Settings.AUTO_CLEAR_CONFIRMATION && plotsToDelete != null && !plotsToDelete.isEmpty() && pp.hasPermission("plots.admin.command.autoclear")) {
|
||||
final int num = plotsToDelete.size();
|
||||
@ -233,8 +239,7 @@ public class ExpireManager {
|
||||
}
|
||||
if ((last = opp.getLastPlayed()) != 0) {
|
||||
dates_cache.put(uuid, last);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -242,7 +247,7 @@ public class ExpireManager {
|
||||
return false;
|
||||
}
|
||||
final long compared = System.currentTimeMillis() - last;
|
||||
if (compared >= (86400000l * Settings.AUTO_CLEAR_DAYS)) {
|
||||
if (compared >= (TimeUnit.DAYS.toMillis(Settings.AUTO_CLEAR_DAYS))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,35 @@ import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import java.io.File;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
@ -106,6 +129,86 @@ public class MainUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void upload(UUID uuid, String file, String extension, final RunnableVal<OutputStream> writeTask, final RunnableVal<URL> whenDone) {
|
||||
if (writeTask == null) {
|
||||
PS.debug("&cWrite task cannot be null");
|
||||
TaskManager.runTask(whenDone);
|
||||
return;
|
||||
}
|
||||
final String filename;
|
||||
final String website;
|
||||
if (uuid == null) {
|
||||
uuid = UUID.randomUUID();
|
||||
website = Settings.WEB_URL + "upload.php?" + uuid;
|
||||
filename = "plot." + extension;
|
||||
} else {
|
||||
website = Settings.WEB_URL + "save.php?" + uuid;
|
||||
filename = file + "." + extension;
|
||||
}
|
||||
final URL url;
|
||||
try {
|
||||
url = new URL(Settings.WEB_URL + "?key=" + uuid + "&ip=" + Settings.WEB_IP + "&type=" + extension);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
whenDone.run();
|
||||
return;
|
||||
}
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final String boundary = Long.toHexString(System.currentTimeMillis());
|
||||
final URLConnection con = new URL(website).openConnection();
|
||||
con.setDoOutput(true);
|
||||
con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
|
||||
try (OutputStream output = con.getOutputStream();
|
||||
PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8), true)) {
|
||||
final String CRLF = "\r\n";
|
||||
writer.append("--" + boundary).append(CRLF);
|
||||
writer.append("Content-Disposition: form-data; name=\"param\"").append(CRLF);
|
||||
writer.append("Content-Type: text/plain; charset=" + StandardCharsets.UTF_8.displayName()).append(CRLF);
|
||||
final String param = "value";
|
||||
writer.append(CRLF).append(param).append(CRLF).flush();
|
||||
writer.append("--" + boundary).append(CRLF);
|
||||
writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"" + filename + "\"").append(CRLF);
|
||||
writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(filename)).append(CRLF);
|
||||
writer.append("Content-Transfer-Encoding: binary").append(CRLF);
|
||||
writer.append(CRLF).flush();
|
||||
writeTask.value = output;
|
||||
writeTask.run();
|
||||
output.flush();
|
||||
writer.append(CRLF).flush();
|
||||
writer.append("--" + boundary + "--").append(CRLF).flush();
|
||||
}
|
||||
// try (Reader response = new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8)) {
|
||||
// final char[] buffer = new char[256];
|
||||
// final StringBuilder result = new StringBuilder();
|
||||
// while (true) {
|
||||
// final int r = response.read(buffer);
|
||||
// if (r < 0) {
|
||||
// break;
|
||||
// }
|
||||
// result.append(buffer, 0, r);
|
||||
// }
|
||||
// if (!result.toString().startsWith("Success")) {
|
||||
// PS.debug(result);
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
final int responseCode = ((HttpURLConnection) con).getResponseCode();
|
||||
if (responseCode == 200) {
|
||||
whenDone.value = url;
|
||||
}
|
||||
TaskManager.runTask(whenDone);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the biome if it was modified
|
||||
* @param area
|
||||
|
@ -24,7 +24,6 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -34,14 +33,10 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@ -566,72 +561,26 @@ public abstract class SchematicHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
public URL upload(final CompoundTag tag, UUID uuid, String file) {
|
||||
public void upload(final CompoundTag tag, UUID uuid, String file, RunnableVal<URL> whenDone) {
|
||||
if (tag == null) {
|
||||
PS.debug("&cCannot save empty tag");
|
||||
return null;
|
||||
TaskManager.runTask(whenDone);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String website;
|
||||
if (uuid == null) {
|
||||
uuid = UUID.randomUUID();
|
||||
website = Settings.WEB_URL + "upload.php?" + uuid;
|
||||
file = "plot";
|
||||
} else {
|
||||
website = Settings.WEB_URL + "save.php?" + uuid;
|
||||
MainUtil.upload(uuid, file, "schematic", new RunnableVal<OutputStream>() {
|
||||
@Override
|
||||
public void run(OutputStream output) {
|
||||
try {
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(output, true);
|
||||
NBTOutputStream nos = new NBTOutputStream(gzip);
|
||||
nos.writeTag(tag);
|
||||
nos.flush();
|
||||
gzip.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
final String boundary = Long.toHexString(System.currentTimeMillis());
|
||||
final URLConnection con = new URL(website).openConnection();
|
||||
con.setDoOutput(true);
|
||||
con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
|
||||
try (OutputStream output = con.getOutputStream();
|
||||
PrintWriter writer = new PrintWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8), true)) {
|
||||
final String CRLF = "\r\n";
|
||||
writer.append("--" + boundary).append(CRLF);
|
||||
writer.append("Content-Disposition: form-data; name=\"param\"").append(CRLF);
|
||||
writer.append("Content-Type: text/plain; charset=" + StandardCharsets.UTF_8.displayName()).append(CRLF);
|
||||
final String param = "value";
|
||||
writer.append(CRLF).append(param).append(CRLF).flush();
|
||||
writer.append("--" + boundary).append(CRLF);
|
||||
writer.append("Content-Disposition: form-data; name=\"schematicFile\"; filename=\"" + file + ".schematic" + "\"").append(CRLF);
|
||||
writer.append("Content-Type: " + URLConnection.guessContentTypeFromName(file + ".schematic")).append(CRLF);
|
||||
writer.append("Content-Transfer-Encoding: binary").append(CRLF);
|
||||
writer.append(CRLF).flush();
|
||||
final GZIPOutputStream gzip = new GZIPOutputStream(output);
|
||||
final NBTOutputStream nos = new NBTOutputStream(gzip);
|
||||
nos.writeTag(tag);
|
||||
gzip.finish();
|
||||
nos.flush();
|
||||
output.flush();
|
||||
writer.append(CRLF).flush();
|
||||
writer.append("--" + boundary + "--").append(CRLF).flush();
|
||||
nos.close();
|
||||
}
|
||||
// try (Reader response = new InputStreamReader(con.getInputStream(), StandardCharsets.UTF_8)) {
|
||||
// final char[] buffer = new char[256];
|
||||
// final StringBuilder result = new StringBuilder();
|
||||
// while (true) {
|
||||
// final int r = response.read(buffer);
|
||||
// if (r < 0) {
|
||||
// break;
|
||||
// }
|
||||
// result.append(buffer, 0, r);
|
||||
// }
|
||||
// if (!result.toString().equals("The file plot.schematic has been uploaded.")) {
|
||||
// PS.debug(result);
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
final int responseCode = ((HttpURLConnection) con).getResponseCode();
|
||||
if (responseCode != 200) {
|
||||
return null;
|
||||
}
|
||||
return new URL(Settings.WEB_URL + "?key=" + uuid + "&ip=" + Settings.WEB_IP);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}, whenDone);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,9 +1,20 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public abstract class WorldUtil {
|
||||
public static WorldUtil IMP;
|
||||
@ -19,6 +30,10 @@ public abstract class WorldUtil {
|
||||
public abstract String[] getSign(Location loc);
|
||||
|
||||
public abstract Location getSpawn(String world);
|
||||
|
||||
public abstract void setSpawn(Location loc);
|
||||
|
||||
public abstract void saveWorld(String world);
|
||||
|
||||
public abstract String getClosestMatchingName(PlotBlock plotBlock);
|
||||
|
||||
@ -37,4 +52,78 @@ public abstract class WorldUtil {
|
||||
public abstract void setSign(String world, int x, int y, int z, String[] lines);
|
||||
|
||||
public abstract void setBiomes(String world, RegionWrapper region, String biome);
|
||||
|
||||
public void upload(final Plot plot, final UUID uuid, final String file, final RunnableVal<URL> whenDone) {
|
||||
if (plot == null) {
|
||||
throw new IllegalArgumentException("Plot may not be null!");
|
||||
}
|
||||
final Location home = plot.getHome();
|
||||
MainUtil.upload(uuid, file, "zip", new RunnableVal<OutputStream>() {
|
||||
@Override
|
||||
public void run(OutputStream output) {
|
||||
try (final ZipOutputStream zos = new ZipOutputStream(output)) {
|
||||
final byte[] buffer = new byte[1024];
|
||||
final File dat = getDat(plot.getArea().worldname);
|
||||
Location spawn = getSpawn(plot.getArea().worldname);
|
||||
setSpawn(home);
|
||||
if (dat != null) {
|
||||
final ZipEntry ze = new ZipEntry("world" + File.separator + dat.getName());
|
||||
zos.putNextEntry(ze);
|
||||
final FileInputStream in = new FileInputStream(dat);
|
||||
int len;
|
||||
while ((len = in.read(buffer)) > 0) {
|
||||
zos.write(buffer, 0, len);
|
||||
}
|
||||
}
|
||||
setSpawn(spawn);
|
||||
for (Plot current : plot.getConnectedPlots()) {
|
||||
final Location bot = current.getBottomAbs();
|
||||
final Location top = current.getTopAbs();
|
||||
final int brx = bot.getX() >> 9;
|
||||
final int brz = bot.getZ() >> 9;
|
||||
final int trx = top.getX() >> 9;
|
||||
final int trz = top.getZ() >> 9;
|
||||
for (int x = brx; x <= trx; x++) {
|
||||
for (int z = brz; z <= trz; z++) {
|
||||
final File file = getMcr(plot.getArea().worldname, x, z);
|
||||
if (file != null) {
|
||||
//final String name = "r." + (x - cx) + "." + (z - cz) + ".mca";
|
||||
String name = file.getName();
|
||||
final ZipEntry ze = new ZipEntry("world" + File.separator + "region" + File.separator + name);
|
||||
zos.putNextEntry(ze);
|
||||
final FileInputStream in = new FileInputStream(file);
|
||||
int len;
|
||||
while ((len = in.read(buffer)) > 0) {
|
||||
zos.write(buffer, 0, len);
|
||||
}
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
zos.closeEntry();
|
||||
zos.flush();
|
||||
zos.finish();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, whenDone);
|
||||
}
|
||||
|
||||
public File getDat(final String world) {
|
||||
final File file = new File(PS.get().IMP.getWorldContainer() + File.separator + world + File.separator + "level.dat");
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public File getMcr(final String world, final int x, final int z) {
|
||||
final File file = new File(PS.get().IMP.getWorldContainer(), world + File.separator + "region" + File.separator + "r." + x + "." + z + ".mca");
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.plotsquared.listener;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
@ -14,13 +15,15 @@ import com.sk89q.worldedit.command.tool.Tool;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.*;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.ChangeSetExtent;
|
||||
import com.sk89q.worldedit.extent.MaskingExtent;
|
||||
import com.sk89q.worldedit.extent.reorder.MultiStageReorder;
|
||||
import com.sk89q.worldedit.extent.world.FastModeExtent;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
|
||||
import com.sk89q.worldedit.util.eventbus.Subscribe;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashSet;
|
||||
|
||||
@ -39,18 +42,30 @@ public class WESubscriber {
|
||||
if (actor != null && actor.isPlayer()) {
|
||||
final String name = actor.getName();
|
||||
final PlotPlayer pp = PlotPlayer.wrap(name);
|
||||
if (pp != null && pp.getAttribute("worldedit")) {
|
||||
return;
|
||||
}
|
||||
final HashSet<RegionWrapper> mask = WEManager.getMask(pp);
|
||||
if (mask.isEmpty()) {
|
||||
if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) {
|
||||
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS);
|
||||
}
|
||||
if (PS.get().hasPlotArea(world)) {
|
||||
final HashSet<RegionWrapper> mask;
|
||||
if (pp == null) {
|
||||
Player player = (Player) actor;
|
||||
Location loc = player.getLocation();
|
||||
com.intellectualcrafters.plot.object.Location pLoc = new com.intellectualcrafters.plot.object.Location(player.getWorld().getName(), loc.getBlockX(), loc.getBlockX(), loc.getBlockZ());
|
||||
Plot plot = pLoc.getPlot();
|
||||
if (plot == null) {
|
||||
event.setExtent(new com.sk89q.worldedit.extent.NullExtent());
|
||||
return;
|
||||
}
|
||||
mask = plot.getRegions();
|
||||
} else if (pp.getAttribute("worldedit")) {
|
||||
return;
|
||||
} else {
|
||||
mask = WEManager.getMask(pp);
|
||||
if (mask.isEmpty()) {
|
||||
if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) {
|
||||
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS);
|
||||
}
|
||||
if (PS.get().hasPlotArea(world)) {
|
||||
event.setExtent(new com.sk89q.worldedit.extent.NullExtent());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Settings.CHUNK_PROCESSOR) {
|
||||
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
|
||||
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
|
@ -13,14 +13,40 @@ import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.ChatManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.InventoryUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.PlotQueue;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.sponge.generator.SpongePlotGenerator;
|
||||
import com.plotsquared.sponge.listener.ChunkProcessor;
|
||||
import com.plotsquared.sponge.listener.MainListener;
|
||||
import com.plotsquared.sponge.listener.WorldEvents;
|
||||
import com.plotsquared.sponge.util.*;
|
||||
import com.plotsquared.sponge.util.KillRoadMobs;
|
||||
import com.plotsquared.sponge.util.SpongeChatManager;
|
||||
import com.plotsquared.sponge.util.SpongeChunkManager;
|
||||
import com.plotsquared.sponge.util.SpongeCommand;
|
||||
import com.plotsquared.sponge.util.SpongeEconHandler;
|
||||
import com.plotsquared.sponge.util.SpongeEventUtil;
|
||||
import com.plotsquared.sponge.util.SpongeHybridUtils;
|
||||
import com.plotsquared.sponge.util.SpongeInventoryUtil;
|
||||
import com.plotsquared.sponge.util.SpongeMetrics;
|
||||
import com.plotsquared.sponge.util.SpongeSchematicHandler;
|
||||
import com.plotsquared.sponge.util.SpongeSetupUtils;
|
||||
import com.plotsquared.sponge.util.SpongeTaskManager;
|
||||
import com.plotsquared.sponge.util.SpongeTitleManager;
|
||||
import com.plotsquared.sponge.util.SpongeUtil;
|
||||
import com.plotsquared.sponge.util.block.FastQueue;
|
||||
import com.plotsquared.sponge.util.block.SlowQueue;
|
||||
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
|
||||
@ -141,7 +167,6 @@ public class SpongeMain implements IPlotMain {
|
||||
public int[] getPluginVersion() {
|
||||
PluginContainer plugin = game.getPluginManager().fromInstance(this).get();
|
||||
String version = plugin.getVersion().get();
|
||||
log("Checking plugin version: PlotSquared: ");
|
||||
final String[] split = version.split("\\.");
|
||||
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
|
||||
}
|
||||
@ -203,7 +228,7 @@ public class SpongeMain implements IPlotMain {
|
||||
|
||||
@Override
|
||||
public void registerCommands() {
|
||||
getGame().getCommandManager().register(THIS, new SpongeCommand(), new String[] { "plots", "p", "plot", "ps", "plotsquared", "p2", "2" });
|
||||
getGame().getCommandManager().register(THIS, new SpongeCommand(), "plots", "p", "plot", "ps", "plotsquared", "p2", "2");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,6 +19,7 @@ import com.plotsquared.sponge.SpongeMain;
|
||||
import com.plotsquared.sponge.object.SpongePlayer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.block.BlockType;
|
||||
@ -355,7 +356,20 @@ public class SpongeUtil extends WorldUtil {
|
||||
result.setY(getHighestBlock(world, result.getX(), result.getZ()));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSpawn(Location loc) {
|
||||
World world = getWorld(loc.getWorld());
|
||||
if (world != null) {
|
||||
world.getProperties().setSpawnPosition(new Vector3i(loc.getX(), loc.getY(), loc.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorld(String worldname) {
|
||||
throw new NotImplementedException("TODO WIP"); // TODO FIXME
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSign(final Location loc) {
|
||||
final World world = SpongeUtil.getWorld(loc.getWorld());
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.plotsquared.sponge.util.block;
|
||||
|
||||
import org.spongepowered.api.world.Chunk;
|
||||
import org.spongepowered.api.world.extent.MutableBiomeArea;
|
||||
import org.spongepowered.api.world.extent.MutableBlockVolume;
|
||||
|
||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.plotsquared.sponge.util.SpongeUtil;
|
||||
import org.spongepowered.api.world.Chunk;
|
||||
import org.spongepowered.api.world.extent.MutableBiomeArea;
|
||||
import org.spongepowered.api.world.extent.MutableBlockVolume;
|
||||
|
||||
public class GenChunk extends PlotChunk<Chunk> {
|
||||
|
||||
@ -41,12 +40,17 @@ public class GenChunk extends PlotChunk<Chunk> {
|
||||
public void setBlock(int x, int y, int z, int id, byte data) {
|
||||
terain.setBlock(bx + x, y, bz + z, SpongeUtil.getBlockState(id, data));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setChunkWrapper(ChunkWrapper loc) {
|
||||
super.setChunkWrapper(loc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotChunk clone() {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PlotChunk shallowClone() {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
|
Loading…
Reference in New Issue
Block a user