Merge remote-tracking branch 'origin/master'

This commit is contained in:
Sauilitired 2014-10-30 16:16:42 +01:00
commit c63cdbf5a6
16 changed files with 410 additions and 243 deletions

4
.gitignore vendored
View file

@ -94,4 +94,6 @@ local.properties
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* hs_err_pid*
.classpath .classpath
.project .project
/target
/plotsquared/target

View file

@ -213,11 +213,11 @@ public enum C {
* Info * Info
*/ */
PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"), PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"),
PLOT_INFO("&6ID&7: &a%id%&7\n&6Alias&7: &a%alias%\n&6Owner&7: &a%owner%\n&6Description&7: &a%desc%\n&6Rating&7: &a%rating%&7/&a10\n&6Can build&7: &a%build%"), PLOT_INFO("&6ID&7: &a%id%&7\n&6Alias&7: &a%alias%\n&6Owner&7: &a%owner%\n&6Helpers&7: &a%helpers%\n&6Trusted&7: &a%trusted%\n&Denied&7: &a%denied%\n&6Denied&7: &a%denied%\n&6Flags&7: &a%flags%\n&6Biome&7: &a%biome%\n&6Rating&7: &a%rating%&7/&a10\n&6Can build&7: &a%build%"),
PLOT_INFO_HELPERS("&6Helpers&7: %helpers%"), PLOT_INFO_HELPERS("&6Helpers&7: %helpers%"),
PLOT_INFO_TRUSTED("&6Trusted&7: %trusted%"), PLOT_INFO_TRUSTED("&6Trusted&7: %trusted%"),
PLOT_INFO_DENIED("&6DENIED&7: %denied%"), PLOT_INFO_DENIED("&6Denied&7: %denied%"),
PLOT_INFO_FLAGS("&6Flags&7: %flags%"), PLOT_INFO_FLAGS("&6Flags&7: %flags%"),
PLOT_INFO_BIOME("&6Biome&7: %biome%"), PLOT_INFO_BIOME("&6Biome&7: %biome%"),
PLOT_INFO_RATING("&6Rating&7: %rating%"), PLOT_INFO_RATING("&6Rating&7: %rating%"),

View file

@ -326,7 +326,7 @@ public class Metrics {
// enabled // enabled
String pluginVersion = description.getVersion(); String pluginVersion = description.getVersion();
String serverVersion = Bukkit.getVersion(); String serverVersion = Bukkit.getVersion();
int playersOnline = Bukkit.getServer().getOnlinePlayers().size(); int playersOnline = Bukkit.getServer().getOnlinePlayers().length;
// END server software specific section -- all code below does not use // END server software specific section -- all code below does not use
// any code outside of this class / Java // any code outside of this class / Java
// Construct the post data // Construct the post data

View file

@ -10,6 +10,8 @@ import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.RegionMask;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
/** /**
@ -55,8 +57,7 @@ public class PWE {
LocalWorld lw = PlotMain.worldEdit.wrapPlayer(p).getWorld(); LocalWorld lw = PlotMain.worldEdit.wrapPlayer(p).getWorld();
CuboidRegion region = new CuboidRegion(lw, bvec, tvec); CuboidRegion region = new CuboidRegion(lw, bvec, tvec);
com.sk89q.worldedit.masks.RegionMask mask = new com.sk89q.worldedit.masks.RegionMask(region); RegionMask mask = new RegionMask(region);
s.setMask(mask); s.setMask(mask);
return; return;
} }
@ -65,8 +66,7 @@ public class PWE {
if (noMask(s)) { if (noMask(s)) {
BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p); BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p);
Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
s.setMask(new com.sk89q.worldedit.masks.RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
} }
} }
catch (Exception e) { catch (Exception e) {
@ -76,33 +76,31 @@ public class PWE {
} }
} }
@SuppressWarnings("unused")
public static boolean noMask(LocalSession s) { public static boolean noMask(LocalSession s) {
// try { return s.getMask() == null;
// com.sk89q.worldedit.masks.Mask mask = s.getMask();
// return mask == null;
// }
// catch (Throwable e) {
//
//
// return true;
//
//
// }
return true;
} }
public static void setNoMask(Player p) {
try {
LocalSession s;
if (PlotMain.worldEdit == null) {
s = WorldEdit.getInstance().getSession(p.getName());
}
else {
s = PlotMain.worldEdit.getSession(p);
}
BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p);
Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
s.setMask(new RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
}
catch (Exception e) {
}
}
public static void removeMask(Player p, LocalSession s) { public static void removeMask(Player p, LocalSession s) {
// try { Mask mask = null;
// s.setMask(null); s.setMask(mask);
// }
// catch (Throwable e) {
// com.sk89q.worldedit.masks.Mask mask = null;
// s.setMask(mask);
// }
} }
public static void removeMask(Player p) { public static void removeMask(Player p) {

View file

@ -266,18 +266,19 @@ public class PlotHelper {
* @param block * @param block
* @param plotblock * @param plotblock
*/ */
public static void setBlock(Block block, PlotBlock plotblock) { public static boolean setBlock(Block block, PlotBlock plotblock) {
if (canSetFast) { if (canSetFast) {
if (block.getTypeId() != plotblock.id && plotblock.data != block.getData()) { if (block.getTypeId() != plotblock.id || plotblock.data != block.getData()) {
try { try {
SetBlockFast.set(block.getWorld(), block.getX(), block.getY(), block.getZ(), plotblock.id, plotblock.data); SetBlockFast.set(block.getWorld(), block.getX(), block.getY(), block.getZ(), plotblock.id, plotblock.data);
return; return true;
} }
catch (NoSuchMethodException e) { catch (NoSuchMethodException e) {
canSetFast = false; canSetFast = false;
} }
} }
return false;
} }
if (block.getData() == plotblock.data) { if (block.getData() == plotblock.data) {
if (block.getTypeId() != plotblock.id) { if (block.getTypeId() != plotblock.id) {
@ -292,6 +293,7 @@ public class PlotHelper {
block.setTypeIdAndData(plotblock.id, plotblock.data, false); block.setTypeIdAndData(plotblock.id, plotblock.data, false);
} }
} }
return false;
} }
/** /**

View file

@ -9,6 +9,7 @@
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
import com.intellectualcrafters.plot.Logger.LogLevel; import com.intellectualcrafters.plot.Logger.LogLevel;
import com.intellectualcrafters.plot.commands.Auto;
import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.database.*; import com.intellectualcrafters.plot.database.*;
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
@ -112,10 +113,9 @@ public class PlotMain extends JavaPlugin {
return new WorldGenerator(worldname); return new WorldGenerator(worldname);
} }
@SuppressWarnings("deprecation")
public static void checkForExpiredPlots() { public static void checkForExpiredPlots() {
final JavaPlugin plugin = PlotMain.getMain(); final JavaPlugin plugin = PlotMain.getMain();
Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() { Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
checkExpired(plugin, true); checkExpired(plugin, true);
@ -473,6 +473,9 @@ public class PlotMain extends JavaPlugin {
PlotHelper.removeSign(worldobj, plot); PlotHelper.removeSign(worldobj, plot);
DBFunc.delete(world, plot); DBFunc.delete(world, plot);
removePlot(world, plot.id, true); removePlot(world, plot.id, true);
if (Math.abs(plot.id.x)<Math.abs(Auto.lastPlot.x) && Math.abs(plot.id.y)<Math.abs(Auto.lastPlot.y)) {
Auto.lastPlot = plot.id;
}
} }
} }
} }
@ -1213,7 +1216,7 @@ public class PlotMain extends JavaPlugin {
options.put("mysql.user", "root"); options.put("mysql.user", "root");
options.put("mysql.password", "password"); options.put("mysql.password", "password");
options.put("mysql.database", "plot_db"); options.put("mysql.database", "plot_db");
options.put("prefix", "plotsquared_"); options.put("prefix", "");
for (Entry<String, Object> node : options.entrySet()) { for (Entry<String, Object> node : options.entrySet()) {
if (!storage.contains(node.getKey())) { if (!storage.contains(node.getKey())) {
storage.set(node.getKey(), node.getValue()); storage.set(node.getKey(), node.getValue());

View file

@ -7,6 +7,7 @@ import org.bukkit.block.Block;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.intellectualcrafters.jnbt.*; import com.intellectualcrafters.jnbt.*;
import com.intellectualcrafters.plot.SchematicHandler.DataCollection;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -27,7 +28,6 @@ import java.util.zip.GZIPOutputStream;
*/ */
@SuppressWarnings({"all"}) @SuppressWarnings({"all"})
public class SchematicHandler { public class SchematicHandler {
/** /**
* Paste a schematic * Paste a schematic
* @param location origin * @param location origin
@ -35,13 +35,12 @@ public class SchematicHandler {
* @param plot plot to paste in * @param plot plot to paste in
* @return true if succeeded * @return true if succeeded
*/ */
public static boolean paste(Location location, Schematic schematic, Plot plot) { public static boolean paste(Location location, Schematic schematic, Plot plot, int x_offset, int z_offset) {
if (schematic == null) { if (schematic == null) {
PlotMain.sendConsoleSenderMessage("Schematic == null :|"); PlotMain.sendConsoleSenderMessage("Schematic == null :|");
return false; return false;
} }
try { try {
Dimension demensions = schematic.getSchematicDimension(); Dimension demensions = schematic.getSchematicDimension();
int WIDTH = demensions.getX(); int WIDTH = demensions.getX();
@ -68,7 +67,7 @@ public class SchematicHandler {
short id = blocks[index].getBlock(); short id = blocks[index].getBlock();
byte data = blocks[index].getData(); byte data = blocks[index].getData();
Block block = world.getBlockAt(l1.getBlockX()+x, l1.getBlockY()+y, l1.getBlockZ()+z); Block block = world.getBlockAt(l1.getBlockX()+x+x_offset, l1.getBlockY()+y, l1.getBlockZ()+z+z_offset);
PlotBlock plotblock = new PlotBlock(id, data); PlotBlock plotblock = new PlotBlock(id, data);
@ -274,9 +273,9 @@ public class SchematicHandler {
PlotMain.sendConsoleSenderMessage("&7 - Cannot save: corrupt chunk at "+(i/16)+", "+(j/16)); PlotMain.sendConsoleSenderMessage("&7 - Cannot save: corrupt chunk at "+(i/16)+", "+(j/16));
return null; return null;
} }
int width = pos2.getBlockX()-pos1.getBlockX(); int width = pos2.getBlockX()-pos1.getBlockX()+1;
int height = 256; int height = 256;
int length = pos2.getBlockZ()-pos1.getBlockZ(); int length = pos2.getBlockZ()-pos1.getBlockZ()+1;
HashMap<String, Tag> schematic = new HashMap<>(); HashMap<String, Tag> schematic = new HashMap<>();
schematic.put("Width", new ShortTag("Width", (short) width)); schematic.put("Width", new ShortTag("Width", (short) width));
@ -354,4 +353,36 @@ public class SchematicHandler {
return this.data; return this.data;
} }
} }
public static boolean pastePart(World world, DataCollection[] blocks, Location l1, int x_offset, int z_offset, int i1, int i2, int WIDTH, int LENGTH) {
boolean result = false;
for (int i = i1; i<=i2 ;i++) {
short id = blocks[i].getBlock();
byte data = blocks[i].getData();
if (id==0) {
continue;
}
int area = WIDTH*LENGTH;
int r = i%(area);
int x = r%WIDTH;
int y = i/area;
int z = r/WIDTH;
if (y>256) {
break;
}
Block block = world.getBlockAt(l1.getBlockX()+x+x_offset, l1.getBlockY()+y, l1.getBlockZ()+z+z_offset);
PlotBlock plotblock = new PlotBlock(id, data);
boolean set = PlotHelper.setBlock(block, plotblock);
if (!result && set) {
result = true;
}
}
return result;
}
} }

View file

@ -27,7 +27,9 @@ public class Auto extends SubCommand {
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING, true); super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING, true);
} }
// TODO auto claim a mega plot!!!!!!!!!!!! public static PlotId lastPlot = new PlotId(0,0);
// TODO auto claim a mega plot with schematic
@Override @Override
public boolean execute(Player plr, String... args) { public boolean execute(Player plr, String... args) {
World world; World world;
@ -109,6 +111,15 @@ public class Auto extends SubCommand {
int x = 0, z = 0, q = 100; int x = 0, z = 0, q = 100;
PlotId id; PlotId id;
if ((size_x == 1) && (size_z == 1)) { if ((size_x == 1) && (size_z == 1)) {
while (!br) {
Plot plot = PlotHelper.getPlot(world, Auto.lastPlot);
if (plot==null || plot.owner == null) {
plot = PlotHelper.getPlot(world, Auto.lastPlot);
boolean result = Claim.claimPlot(plr, plot, true);
br = !result;
}
Auto.lastPlot = getNextPlot(Auto.lastPlot, 1);
}
while (!br) { while (!br) {
id = new PlotId(x, z); id = new PlotId(x, z);
if (PlotHelper.getPlot(world, id).owner == null) { if (PlotHelper.getPlot(world, id).owner == null) {
@ -133,39 +144,69 @@ public class Auto extends SubCommand {
} }
} }
else { else {
while (!br) { boolean claimed = true;
PlotId start = new PlotId(x, z); while (!br) {
PlotId end = new PlotId((x + size_x) - 1, (z + size_z) - 1); PlotId start = getNextPlot(Auto.lastPlot, 1);
if (isUnowned(world, start, end)) {
for (int i = start.x; i <= end.x; i++) { if (claimed) {
for (int j = start.y; j <= end.y; j++) { if (PlotMain.getPlots(world).get(start) == null || PlotMain.getPlots(world).get(start).owner == null) {
Plot plot = PlotHelper.getPlot(world, new PlotId(i, j)); Auto.lastPlot = start;
boolean teleport = ((i == end.x) && (j == end.y)); continue;
Claim.claimPlot(plr, plot, teleport); }
} }
}
if (!PlotHelper.mergePlots(plr, world, PlayerFunctions.getPlotSelectionIds(world, start, end))) { PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
return false; if (isUnowned(world, start, end)) {
} for (int i = start.x; i <= end.x; i++) {
br = true; for (int j = start.y; j <= end.y; j++) {
} Plot plot = PlotHelper.getPlot(world, new PlotId(i, j));
if ((z < q) && ((z - x) < q)) { boolean teleport = ((i == end.x) && (j == end.y));
z += size_z; Claim.claimPlot(plr, plot, teleport);
} }
else }
if (x < q) { if (!PlotHelper.mergePlots(plr, world, PlayerFunctions.getPlotSelectionIds(world, start, end))) {
x += size_x; return false;
z = q - 100; }
} br = true;
else { }
q += 100; }
x = q;
z = q;
}
}
} }
return true; return true;
} }
public static PlotId getNextPlot(PlotId id, int step) {
int absX = Math.abs(id.x);
int absY = Math.abs(id.y);
if (absX > absY) {
if (id.x > 0) {
return new PlotId(id.x, id.y + 1);
}
else {
return new PlotId(id.x, id.y - 1);
}
}
else if (absY > absX ){
if (id.y > 0) {
return new PlotId(id.x - 1, id.y);
}
else {
return new PlotId(id.x + 1, id.y);
}
}
else {
if (id.x==id.y && id.x > 0) {
return new PlotId(id.x, id.y + step);
}
if (id.x==absX) {
return new PlotId(id.x, id.y + 1);
}
if (id.y == absY) {
return new PlotId(id.x, id.y - 1);
}
return new PlotId(id.x + 1, id.y);
}
}
public boolean isUnowned(World world, PlotId pos1, PlotId pos2) { public boolean isUnowned(World world, PlotId pos1, PlotId pos2) {
for (int x = pos1.x; x <= pos2.x; x++) { for (int x = pos1.x; x <= pos2.x; x++) {

View file

@ -110,7 +110,7 @@ public class Claim extends SubCommand {
sch = SchematicHandler.getSchematic(world.SCHEMATIC_FILE); sch = SchematicHandler.getSchematic(world.SCHEMATIC_FILE);
} }
} }
SchematicHandler.paste(player.getLocation(), sch, plot); SchematicHandler.paste(player.getLocation(), sch, plot, 0, 0);
} }
if (world.DEFAULT_FLAGS != null && world.DEFAULT_FLAGS.size() > 0) { if (world.DEFAULT_FLAGS != null && world.DEFAULT_FLAGS.size() > 0) {
plot.settings.setFlags(FlagManager.parseFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS)); plot.settings.setFlags(FlagManager.parseFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS));

View file

@ -175,21 +175,6 @@ public class DebugClaimTest extends SubCommand {
if (teleport) { if (teleport) {
PlotMain.teleportPlayer(player, player.getLocation(), plot); PlotMain.teleportPlayer(player, player.getLocation(), plot);
} }
PlotWorld world = PlotMain.getWorldSettings(plot.getWorld());
if (world.SCHEMATIC_ON_CLAIM) {
SchematicHandler handler = new SchematicHandler();
SchematicHandler.Schematic sch;
if (schematic.equals("")) {
sch = handler.getSchematic(world.SCHEMATIC_FILE);
}
else {
sch = handler.getSchematic(schematic);
if (sch == null) {
sch = handler.getSchematic(world.SCHEMATIC_FILE);
}
}
handler.paste(player.getLocation(), sch, plot);
}
plot.settings.setFlags(FlagManager.parseFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS)); plot.settings.setFlags(FlagManager.parseFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS));
} }
return event.isCancelled(); return event.isCancelled();

View file

@ -58,6 +58,9 @@ public class Delete extends SubCommand {
if (result) { if (result) {
plot.clear(plr); plot.clear(plr);
DBFunc.delete(plr.getWorld().getName(), plot); DBFunc.delete(plr.getWorld().getName(), plot);
if (Math.abs(plot.id.x)<=Math.abs(Auto.lastPlot.x) && Math.abs(plot.id.y)<=Math.abs(Auto.lastPlot.y)) {
Auto.lastPlot = plot.id;
}
} }
else { else {
PlayerFunctions.sendMessage(plr, "Plot clearing has been denied."); PlayerFunctions.sendMessage(plr, "Plot clearing has been denied.");

View file

@ -2,7 +2,11 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.jnbt.CompoundTag; import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.SchematicHandler.DataCollection;
import com.intellectualcrafters.plot.SchematicHandler.Dimension;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -11,122 +15,186 @@ import java.util.HashMap;
public class Schematic extends SubCommand { public class Schematic extends SubCommand {
public Schematic() { public Schematic() {
super("schematic", "plots.admin", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS, false); super("schematic", "plots.admin", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS, false);
// TODO command to fetch schematic from worldedit directory // TODO command to fetch schematic from worldedit directory
} }
private int counter = 0; private int counter = 0;
private boolean running = false; private boolean running = false;
private Plot[] plots; private Plot[] plots;
private int task; private int task;
@Override
public boolean execute(final Player plr, String... args) {
@Override if (args.length < 1) {
public boolean execute(final Player plr, String... args) { sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
if (args.length < 1) { return true;
sendMessage(plr, C.SCHEMATIC_MISSING_ARG); }
return true; String arg = args[0].toLowerCase();
} final String file;
String arg = args[0].toLowerCase(); final SchematicHandler.Schematic schematic;
String file; switch (arg) {
SchematicHandler.Schematic schematic; case "paste":
switch (arg) { if (plr==null) {
case "paste":
if (plr==null) {
PlotMain.sendConsoleSenderMessage(C.IS_CONSOLE); PlotMain.sendConsoleSenderMessage(C.IS_CONSOLE);
return false; return false;
} }
if (!PlotMain.hasPermission(plr, "plots.schematic.save")) { if (!PlotMain.hasPermission(plr, "plots.schematic.paste")) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste"); PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste");
return false; return false;
} }
if (args.length < 2) { if (args.length < 2) {
sendMessage(plr, C.SCHEMATIC_MISSING_ARG); sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
break; break;
} }
if (!PlayerFunctions.isInPlot(plr)) { if (!PlayerFunctions.isInPlot(plr)) {
sendMessage(plr, C.NOT_IN_PLOT); sendMessage(plr, C.NOT_IN_PLOT);
break; break;
} }
file = args[1]; if (running) {
schematic = SchematicHandler.getSchematic(file); PlayerFunctions.sendMessage(plr, "&cTask is already running.");
boolean s = SchematicHandler.paste(plr.getLocation(), schematic, PlayerFunctions.getCurrentPlot(plr)); return false;
if (s) { }
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS); final String file2 = args[1];
} running = true;
else { this.counter = 0;
sendMessage(plr, C.SCHEMATIC_PASTE_FAILED); Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() {
} @Override
break; public void run() {
case "test": final SchematicHandler.Schematic schematic = SchematicHandler.getSchematic(file2);
if (plr==null) { if (schematic==null) {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent or not in gzip format");
running = false;
return;
}
final int x;
final int z;
final Plot plot2 = PlayerFunctions.getCurrentPlot(plr);
Dimension dem = schematic.getSchematicDimension();
Location bot = PlotHelper.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1);
int length2 = PlotHelper.getPlotWidth(plr.getWorld(), plot2.id);
if ((dem.getX() > length2) || (dem.getZ() > length2)) {
sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", dem.getX(), dem.getZ(), length2));
running = false;
return;
}
if (dem.getX() != length2 || dem.getZ() != length2) {
Location loc = plr.getLocation();
x = Math.min(length2-dem.getX(),loc.getBlockX() - bot.getBlockX());
z = Math.min(length2-dem.getZ(),loc.getBlockZ() - bot.getBlockZ());
}
else {
x = 0;
z = 0;
}
final World w = plot2.getWorld();
final DataCollection[] b = schematic.getBlockCollection();
int sy = w.getHighestBlockYAt(bot.getBlockX(), bot.getBlockZ());
final Location l1 = bot.add(0, sy-1, 0);
final int WIDTH = schematic.getSchematicDimension().getX();
final int LENGTH = schematic.getSchematicDimension().getZ();
final int blen = b.length-1;
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
boolean result = false;
while (!result) {
int start = counter*5000;
if (start>blen) {
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
if (PlotHelper.canSetFast) {
SetBlockFast.update(plr);
}
running = false;
Bukkit.getScheduler().cancelTask(task);
return;
}
int end = Math.min(start+5000,blen);
result = SchematicHandler.pastePart(w, b, l1, x, z, start, end, WIDTH, LENGTH);
counter++;
}
}
}, 1, 1);
}
});
break;
case "test":
if (plr==null) {
PlotMain.sendConsoleSenderMessage(C.IS_CONSOLE); PlotMain.sendConsoleSenderMessage(C.IS_CONSOLE);
return false; return false;
} }
if (!PlotMain.hasPermission(plr, "plots.schematic.save")) { if (!PlotMain.hasPermission(plr, "plots.schematic.test")) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test"); PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test");
return false; return false;
} }
if (args.length < 2) { if (args.length < 2) {
sendMessage(plr, C.SCHEMATIC_MISSING_ARG); sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
break; break;
} }
file = args[1]; file = args[1];
schematic = SchematicHandler.getSchematic(file); schematic = SchematicHandler.getSchematic(file);
if (schematic == null) { if (schematic == null) {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent"); sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
break; break;
} }
int l1 = schematic.getSchematicDimension().getX(); int l1 = schematic.getSchematicDimension().getX();
int l2 = schematic.getSchematicDimension().getZ(); int l2 = schematic.getSchematicDimension().getZ();
Plot plot = PlayerFunctions.getCurrentPlot(plr); Plot plot = PlayerFunctions.getCurrentPlot(plr);
int length = PlotHelper.getPlotWidth(plr.getWorld(), plot.id); int length = PlotHelper.getPlotWidth(plr.getWorld(), plot.id);
if ((l1 != length) || (l2 != length)) { if ((l1 < length) || (l2 < length)) {
sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length)); sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
break; break;
} }
sendMessage(plr, C.SCHEMATIC_VALID); sendMessage(plr, C.SCHEMATIC_VALID);
break; break;
case "saveall": case "saveall":
case "exportall": case "exportall":
if (plr!=null) { if (plr!=null) {
PlayerFunctions.sendMessage(plr, C.NOT_CONSOLE); PlayerFunctions.sendMessage(plr, C.NOT_CONSOLE);
return false; return false;
} }
if (args.length!=2) { if (args.length!=2) {
PlayerFunctions.sendMessage(plr, "&cNeed world arg. Use &7/plots sch exportall <world>"); PlayerFunctions.sendMessage(plr, "&cNeed world arg. Use &7/plots sch exportall <world>");
return false; return false;
} }
HashMap<PlotId, Plot> plotmap = PlotMain.getPlots(args[1]); HashMap<PlotId, Plot> plotmap = PlotMain.getPlots(args[1]);
if (plotmap==null || plotmap.size()==0) { if (plotmap==null || plotmap.size()==0) {
PlayerFunctions.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall <world>"); PlayerFunctions.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall <world>");
return false; return false;
} }
if (running) { if (running) {
PlayerFunctions.sendMessage(plr, "&cTask is already running."); PlayerFunctions.sendMessage(plr, "&cTask is already running.");
return false; return false;
} }
PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while."); PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while.");
PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &7Found &c"+plotmap.size()+"&7 plots..."); PlotMain.sendConsoleSenderMessage("&3PlotSquared&8->&3Schemaitc&8: &7Found &c"+plotmap.size()+"&7 plots...");
final World worldObj = Bukkit.getWorld(args[1]); final World worldObj = Bukkit.getWorld(args[1]);
final String worldname = Bukkit.getWorld(args[1]).getName(); final String worldname = Bukkit.getWorld(args[1]).getName();
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"); final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
this.plots = plotmap.values().toArray(new Plot[0]); this.plots = plotmap.values().toArray(new Plot[0]);
this.running = true; this.running = true;
this.counter = 0; this.counter = 0;
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
if (counter>=plots.length) { if (counter>=plots.length) {
@ -159,56 +227,56 @@ public class Schematic extends SubCommand {
} }
counter++; counter++;
} }
}, 20, 20); }, 20, 20);
break; break;
case "export": case "export":
case "save": case "save":
if (!PlotMain.hasPermission(plr, "plots.schematic.save")) { if (!PlotMain.hasPermission(plr, "plots.schematic.save")) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save"); PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save");
return false; return false;
} }
if (running) { if (running) {
PlayerFunctions.sendMessage(plr, "&cTask is already running."); PlayerFunctions.sendMessage(plr, "&cTask is already running.");
return false; return false;
} }
final String world; final String world;
final Plot p2; final Plot p2;
if (plr!=null) { if (plr!=null) {
if(!PlayerFunctions.isInPlot(plr)) { if(!PlayerFunctions.isInPlot(plr)) {
sendMessage(plr, C.NOT_IN_PLOT); sendMessage(plr, C.NOT_IN_PLOT);
return false; return false;
} }
Plot myplot = PlayerFunctions.getCurrentPlot(plr); Plot myplot = PlayerFunctions.getCurrentPlot(plr);
if(!myplot.hasRights(plr)) { if(!myplot.hasRights(plr)) {
sendMessage(plr, C.NO_PLOT_PERMS); sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
} }
p2 = myplot; p2 = myplot;
world = plr.getWorld().getName(); world = plr.getWorld().getName();
} }
else { else {
if (args.length==3) { if (args.length==3) {
try { try {
world = args[0]; world = args[0];
String[] split = args[2].split(";"); String[] split = args[2].split(";");
PlotId i = new PlotId(Integer.parseInt(split[0]),Integer.parseInt(split[1])); PlotId i = new PlotId(Integer.parseInt(split[0]),Integer.parseInt(split[1]));
if (PlotMain.getPlots(world)==null || PlotMain.getPlots(world).get(i) == null) { if (PlotMain.getPlots(world)==null || PlotMain.getPlots(world).get(i) == null) {
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>"); PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
return false; return false;
} }
p2 = PlotMain.getPlots(world).get(i); p2 = PlotMain.getPlots(world).get(i);
} }
catch (Exception e) { catch (Exception e) {
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>"); PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
return false; return false;
} }
} }
else { else {
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>"); PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
return false; return false;
} }
} }
final Plugin plugin2 = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"); final Plugin plugin2 = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
@ -250,11 +318,11 @@ public class Schematic extends SubCommand {
counter++; counter++;
} }
}, 20, 60); }, 20, 60);
break; break;
default: default:
sendMessage(plr, C.SCHEMATIC_MISSING_ARG); sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
break; break;
} }
return true; return true;
} }
} }

View file

@ -1034,7 +1034,7 @@ public class SQLManager extends AbstractDB {
public void run() { public void run() {
try { try {
PreparedStatement statement = PreparedStatement statement =
connection.prepareStatement("DELETE FROM `"+PREFIX+"+plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); connection.prepareStatement("DELETE FROM `"+PREFIX+"plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
statement.setInt(1, getId(world, plot.id)); statement.setInt(1, getId(world, plot.id));
statement.setString(2, player.getUniqueId().toString()); statement.setString(2, player.getUniqueId().toString());
statement.executeUpdate(); statement.executeUpdate();

View file

@ -6,8 +6,12 @@ package com.intellectualcrafters.plot.database.sqlobjects;
public class PlotTable extends SQLTable { public class PlotTable extends SQLTable {
public PlotTable() { public PlotTable() {
super("plots"); super("plots", name, fields);
} }
public @Override
public void create() {
// TODO Auto-generated method stub
}
} }

View file

@ -70,7 +70,13 @@ public class WorldGenerator extends PlotGenerator {
} }
return manager; return manager;
} }
/**
* Allow spawning everywhere
*/
@Override
public boolean canSpawn(World world, int x, int z) {
return true;
}
/** /**
* Get a new plotworld class For square plots you can use the * Get a new plotworld class For square plots you can use the
* DefaultPlotWorld class which comes with PlotSquared * DefaultPlotWorld class which comes with PlotSquared

View file

@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -25,6 +26,7 @@ import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
/** /**
* @author Citymonstret * @author Citymonstret
@ -37,6 +39,28 @@ public class WorldEditListener implements Listener {
private boolean isPlotWorld(Location l) { private boolean isPlotWorld(Location l) {
return (PlotMain.isPlotWorld(l.getWorld())); return (PlotMain.isPlotWorld(l.getWorld()));
} }
@EventHandler(
priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onDelete(PlotDeleteEvent e) {
String world = e.getWorld();
PlotId id = e.getPlotId();
Plot plot = PlotMain.getPlots(world).get(id);
if (plot==null || plot.owner == null) {
return;
}
Player player = Bukkit.getPlayer(plot.owner);
if (player == null) {
return;
}
if (!world.equals(player.getWorld().getName())) {
return;
}
if (PlotMain.hasPermission(player, "plots.worldedit.bypass")) {
return;
}
PWE.setNoMask(player);
}
@EventHandler( @EventHandler(
priority = EventPriority.LOWEST, ignoreCancelled = true) priority = EventPriority.LOWEST, ignoreCancelled = true)