mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
0f01ff1b7b
@ -108,11 +108,14 @@ import com.intellectualcrafters.plot.util.ExpireManager;
|
|||||||
import com.intellectualcrafters.plot.util.Lag;
|
import com.intellectualcrafters.plot.util.Lag;
|
||||||
import com.intellectualcrafters.plot.util.Logger;
|
import com.intellectualcrafters.plot.util.Logger;
|
||||||
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
||||||
|
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||||
import com.intellectualcrafters.plot.util.Metrics;
|
import com.intellectualcrafters.plot.util.Metrics;
|
||||||
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.SendChunk;
|
import com.intellectualcrafters.plot.util.SendChunk;
|
||||||
import com.intellectualcrafters.plot.util.SetBlockFast;
|
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||||
|
import com.intellectualcrafters.plot.util.SetBlockFast_1_8;
|
||||||
|
import com.intellectualcrafters.plot.util.SetBlockSlow;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||||
@ -1587,13 +1590,22 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
// Test for SetBlockFast
|
// Test for SetBlockFast
|
||||||
{
|
{
|
||||||
|
if (checkVersion(1, 8, 0)) {
|
||||||
try {
|
try {
|
||||||
new SetBlockFast();
|
AbstractSetBlock.setBlockManager = new SetBlockFast_1_8();
|
||||||
PlotHelper.canSetFast = true;
|
}
|
||||||
} catch (final Throwable e) {
|
catch (Exception e) {
|
||||||
PlotHelper.canSetFast = false;
|
e.printStackTrace();
|
||||||
|
AbstractSetBlock.setBlockManager = new SetBlockSlow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
AbstractSetBlock.setBlockManager = new SetBlockFast();
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
AbstractSetBlock.setBlockManager = new SetBlockSlow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new SendChunk();
|
new SendChunk();
|
||||||
PlotHelper.canSendChunk = true;
|
PlotHelper.canSendChunk = true;
|
||||||
|
@ -32,6 +32,7 @@ import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
|||||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||||
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.SchematicHandler;
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
@ -83,9 +84,7 @@ public class Claim extends SubCommand {
|
|||||||
final HybridPlotWorld pW = (HybridPlotWorld) world;
|
final HybridPlotWorld pW = (HybridPlotWorld) world;
|
||||||
if (!(pW.CLAIMED_WALL_BLOCK.equals(pW.WALL_BLOCK))) {
|
if (!(pW.CLAIMED_WALL_BLOCK.equals(pW.WALL_BLOCK))) {
|
||||||
PlotMain.getPlotManager(plot.getWorld()).setWall(plot.getWorld(), world, plot.getId(), pW.CLAIMED_WALL_BLOCK);
|
PlotMain.getPlotManager(plot.getWorld()).setWall(plot.getWorld(), world, plot.getId(), pW.CLAIMED_WALL_BLOCK);
|
||||||
if (PlotHelper.canSetFast) {
|
PlotHelper.update(player);
|
||||||
SetBlockFast.update(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,9 @@ import com.intellectualcrafters.plot.config.C;
|
|||||||
import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
||||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||||
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.util.SetBlockFast;
|
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||||
|
|
||||||
public class CreateRoadSchematic extends SubCommand {
|
public class CreateRoadSchematic extends SubCommand {
|
||||||
@ -54,8 +56,7 @@ public class CreateRoadSchematic extends SubCommand {
|
|||||||
HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(player.getWorld());
|
HybridPlotManager manager = (HybridPlotManager) PlotMain.getPlotManager(player.getWorld());
|
||||||
|
|
||||||
manager.setupRoadSchematic(plot);
|
manager.setupRoadSchematic(plot);
|
||||||
SetBlockFast.update(player);
|
PlotHelper.update(player);
|
||||||
|
|
||||||
PlayerFunctions.sendMessage(player, "&6Saved new road schematic");
|
PlayerFunctions.sendMessage(player, "&6Saved new road schematic");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -36,6 +36,7 @@ import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
|||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||||
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.SetBlockFast;
|
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||||
@ -178,10 +179,7 @@ public class Merge extends SubCommand {
|
|||||||
PlotHelper.mergePlots(world, plots);
|
PlotHelper.mergePlots(world, plots);
|
||||||
|
|
||||||
PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot);
|
PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot);
|
||||||
|
PlotHelper.update(plr);
|
||||||
if (PlotHelper.canSetFast) {
|
|
||||||
SetBlockFast.update(plr);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import com.intellectualcrafters.plot.config.C;
|
|||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||||
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.SchematicHandler;
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
@ -140,9 +141,7 @@ public class Schematic extends SubCommand {
|
|||||||
final int start = Schematic.this.counter * 5000;
|
final int start = Schematic.this.counter * 5000;
|
||||||
if (start > blen) {
|
if (start > blen) {
|
||||||
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
|
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
|
||||||
if (PlotHelper.canSetFast) {
|
PlotHelper.update(plr);
|
||||||
SetBlockFast.update(plr);
|
|
||||||
}
|
|
||||||
Schematic.this.running = false;
|
Schematic.this.running = false;
|
||||||
Bukkit.getScheduler().cancelTask(Schematic.this.task);
|
Bukkit.getScheduler().cancelTask(Schematic.this.task);
|
||||||
return;
|
return;
|
||||||
|
@ -27,10 +27,12 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
|||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotSelection;
|
import com.intellectualcrafters.plot.object.PlotSelection;
|
||||||
|
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||||
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.SetBlockFast;
|
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -93,11 +95,7 @@ public class Swap extends SubCommand {
|
|||||||
// TODO Requires testing!!
|
// TODO Requires testing!!
|
||||||
|
|
||||||
PlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS);
|
PlayerFunctions.sendMessage(plr, C.SWAP_SUCCESS);
|
||||||
|
PlotHelper.update(plr);
|
||||||
if (PlotHelper.canSetFast) {
|
|
||||||
SetBlockFast.update(plr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||||
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.SetBlockFast;
|
import com.intellectualcrafters.plot.util.SetBlockFast;
|
||||||
@ -70,9 +71,7 @@ public class Unlink extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (PlotHelper.canSetFast) {
|
PlotHelper.update(plr);
|
||||||
SetBlockFast.update(plr);
|
|
||||||
}
|
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
// execute(final Player plr, final String... args) {
|
// execute(final Player plr, final String... args) {
|
||||||
try {
|
try {
|
||||||
|
@ -177,9 +177,7 @@ public class AugmentedPopulator extends BlockPopulator {
|
|||||||
if (p && manager.getPlotIdAbs(plotworld, new Location(world, xx, 0, zz)) != null) {
|
if (p && manager.getPlotIdAbs(plotworld, new Location(world, xx, 0, zz)) != null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PlotBlock plotblock = new PlotBlock((short) blockInfo.id, (byte) 0 );
|
PlotHelper.setBlock(world, xx, blockInfo.y, zz, blockInfo.id, (byte) 0);
|
||||||
Block block = world.getBlockAt(xx, blockInfo.y, zz);
|
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (BlockPopulator populator : generator.getDefaultPopulators(world)) {
|
for (BlockPopulator populator : generator.getDefaultPopulators(world)) {
|
||||||
|
@ -42,6 +42,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
||||||
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.SchematicHandler;
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
@ -191,13 +192,15 @@ import com.intellectualcrafters.plot.util.SendChunk;
|
|||||||
chunks.add(chunk);
|
chunks.add(chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ArrayList<Chunk> chunks2 = new ArrayList<>();
|
||||||
for (int x = sx; x < sx + 16; x++) {
|
for (int x = sx; x < sx + 16; x++) {
|
||||||
for (int z = sz; z < sz + 16; z++) {
|
for (int z = sz; z < sz + 16; z++) {
|
||||||
Chunk chunk = world.getChunkAt(x, z);
|
Chunk chunk = world.getChunkAt(x, z);
|
||||||
|
chunks2.add(chunk);
|
||||||
regenerateRoad(chunk);
|
regenerateRoad(chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
AbstractSetBlock.setBlockManager.update(chunks2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean scheduleRoadUpdate(final World world) {
|
public boolean scheduleRoadUpdate(final World world) {
|
||||||
@ -343,17 +346,13 @@ import com.intellectualcrafters.plot.util.SendChunk;
|
|||||||
ChunkLoc loc = new ChunkLoc(absX, absZ);
|
ChunkLoc loc = new ChunkLoc(absX, absZ);
|
||||||
HashMap<Short, Short> blocks = plotworld.G_SCH.get(loc);
|
HashMap<Short, Short> blocks = plotworld.G_SCH.get(loc);
|
||||||
for (short y = (short) (plotworld.ROAD_HEIGHT + 1); y <= plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT; y++) {
|
for (short y = (short) (plotworld.ROAD_HEIGHT + 1); y <= plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT; y++) {
|
||||||
Block block = world.getBlockAt(x + X, y, z + Z);
|
PlotHelper.setBlock(world, x + X, sy + y, z + Z, 0, (byte) 0);
|
||||||
PlotBlock plotBlock = new PlotBlock((short) 0, (byte) 0);
|
|
||||||
PlotHelper.setBlock(block, plotBlock);
|
|
||||||
}
|
}
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
HashMap<Short, Byte> datas = plotworld.G_SCH_DATA.get(loc);
|
HashMap<Short, Byte> datas = plotworld.G_SCH_DATA.get(loc);
|
||||||
if (datas == null) {
|
if (datas == null) {
|
||||||
for (Short y : blocks.keySet()) {
|
for (Short y : blocks.keySet()) {
|
||||||
Block block = world.getBlockAt(x + X, sy + y, z + Z);
|
PlotHelper.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), (byte) 0);
|
||||||
PlotBlock plotBlock = new PlotBlock(blocks.get(y), (byte) 0);
|
|
||||||
PlotHelper.setBlock(block, plotBlock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -362,26 +361,13 @@ import com.intellectualcrafters.plot.util.SendChunk;
|
|||||||
if (data == null) {
|
if (data == null) {
|
||||||
data = 0;
|
data = 0;
|
||||||
}
|
}
|
||||||
Block block = world.getBlockAt(x + X, sy + y, z + Z);
|
PlotHelper.setBlock(world, x + X, sy + y, z + Z, blocks.get(y), data);
|
||||||
PlotBlock plotBlock = new PlotBlock(blocks.get(y), data);
|
|
||||||
PlotHelper.setBlock(block, plotBlock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlotHelper.canSetFast) {
|
|
||||||
if (PlotHelper.canSendChunk) {
|
|
||||||
ArrayList<Chunk> chunks = new ArrayList<>();
|
|
||||||
chunks.add(chunk);
|
|
||||||
SendChunk.sendChunk(chunks);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
world.refreshChunk(chunk.getX(), chunk.getZ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -963,37 +949,30 @@ import com.intellectualcrafters.plot.util.SendChunk;
|
|||||||
final Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
final Location top = PlotHelper.getPlotTopLoc(w, plotid);
|
||||||
|
|
||||||
int x, z;
|
int x, z;
|
||||||
|
|
||||||
Block block;
|
|
||||||
|
|
||||||
z = bottom.getBlockZ();
|
z = bottom.getBlockZ();
|
||||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
block = w.getBlockAt(x, y, z);
|
PlotHelper.setBlock(w, x, y, z, plotblock.id, plotblock.data);
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x = top.getBlockX() + 1;
|
x = top.getBlockX() + 1;
|
||||||
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
block = w.getBlockAt(x, y, z);
|
PlotHelper.setBlock(w, x, y, z, plotblock.id, plotblock.data);
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
z = top.getBlockZ() + 1;
|
z = top.getBlockZ() + 1;
|
||||||
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
block = w.getBlockAt(x, y, z);
|
PlotHelper.setBlock(w, x, y, z, plotblock.id, plotblock.data);
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x = bottom.getBlockX();
|
x = bottom.getBlockX();
|
||||||
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
block = w.getBlockAt(x, y, z);
|
PlotHelper.setBlock(w, x, y, z, plotblock.id, plotblock.data);
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1010,26 +989,21 @@ import com.intellectualcrafters.plot.util.SendChunk;
|
|||||||
|
|
||||||
int x, z;
|
int x, z;
|
||||||
|
|
||||||
Block block;
|
|
||||||
z = bottom.getBlockZ();
|
z = bottom.getBlockZ();
|
||||||
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
for (x = bottom.getBlockX(); x < (top.getBlockX() + 1); x++) {
|
||||||
block = w.getBlockAt(x, dpw.WALL_HEIGHT + 1, z);
|
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, plotblock.id, plotblock.data);
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
}
|
||||||
x = top.getBlockX() + 1;
|
x = top.getBlockX() + 1;
|
||||||
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
for (z = bottom.getBlockZ(); z < (top.getBlockZ() + 1); z++) {
|
||||||
block = w.getBlockAt(x, dpw.WALL_HEIGHT + 1, z);
|
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, plotblock.id, plotblock.data);
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
}
|
||||||
z = top.getBlockZ() + 1;
|
z = top.getBlockZ() + 1;
|
||||||
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
for (x = top.getBlockX() + 1; x > (bottom.getBlockX() - 1); x--) {
|
||||||
block = w.getBlockAt(x, dpw.WALL_HEIGHT + 1, z);
|
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, plotblock.id, plotblock.data);
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
}
|
||||||
x = bottom.getBlockX();
|
x = bottom.getBlockX();
|
||||||
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
for (z = top.getBlockZ() + 1; z > (bottom.getBlockZ() - 1); z--) {
|
||||||
block = w.getBlockAt(x, dpw.WALL_HEIGHT + 1, z);
|
PlotHelper.setBlock(w, x, dpw.WALL_HEIGHT + 1, z, plotblock.id, plotblock.data);
|
||||||
PlotHelper.setBlock(block, plotblock);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1246,9 +1220,7 @@ import com.intellectualcrafters.plot.util.SendChunk;
|
|||||||
HashMap<Short, Byte> datas = hpw.G_SCH_DATA.get(loc);
|
HashMap<Short, Byte> datas = hpw.G_SCH_DATA.get(loc);
|
||||||
if (datas == null) {
|
if (datas == null) {
|
||||||
for (Short y : blocks.keySet()) {
|
for (Short y : blocks.keySet()) {
|
||||||
Block block = world.getBlockAt(sx + loc.x, sy + y, sz + loc.z);
|
PlotHelper.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), (byte) 0);
|
||||||
PlotBlock plotBlock = new PlotBlock(blocks.get(y), (byte) 0);
|
|
||||||
PlotHelper.setBlock(block, plotBlock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1257,9 +1229,7 @@ import com.intellectualcrafters.plot.util.SendChunk;
|
|||||||
if (data == null) {
|
if (data == null) {
|
||||||
data = 0;
|
data = 0;
|
||||||
}
|
}
|
||||||
Block block = world.getBlockAt(sx + loc.x, sy + y, sz + loc.z);
|
PlotHelper.setBlock(world, sx + loc.x, sy + y, sz + loc.z, blocks.get(y), data);
|
||||||
PlotBlock plotBlock = new PlotBlock(blocks.get(y), data);
|
|
||||||
PlotHelper.setBlock(block, plotBlock);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ public class HybridPlotWorld extends PlotWorld {
|
|||||||
this.ROAD_SCHEMATIC_ENABLED = true;
|
this.ROAD_SCHEMATIC_ENABLED = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRotate(short id) {
|
public static boolean isRotate(short id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 23:
|
case 23:
|
||||||
return true;
|
return true;
|
||||||
@ -424,17 +424,18 @@ public class HybridPlotWorld extends PlotWorld {
|
|||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
x += this.SIZE;
|
x += this.SIZE;
|
||||||
}
|
}
|
||||||
if (rotate && isRotate(id)) {
|
|
||||||
data = (byte) ((data + 2) % 4);
|
|
||||||
}
|
|
||||||
ChunkLoc loc = new ChunkLoc(x, z);
|
ChunkLoc loc = new ChunkLoc(x, z);
|
||||||
if (!this.G_SCH.containsKey(loc)) {
|
if (!this.G_SCH.containsKey(loc)) {
|
||||||
this.G_SCH.put(loc, new HashMap<Short, Short>());
|
this.G_SCH.put(loc, new HashMap<Short, Short>());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.G_SCH.get(loc).put(y, id);
|
this.G_SCH.get(loc).put(y, id);
|
||||||
|
if (isRotate(id)) {
|
||||||
if (data == 0) {
|
if (rotate) {
|
||||||
|
data = (byte) ((data + 2) % 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (data == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.G_SCH_DATA.containsKey(loc)) {
|
if (!this.G_SCH_DATA.containsKey(loc)) {
|
||||||
|
@ -78,13 +78,7 @@ import com.intellectualcrafters.plot.util.SetBlockFast;
|
|||||||
final Location bot2 = PlotHelper.getPlotBottomLocAbs(world, id2).add(1, 0, 1);
|
final Location bot2 = PlotHelper.getPlotBottomLocAbs(world, id2).add(1, 0, 1);
|
||||||
final Location bot1 = PlotHelper.getPlotBottomLocAbs(world, id1).add(1, 0, 1);
|
final Location bot1 = PlotHelper.getPlotBottomLocAbs(world, id1).add(1, 0, 1);
|
||||||
final Location top1 = PlotHelper.getPlotTopLocAbs(world, id1);
|
final Location top1 = PlotHelper.getPlotTopLocAbs(world, id1);
|
||||||
|
final int minX = bot1.getBlockX(), maxX = top1.getBlockX(), minZ = bot1.getBlockZ(), maxZ = top1.getBlockZ(), minX2 = bot2.getBlockX(), minZ2 = bot2.getBlockZ();
|
||||||
final int minX = bot1.getBlockX(), maxX = top1.getBlockX(), minZ = bot1.getBlockZ(), maxZ = top1.getBlockZ(),
|
|
||||||
|
|
||||||
minX2 = bot2.getBlockX(), minZ2 = bot2.getBlockZ();
|
|
||||||
|
|
||||||
final boolean canSetFast = PlotHelper.canSetFast;
|
|
||||||
|
|
||||||
for (int x = 0; x <= (maxX - minX); x++) {
|
for (int x = 0; x <= (maxX - minX); x++) {
|
||||||
for (int z = 0; z <= (maxZ - minZ); z++) {
|
for (int z = 0; z <= (maxZ - minZ); z++) {
|
||||||
for (int y = 1; y <= world.getMaxHeight(); y++) {
|
for (int y = 1; y <= world.getMaxHeight(); y++) {
|
||||||
@ -96,25 +90,7 @@ import com.intellectualcrafters.plot.util.SetBlockFast;
|
|||||||
final BlockWrapper b2 = wrapBlock(block2);
|
final BlockWrapper b2 = wrapBlock(block2);
|
||||||
|
|
||||||
if ((b1.id != b2.id) || (b1.data != b2.data)) {
|
if ((b1.id != b2.id) || (b1.data != b2.data)) {
|
||||||
if (canSetFast) {
|
PlotHelper.setBlock(world, b1.x, b1.y, b1.z, b2.id, b2.data);
|
||||||
try {
|
|
||||||
SetBlockFast.set(world, b1.x, b1.y, b1.z, b2.id, b2.data);
|
|
||||||
SetBlockFast.set(world, b2.x, b2.y, b2.z, b1.id, b1.data);
|
|
||||||
} catch (final NoSuchMethodException e) {
|
|
||||||
PlotHelper.canSetFast = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((b1.id != b2.id) && (b1.data != b2.data)) {
|
|
||||||
block1.setTypeIdAndData(b2.id, b2.data, false);
|
|
||||||
block2.setTypeIdAndData(b1.id, b1.data, false);
|
|
||||||
} else if (b1.id != b2.id) {
|
|
||||||
block1.setTypeId(b2.id);
|
|
||||||
block2.setTypeId(b1.id);
|
|
||||||
} else {
|
|
||||||
block1.setData(b2.data);
|
|
||||||
block2.setData(b1.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
|
||||||
|
public abstract class AbstractSetBlock {
|
||||||
|
public static AbstractSetBlock setBlockManager = null;
|
||||||
|
|
||||||
|
public abstract boolean set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data);
|
||||||
|
|
||||||
|
public abstract void update(ArrayList<Chunk> chunks);
|
||||||
|
}
|
@ -60,7 +60,6 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unused", "javadoc", "deprecation"}) public class PlotHelper {
|
@SuppressWarnings({"unused", "javadoc", "deprecation"}) public class PlotHelper {
|
||||||
public final static HashMap<Plot, Integer> runners = new HashMap<>();
|
public final static HashMap<Plot, Integer> runners = new HashMap<>();
|
||||||
public static boolean canSetFast = false;
|
|
||||||
public static boolean canSendChunk = false;
|
public static boolean canSendChunk = false;
|
||||||
public static ArrayList<String> runners_p = new ArrayList<>();
|
public static ArrayList<String> runners_p = new ArrayList<>();
|
||||||
static long state = 1;
|
static long state = 1;
|
||||||
@ -339,38 +338,41 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static boolean setBlock(World world, int x, int y, int z, int id, byte data) {
|
||||||
* Set a block quickly, attempts to use NMS if possible
|
|
||||||
*
|
|
||||||
* @param block
|
|
||||||
* @param plotblock
|
|
||||||
*/
|
|
||||||
public static boolean setBlock(final Block block, final PlotBlock plotblock) {
|
|
||||||
|
|
||||||
if (canSetFast) {
|
|
||||||
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);
|
return AbstractSetBlock.setBlockManager.set(world, x, y, z, id, data);
|
||||||
return true;
|
}
|
||||||
} catch (final Throwable e) {
|
catch (Throwable e) {
|
||||||
canSetFast = false;
|
AbstractSetBlock.setBlockManager = new SetBlockSlow();
|
||||||
|
return AbstractSetBlock.setBlockManager.set(world, x, y, z, id, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
// public static boolean setBlock(final Block block, final PlotBlock plotblock) {
|
||||||
if (block.getData() == plotblock.data) {
|
// if (canSetFast) {
|
||||||
if (block.getTypeId() != plotblock.id) {
|
// if ((block.getTypeId() != plotblock.id) || (plotblock.data != block.getData())) {
|
||||||
block.setTypeId(plotblock.id);
|
// try {
|
||||||
}
|
// SetBlockFast.set(block.getWorld(), block.getX(), block.getY(), block.getZ(), plotblock.id, plotblock.data);
|
||||||
} else {
|
// return true;
|
||||||
if (block.getTypeId() == plotblock.id) {
|
// } catch (final Throwable e) {
|
||||||
block.setData(plotblock.data);
|
// canSetFast = false;
|
||||||
} else {
|
// }
|
||||||
block.setTypeIdAndData(plotblock.id, plotblock.data, false);
|
// }
|
||||||
}
|
// return false;
|
||||||
}
|
// }
|
||||||
return false;
|
// if (block.getData() == plotblock.data) {
|
||||||
}
|
// if (block.getTypeId() != plotblock.id) {
|
||||||
|
// block.setTypeId(plotblock.id);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// if (block.getTypeId() == plotblock.id) {
|
||||||
|
// block.setData(plotblock.data);
|
||||||
|
// } else {
|
||||||
|
// block.setTypeIdAndData(plotblock.id, plotblock.data, false);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adjusts a plot wall
|
* Adjusts a plot wall
|
||||||
@ -385,9 +387,19 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
|
|
||||||
manager.setWall(world, plotworld, plot.id, block);
|
manager.setWall(world, plotworld, plot.id, block);
|
||||||
if (canSetFast) {
|
update(player);
|
||||||
SetBlockFast.update(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void update(Player player) {
|
||||||
|
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||||
|
final int distance = Bukkit.getViewDistance();
|
||||||
|
for (int cx = -distance; cx < distance; cx++) {
|
||||||
|
for (int cz = -distance; cz < distance; cz++) {
|
||||||
|
final Chunk chunk = player.getWorld().getChunkAt(player.getLocation().getChunk().getX() + cx, player.getLocation().getChunk().getZ() + cz);
|
||||||
|
chunks.add(chunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AbstractSetBlock.setBlockManager.update(chunks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void autoMerge(final World world, final Plot plot, final Player player) {
|
public static void autoMerge(final World world, final Plot plot, final Player player) {
|
||||||
@ -445,9 +457,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
}
|
}
|
||||||
merge = false;
|
merge = false;
|
||||||
}
|
}
|
||||||
if (canSetFast) {
|
update(player);
|
||||||
SetBlockFast.update(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean ownsPlots(final World world, final ArrayList<PlotId> plots, final Player player, final int dir) {
|
private static boolean ownsPlots(final World world, final ArrayList<PlotId> plots, final Player player, final int dir) {
|
||||||
@ -543,9 +553,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
manager.setWallFilling(world, plotworld, plot.id, block);
|
manager.setWallFilling(world, plotworld, plot.id, block);
|
||||||
PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED);
|
PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED);
|
||||||
if (canSetFast) {
|
update(requester);
|
||||||
SetBlockFast.update(requester);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFloor(final Player requester, final Plot plot, final PlotBlock[] blocks) {
|
public static void setFloor(final Player requester, final Plot plot, final PlotBlock[] blocks) {
|
||||||
@ -559,9 +567,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED);
|
PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED);
|
||||||
manager.setFloor(world, plotworld, plot.id, blocks);
|
manager.setFloor(world, plotworld, plot.id, blocks);
|
||||||
if (canSetFast) {
|
update(requester);
|
||||||
SetBlockFast.update(requester);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int square(final int x) {
|
public static int square(final int x) {
|
||||||
@ -635,17 +641,18 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
|
|
||||||
manager.clearPlot(world, plot, isDelete);
|
manager.clearPlot(world, plot, isDelete);
|
||||||
|
|
||||||
if (canSetFast) {
|
|
||||||
final Plugin plugin = PlotMain.getMain();
|
final Plugin plugin = PlotMain.getMain();
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PlotHelper.setBiome(world, plot, Biome.FOREST);
|
PlotHelper.setBiome(world, plot, Biome.FOREST);
|
||||||
refreshPlotChunks(world, plot);
|
if (player != null && player.isOnline()) {
|
||||||
|
PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start))));
|
||||||
|
}
|
||||||
|
update(player);
|
||||||
}
|
}
|
||||||
}, 90L);
|
}, 90L);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear a plot and associated sections: [sign, entities, border]
|
* Clear a plot and associated sections: [sign, entities, border]
|
||||||
@ -676,33 +683,16 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock newblock) {
|
public static void setCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock newblock) {
|
||||||
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++) {
|
||||||
final Block block = world.getBlockAt(x, y, z);
|
final Block block = world.getBlockAt(x, y, z);
|
||||||
if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
||||||
block.setTypeIdAndData(newblock.id, newblock.data, false);
|
setBlock(world, x, y, z, newblock.id, newblock.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} 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++) {
|
|
||||||
final Block block = world.getBlockAt(x, y, z);
|
|
||||||
if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
|
||||||
SetBlockFast.set(world, x, y, z, newblock.id, newblock.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (final Exception e) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {
|
public static void setCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {
|
||||||
@ -710,7 +700,6 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
setCuboid(world, pos1, pos2, blocks[0]);
|
setCuboid(world, pos1, pos2, blocks[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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++) {
|
||||||
@ -718,59 +707,24 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
final PlotBlock newblock = blocks[i];
|
final PlotBlock newblock = blocks[i];
|
||||||
final Block block = world.getBlockAt(x, y, z);
|
final Block block = world.getBlockAt(x, y, z);
|
||||||
if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
||||||
block.setTypeIdAndData(newblock.id, newblock.data, false);
|
setBlock(world, x, y, z, newblock.id, newblock.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} 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++) {
|
|
||||||
final int i = random(blocks.length);
|
|
||||||
final PlotBlock newblock = blocks[i];
|
|
||||||
final Block block = world.getBlockAt(x, y, z);
|
|
||||||
if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
|
|
||||||
SetBlockFast.set(world, x, y, z, newblock.id, newblock.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (final Exception e) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSimpleCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock newblock) {
|
public static void setSimpleCuboid(final World world, final Location pos1, final Location pos2, final PlotBlock newblock) {
|
||||||
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++) {
|
||||||
final Block block = world.getBlockAt(x, y, z);
|
final Block block = world.getBlockAt(x, y, z);
|
||||||
if (!((block.getTypeId() == newblock.id))) {
|
if (!((block.getTypeId() == newblock.id))) {
|
||||||
block.setTypeId(newblock.id, false);
|
setBlock(world, x, y, z, newblock.id, (byte) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} 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++) {
|
|
||||||
final Block block = world.getBlockAt(x, y, z);
|
|
||||||
if (!((block.getTypeId() == newblock.id))) {
|
|
||||||
SetBlockFast.set(world, x, y, z, newblock.id, (byte) 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (final Exception e) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBiome(final World world, final Plot plot, final Biome b) {
|
public static void setBiome(final World world, final Plot plot, final Biome b) {
|
||||||
|
@ -113,11 +113,7 @@ public class SchematicHandler {
|
|||||||
// z_offset, block.tag);
|
// z_offset, block.tag);
|
||||||
// }
|
// }
|
||||||
// else {
|
// else {
|
||||||
final Block bukkitBlock = world.getBlockAt(l1.getBlockX() + x + x_offset, y + y_offset, l1.getBlockZ() + z + z_offset);
|
PlotHelper.setBlock(world, l1.getBlockX() + x + x_offset, y + y_offset, l1.getBlockZ() + z + z_offset, id, data);
|
||||||
|
|
||||||
final PlotBlock plotblock = new PlotBlock(id, data);
|
|
||||||
|
|
||||||
PlotHelper.setBlock(bukkitBlock, plotblock);
|
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,7 +346,6 @@ public class SchematicHandler {
|
|||||||
|
|
||||||
final int area = WIDTH * LENGTH;
|
final int area = WIDTH * LENGTH;
|
||||||
final int r = i % (area);
|
final int r = i % (area);
|
||||||
|
|
||||||
final int x = r % WIDTH;
|
final int x = r % WIDTH;
|
||||||
final int y = i / area;
|
final int y = i / area;
|
||||||
final int z = r / WIDTH;
|
final int z = r / WIDTH;
|
||||||
@ -358,12 +353,7 @@ public class SchematicHandler {
|
|||||||
if (y > 256) {
|
if (y > 256) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
final boolean set = PlotHelper.setBlock(world, l1.getBlockX() + x + x_offset, l1.getBlockY() + y, l1.getBlockZ() + z + z_offset, id, data);
|
||||||
final Block block = world.getBlockAt(l1.getBlockX() + x + x_offset, l1.getBlockY() + y, l1.getBlockZ() + z + z_offset);
|
|
||||||
|
|
||||||
final PlotBlock plotblock = new PlotBlock(id, data);
|
|
||||||
|
|
||||||
final boolean set = PlotHelper.setBlock(block, plotblock);
|
|
||||||
if (!result && set) {
|
if (!result && set) {
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||||
@ -36,7 +38,7 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
|||||||
*
|
*
|
||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
public class SetBlockFast {
|
public class SetBlockFast extends AbstractSetBlock {
|
||||||
|
|
||||||
private static final RefClass classBlock = getRefClass("{nms}.Block");
|
private static final RefClass classBlock = getRefClass("{nms}.Block");
|
||||||
private static final RefClass classChunk = getRefClass("{nms}.Chunk");
|
private static final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||||
@ -71,10 +73,9 @@ public class SetBlockFast {
|
|||||||
* @param data Block Data Value
|
* @param data Block Data Value
|
||||||
*
|
*
|
||||||
* @return true
|
* @return true
|
||||||
*
|
|
||||||
* @throws NoSuchMethodException
|
|
||||||
*/
|
*/
|
||||||
public static boolean set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data) throws NoSuchMethodException {
|
@Override
|
||||||
|
public boolean set(final org.bukkit.World world, final int x, final int y, final int z, final int blockId, final byte data) {
|
||||||
|
|
||||||
final Object w = methodGetHandle.of(world).call();
|
final Object w = methodGetHandle.of(world).call();
|
||||||
final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4);
|
final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4);
|
||||||
@ -88,31 +89,18 @@ public class SetBlockFast {
|
|||||||
*
|
*
|
||||||
* @param player Player whose chunks we're updating
|
* @param player Player whose chunks we're updating
|
||||||
*/
|
*/
|
||||||
public static void update(final org.bukkit.entity.Player player) {
|
@Override
|
||||||
if (!PlotHelper.canSetFast) {
|
public void update(ArrayList<Chunk> chunks) {
|
||||||
|
if (chunks.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!PlotHelper.canSendChunk) {
|
if (!PlotHelper.canSendChunk) {
|
||||||
|
World world = chunks.get(0).getWorld();
|
||||||
final int distance = Bukkit.getViewDistance();
|
for (Chunk chunk : chunks) {
|
||||||
for (int cx = -distance; cx < distance; cx++) {
|
world.refreshChunk(chunk.getX(), chunk.getZ());
|
||||||
for (int cz = -distance; cz < distance; cz++) {
|
|
||||||
player.getWorld().refreshChunk(player.getLocation().getChunk().getX() + cx, player.getLocation().getChunk().getZ() + cz);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
|
||||||
|
|
||||||
final int distance = Bukkit.getViewDistance();
|
|
||||||
for (int cx = -distance; cx < distance; cx++) {
|
|
||||||
for (int cz = -distance; cz < distance; cz++) {
|
|
||||||
final Chunk chunk = player.getWorld().getChunkAt(player.getLocation().getChunk().getX() + cx, player.getLocation().getChunk().getZ() + cz);
|
|
||||||
chunks.add(chunk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SendChunk.sendChunk(chunks);
|
SendChunk.sendChunk(chunks);
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
@ -0,0 +1,121 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||||
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||||
|
// /
|
||||||
|
// This program is free software; you can redistribute it and/or modify /
|
||||||
|
// it under the terms of the GNU General Public License as published by /
|
||||||
|
// the Free Software Foundation; either version 3 of the License, or /
|
||||||
|
// (at your option) any later version. /
|
||||||
|
// /
|
||||||
|
// This program is distributed in the hope that it will be useful, /
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||||
|
// GNU General Public License for more details. /
|
||||||
|
// /
|
||||||
|
// You should have received a copy of the GNU General Public License /
|
||||||
|
// along with this program; if not, write to the Free Software Foundation, /
|
||||||
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||||
|
// /
|
||||||
|
// You can contact us via: support@intellectualsites.com /
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
|
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||||
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
|
||||||
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SetBlockFast class<br> Used to do fast world editing
|
||||||
|
*
|
||||||
|
* @author Empire92
|
||||||
|
*/
|
||||||
|
public class SetBlockFast_1_8 extends AbstractSetBlock {
|
||||||
|
|
||||||
|
private static final RefClass classBlock = getRefClass("{nms}.Block");
|
||||||
|
private static final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
|
||||||
|
private static final RefClass classIBlockData = getRefClass("{nms}.IBlockData");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||||
|
private static final RefClass classWorld = getRefClass("{nms}.World");
|
||||||
|
private static final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
|
||||||
|
|
||||||
|
private static RefMethod methodGetHandle;
|
||||||
|
private static RefMethod methodGetChunkAt;
|
||||||
|
private static RefMethod methodA;
|
||||||
|
private static RefMethod methodGetByCombinedId;
|
||||||
|
|
||||||
|
private static RefConstructor constructorBlockPosition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @throws NoSuchMethodException
|
||||||
|
*/
|
||||||
|
public SetBlockFast_1_8() throws NoSuchMethodException {
|
||||||
|
|
||||||
|
constructorBlockPosition = classBlockPosition.getConstructor(int.class, int.class, int.class);
|
||||||
|
methodGetByCombinedId = classBlock.getMethod("getByCombinedId", int.class);
|
||||||
|
|
||||||
|
methodGetHandle = classCraftWorld.getMethod("getHandle");
|
||||||
|
methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class);
|
||||||
|
methodA = classChunk.getMethod("a", classBlockPosition, classIBlockData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the block at the location
|
||||||
|
*
|
||||||
|
* @param world World in which the block should be set
|
||||||
|
* @param x X Coordinate
|
||||||
|
* @param y Y Coordinate
|
||||||
|
* @param z Z Coordinate
|
||||||
|
* @param blockId Block ID
|
||||||
|
* @param data Block Data Value
|
||||||
|
*
|
||||||
|
* @return true
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean set(final World world, final int x, final int y, final int z, final int blockId, final byte data) {
|
||||||
|
final Object w = methodGetHandle.of(world).call();
|
||||||
|
final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4);
|
||||||
|
final Object pos = constructorBlockPosition.create((int) (x & 0x0f), y, (int) (z & 0x0f));
|
||||||
|
final Object id = methodGetByCombinedId.of(null).call(blockId + (data << 12));
|
||||||
|
methodA.of(chunk).call(pos, id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update chunks
|
||||||
|
*
|
||||||
|
* @param player Player whose chunks we're updating
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void update(ArrayList<Chunk> chunks) {
|
||||||
|
if (chunks.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!PlotHelper.canSendChunk) {
|
||||||
|
World world = chunks.get(0).getWorld();
|
||||||
|
for (Chunk chunk : chunks) {
|
||||||
|
world.refreshChunk(chunk.getX(), chunk.getZ());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
SendChunk.sendChunk(chunks);
|
||||||
|
} catch (final Throwable e) {
|
||||||
|
PlotHelper.canSendChunk = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class SetBlockSlow extends AbstractSetBlock {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean set(World world, int x, int y, int z, int id, byte data) {
|
||||||
|
Block block = world.getBlockAt(x, y, z);
|
||||||
|
if (block.getData() == data) {
|
||||||
|
if (block.getTypeId() != id) {
|
||||||
|
block.setTypeId(id, false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (block.getTypeId() == id) {
|
||||||
|
block.setData(data, false);
|
||||||
|
} else {
|
||||||
|
block.setTypeIdAndData(id, data, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(ArrayList<Chunk> chunks) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user