dsakjldjsakljksld jdsiklsadjklsad jk

This commit is contained in:
boy0001 2015-02-20 00:01:36 +11:00
parent f20a21c1c3
commit fa822dcf29
3 changed files with 68 additions and 44 deletions

View File

@ -39,6 +39,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.ClusterManager;
import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.PlotHelper;
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
public class Auto extends SubCommand { public class Auto extends SubCommand {
public Auto() { public Auto() {
@ -163,7 +164,7 @@ public class Auto extends SubCommand {
String worldname = world.getName(); String worldname = world.getName();
PlotWorld plotworld = PlotSquared.getWorldSettings(worldname); PlotWorld plotworld = PlotSquared.getWorldSettings(worldname);
if (plotworld.TYPE == 2) { if (plotworld.TYPE == 2) {
Location loc = plr.getLocation(); Location loc = BukkitUtil.getLocation(plr);
Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); Plot plot = PlotHelper.getCurrentPlot(new com.intellectualcrafters.plot.object.Location(worldname, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
if (plot == null) { if (plot == null) {
return sendMessage(plr, C.NOT_IN_PLOT); return sendMessage(plr, C.NOT_IN_PLOT);

View File

@ -542,7 +542,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
update(location); update(location);
} }
}; };
manager.clearPlot(world, plotworld, plot, isDelete, run); manager.clearPlot(plotworld, plot, isDelete, run);
} }
/** /**
@ -555,7 +555,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
if (requester == null) { if (requester == null) {
clearAllEntities(plot.world, plot, false); clearAllEntities(plot.world, plot, false);
clear(requester, plot.world, plot, isDelete); clear(requester, plot.world, plot, isDelete);
removeSign(plot.world, plot); removeSign(plot);
return; return;
} }
if (runners.containsKey(plot)) { if (runners.containsKey(plot)) {
@ -569,72 +569,79 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
clearAllEntities(world, plot, false); clearAllEntities(world, plot, false);
clear(requester, world, plot, isDelete); clear(requester, world, plot, isDelete);
removeSign(world, plot); removeSign(plot);
} }
public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {
if (blocks.length == 1) { if (blocks.length == 1) {
setCuboid(world, pos1, pos2, blocks[0]); setSimpleCuboid(world, pos1, pos2, blocks[0]);
return; return;
} }
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ());
int[] xl = new int[length];
int[] yl = new int[length];
int[] zl = new int[length];
int[] ids = new int[length];
byte[] data = new byte[length];
int index = 0;
for (int y = pos1.getY(); y < pos2.getY(); y++) {
for (int x = pos1.getX(); x < pos2.getX(); x++) { for (int x = pos1.getX(); x < pos2.getX(); x++) {
for (int z = pos1.getZ(); z < pos2.getZ(); z++) { for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
final int i = random(blocks.length); int i = BlockManager.random(blocks.length);
final PlotBlock newblock = blocks[i]; xl[index] = x;
final Block block = world.getBlockAt(x, y, z); yl[index] = y;
if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) { zl[index] = z;
setBlock(world, x, y, z, newblock.id, newblock.data);
} PlotBlock block = blocks[i];
ids[index] = block.id;
data[index] = block.data;
index++;
} }
} }
} }
BlockManager.setBlocks(world, xl, yl, zl, ids, data);
} }
public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) {
int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ());
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { int[] xl = new int[length];
int[] yl = new int[length];
int[] zl = new int[length];
int[] ids = new int[length];
byte[] data = new byte[length];
int index = 0;
for (int y = pos1.getY(); y < pos2.getY(); y++) {
for (int x = pos1.getX(); x < pos2.getX(); x++) { for (int x = pos1.getX(); x < pos2.getX(); x++) {
for (int z = pos1.getZ(); z < pos2.getZ(); z++) { for (int z = pos1.getZ(); z < pos2.getZ(); z++) {
final Block block = world.getBlockAt(x, y, z); xl[index] = x;
if (!((block.getTypeId() == newblock.id))) { yl[index] = y;
setBlock(world, x, y, z, newblock.id, (byte) 0); zl[index] = z;
}
ids[index] = newblock.id;
data[index] = newblock.data;
index++;
} }
} }
} }
BlockManager.setBlocks(world, xl, yl, zl, ids, data);
} }
public static void setBiome(final String world, final Plot plot, final Biome b) { public static void setBiome(final String world, final Plot plot, final Biome b) {
final int bottomX = getPlotBottomLoc(world, plot.id).getX(); final int bottomX = getPlotBottomLoc(world, plot.id).getX() + 1;
final int topX = getPlotTopLoc(world, plot.id).getX() + 1; final int topX = getPlotTopLoc(world, plot.id).getX();
final int bottomZ = getPlotBottomLoc(world, plot.id).getZ(); final int bottomZ = getPlotBottomLoc(world, plot.id).getZ() + 1;
final int topZ = getPlotTopLoc(world, plot.id).getZ() + 1; final int topZ = getPlotTopLoc(world, plot.id).getZ();
BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, b);
final Block block = world.getBlockAt(getPlotBottomLoc(world, plot.id).add(1, 1, 1));
final Biome biome = block.getBiome();
if (biome.equals(b)) {
return;
}
for (int x = bottomX; x <= topX; x++) {
for (int z = bottomZ; z <= topZ; z++) {
final Block blk = world.getBlockAt(x, 0, z);
final Biome c = blk.getBiome();
if (c.equals(b)) {
x += 15;
continue;
}
blk.setBiome(b);
}
}
} }
public static int getHeighestBlock(final String world, final int x, final int z) { public static int getHeighestBlock(final String world, final int x, final int z) {
boolean safe = false; boolean safe = false;
int id; int id;
for (int i = 1; i < world.getMaxHeight(); i++) { for (int i = 1; i < world.getMaxHeight(); i++) {
@ -666,7 +673,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
final Location top = getPlotTopLoc(w, plotid); final Location top = getPlotTopLoc(w, plotid);
final int x = ((top.getX() - bot.getX())/2) + bot.getX(); final int x = ((top.getX() - bot.getX())/2) + bot.getX();
final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ(); final int z = ((top.getZ() - bot.getZ())/2) + bot.getZ();
final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotSquared.getWorldSettings(w), plot).getBlockY()); final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(w, PlotSquared.getWorldSettings(w), plot).getY());
return new Location(w, x, y, z); return new Location(w, x, y, z);
} }
else { else {

View File

@ -8,6 +8,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
@ -86,6 +87,21 @@ public class BukkitUtil extends BlockManager {
} }
} }
public static void setBiome(String worldname, int pos1_x, int pos1_z, int pos2_x, int pos2_z, Biome b) {
World world = getWorld(worldname);
for (int x = pos1_x; x<= pos2_x; x++) {
for (int z = pos1_z; z<= pos2_z; z++) {
final Block blk = world.getBlockAt(x, 0, z);
final Biome c = blk.getBiome();
if (c.equals(b)) {
x += 15;
continue;
}
blk.setBiome(b);
}
}
}
public static PlotBlock getBlock(Location loc) { public static PlotBlock getBlock(Location loc) {
World world = getWorld(loc.getWorld()); World world = getWorld(loc.getWorld());
Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ()); Block block = world.getBlockAt(loc.getX(), loc.getY(), loc.getZ());