mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Bug fixes.
This commit is contained in:
parent
e548cd8158
commit
b0351b5c99
@ -305,7 +305,7 @@ public class PlotHelper {
|
||||
PlotManager manager = PlotMain.getPlotManager(world);
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
|
||||
manager.setWall(player, plotworld, plot.id, block);
|
||||
manager.setWall(world, plotworld, plot.id, block);
|
||||
}
|
||||
|
||||
public static void autoMerge(World world, Plot plot, Player player) {
|
||||
@ -599,7 +599,7 @@ public class PlotHelper {
|
||||
World world = requester.getWorld();
|
||||
PlotManager manager = PlotMain.getPlotManager(world);
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
manager.setWall(requester, plotworld, plot.id, block);
|
||||
manager.setWallFilling(world, plotworld, plot.id, block);
|
||||
PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED);
|
||||
if (canSetFast) {
|
||||
SetBlockFast.update(requester);
|
||||
@ -617,7 +617,7 @@ public class PlotHelper {
|
||||
PlotManager manager = PlotMain.getPlotManager(world);
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED);
|
||||
manager.setFloor(requester, plotworld, plot.id, blocks);
|
||||
manager.setFloor(world, plotworld, plot.id, blocks);
|
||||
if (canSetFast) {
|
||||
SetBlockFast.update(requester);
|
||||
}
|
||||
|
@ -39,11 +39,13 @@ public abstract class PlotManager {
|
||||
* method)
|
||||
*/
|
||||
|
||||
public abstract boolean setWall(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock block);
|
||||
public abstract boolean setWallFilling(World world, PlotWorld plotworld, PlotId plotid, PlotBlock block);
|
||||
|
||||
public abstract boolean setWall(World world, PlotWorld plotworld, PlotId plotid, PlotBlock block);
|
||||
|
||||
public abstract boolean setFloor(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock[] block);
|
||||
public abstract boolean setFloor(World world, PlotWorld plotworld, PlotId plotid, PlotBlock[] block);
|
||||
|
||||
public abstract boolean setBiome(Player player, Plot plot, Biome biome);
|
||||
public abstract boolean setBiome(World world, Plot plot, Biome biome);
|
||||
|
||||
/*
|
||||
* PLOT MERGING (return false if your generator does not support plot
|
||||
|
@ -1,15 +1,24 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.intellectualcrafters.jnbt.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
@ -181,6 +190,160 @@ public class SchematicHandler {
|
||||
return this.z;
|
||||
}
|
||||
}
|
||||
public boolean save(CompoundTag tag, String path) {
|
||||
try {
|
||||
OutputStream stream = new FileOutputStream(path);
|
||||
NBTOutputStream output = new NBTOutputStream(stream);
|
||||
output.writeTag(tag);
|
||||
output.close();
|
||||
stream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public CompoundTag getCompoundTag(World world, Plot plot) {
|
||||
|
||||
// loading chunks
|
||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
||||
for (int i = (pos1.getBlockX() / 16) * 16; i < (16 + ((pos2.getBlockX() / 16) * 16)); i += 16) {
|
||||
for (int j = (pos1.getBlockZ() / 16) * 16; j < (16 + ((pos2.getBlockZ() / 16) * 16)); j += 16) {
|
||||
Chunk chunk = world.getChunkAt(i, j);
|
||||
chunk.load(true);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO get blocks
|
||||
|
||||
// save as a schematic
|
||||
int MAX_SIZE = Short.MAX_VALUE - Short.MIN_VALUE;
|
||||
|
||||
return null;
|
||||
|
||||
// int width = region.getWidth();
|
||||
// int height = region.getHeight();
|
||||
// int length = region.getLength();
|
||||
//
|
||||
// if (width > MAX_SIZE) {
|
||||
// throw new IllegalArgumentException("Width of region too large for a .schematic");
|
||||
// }
|
||||
// if (height > MAX_SIZE) {
|
||||
// throw new IllegalArgumentException("Height of region too large for a .schematic");
|
||||
// }
|
||||
// if (length > MAX_SIZE) {
|
||||
// throw new IllegalArgumentException("Length of region too large for a .schematic");
|
||||
// }
|
||||
//
|
||||
// // ====================================================================
|
||||
// // Metadata
|
||||
// // ====================================================================
|
||||
//
|
||||
// HashMap<String, Tag> schematic = new HashMap<String, Tag>();
|
||||
// schematic.put("Width", new ShortTag("Width", (short) width));
|
||||
// schematic.put("Length", new ShortTag("Length", (short) length));
|
||||
// schematic.put("Height", new ShortTag("Height", (short) height));
|
||||
// schematic.put("Materials", new StringTag("Materials", "Alpha"));
|
||||
// schematic.put("WEOriginX", new IntTag("WEOriginX", min.getBlockX()));
|
||||
// schematic.put("WEOriginY", new IntTag("WEOriginY", min.getBlockY()));
|
||||
// schematic.put("WEOriginZ", new IntTag("WEOriginZ", min.getBlockZ()));
|
||||
// schematic.put("WEOffsetX", new IntTag("WEOffsetX", offset.getBlockX()));
|
||||
// schematic.put("WEOffsetY", new IntTag("WEOffsetY", offset.getBlockY()));
|
||||
// schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", offset.getBlockZ()));
|
||||
//
|
||||
// // ====================================================================
|
||||
// // Block handling
|
||||
// // ====================================================================
|
||||
//
|
||||
// byte[] blocks = new byte[width * height * length];
|
||||
// byte[] addBlocks = null;
|
||||
// byte[] blockData = new byte[width * height * length];
|
||||
// List<Tag> tileEntities = new ArrayList<Tag>();
|
||||
//
|
||||
// for (Vector point : region) {
|
||||
// Vector relative = point.subtract(min);
|
||||
// int x = relative.getBlockX();
|
||||
// int y = relative.getBlockY();
|
||||
// int z = relative.getBlockZ();
|
||||
//
|
||||
// int index = y * width * length + z * width + x;
|
||||
// BaseBlock block = clipboard.getBlock(point);
|
||||
//
|
||||
// // Save 4096 IDs in an AddBlocks section
|
||||
// if (block.getType() > 255) {
|
||||
// if (addBlocks == null) { // Lazily create section
|
||||
// addBlocks = new byte[(blocks.length >> 1) + 1];
|
||||
// }
|
||||
//
|
||||
// addBlocks[index >> 1] = (byte) (((index & 1) == 0) ?
|
||||
// addBlocks[index >> 1] & 0xF0 | (block.getType() >> 8) & 0xF
|
||||
// : addBlocks[index >> 1] & 0xF | ((block.getType() >> 8) & 0xF) << 4);
|
||||
// }
|
||||
//
|
||||
// blocks[index] = (byte) block.getType();
|
||||
// blockData[index] = (byte) block.getData();
|
||||
//
|
||||
// // Store TileEntity data
|
||||
// CompoundTag rawTag = block.getNbtData();
|
||||
// if (rawTag != null) {
|
||||
// Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
// for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||
// values.put(entry.getKey(), entry.getValue());
|
||||
// }
|
||||
//
|
||||
// values.put("id", new StringTag("id", block.getNbtId()));
|
||||
// values.put("x", new IntTag("x", x));
|
||||
// values.put("y", new IntTag("y", y));
|
||||
// values.put("z", new IntTag("z", z));
|
||||
//
|
||||
// CompoundTag tileEntityTag = new CompoundTag("TileEntity", values);
|
||||
// tileEntities.add(tileEntityTag);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||
// schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||
// schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
||||
//
|
||||
// if (addBlocks != null) {
|
||||
// schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks));
|
||||
// }
|
||||
//
|
||||
// // ====================================================================
|
||||
// // Entities
|
||||
// // ====================================================================
|
||||
//
|
||||
// List<Tag> entities = new ArrayList<Tag>();
|
||||
// for (Entity entity : clipboard.getEntities()) {
|
||||
// BaseEntity state = entity.getState();
|
||||
//
|
||||
// if (state != null) {
|
||||
// Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
//
|
||||
// // Put NBT provided data
|
||||
// CompoundTag rawTag = state.getNbtData();
|
||||
// if (rawTag != null) {
|
||||
// values.putAll(rawTag.getValue());
|
||||
// }
|
||||
//
|
||||
// // Store our location data, overwriting any
|
||||
// values.put("id", new StringTag("id", state.getTypeId()));
|
||||
// values.put("Pos", writeVector(entity.getLocation().toVector(), "Pos"));
|
||||
// values.put("Rotation", writeRotation(entity.getLocation(), "Rotation"));
|
||||
//
|
||||
// CompoundTag entityTag = new CompoundTag("Entity", values);
|
||||
// entities.add(entityTag);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// schematic.put("Entities", new ListTag("Entities", CompoundTag.class, entities));
|
||||
//
|
||||
//
|
||||
// CompoundTag schematicTag = new CompoundTag("Schematic", schematic);
|
||||
// return schematicTag;
|
||||
}
|
||||
|
||||
public class DataCollection {
|
||||
private short block;
|
||||
|
@ -78,7 +78,7 @@ public class Denied extends SubCommand {
|
||||
}
|
||||
if (!uuid.equals(DBFunc.everyone) && (Bukkit.getPlayer(uuid) != null) && Bukkit.getPlayer(uuid).isOnline()) {
|
||||
Plot pl = PlayerFunctions.getCurrentPlot(Bukkit.getPlayer((uuid)));
|
||||
if (pl.id == plot.id) {
|
||||
if (pl!=null && pl.id.equals(plot.id)) {
|
||||
PlayerFunctions.sendMessage(Bukkit.getPlayer(uuid), C.YOU_BE_DENIED);
|
||||
Bukkit.getPlayer(uuid).teleport(Bukkit.getPlayer(uuid).getWorld().getSpawnLocation());
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.UUIDHandler;
|
||||
|
||||
public class Visit extends SubCommand {
|
||||
public Visit() {
|
||||
@ -43,8 +44,13 @@ public class Visit extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
String username = args[0];
|
||||
List<Plot> plots = getPlots(Bukkit.getOfflinePlayer(username).getUniqueId());
|
||||
if (plots.isEmpty()) {
|
||||
|
||||
UUID uuid = UUIDHandler.getUUID(username);
|
||||
List<Plot> plots = null;
|
||||
if (uuid!=null) {
|
||||
plots = getPlots(uuid);
|
||||
}
|
||||
if (uuid==null || plots.isEmpty()) {
|
||||
PlayerFunctions.sendMessage(plr, C.FOUND_NO_PLOTS);
|
||||
return true;
|
||||
}
|
||||
|
@ -229,6 +229,19 @@ public class DefaultPlotManager extends PlotManager {
|
||||
PlotBlock[] plotfloor = dpw.TOP_BLOCK;
|
||||
PlotBlock[] filling = dpw.TOP_BLOCK;
|
||||
|
||||
PlotBlock wall = dpw.WALL_BLOCK;
|
||||
PlotBlock wall_filling = dpw.WALL_FILLING;
|
||||
|
||||
Block block = world.getBlockAt(new Location(world, pos1.getBlockX()-1, 1, pos1.getBlockZ()));
|
||||
if (block.getTypeId()!=wall_filling.id || block.getData()!=wall_filling.data) {
|
||||
setWallFilling(world, dpw, plot.id, wall_filling);
|
||||
}
|
||||
|
||||
block = world.getBlockAt(new Location(world, pos1.getBlockX()-1, dpw.WALL_HEIGHT+1, pos1.getBlockZ()));
|
||||
if (block.getTypeId()!=wall.id || block.getData()!=wall.data) {
|
||||
setWall(world, dpw, plot.id, wall_filling);
|
||||
}
|
||||
|
||||
if ((pos2.getBlockX() - pos1.getBlockX()) < 48) {
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||
@ -356,9 +369,8 @@ public class DefaultPlotManager extends PlotManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setFloor(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
public boolean setFloor(World world, PlotWorld plotworld, PlotId plotid, PlotBlock[] blocks) {
|
||||
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
|
||||
World world = player.getWorld();
|
||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plotid).add(1, 0, 1);
|
||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plotid);
|
||||
PlotHelper.setCuboid(world, new Location(world,pos1.getX(),dpw.PLOT_HEIGHT,pos1.getZ()), new Location(world,pos2.getX()+1,dpw.PLOT_HEIGHT+1,pos2.getZ()+1), blocks);
|
||||
@ -366,9 +378,52 @@ public class DefaultPlotManager extends PlotManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setWall(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock plotblock) {
|
||||
public boolean setWallFilling(World w, PlotWorld plotworld, PlotId plotid, PlotBlock plotblock) {
|
||||
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
|
||||
|
||||
Location bottom = PlotHelper.getPlotBottomLoc(w, plotid);
|
||||
Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
||||
|
||||
int x, z;
|
||||
|
||||
Block block;
|
||||
|
||||
z = bottom.getBlockZ();
|
||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
||||
for (int y = 1; y<= dpw.WALL_HEIGHT; y++) {
|
||||
block = w.getBlockAt(x, y, z);
|
||||
PlotHelper.setBlock(block, plotblock);
|
||||
}
|
||||
}
|
||||
|
||||
x = top.getBlockX() + 1;
|
||||
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
||||
for (int y = 1; y<= dpw.WALL_HEIGHT; y++) {
|
||||
block = w.getBlockAt(x, y, z);
|
||||
PlotHelper.setBlock(block, plotblock);
|
||||
}
|
||||
}
|
||||
|
||||
z = top.getBlockZ() + 1;
|
||||
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
||||
for (int y = 1; y<= dpw.WALL_HEIGHT; y++) {
|
||||
block = w.getBlockAt(x, y, z);
|
||||
PlotHelper.setBlock(block, plotblock);
|
||||
}
|
||||
}
|
||||
x = bottom.getBlockX();
|
||||
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
||||
for (int y = 1; y<= dpw.WALL_HEIGHT; y++) {
|
||||
block = w.getBlockAt(x, y, z);
|
||||
PlotHelper.setBlock(block, plotblock);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setWall(World w, PlotWorld plotworld, PlotId plotid, PlotBlock plotblock) {
|
||||
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
|
||||
World w = player.getWorld();
|
||||
|
||||
Location bottom = PlotHelper.getPlotBottomLoc(w, plotid);
|
||||
Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
||||
@ -376,33 +431,24 @@ public class DefaultPlotManager extends PlotManager {
|
||||
int x, z;
|
||||
|
||||
Block block;
|
||||
|
||||
// TODO use PlotHelper.setSimpleCuboid rather than this for loop
|
||||
|
||||
z = bottom.getBlockZ();
|
||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
||||
z = bottom.getBlockZ();
|
||||
|
||||
block = w.getBlockAt(x, dpw.ROAD_HEIGHT + 1, z);
|
||||
block = w.getBlockAt(x, dpw.WALL_HEIGHT + 1, z);
|
||||
PlotHelper.setBlock(block, plotblock);
|
||||
}
|
||||
|
||||
x = top.getBlockX() + 1;
|
||||
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
||||
x = top.getBlockX() + 1;
|
||||
|
||||
block = w.getBlockAt(x, dpw.ROAD_HEIGHT + 1, z);
|
||||
block = w.getBlockAt(x, dpw.WALL_HEIGHT + 1, z);
|
||||
PlotHelper.setBlock(block, plotblock);
|
||||
}
|
||||
|
||||
z = top.getBlockZ() + 1;
|
||||
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
||||
z = top.getBlockZ() + 1;
|
||||
|
||||
block = w.getBlockAt(x, dpw.ROAD_HEIGHT + 1, z);
|
||||
block = w.getBlockAt(x, dpw.WALL_HEIGHT + 1, z);
|
||||
PlotHelper.setBlock(block, plotblock);
|
||||
}
|
||||
|
||||
x = bottom.getBlockX();
|
||||
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
||||
x = bottom.getBlockX();
|
||||
block = w.getBlockAt(x, dpw.ROAD_HEIGHT + 1, z);
|
||||
block = w.getBlockAt(x, dpw.WALL_HEIGHT + 1, z);
|
||||
PlotHelper.setBlock(block, plotblock);
|
||||
}
|
||||
return true;
|
||||
@ -412,9 +458,7 @@ public class DefaultPlotManager extends PlotManager {
|
||||
* Set a plot biome
|
||||
*/
|
||||
@Override
|
||||
public boolean setBiome(Player player, Plot plot, Biome biome) {
|
||||
|
||||
World world = player.getWorld();
|
||||
public boolean setBiome(World world, Plot plot, Biome biome) {
|
||||
|
||||
int bottomX = PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX() - 1;
|
||||
int topX = PlotHelper.getPlotTopLoc(world, plot.id).getBlockX() + 1;
|
||||
|
@ -161,9 +161,15 @@ public class PlotListener {
|
||||
PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
|
||||
Bukkit.getPluginManager().callEvent(callEvent);
|
||||
}
|
||||
player.setGameMode(Bukkit.getDefaultGameMode());
|
||||
player.resetPlayerTime();
|
||||
player.resetPlayerWeather();
|
||||
if(plot.settings.getFlag("gamemode") != null) {
|
||||
player.setGameMode(Bukkit.getDefaultGameMode());
|
||||
}
|
||||
if(plot.settings.getFlag("time") != null) {
|
||||
player.resetPlayerTime();
|
||||
}
|
||||
if(plot.settings.getFlag("weather") != null) {
|
||||
player.resetPlayerWeather();
|
||||
}
|
||||
PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user