last commit before 4.0.0

Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
matt
2019-03-14 21:49:33 -04:00
parent cf1764723f
commit 7f14e88c4c
24 changed files with 303 additions and 310 deletions

View File

@ -73,7 +73,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS);
} catch (final Throwable throwable) {
throw new IllegalStateException(
"Failed to force load WorldEdit." + " Road schematics will fail to generate",
"Failed to force load WorldEdit. Road schematics will fail to generate",
throwable);
}
}

View File

@ -181,13 +181,13 @@ public final class Reflection {
*/
public synchronized static Method getMethod(Class<?> clazz, String name, Class<?>... args) {
if (!_loadedMethods.containsKey(clazz)) {
_loadedMethods.put(clazz, new HashMap<String, Map<ArrayWrapper<Class<?>>, Method>>());
_loadedMethods.put(clazz, new HashMap<>());
}
Map<String, Map<ArrayWrapper<Class<?>>, Method>> loadedMethodNames =
_loadedMethods.get(clazz);
if (!loadedMethodNames.containsKey(name)) {
loadedMethodNames.put(name, new HashMap<ArrayWrapper<Class<?>>, Method>());
loadedMethodNames.put(name, new HashMap<>());
}
Map<ArrayWrapper<Class<?>>, Method> loadedSignatures = loadedMethodNames.get(name);

View File

@ -24,7 +24,7 @@ public class BukkitAugmentedGenerator extends BlockPopulator {
return generator;
}
@Override public void populate(World world, Random r, Chunk chunk) {
AugmentedUtils.generate(world.getName(), chunk.getX(), chunk.getZ(), null);
@Override public void populate(World world, Random random, Chunk source) {
AugmentedUtils.generate(world.getName(), source.getX(), source.getZ(), null);
}
}

View File

@ -69,12 +69,10 @@ public class BukkitPlotGenerator extends ChunkGenerator
+ " is already a BukkitPlotGenerator!");
}
this.full = false;
PlotSquared.debug("BukkitPlotGenerator does not fully support: " + cg);
//todo figure out why this was put here in the first place:
//PlotSquared.debug("BukkitPlotGenerator does not fully support: " + cg);
this.platformGenerator = cg;
this.plotGenerator = new IndependentPlotGenerator() {
@Override public void processSetup(SetupObject setup) {
}
@Override public void initialize(PlotArea area) {
}

View File

@ -59,48 +59,45 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
for (World world : Bukkit.getWorlds()) {
world.setAutoSave(false);
}
TaskManager.runTaskRepeat(new Runnable() {
@Override public void run() {
try {
HashSet<Chunk> toUnload = new HashSet<>();
for (World world : Bukkit.getWorlds()) {
String worldName = world.getName();
if (!PlotSquared.get().hasPlotArea(worldName)) {
TaskManager.runTaskRepeat(() -> {
try {
HashSet<Chunk> toUnload = new HashSet<>();
for (World world : Bukkit.getWorlds()) {
String worldName = world.getName();
if (!PlotSquared.get().hasPlotArea(worldName)) {
continue;
}
Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world);
Object chunkMap = w.getClass().getDeclaredMethod("getPlayerChunkMap").invoke(w);
Method methodIsChunkInUse =
chunkMap.getClass().getDeclaredMethod("isChunkInUse", int.class, int.class);
Chunk[] chunks = world.getLoadedChunks();
for (Chunk chunk : chunks) {
if ((boolean) methodIsChunkInUse
.invoke(chunkMap, chunk.getX(), chunk.getZ())) {
continue;
}
Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world);
Object chunkMap =
w.getClass().getDeclaredMethod("getPlayerChunkMap").invoke(w);
Method methodIsChunkInUse = chunkMap.getClass()
.getDeclaredMethod("isChunkInUse", int.class, int.class);
Chunk[] chunks = world.getLoadedChunks();
for (Chunk chunk : chunks) {
if ((boolean) methodIsChunkInUse
.invoke(chunkMap, chunk.getX(), chunk.getZ())) {
continue;
}
int x = chunk.getX();
int z = chunk.getZ();
if (!shouldSave(worldName, x, z)) {
unloadChunk(worldName, chunk, false);
continue;
}
toUnload.add(chunk);
int x = chunk.getX();
int z = chunk.getZ();
if (!shouldSave(worldName, x, z)) {
unloadChunk(worldName, chunk, false);
continue;
}
toUnload.add(chunk);
}
if (toUnload.isEmpty()) {
}
if (toUnload.isEmpty()) {
return;
}
long start = System.currentTimeMillis();
for (Chunk chunk : toUnload) {
if (System.currentTimeMillis() - start > 5) {
return;
}
long start = System.currentTimeMillis();
for (Chunk chunk : toUnload) {
if (System.currentTimeMillis() - start > 5) {
return;
}
chunk.unload(true, false);
}
} catch (Throwable e) {
e.printStackTrace();
chunk.unload(true, false);
}
} catch (Throwable e) {
e.printStackTrace();
}
}, 1);
}
@ -222,9 +219,28 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
private void cleanChunk(final Chunk chunk) {
TaskManager.index.incrementAndGet();
final Integer currentIndex = TaskManager.index.get();
Integer task = TaskManager.runTaskRepeat(new Runnable() {
@Override public void run() {
if (!chunk.isLoaded()) {
Integer task = TaskManager.runTaskRepeat(() -> {
if (!chunk.isLoaded()) {
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
PlotSquared
.debug(Captions.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
chunk.unload(true, true);
return;
}
BlockState[] tiles = chunk.getTileEntities();
if (tiles.length == 0) {
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
PlotSquared
.debug(Captions.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
chunk.unload(true, true);
return;
}
long start = System.currentTimeMillis();
int i = 0;
while (System.currentTimeMillis() - start < 250) {
if (i >= tiles.length) {
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
PlotSquared.debug(
@ -232,29 +248,8 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
chunk.unload(true, true);
return;
}
BlockState[] tiles = chunk.getTileEntities();
if (tiles.length == 0) {
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
PlotSquared.debug(
Captions.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
chunk.unload(true, true);
return;
}
long start = System.currentTimeMillis();
int i = 0;
while (System.currentTimeMillis() - start < 250) {
if (i >= tiles.length) {
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
PlotSquared.debug(
Captions.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
chunk.unload(true, true);
return;
}
tiles[i].getBlock().setType(Material.AIR, false);
i++;
}
tiles[i].getBlock().setType(Material.AIR, false);
i++;
}
}, 5);
TaskManager.tasks.put(currentIndex, task);

View File

@ -65,10 +65,10 @@ public class EntitySpawnListener implements Listener {
Entity entity = event.getEntity();
Location location = BukkitUtil.getLocation(entity.getLocation());
PlotArea area = location.getPlotArea();
if (area == null) {
if (!location.isPlotArea()) {
return;
}
Plot plot = area.getOwnedPlotAbs(location);
Plot plot = location.getOwnedPlotAbs();
if (plot == null) {
if (!area.MOB_SPAWNING) {
EntityType type = entity.getType();

View File

@ -237,26 +237,24 @@ import java.util.regex.Pattern;
@EventHandler public void onVehicleEntityCollision(VehicleEntityCollisionEvent e) {
if (e.getVehicle().getType() == EntityType.BOAT) {
Location location = BukkitUtil.getLocation(e.getEntity());
if (location.getPlotArea() == null) {
//we don't care about events that happen outside of a plot area.
return;
}
if (e.getEntity() instanceof Player) {
PlotPlayer player = BukkitUtil.getPlayer((Player) e.getEntity());
Plot plot = player.getCurrentPlot();
if (plot != null) {
if (!plot.isAdded(player.getUUID())) {
//Here the event is only canceled if the player is not the owner
//of the property on which he is located.
if (location.isPlotArea()) {
if (e.getEntity() instanceof Player) {
PlotPlayer player = BukkitUtil.getPlayer((Player) e.getEntity());
Plot plot = player.getCurrentPlot();
if (plot != null) {
if (!plot.isAdded(player.getUUID())) {
//Here the event is only canceled if the player is not the owner
//of the property on which he is located.
e.setCancelled(true);
}
} else {
e.setCancelled(true);
}
} else {
//Here the event is cancelled too, otherwise you can move the
//boat with EchoPets or other mobs running around on the plot.
e.setCancelled(true);
}
} else {
//Here the event is cancelled too, otherwise you can move the
//boat with EchoPets or other mobs running around on the plot.
e.setCancelled(true);
}
}
}
@ -315,7 +313,7 @@ import java.util.regex.Pattern;
if (area == null) {
return;
}
Plot plot = area.getOwnedPlot(loc);
Plot plot = loc.getOwnedPlot();
if (plot == null) {
return;
}
@ -655,7 +653,7 @@ import java.util.regex.Pattern;
Player player = event.getPlayer();
PlotPlayer pp = PlotPlayer.wrap(player);
Location loc = BukkitUtil.getLocation(to);
PlotArea area = PlotSquared.get().getPlotAreaAbs(loc);
PlotArea area = loc.getPlotArea();
if (area == null) {
return;
}
@ -1029,7 +1027,7 @@ import java.util.regex.Pattern;
Iterator<Block> iterator = event.blockList().iterator();
while (iterator.hasNext()) {
iterator.next();
if (location.getPlotArea() != null) {
if (location.isPlotArea()) {
iterator.remove();
}
}
@ -1095,13 +1093,12 @@ import java.util.regex.Pattern;
pp.deleteMeta("perm");
}
Location loc = pp.getLocation();
PlotArea area = PlotSquared.get().getPlotAreaAbs(loc);
if (area == null) {
return;
}
plot = area.getPlot(loc);
if (plot != null) {
plotEntry(pp, plot);
PlotArea area = loc.getPlotArea();
if (loc.isPlotArea()) {
plot = loc.getPlot();
if (plot != null) {
plotEntry(pp, plot);
}
}
}
@ -1372,8 +1369,7 @@ import java.util.regex.Pattern;
return;
}
for (Block block1 : event.getBlocks()) {
if (BukkitUtil.getLocation(block1.getLocation().add(relative)).getPlotArea()
!= null) {
if (BukkitUtil.getLocation(block1.getLocation().add(relative)).isPlotArea()) {
event.setCancelled(true);
return;
}
@ -1414,7 +1410,7 @@ import java.util.regex.Pattern;
try {
for (Block pulled : event.getBlocks()) {
location = BukkitUtil.getLocation(pulled.getLocation());
if (location.getPlotArea() != null) {
if (location.isPlotArea()) {
event.setCancelled(true);
return;
}
@ -1427,7 +1423,7 @@ import java.util.regex.Pattern;
BlockFace dir = event.getDirection();
location = BukkitUtil.getLocation(block.getLocation()
.add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
if (location.getPlotArea() != null) {
if (location.isPlotArea()) {
event.setCancelled(true);
return;
}
@ -1512,7 +1508,7 @@ import java.util.regex.Pattern;
if (area == null) {
for (int i = blocks.size() - 1; i >= 0; i--) {
location = BukkitUtil.getLocation(blocks.get(i).getLocation());
if (location.getPlotArea() != null) {
if (location.isPlotArea()) {
blocks.remove(i);
}
}
@ -1746,7 +1742,7 @@ import java.util.regex.Pattern;
Iterator<Block> iterator = event.blockList().iterator();
while (iterator.hasNext()) {
location = BukkitUtil.getLocation(iterator.next().getLocation());
if (location.getPlotArea() != null) {
if (location.isPlotArea()) {
iterator.remove();
}
}
@ -2054,12 +2050,6 @@ import java.util.regex.Pattern;
case TNT_MINECART:
eventType = PlayerBlockEventType.PLACE_VEHICLE;
break;
case ITEM_FRAME:
case PAINTING:
location = BukkitUtil
.getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_HANGING;
break;
default:
eventType = PlayerBlockEventType.INTERACT_BLOCK;
break;

View File

@ -36,45 +36,43 @@ import java.util.UUID;
private static final HashMap<UUID, Interval> healRunnable = new HashMap<>();
public static void startRunnable(JavaPlugin plugin) {
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override public void run() {
if (!healRunnable.isEmpty()) {
for (Iterator<Entry<UUID, Interval>> iterator =
healRunnable.entrySet().iterator(); iterator.hasNext(); ) {
Entry<UUID, Interval> entry = iterator.next();
Interval value = entry.getValue();
++value.count;
if (value.count == value.interval) {
value.count = 0;
Player player = Bukkit.getPlayer(entry.getKey());
if (player == null) {
iterator.remove();
continue;
}
double level = player.getHealth();
if (level != value.max) {
player.setHealth(Math.min(level + value.amount, value.max));
}
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
if (!healRunnable.isEmpty()) {
for (Iterator<Entry<UUID, Interval>> iterator =
healRunnable.entrySet().iterator(); iterator.hasNext(); ) {
Entry<UUID, Interval> entry = iterator.next();
Interval value = entry.getValue();
++value.count;
if (value.count == value.interval) {
value.count = 0;
Player player = Bukkit.getPlayer(entry.getKey());
if (player == null) {
iterator.remove();
continue;
}
double level = player.getHealth();
if (level != value.max) {
player.setHealth(Math.min(level + value.amount, value.max));
}
}
}
if (!feedRunnable.isEmpty()) {
for (Iterator<Entry<UUID, Interval>> iterator =
feedRunnable.entrySet().iterator(); iterator.hasNext(); ) {
Entry<UUID, Interval> entry = iterator.next();
Interval value = entry.getValue();
++value.count;
if (value.count == value.interval) {
value.count = 0;
Player player = Bukkit.getPlayer(entry.getKey());
if (player == null) {
iterator.remove();
continue;
}
int level = player.getFoodLevel();
if (level != value.max) {
player.setFoodLevel(Math.min(level + value.amount, value.max));
}
}
if (!feedRunnable.isEmpty()) {
for (Iterator<Entry<UUID, Interval>> iterator =
feedRunnable.entrySet().iterator(); iterator.hasNext(); ) {
Entry<UUID, Interval> entry = iterator.next();
Interval value = entry.getValue();
++value.count;
if (value.count == value.interval) {
value.count = 0;
Player player = Bukkit.getPlayer(entry.getKey());
if (player == null) {
iterator.remove();
continue;
}
int level = player.getFoodLevel();
if (level != value.max) {
player.setFoodLevel(Math.min(level + value.amount, value.max));
}
}
}

View File

@ -33,8 +33,8 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
this.done = classChunk.getField("done").getRealField();
this.lit = classChunk.getField("lit").getRealField();
this.s = classChunk.getField("s").getRealField();
} catch (Throwable ignore) {
ignore.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
Bukkit.getPluginManager().registerEvents(this, plugin);
}

View File

@ -111,10 +111,82 @@ public class BukkitChunkManager extends ChunkManager {
return chunks;
}
@Override
public boolean copyRegion(com.github.intellectualsites.plotsquared.plot.object.Location pos1,
com.github.intellectualsites.plotsquared.plot.object.Location pos2,
com.github.intellectualsites.plotsquared.plot.object.Location newPos,
@Override public int[] countEntities(Plot plot) {
int[] existing = (int[]) plot.getMeta("EntityCount");
if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime")
< 1000)) {
return existing;
}
PlotArea area = plot.getArea();
World world = BukkitUtil.getWorld(area.worldname);
Location bot = plot.getBottomAbs();
Location top = plot.getTopAbs();
int bx = bot.getX() >> 4;
int bz = bot.getZ() >> 4;
int tx = top.getX() >> 4;
int tz = top.getZ() >> 4;
int size = tx - bx << 4;
Set<Chunk> chunks = new HashSet<>();
for (int X = bx; X <= tx; X++) {
for (int Z = bz; Z <= tz; Z++) {
if (world.isChunkLoaded(X, Z)) {
chunks.add(world.getChunkAt(X, Z));
}
}
}
boolean doWhole = false;
List<Entity> entities = null;
if (size > 200 && chunks.size() > 200) {
entities = world.getEntities();
if (entities.size() < 16 + size / 8) {
doWhole = true;
}
}
int[] count = new int[6];
if (doWhole) {
for (Entity entity : entities) {
org.bukkit.Location location = entity.getLocation();
Chunk chunk = location.getChunk();
if (chunks.contains(chunk)) {
int X = chunk.getX();
int Z = chunk.getZ();
if (X > bx && X < tx && Z > bz && Z < tz) {
count(count, entity);
} else {
Plot other = area.getPlot(BukkitUtil.getLocation(location));
if (plot.equals(other)) {
count(count, entity);
}
}
}
}
} else {
for (Chunk chunk : chunks) {
int X = chunk.getX();
int Z = chunk.getZ();
Entity[] entities1 = chunk.getEntities();
for (Entity entity : entities1) {
if (X == bx || X == tx || Z == bz || Z == tz) {
Plot other = area.getPlot(BukkitUtil.getLocation(entity));
if (plot.equals(other)) {
count(count, entity);
}
} else {
count(count, entity);
}
}
}
}
return count;
}
@Override public boolean copyRegion(Location pos1, Location pos2, Location newPos,
final Runnable whenDone) {
final int relX = newPos.getX() - pos1.getX();
final int relZ = newPos.getZ() - pos1.getZ();
@ -140,7 +212,7 @@ public class BukkitChunkManager extends ChunkManager {
map.saveEntitiesIn(chunk, region);
for (int x = bx & 15; x <= (tx & 15); x++) {
for (int z = bz & 15; z <= (tz & 15); z++) {
map.saveBlocks(oldBukkitWorld, 256, cxx + x, czz + z, relX, relZ);
map.saveBlocks(oldBukkitWorld, cxx + x, czz + z, relX, relZ);
}
}
}
@ -165,9 +237,7 @@ public class BukkitChunkManager extends ChunkManager {
return true;
}
@Override public boolean regenerateRegion(
final com.github.intellectualsites.plotsquared.plot.object.Location pos1,
final com.github.intellectualsites.plotsquared.plot.object.Location pos2,
@Override public boolean regenerateRegion(final Location pos1, final Location pos2,
final boolean ignoreAugment, final Runnable whenDone) {
final String world = pos1.getWorld();
@ -275,8 +345,7 @@ public class BukkitChunkManager extends ChunkManager {
AugmentedUtils.bypass(ignoreAugment,
() -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() {
@Override public void run(ScopedLocalBlockQueue value) {
com.github.intellectualsites.plotsquared.plot.object.Location min =
value.getMin();
Location min = value.getMin();
int bx = min.getX();
int bz = min.getZ();
for (int x1 = 0; x1 < 16; x1++) {
@ -317,9 +386,22 @@ public class BukkitChunkManager extends ChunkManager {
return true;
}
@Override
public void clearAllEntities(com.github.intellectualsites.plotsquared.plot.object.Location pos1,
com.github.intellectualsites.plotsquared.plot.object.Location pos2) {
@Override public boolean loadChunk(String world, ChunkLoc loc, boolean force) {
return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
}
@SuppressWarnings("deprecation") @Override
public void unloadChunk(final String world, final ChunkLoc loc, final boolean save,
final boolean safe) {
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
TaskManager
.runTask(() -> BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe));
} else {
BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe);
}
}
@Override public void clearAllEntities(Location pos1, Location pos2) {
String world = pos1.getWorld();
List<Entity> entities = BukkitUtil.getEntities(world);
int bx = pos1.getX();
@ -340,25 +422,7 @@ public class BukkitChunkManager extends ChunkManager {
}
}
@Override public boolean loadChunk(String world, ChunkLoc loc, boolean force) {
return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
}
@SuppressWarnings("deprecation") @Override
public void unloadChunk(final String world, final ChunkLoc loc, final boolean save,
final boolean safe) {
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
TaskManager
.runTask(() -> BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe));
} else {
BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe);
}
}
@Override public void swap(com.github.intellectualsites.plotsquared.plot.object.Location bot1,
com.github.intellectualsites.plotsquared.plot.object.Location top1,
com.github.intellectualsites.plotsquared.plot.object.Location bot2,
com.github.intellectualsites.plotsquared.plot.object.Location top2,
@Override public void swap(Location bot1, Location top1, Location bot2, Location top2,
final Runnable whenDone) {
RegionWrapper region1 =
new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
@ -387,81 +451,6 @@ public class BukkitChunkManager extends ChunkManager {
});
}
@Override public int[] countEntities(Plot plot) {
int[] existing = (int[]) plot.getMeta("EntityCount");
if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime")
< 1000)) {
return existing;
}
PlotArea area = plot.getArea();
World world = BukkitUtil.getWorld(area.worldname);
com.github.intellectualsites.plotsquared.plot.object.Location bot = plot.getBottomAbs();
com.github.intellectualsites.plotsquared.plot.object.Location top = plot.getTopAbs();
int bx = bot.getX() >> 4;
int bz = bot.getZ() >> 4;
int tx = top.getX() >> 4;
int tz = top.getZ() >> 4;
int size = tx - bx << 4;
Set<Chunk> chunks = new HashSet<>();
for (int X = bx; X <= tx; X++) {
for (int Z = bz; Z <= tz; Z++) {
if (world.isChunkLoaded(X, Z)) {
chunks.add(world.getChunkAt(X, Z));
}
}
}
boolean doWhole = false;
List<Entity> entities = null;
if (size > 200 && chunks.size() > 200) {
entities = world.getEntities();
if (entities.size() < 16 + size / 8) {
doWhole = true;
}
}
int[] count = new int[6];
if (doWhole) {
for (Entity entity : entities) {
org.bukkit.Location location = entity.getLocation();
Chunk chunk = location.getChunk();
if (chunks.contains(chunk)) {
int X = chunk.getX();
int Z = chunk.getZ();
if (X > bx && X < tx && Z > bz && Z < tz) {
count(count, entity);
} else {
Plot other = area.getPlot(BukkitUtil.getLocation(location));
if (plot.equals(other)) {
count(count, entity);
}
}
}
}
} else {
for (Chunk chunk : chunks) {
int X = chunk.getX();
int Z = chunk.getZ();
Entity[] entities1 = chunk.getEntities();
for (Entity entity : entities1) {
if (X == bx || X == tx || Z == bz || Z == tz) {
Plot other = area.getPlot(BukkitUtil.getLocation(entity));
if (plot.equals(other)) {
count(count, entity);
}
} else {
count(count, entity);
}
}
}
}
return count;
}
private void count(int[] count, Entity entity) {
switch (entity.getType()) {
case PLAYER:
@ -595,6 +584,7 @@ public class BukkitChunkManager extends ChunkManager {
count[0]++;
}
public static class ContentMap {
final Set<EntityWrapper> entities;
@ -629,8 +619,7 @@ public class BukkitChunkManager extends ChunkManager {
public void saveEntitiesOut(Chunk chunk, RegionWrapper region) {
for (Entity entity : chunk.getEntities()) {
com.github.intellectualsites.plotsquared.plot.object.Location loc =
BukkitUtil.getLocation(entity);
Location loc = BukkitUtil.getLocation(entity);
int x = loc.getX();
int z = loc.getZ();
if (isIn(region, x, z)) {
@ -648,8 +637,7 @@ public class BukkitChunkManager extends ChunkManager {
public void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ,
boolean delete) {
for (Entity entity : chunk.getEntities()) {
com.github.intellectualsites.plotsquared.plot.object.Location loc =
BukkitUtil.getLocation(entity);
Location loc = BukkitUtil.getLocation(entity);
int x = loc.getX();
int z = loc.getZ();
if (!isIn(region, x, z)) {
@ -683,6 +671,7 @@ public class BukkitChunkManager extends ChunkManager {
this.entities.clear();
}
//todo optimize maxY
public void saveBlocks(BukkitWorld world, int maxY, int x, int z, int offsetX,
int offsetZ) {
maxY = Math.min(255, maxY);

View File

@ -192,8 +192,7 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
for (int x = 0; x < lc.biomes.length; x++) {
String[] biomes2 = lc.biomes[x];
if (biomes2 != null) {
for (int y = 0; y < biomes2.length; y++) {
String biomeStr = biomes2[y];
for (String biomeStr : biomes2) {
if (biomeStr != null) {
if (last == null || !StringMan.isEqual(last, biomeStr)) {
biome = Biome.valueOf(biomeStr.toUpperCase());
@ -247,8 +246,8 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
if (disableResult != null) {
try {
fieldNeighbors.set(disableResult[0], disableResult[1]);
} catch (Throwable ignore) {
ignore.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}