mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
MegaPlots mostly done now
Fixed up methods throwing errors when not merged properly Plot merge command now merges plots as far as the plugin is concerned - Roads are not removed between the plots - No way to unlink a merged plot Added plot delete command (permission: plots.clear.delete) Modified plot clear to simply clear the terrain.
This commit is contained in:
parent
eb7106eb76
commit
c6859a5d50
@ -53,7 +53,7 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Permission
|
* Permission
|
||||||
*/
|
*/
|
||||||
NO_PERMISSION("&cYou don't have the permissions required to use this command."), NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"), CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."), YOU_BE_DENIED("&cYou are not allowed to enter this plot"), NO_PERM_MERGE("&cYou must be the owner of all plots taking place in the merge."),
|
NO_PERMISSION("&cYou don't have the permissions required to use this command."), NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"), CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."), YOU_BE_DENIED("&cYou are not allowed to enter this plot"), NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"), UNLINK_REQUIRED("&cAn unlink is required to do this."),
|
||||||
/*
|
/*
|
||||||
* Commands
|
* Commands
|
||||||
*/
|
*/
|
||||||
@ -65,7 +65,7 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Block List
|
* Block List
|
||||||
*/
|
*/
|
||||||
NOT_VALID_BLOCK_LIST_HEADER("&cThat's not a valid block. Valid blocks are:\\n"), BLOCK_LIST_ITEM(" &6%mat%&c,"),
|
NOT_VALID_BLOCK_LIST_HEADER("&cThat's not a valid block. Valid blocks are:\\n"), BLOCK_LIST_ITEM(" &6%mat%&c,"), BLOCK_LIST_SEPARATER("&6,&c "),
|
||||||
/*
|
/*
|
||||||
* Biome
|
* Biome
|
||||||
*/
|
*/
|
||||||
|
@ -15,6 +15,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -56,27 +57,10 @@ public class PlayerFunctions {
|
|||||||
return (lp - cu) > 30l;
|
return (lp - cu) > 30l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<PlotId> getPlotSelectionIds(World world, PlotId pos1, PlotId pos2) {
|
public static ArrayList<PlotId> getPlotSelectionIds(World world, PlotId pos1, PlotId pos2) {
|
||||||
Set<PlotId> myplots = new HashSet<PlotId>();
|
ArrayList<PlotId> myplots = new ArrayList<PlotId>();
|
||||||
int sx, ex, sy, ey;
|
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
if (pos1.x > pos2.x) {
|
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||||
sx = pos2.x;
|
|
||||||
ex = pos1.x;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sx = pos1.x;
|
|
||||||
ex = pos2.x;
|
|
||||||
}
|
|
||||||
if (pos1.y > pos2.y) {
|
|
||||||
sy = pos2.y;
|
|
||||||
ey = pos1.y;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sy = pos1.y;
|
|
||||||
ey = pos2.y;
|
|
||||||
}
|
|
||||||
for (int x = sx; x <= ex; x++) {
|
|
||||||
for (int y = sy; x <= ey; x++) {
|
|
||||||
myplots.add(new PlotId(x,y));
|
myplots.add(new PlotId(x,y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +69,7 @@ public class PlayerFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Plot getBottomPlot(World world, Plot plot) {
|
public static Plot getBottomPlot(World world, Plot plot) {
|
||||||
if (plot.settings.getMerged(2)) {
|
if (plot.settings.getMerged(0)) {
|
||||||
return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y-1)));
|
return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y-1)));
|
||||||
}
|
}
|
||||||
if (plot.settings.getMerged(3)) {
|
if (plot.settings.getMerged(3)) {
|
||||||
@ -94,11 +78,11 @@ public class PlayerFunctions {
|
|||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
public static Plot getTopPlot(World world, Plot plot) {
|
public static Plot getTopPlot(World world, Plot plot) {
|
||||||
if (plot.settings.getMerged(0)) {
|
if (plot.settings.getMerged(2)) {
|
||||||
return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y-1)));
|
return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y+1)));
|
||||||
}
|
}
|
||||||
if (plot.settings.getMerged(1)) {
|
if (plot.settings.getMerged(1)) {
|
||||||
return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x-1, plot.id.y)));
|
return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x+1, plot.id.y)));
|
||||||
}
|
}
|
||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
@ -107,6 +91,46 @@ public class PlayerFunctions {
|
|||||||
* @param loc
|
* @param loc
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
public static PlotId getPlotAbs(Location loc) {
|
||||||
|
int x = loc.getBlockX();
|
||||||
|
int z = loc.getBlockZ();
|
||||||
|
|
||||||
|
String world = loc.getWorld().getName();
|
||||||
|
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
|
int size = plotworld.PLOT_WIDTH + plotworld.ROAD_WIDTH;
|
||||||
|
int pathWidthLower;
|
||||||
|
if ((plotworld.ROAD_WIDTH % 2) == 0) {
|
||||||
|
pathWidthLower = (int) (Math.floor(plotworld.ROAD_WIDTH / 2)-1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pathWidthLower = (int) Math.floor(plotworld.ROAD_WIDTH / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int dx = x/size;
|
||||||
|
int dz = z/size;
|
||||||
|
|
||||||
|
if (x<0) {
|
||||||
|
dx--;
|
||||||
|
x+=((-dx) * size);
|
||||||
|
}
|
||||||
|
if (z<0) {
|
||||||
|
dz--;
|
||||||
|
z+=((-dz) * size);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rx = (x)%size;
|
||||||
|
int rz = (z)%size;
|
||||||
|
|
||||||
|
int end = pathWidthLower+plotworld.PLOT_WIDTH;
|
||||||
|
boolean northSouth = rz<=pathWidthLower || rz>pathWidthLower+plotworld.PLOT_WIDTH;
|
||||||
|
boolean eastWest = rx<=pathWidthLower || rx>end;
|
||||||
|
|
||||||
|
if (northSouth || eastWest) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new PlotId(dx+1,dz+1);
|
||||||
|
}
|
||||||
|
|
||||||
public static PlotId getPlot(Location loc) {
|
public static PlotId getPlot(Location loc) {
|
||||||
int x = loc.getBlockX();
|
int x = loc.getBlockX();
|
||||||
int z = loc.getBlockZ();
|
int z = loc.getBlockZ();
|
||||||
@ -144,19 +168,19 @@ public class PlayerFunctions {
|
|||||||
|
|
||||||
if (northSouth && eastWest) {
|
if (northSouth && eastWest) {
|
||||||
// This means you are in the intersection
|
// This means you are in the intersection
|
||||||
PlotId id = getPlot(loc.add(plotworld.ROAD_WIDTH, 0, plotworld.ROAD_WIDTH));
|
PlotId id = getPlotAbs(loc.add(plotworld.ROAD_WIDTH, 0, plotworld.ROAD_WIDTH));
|
||||||
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||||
if (plot==null) {
|
if (plot==null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (plot.settings.getMerged(0) && plot.settings.getMerged(3)) {
|
if ((plot.settings.getMerged(0) && plot.settings.getMerged(3))) {
|
||||||
return getBottomPlot(loc.getWorld(), plot).id;
|
return getBottomPlot(loc.getWorld(), plot).id;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (northSouth) {
|
if (northSouth) {
|
||||||
// You are on a road running West to East (yeah, I named the var poorly)
|
// You are on a road running West to East (yeah, I named the var poorly)
|
||||||
PlotId id = getPlot(loc.add(0, 0, plotworld.ROAD_WIDTH));
|
PlotId id = getPlotAbs(loc.add(0, 0, plotworld.ROAD_WIDTH));
|
||||||
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||||
if (plot==null) {
|
if (plot==null) {
|
||||||
return null;
|
return null;
|
||||||
@ -168,8 +192,9 @@ public class PlayerFunctions {
|
|||||||
}
|
}
|
||||||
if (eastWest) {
|
if (eastWest) {
|
||||||
// This is the road separating an Eastern and Western plot
|
// This is the road separating an Eastern and Western plot
|
||||||
PlotId id = getPlot(loc.add(plotworld.ROAD_WIDTH, 0, 0));
|
PlotId id = getPlotAbs(loc.add(plotworld.ROAD_WIDTH, 0, 0));
|
||||||
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||||
|
System.out.print("IDS "+id);
|
||||||
if (plot==null) {
|
if (plot==null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -25,7 +26,7 @@ import java.util.*;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PlotHelper {
|
public class PlotHelper {
|
||||||
|
static boolean canSetFast;
|
||||||
static long state;
|
static long state;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,6 +39,29 @@ public class PlotHelper {
|
|||||||
return (blocks / blocks_per_second);
|
return (blocks / blocks_per_second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges 2 plots
|
||||||
|
* <br> - Assumes the first plot parameter is lower
|
||||||
|
* <br> - Assumes neither are a Mega-plot
|
||||||
|
* <br> - Assumes plots are directly next to each other
|
||||||
|
* <br> - Does not save to DB
|
||||||
|
* <br><b>This is the only public merge method as the other ones were deemed unsafe if used incorrectly</b>
|
||||||
|
* @param world
|
||||||
|
* @param lesserPlot
|
||||||
|
* @param greaterPlot
|
||||||
|
*/
|
||||||
|
public static void mergePlot(World world, Plot lesserPlot, Plot greaterPlot) {
|
||||||
|
if (lesserPlot.id.x == greaterPlot.id.x) {
|
||||||
|
lesserPlot.settings.setMerged(2, true);
|
||||||
|
greaterPlot.settings.setMerged(0, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lesserPlot.settings.setMerged(1, true);
|
||||||
|
greaterPlot.settings.setMerged(3, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static final long nextLong() {
|
public static final long nextLong() {
|
||||||
long a = state;
|
long a = state;
|
||||||
state = xorShift64(a);
|
state = xorShift64(a);
|
||||||
@ -464,15 +488,9 @@ public class PlotHelper {
|
|||||||
*/
|
*/
|
||||||
public static void clear(final Player requester, final Plot plot) {
|
public static void clear(final Player requester, final Plot plot) {
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO unlink any adjacent plots
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
final long start = System.nanoTime();
|
final long start = System.nanoTime();
|
||||||
final PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world));
|
final PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world));
|
||||||
PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST);
|
PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST);
|
||||||
PlotHelper.removeSign(requester, plot);
|
|
||||||
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
||||||
final World world = requester.getWorld();
|
final World world = requester.getWorld();
|
||||||
final Location pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
final Location pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||||
@ -501,80 +519,12 @@ public class PlotHelper {
|
|||||||
h = (prime * h) + pos1.getBlockZ();
|
h = (prime * h) + pos1.getBlockZ();
|
||||||
state = h;
|
state = h;
|
||||||
|
|
||||||
boolean canSetFast;
|
|
||||||
try {
|
try {
|
||||||
new SetBlockFast();
|
new SetBlockFast();
|
||||||
canSetFast = true;
|
canSetFast = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
canSetFast = false;
|
canSetFast = false;
|
||||||
}
|
}
|
||||||
if (canSetFast) {
|
|
||||||
PlotMain.getMain().getServer().getScheduler().runTaskAsynchronously(PlotMain.getMain(), (new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
for (int y = 0; y < 1; y++) {
|
|
||||||
for (int x = pos1.getBlockX(); x <= pos2.getBlockX(); x++) {
|
|
||||||
for (int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) {
|
|
||||||
Block block = world.getBlockAt(x, y, z);
|
|
||||||
if (!((block.getTypeId() == 7))) {
|
|
||||||
SetBlockFast.set(world, x, y, z, 7, (byte) 7);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int y = 1; y < plotworld.PLOT_HEIGHT; y++) {
|
|
||||||
for (int x = pos1.getBlockX(); x <= pos2.getBlockX(); x++) {
|
|
||||||
for (int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) {
|
|
||||||
int i = random(filling.length);
|
|
||||||
short id = filling[i];
|
|
||||||
byte d = (byte) filling_data[i];
|
|
||||||
Block block = world.getBlockAt(x, y, z);
|
|
||||||
if (!((block.getTypeId() == id && block.getData() == d))) {
|
|
||||||
SetBlockFast.set(world, x, y, z, id, d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int y = plotworld.PLOT_HEIGHT; y < (plotworld.PLOT_HEIGHT + 1); y++) {
|
|
||||||
for (int x = pos1.getBlockX(); x <= pos2.getBlockX(); x++) {
|
|
||||||
for (int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) {
|
|
||||||
int i = random(plotfloors.length);
|
|
||||||
short id = plotfloors[i];
|
|
||||||
byte d = (byte) plotfloors_data[i];
|
|
||||||
Block block = world.getBlockAt(x, y, z);
|
|
||||||
if (!((block.getTypeId() == id && block.getData() == d))) {
|
|
||||||
SetBlockFast.set(world, x, y, z, id, d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int y = plotworld.PLOT_HEIGHT + 1; y < (world.getMaxHeight() + 1); y++) {
|
|
||||||
for (int x = pos1.getBlockX(); x <= pos2.getBlockX(); x++) {
|
|
||||||
for (int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) {
|
|
||||||
Block block = world.getBlockAt(x, y, z);
|
|
||||||
if (!((block.getTypeId() == 0))) {
|
|
||||||
SetBlockFast.set(world, x, y, z, 0, (byte) 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.nanoTime() - start) / 1000000.0)));
|
|
||||||
SetBlockFast.update(requester);
|
|
||||||
return;
|
|
||||||
} catch (Exception e) {
|
|
||||||
if(Settings.DEBUG) {
|
|
||||||
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "Debug Mode Enabled -> Throwing epic stacktrace.");
|
|
||||||
e.printStackTrace();
|
|
||||||
} else {
|
|
||||||
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "Something went wrong with plot clearing... Enable debug to get stacktraces.");
|
|
||||||
}
|
|
||||||
PlayerFunctions.sendMessage(requester, C.PREFIX.s() + "&cPlot clear failed... Trying again...");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ((pos2.getBlockX() - pos1.getBlockX()) < 16) {
|
if ((pos2.getBlockX() - pos1.getBlockX()) < 16) {
|
||||||
setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), 1, pos2.getBlockZ()), (short) 7);
|
setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), 1, pos2.getBlockZ()), (short) 7);
|
||||||
setSimpleCuboid(world, new Location(world, pos1.getBlockX(), plotworld.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), world.getMaxHeight(), pos2.getBlockZ()), (short) 0);
|
setSimpleCuboid(world, new Location(world, pos1.getBlockX(), plotworld.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX(), world.getMaxHeight(), pos2.getBlockZ()), (short) 0);
|
||||||
@ -663,11 +613,15 @@ public class PlotHelper {
|
|||||||
setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX, plotworld.PLOT_HEIGHT, plotMaxZ), filling, filling_data);
|
setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX, plotworld.PLOT_HEIGHT, plotMaxZ), filling, filling_data);
|
||||||
setCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX, plotworld.PLOT_HEIGHT + 1, plotMaxZ), plotfloors, plotfloors_data);
|
setCuboid(world, new Location(world, max.getBlockX(), plotworld.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX, plotworld.PLOT_HEIGHT + 1, plotMaxZ), plotfloors, plotfloors_data);
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(requester, "&c(depreciated) &r" + C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.nanoTime() - start) / 1000000.0)));
|
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.nanoTime() - start) / 1000000.0)));
|
||||||
|
if (canSetFast) {
|
||||||
|
SetBlockFast.update(requester);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCuboid(World world, Location pos1, Location pos2, short[] id_l, short[] d_l) {
|
public static void setCuboid(World world, Location pos1, Location pos2, short[] id_l, short[] d_l) {
|
||||||
|
if (!canSetFast) {
|
||||||
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||||
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
||||||
for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) {
|
for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) {
|
||||||
@ -682,8 +636,30 @@ public class PlotHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||||
|
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
||||||
|
for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) {
|
||||||
|
int i = random(id_l.length);
|
||||||
|
short id = id_l[i];
|
||||||
|
byte d = (byte) d_l[i];
|
||||||
|
Block block = world.getBlockAt(x, y, z);
|
||||||
|
if (!((block.getTypeId() == id) && (block.getData() == d))) {
|
||||||
|
SetBlockFast.set(world, x, y, z, id, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setSimpleCuboid(World world, Location pos1, Location pos2, short id) {
|
public static void setSimpleCuboid(World world, Location pos1, Location pos2, short id) {
|
||||||
|
if (!canSetFast) {
|
||||||
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||||
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
||||||
for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) {
|
for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) {
|
||||||
@ -695,6 +671,24 @@ public class PlotHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||||
|
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
||||||
|
for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) {
|
||||||
|
Block block = world.getBlockAt(x, y, z);
|
||||||
|
if (!((block.getTypeId() == id))) {
|
||||||
|
SetBlockFast.set(world, x, y, z, id, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setBiome(World world, Plot plot, Biome b) {
|
public static void setBiome(World world, Plot plot, Biome b) {
|
||||||
int bottomX = getPlotBottomLoc(world, plot.id).getBlockX() - 1;
|
int bottomX = getPlotBottomLoc(world, plot.id).getBlockX() - 1;
|
||||||
|
@ -87,6 +87,10 @@ public class PlotSettings {
|
|||||||
public void setMerged(boolean[] merged) {
|
public void setMerged(boolean[] merged) {
|
||||||
this.merged = merged;
|
this.merged = merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMerged(int direction, boolean merged) {
|
||||||
|
this.merged[direction] = merged;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param b
|
* @param b
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
|
|||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
|
||||||
@ -33,17 +34,16 @@ public class Clear extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
|
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if ((plot==null || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
if ((plot==null || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true);
|
PlotHelper.removeSign(plr, plot);
|
||||||
if (result) {
|
|
||||||
plot.clear(plr);
|
plot.clear(plr);
|
||||||
DBFunc.delete(plr.getWorld().getName(), plot);
|
|
||||||
} else {
|
|
||||||
PlayerFunctions.sendMessage(plr, "Plot clearing has been denied.");
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,11 @@ public enum Command {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
CLEAR("clear", "delete", new CommandPermission("plots.clear")),
|
CLEAR("clear", "clear", new CommandPermission("plots.clear")),
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
DELETE("delete", "d", new CommandPermission("plots.clear.delete")),
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) IntellectualCrafters - 2014.
|
||||||
|
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||||
|
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||||
|
*
|
||||||
|
* >> File = Clear.java
|
||||||
|
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.C;
|
||||||
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Citymonstret on 2014-08-01.
|
||||||
|
*/
|
||||||
|
public class Delete extends SubCommand {
|
||||||
|
|
||||||
|
public Delete() {
|
||||||
|
super(Command.DELETE, "Delete a plot", "delete", CommandCategory.ACTIONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(Player plr, String... args) {
|
||||||
|
if (!PlayerFunctions.isInPlot(plr)) {
|
||||||
|
PlayerFunctions.sendMessage(plr, "You're not in a plot.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
|
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ((plot==null || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true);
|
||||||
|
if (result) {
|
||||||
|
PlotHelper.removeSign(plr, plot);
|
||||||
|
plot.clear(plr);
|
||||||
|
DBFunc.delete(plr.getWorld().getName(), plot);
|
||||||
|
} else {
|
||||||
|
PlayerFunctions.sendMessage(plr, "Plot clearing has been denied.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -82,6 +82,8 @@ public class Info extends SubCommand {
|
|||||||
info = info.replaceAll("%helpers%", getPlayerList(plot.helpers));
|
info = info.replaceAll("%helpers%", getPlayerList(plot.helpers));
|
||||||
info = info.replaceAll("%denied%", getPlayerList(plot.denied));
|
info = info.replaceAll("%denied%", getPlayerList(plot.denied));
|
||||||
info = info.replaceAll("%flags%", StringUtils.join(plot.settings.getFlags(), "").length() > 0 ? StringUtils.join(plot.settings.getFlags(), ",") : "none");
|
info = info.replaceAll("%flags%", StringUtils.join(plot.settings.getFlags(), "").length() > 0 ? StringUtils.join(plot.settings.getFlags(), ",") : "none");
|
||||||
|
PlayerFunctions.sendMessage(player, PlayerFunctions.getTopPlot(player.getWorld(), plot).id.toString());
|
||||||
|
PlayerFunctions.sendMessage(player, PlayerFunctions.getBottomPlot(player.getWorld(), plot).id.toString());
|
||||||
PlayerFunctions.sendMessage(player, info);
|
PlayerFunctions.sendMessage(player, info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.PlotMain;
|
|||||||
*/
|
*/
|
||||||
public class MainCommand implements CommandExecutor {
|
public class MainCommand implements CommandExecutor {
|
||||||
|
|
||||||
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new SetOwner(), new Denied(), new Helpers(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Reload() };
|
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Reload(), new Merge() };
|
||||||
|
|
||||||
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
||||||
{
|
{
|
||||||
|
@ -9,11 +9,20 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -22,8 +31,11 @@ import com.intellectualcrafters.plot.Plot;
|
|||||||
*/
|
*/
|
||||||
public class Merge extends SubCommand {
|
public class Merge extends SubCommand {
|
||||||
|
|
||||||
|
public static String[] values = new String[] { "north", "east", "south", "west" };
|
||||||
|
public static String[] aliases = new String[] { "n", "e", "s", "w"};
|
||||||
|
|
||||||
public Merge() {
|
public Merge() {
|
||||||
super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING);
|
super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -33,7 +45,7 @@ public class Merge extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
if (!plot.hasOwner()) {
|
if (plot==null || !plot.hasOwner()) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -41,24 +53,70 @@ public class Merge extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// get the plots involved
|
if (args.length<1) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values,C.BLOCK_LIST_SEPARATER.s()));
|
||||||
// C.NO_PERM_MERGE;
|
return false;
|
||||||
|
}
|
||||||
// for each plot check if you are the owner
|
int direction = -1;
|
||||||
|
for (int i = 0; i<values.length; i++) {
|
||||||
// execute the merge
|
if (args[0].equalsIgnoreCase(values[i]) || args[0].equalsIgnoreCase(aliases[i])) {
|
||||||
|
direction = i;
|
||||||
// add methods to get plots relative to your current plot
|
break;
|
||||||
// getNorthernPlot | getEasternPlot | getSouthernPlot | getWesternPlot
|
}
|
||||||
// return mergePlot(plr, plot, false);
|
}
|
||||||
|
int direction2 = direction > 1 ? direction-2 : direction+2;
|
||||||
// merge the plots
|
if (direction==-1) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values,C.BLOCK_LIST_SEPARATER.s()));
|
||||||
return true;
|
return false;
|
||||||
|
}
|
||||||
|
World world = plr.getWorld();
|
||||||
|
PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id;
|
||||||
|
PlotId top = PlayerFunctions.getTopPlot(world, plot).id;
|
||||||
|
ArrayList<PlotId> plots;
|
||||||
|
switch (direction) {
|
||||||
|
case 0: // north = -y
|
||||||
|
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,bot.y-1), new PlotId(top.x,bot.y-1));
|
||||||
|
break;
|
||||||
|
case 1: // east = +x
|
||||||
|
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(top.x+1,bot.y), new PlotId(top.x+1,top.y));
|
||||||
|
break;
|
||||||
|
case 2: // south = +y
|
||||||
|
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,top.y+1), new PlotId(top.x,top.y+1));
|
||||||
|
break;
|
||||||
|
case 3: // west = -x
|
||||||
|
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x-1,bot.y), new PlotId(bot.x-1,top.y));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (PlotId myid:plots) {
|
||||||
|
Plot myplot = PlotMain.getPlots(world).get(myid);
|
||||||
|
if (myplot==null || !myplot.hasOwner() || !(myplot.getOwner().equals(plr.getUniqueId()))) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerFunctions.sendMessage(plr, "PLOTS HAVE BEEN MERGED");
|
||||||
|
return mergePlot(world, plr, PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,bot.y), new PlotId(top.x,top.y)), plots, direction, direction2);
|
||||||
|
}
|
||||||
|
public static boolean mergePlot(World world, Player player, ArrayList<PlotId> currentMegaPlots, ArrayList<PlotId> toMerge, int dir1, int dir2) {
|
||||||
|
for (PlotId plotid:currentMegaPlots) {
|
||||||
|
Plot plot = PlotMain.getPlots(world).get(plotid);
|
||||||
|
plot.settings.setMerged(dir1, true);
|
||||||
|
DBFunc.setMerged(world.getName(), plot, plot.settings.getMerged());
|
||||||
|
}
|
||||||
|
for (int i = 0;i < toMerge.size(); i++) {
|
||||||
|
PlotId plotid = toMerge.get(i);
|
||||||
|
Plot plot = PlotMain.getPlots(world).get(plotid);
|
||||||
|
plot.settings.setMerged(dir2, true);
|
||||||
|
if (i<toMerge.size()-1) {
|
||||||
|
PlotHelper.mergePlot(world, plot, PlotMain.getPlots(world).get(toMerge.get(i+1)));
|
||||||
|
}
|
||||||
|
DBFunc.setMerged(world.getName(), plot, plot.settings.getMerged());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean mergePlot(Player player, Plot plot, java.util.Set<Plot> plots) {
|
//TODO replace road sections
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user