WE unregistration + home/visit sorting + format

- WorldEdit listener unregistration for external masking/extent/async
worldedit management. (wink)
- Use the same listing for home and visit as previous behavior was
confusing.
This commit is contained in:
boy0001
2015-09-13 01:19:39 +10:00
parent c386f33df8
commit 1c28a72f9c
28 changed files with 490 additions and 465 deletions

View File

@ -563,7 +563,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
return this;
}
*/
*/
/**
* If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the message.

View File

@ -372,7 +372,7 @@ public class EntityWrapper
}
case ARMOR_STAND:
{ // NEW
// CHECK positions
// CHECK positions
final ArmorStand stand = (ArmorStand) entity;
inventory = new ItemStack[] { stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(), stand.getLeggings().clone(), stand.getBoots().clone() };
storeLiving((LivingEntity) entity);
@ -665,7 +665,7 @@ public class EntityWrapper
}
case ARMOR_STAND:
{ // NEW
// CHECK positions
// CHECK positions
final ArmorStand stand = (ArmorStand) entity;
if (inventory[0] != null)
{

View File

@ -315,181 +315,181 @@ public class BukkitChunkManager extends ChunkManager
final int p2x = pos2.getX();
final int p2z = pos2.getZ();
final int bcx = p1x >> 4;
final int bcz = p1z >> 4;
final int tcx = p2x >> 4;
final int tcz = p2z >> 4;
final int bcz = p1z >> 4;
final int tcx = p2x >> 4;
final int tcz = p2z >> 4;
final boolean canRegen = ((plotworld.TYPE != 0) && (plotworld.TERRAIN == 0));
final boolean canRegen = ((plotworld.TYPE != 0) && (plotworld.TERRAIN == 0));
final ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
final ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
for (int x = bcx; x <= tcx; x++)
{
for (int z = bcz; z <= tcz; z++)
{
chunks.add(new ChunkLoc(x, z));
}
}
AugmentedPopulator augpop = null;
final World worldObj = Bukkit.getWorld(world);
final List<BlockPopulator> populators = worldObj.getPopulators();
for (final BlockPopulator populator : populators)
{
if (populator instanceof AugmentedPopulator)
{
final AugmentedPopulator current = ((AugmentedPopulator) populator);
if (current.cluster == null)
for (int x = bcx; x <= tcx; x++)
{
augpop = current;
break;
}
else if (ClusterManager.contains(current.cluster, pos1))
{
augpop = current;
break;
}
}
}
final Random r = new Random(System.currentTimeMillis());
final AugmentedPopulator ap = augpop;
TaskManager.runTask(new Runnable()
{
@Override
public void run()
{
final long start = System.currentTimeMillis();
while ((chunks.size() > 0) && ((System.currentTimeMillis() - start) < 5))
{
final ChunkLoc chunk = chunks.remove(0);
final int x = chunk.x;
final int z = chunk.z;
final int xxb = x << 4;
final int zzb = z << 4;
final int xxt = xxb + 15;
final int zzt = zzb + 15;
CURRENT_PLOT_CLEAR = null;
final Chunk chunkObj = worldObj.getChunkAt(x, z);
if (!chunkObj.load(false))
for (int z = bcz; z <= tcz; z++)
{
continue;
chunks.add(new ChunkLoc(x, z));
}
CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
if ((xxb >= p1x) && (xxt <= p2x) && (zzb >= p1z) && (zzt <= p2z))
}
AugmentedPopulator augpop = null;
final World worldObj = Bukkit.getWorld(world);
final List<BlockPopulator> populators = worldObj.getPopulators();
for (final BlockPopulator populator : populators)
{
if (populator instanceof AugmentedPopulator)
{
if (canRegen && (ap != null))
final AugmentedPopulator current = ((AugmentedPopulator) populator);
if (current.cluster == null)
{
ap.populate(worldObj, r, chunkObj);
augpop = current;
break;
}
else if (ClusterManager.contains(current.cluster, pos1))
{
augpop = current;
break;
}
}
}
final Random r = new Random(System.currentTimeMillis());
final AugmentedPopulator ap = augpop;
TaskManager.runTask(new Runnable()
{
@Override
public void run()
{
final long start = System.currentTimeMillis();
while ((chunks.size() > 0) && ((System.currentTimeMillis() - start) < 5))
{
final ChunkLoc chunk = chunks.remove(0);
final int x = chunk.x;
final int z = chunk.z;
final int xxb = x << 4;
final int zzb = z << 4;
final int xxt = xxb + 15;
final int zzt = zzb + 15;
CURRENT_PLOT_CLEAR = null;
final Chunk chunkObj = worldObj.getChunkAt(x, z);
if (!chunkObj.load(false))
{
continue;
}
CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
if ((xxb >= p1x) && (xxt <= p2x) && (zzb >= p1z) && (zzt <= p2z))
{
if (canRegen && (ap != null))
{
ap.populate(worldObj, r, chunkObj);
}
else
{
regenerateChunk(world, chunk);
}
continue;
}
boolean checkX1 = false;
boolean checkX2 = false;
boolean checkZ1 = false;
boolean checkZ2 = false;
int xxb2;
int zzb2;
int xxt2;
int zzt2;
if (x == bcx)
{
xxb2 = p1x - 1;
checkX1 = true;
}
else
{
xxb2 = xxb;
}
if (x == tcx)
{
xxt2 = p2x + 1;
checkX2 = true;
}
else
{
xxt2 = xxt;
}
if (z == bcz)
{
zzb2 = p1z - 1;
checkZ1 = true;
}
else
{
zzb2 = zzb;
}
if (z == tcz)
{
zzt2 = p2z + 1;
checkZ2 = true;
}
else
{
zzt2 = zzt;
}
initMaps();
if (checkX1)
{
saveRegion(worldObj, xxb, xxb2, zzb2, zzt2); //
}
if (checkX2)
{
saveRegion(worldObj, xxt2, xxt, zzb2, zzt2); //
}
if (checkZ1)
{
saveRegion(worldObj, xxb2, xxt2, zzb, zzb2); //
}
if (checkZ2)
{
saveRegion(worldObj, xxb2, xxt2, zzt2, zzt); //
}
if (checkX1 && checkZ1)
{
saveRegion(worldObj, xxb, xxb2, zzb, zzb2); //
}
if (checkX2 && checkZ1)
{
saveRegion(worldObj, xxt2, xxt, zzb, zzb2); // ?
}
if (checkX1 && checkZ2)
{
saveRegion(worldObj, xxb, xxb2, zzt2, zzt); // ?
}
if (checkX2 && checkZ2)
{
saveRegion(worldObj, xxt2, xxt, zzt2, zzt); //
}
saveEntitiesOut(chunkObj, CURRENT_PLOT_CLEAR);
if (canRegen && (ap != null))
{
ap.populate(worldObj, r, chunkObj);
}
else
{
regenerateChunk(world, chunk);
}
restoreBlocks(worldObj, 0, 0);
restoreEntities(worldObj, 0, 0);
}
CURRENT_PLOT_CLEAR = null;
if (chunks.size() != 0)
{
TaskManager.runTaskLater(this, 1);
}
else
{
regenerateChunk(world, chunk);
TaskManager.runTaskLater(whenDone, 1);
}
continue;
}
boolean checkX1 = false;
boolean checkX2 = false;
boolean checkZ1 = false;
boolean checkZ2 = false;
int xxb2;
int zzb2;
int xxt2;
int zzt2;
if (x == bcx)
{
xxb2 = p1x - 1;
checkX1 = true;
}
else
{
xxb2 = xxb;
}
if (x == tcx)
{
xxt2 = p2x + 1;
checkX2 = true;
}
else
{
xxt2 = xxt;
}
if (z == bcz)
{
zzb2 = p1z - 1;
checkZ1 = true;
}
else
{
zzb2 = zzb;
}
if (z == tcz)
{
zzt2 = p2z + 1;
checkZ2 = true;
}
else
{
zzt2 = zzt;
}
initMaps();
if (checkX1)
{
saveRegion(worldObj, xxb, xxb2, zzb2, zzt2); //
}
if (checkX2)
{
saveRegion(worldObj, xxt2, xxt, zzb2, zzt2); //
}
if (checkZ1)
{
saveRegion(worldObj, xxb2, xxt2, zzb, zzb2); //
}
if (checkZ2)
{
saveRegion(worldObj, xxb2, xxt2, zzt2, zzt); //
}
if (checkX1 && checkZ1)
{
saveRegion(worldObj, xxb, xxb2, zzb, zzb2); //
}
if (checkX2 && checkZ1)
{
saveRegion(worldObj, xxt2, xxt, zzb, zzb2); // ?
}
if (checkX1 && checkZ2)
{
saveRegion(worldObj, xxb, xxb2, zzt2, zzt); // ?
}
if (checkX2 && checkZ2)
{
saveRegion(worldObj, xxt2, xxt, zzt2, zzt); //
}
saveEntitiesOut(chunkObj, CURRENT_PLOT_CLEAR);
if (canRegen && (ap != null))
{
ap.populate(worldObj, r, chunkObj);
}
else
{
regenerateChunk(world, chunk);
}
restoreBlocks(worldObj, 0, 0);
restoreEntities(worldObj, 0, 0);
}
CURRENT_PLOT_CLEAR = null;
if (chunks.size() != 0)
{
TaskManager.runTaskLater(this, 1);
}
else
{
TaskManager.runTaskLater(whenDone, 1);
}
}
});
return true;
});
return true;
}
public static void initMaps()
@ -1293,91 +1293,91 @@ public class BukkitChunkManager extends ChunkManager
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
final int bx = bot.getX() >> 4;
final int bz = bot.getZ() >> 4;
final int bz = bot.getZ() >> 4;
final int tx = top.getX() >> 4;
final int tz = top.getZ() >> 4;
final int tx = top.getX() >> 4;
final int tz = top.getZ() >> 4;
final int size = (tx - bx) << 4;
final int size = (tx - bx) << 4;
final HashSet<Chunk> chunks = new HashSet<>();
for (int X = bx; X <= tx; X++)
{
for (int Z = bz; Z <= tz; Z++)
{
chunks.add(world.getChunkAt(X, Z));
}
}
boolean doWhole = false;
List<Entity> entities = null;
if (size > 200)
{
entities = world.getEntities();
if (entities.size() < (16 + ((size * size) / 64)))
{
doWhole = true;
}
}
if (doWhole)
{
for (final Entity entity : entities)
{
if (!((entity instanceof Creature) || (entity instanceof Vehicle)))
{
continue;
}
final org.bukkit.Location loc = entity.getLocation();
final Chunk chunk = loc.getChunk();
if (chunks.contains(chunk))
{
final int X = chunk.getX();
final int Z = chunk.getX();
if ((X > bx) && (X < tx) && (Z > bz) && (Z < tz))
{
count(count, entity);
}
else
{
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(loc));
if (plot.id.equals(id))
final HashSet<Chunk> chunks = new HashSet<>();
for (int X = bx; X <= tx; X++)
{
count(count, entity);
for (int Z = bz; Z <= tz; Z++)
{
chunks.add(world.getChunkAt(X, Z));
}
}
}
}
}
}
else
{
for (final Chunk chunk : chunks)
{
final int X = chunk.getX();
final int Z = chunk.getX();
final Entity[] ents = chunk.getEntities();
for (final Entity entity : ents)
{
if (!((entity instanceof Creature) || (entity instanceof Vehicle)))
{
continue;
}
if ((X == bx) || (X == tx) || (Z == bz) || (Z == tz))
{
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity));
if (plot.id.equals(id))
boolean doWhole = false;
List<Entity> entities = null;
if (size > 200)
{
count(count, entity);
entities = world.getEntities();
if (entities.size() < (16 + ((size * size) / 64)))
{
doWhole = true;
}
}
}
else
{
count(count, entity);
}
}
}
}
return count;
if (doWhole)
{
for (final Entity entity : entities)
{
if (!((entity instanceof Creature) || (entity instanceof Vehicle)))
{
continue;
}
final org.bukkit.Location loc = entity.getLocation();
final Chunk chunk = loc.getChunk();
if (chunks.contains(chunk))
{
final int X = chunk.getX();
final int Z = chunk.getX();
if ((X > bx) && (X < tx) && (Z > bz) && (Z < tz))
{
count(count, entity);
}
else
{
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(loc));
if (plot.id.equals(id))
{
count(count, entity);
}
}
}
}
}
else
{
for (final Chunk chunk : chunks)
{
final int X = chunk.getX();
final int Z = chunk.getX();
final Entity[] ents = chunk.getEntities();
for (final Entity entity : ents)
{
if (!((entity instanceof Creature) || (entity instanceof Vehicle)))
{
continue;
}
if ((X == bx) || (X == tx) || (Z == bz) || (Z == tz))
{
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity));
if (plot.id.equals(id))
{
count(count, entity);
}
}
else
{
count(count, entity);
}
}
}
}
return count;
}
private void count(final int[] count, final Entity entity)

View File

@ -54,7 +54,7 @@ public class BukkitHybridUtils extends HybridUtils
final World world = Bukkit.getWorld(plot.world);
final ChunkGenerator gen = world.getGenerator();
if (gen == null) {
return;
return;
}
final BiomeGrid base = new BiomeGrid()
{

View File

@ -79,7 +79,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager
@Override
public void run()
{
if (toUpdate.size() == 0) {
if (toUpdate.size() == 0) {
return;
}
int count = 0;
@ -91,7 +91,7 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager
i.remove();
count++;
}
if (count == 0) {
if (count == 0) {
return;
}
update(chunks);
@ -336,24 +336,24 @@ public class SetBlockFast_1_8 extends BukkitSetBlockManager
}
// End blockstate workaround //
final int X = x >> 4;
final int Z = z >> 4;
final ChunkLoc loc = new ChunkLoc(X, Z);
if (!loc.equals(lastLoc))
{
Chunk chunk = toUpdate.get(loc);
if (chunk == null)
{
chunk = world.getChunkAt(X, Z);
toUpdate.put(loc, chunk);
}
chunk.load(false);
}
// check sign
final Object w = methodGetHandle.of(world).call();
final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4);
final Object pos = constructorBlockPosition.create(x & 0x0f, y, z & 0x0f);
final Object combined = methodGetByCombinedId.of(null).call(id + (data << 12));
final int X = x >> 4;
final int Z = z >> 4;
final ChunkLoc loc = new ChunkLoc(X, Z);
if (!loc.equals(lastLoc))
{
Chunk chunk = toUpdate.get(loc);
if (chunk == null)
{
chunk = world.getChunkAt(X, Z);
toUpdate.put(loc, chunk);
}
chunk.load(false);
}
// check sign
final Object w = methodGetHandle.of(world).call();
final Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4);
final Object pos = constructorBlockPosition.create(x & 0x0f, y, z & 0x0f);
final Object combined = methodGetByCombinedId.of(null).call(id + (data << 12));
methodA.of(chunk).call(pos, combined);
}

View File

@ -79,13 +79,13 @@ public class CommandManager<T extends CommandCaller>
public int compare(final Command<T> a, final Command<T> b)
{
if (a == b) {
return 0;
return 0;
}
if (a == null) {
return -1;
return -1;
}
if (b == null) {
return 1;
return 1;
}
return a.getCommand().compareTo(b.getCommand());
}

View File

@ -36,7 +36,7 @@ public class WESubscriber
final WorldEdit worldedit = PS.get().worldedit;
if (worldedit == null)
{
worldedit.getEventBus().unregister(this);
WorldEdit.getInstance().getEventBus().unregister(this);
return;
}
final World worldObj = event.getWorld();

View File

@ -293,7 +293,7 @@ public class SpongeMain implements IPlotMain, PluginContainer
PS.get().loadWorld(world, wrapper);
switch (plotworld.TYPE)
{
// Normal
// Normal
case 0:
{
modify = new WorldModify(generator, false);

View File

@ -230,18 +230,18 @@ public class AugmentedPopulator implements Populator
public void setBlock(final int x, final int y, final int z, final BlockState t)
{
if (check && (((z) < bz) || ((z) > tz) || ((x) < bx) || ((x) > tx))) {
return;
return;
}
if (p)
{
if (ChunkManager.CURRENT_PLOT_CLEAR != null)
{
if (ChunkManager.CURRENT_PLOT_CLEAR.isIn(x, z)) {
return;
return;
}
}
else if (manager.getPlotIdAbs(plotworld, x, 0, z) != null) {
return;
return;
}
}
final PlotBlock block = SpongeMain.THIS.getPlotBlock(t);
@ -315,18 +315,18 @@ public class AugmentedPopulator implements Populator
public void setBlockType(final int x, final int y, final int z, final BlockType t)
{
if (check && (((z) < bz) || ((z) > tz) || ((x) < bx) || ((x) > tx))) {
return;
return;
}
if (p)
{
if (ChunkManager.CURRENT_PLOT_CLEAR != null)
{
if (ChunkManager.CURRENT_PLOT_CLEAR.isIn(x, z)) {
return;
return;
}
}
else if (manager.getPlotIdAbs(plotworld, x, 0, z) != null) {
return;
return;
}
}
final PlotBlock block = SpongeMain.THIS.getPlotBlock(t.getDefaultState());

View File

@ -119,7 +119,7 @@ public class MainListener
public boolean apply(final org.spongepowered.api.world.Location<World> loc)
{
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
return false;
return false;
}
return true;
}
@ -323,7 +323,7 @@ public class MainListener
public boolean apply(final org.spongepowered.api.world.Location loc)
{
if (MainUtil.isPlotRoad(SpongeUtil.getLocation(worldname, loc))) {
return false;
return false;
}
return true;
}
@ -427,7 +427,7 @@ public class MainListener
public boolean apply(final org.spongepowered.api.world.Location loc)
{
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
return false;
return false;
}
return true;
}
@ -438,7 +438,7 @@ public class MainListener
public boolean apply(final Entity entity)
{
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) {
return false;
return false;
}
return true;
}
@ -457,7 +457,7 @@ public class MainListener
public boolean apply(final Entity entity)
{
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) {
return false;
return false;
}
return true;
}
@ -474,7 +474,7 @@ public class MainListener
public boolean apply(final org.spongepowered.api.world.Location loc)
{
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
return false;
return false;
}
return true;
}
@ -485,7 +485,7 @@ public class MainListener
public boolean apply(final Entity entity)
{
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) {
return false;
return false;
}
return true;
}