mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-29 12:37:53 +01:00
refactor
This commit is contained in:
commit
d37396716f
5
pom.xml
5
pom.xml
@ -210,6 +210,11 @@
|
||||
<artifactId>towny</artifactId>
|
||||
<version>0.84.0.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.intellectualcrafters.plot</groupId>
|
||||
<artifactId>plotsquared</artifactId>
|
||||
<version>3.2.24</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.worldcretornica</groupId>
|
||||
<artifactId>plotme_core</artifactId>
|
||||
|
@ -20,7 +20,7 @@ import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.util.Lag;
|
||||
import com.boydti.fawe.util.MemUtil;
|
||||
import com.boydti.fawe.util.SetBlockQueue;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.util.WEManager;
|
||||
import com.boydti.fawe.util.WESubscriber;
|
||||
@ -107,7 +107,7 @@ public class Fawe {
|
||||
// TODO command event - queue?
|
||||
|
||||
TaskManager.IMP = IMP.getTaskManager();
|
||||
SetBlockQueue.IMP.queue = IMP.getQueue();
|
||||
SetQueue.IMP.queue = IMP.getQueue();
|
||||
|
||||
// Delayed setup
|
||||
TaskManager.IMP.later(new Runnable() {
|
||||
|
@ -17,7 +17,7 @@ import org.bukkit.Material;
|
||||
import com.boydti.fawe.object.ChunkLoc;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweLocation;
|
||||
import com.boydti.fawe.util.SetBlockQueue;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.jnbt.ByteArrayTag;
|
||||
import com.sk89q.jnbt.IntTag;
|
||||
@ -40,7 +40,7 @@ public class FaweAPI {
|
||||
* @param m
|
||||
*/
|
||||
public static void setBlockAsync(final Location loc, final Material m) {
|
||||
SetBlockQueue.IMP.setBlock(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), (short) m.getId());
|
||||
SetQueue.IMP.setBlock(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), (short) m.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,7 +53,7 @@ public class FaweAPI {
|
||||
* @param data
|
||||
*/
|
||||
public static void setBlockAsync(final String world, final int x, final int y, final int z, final short id, final byte data) {
|
||||
SetBlockQueue.IMP.setBlock(world, x, y, z, id, data);
|
||||
SetQueue.IMP.setBlock(world, x, y, z, id, data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,7 +65,7 @@ public class FaweAPI {
|
||||
* @param data
|
||||
*/
|
||||
public static void setBiomeAsync(final String world, final int x, final int z, BaseBiome biome) {
|
||||
SetBlockQueue.IMP.setBiome(world, x, z, biome);
|
||||
SetQueue.IMP.setBiome(world, x, z, biome);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,7 +74,7 @@ public class FaweAPI {
|
||||
* @param biome
|
||||
*/
|
||||
public static void setBiomeAsync(Location loc, BaseBiome biome) {
|
||||
SetBlockQueue.IMP.setBiome(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockZ(), biome);
|
||||
SetQueue.IMP.setBiome(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockZ(), biome);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +86,7 @@ public class FaweAPI {
|
||||
* @return
|
||||
*/
|
||||
public static FaweChunk<?> createChunk() {
|
||||
return SetBlockQueue.IMP.queue.getChunk(new ChunkLoc(null, 0, 0));
|
||||
return SetQueue.IMP.queue.getChunk(new ChunkLoc(null, 0, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,7 +116,7 @@ public class FaweAPI {
|
||||
* @param loc
|
||||
*/
|
||||
public static void fixLighting(ChunkLoc loc, boolean fixAll) {
|
||||
SetBlockQueue.IMP.queue.fixLighting(SetBlockQueue.IMP.queue.getChunk(loc), fixAll);
|
||||
SetQueue.IMP.queue.fixLighting(SetQueue.IMP.queue.getChunk(loc), fixAll);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,7 +126,7 @@ public class FaweAPI {
|
||||
*/
|
||||
public static void fixLighting(Chunk chunk, boolean fixAll) {
|
||||
ChunkLoc loc = new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||
SetBlockQueue.IMP.queue.fixLighting(SetBlockQueue.IMP.queue.getChunk(loc), fixAll);
|
||||
SetQueue.IMP.queue.fixLighting(SetQueue.IMP.queue.getChunk(loc), fixAll);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -322,6 +322,6 @@ public class FaweAPI {
|
||||
* @param whenDone
|
||||
*/
|
||||
public static void addTask(final Runnable whenDone) {
|
||||
SetBlockQueue.IMP.addTask(whenDone);
|
||||
SetQueue.IMP.addTask(whenDone);
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.mcore.ps.PS;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
|
||||
public class FactionsFeature extends BukkitMaskManager implements Listener {
|
||||
FaweBukkit plugin;
|
||||
@ -27,7 +27,8 @@ public class FactionsFeature extends BukkitMaskManager implements Listener {
|
||||
public FaweMask getMask(final FawePlayer<Player> fp) {
|
||||
final Player player = fp.parent;
|
||||
final Location loc = player.getLocation();
|
||||
final Faction fac = BoardColl.get().getFactionAt(PS.valueOf(loc));
|
||||
PS ps = PS.valueOf(loc);
|
||||
final Faction fac = BoardColl.get().getFactionAt(ps);
|
||||
if (fac != null) {
|
||||
if (fac.getOnlinePlayers().contains(player)) {
|
||||
if (fac.getComparisonName().equals("wilderness") == false) {
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.boydti.fawe.bukkit.v0;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -10,10 +12,15 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
@ -21,7 +28,7 @@ import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.ChunkLoc;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.util.FaweQueue;
|
||||
import com.boydti.fawe.util.SetBlockQueue;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
@ -29,6 +36,8 @@ public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
||||
|
||||
private final HashMap<ChunkLoc, FaweChunk<Chunk>> toLight = new HashMap<>();
|
||||
|
||||
private final HashMap<String, HashSet<Long>> loaded = new HashMap<>();
|
||||
|
||||
public BukkitQueue_0() {
|
||||
TaskManager.IMP.task(new Runnable() {
|
||||
@Override
|
||||
@ -36,36 +45,102 @@ public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
||||
Bukkit.getPluginManager().registerEvents(BukkitQueue_0.this, (Plugin) Fawe.imp());
|
||||
}
|
||||
});
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
addLoaded(chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
World world = event.getWorld();
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
addLoaded(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
loaded.remove(event.getWorld().getName());
|
||||
}
|
||||
|
||||
public void addLoaded(Chunk chunk) {
|
||||
String world = chunk.getWorld().getName();
|
||||
long x = chunk.getX();
|
||||
long z = chunk.getZ();
|
||||
long id = x << 32 | z & 0xFFFFFFFFL;
|
||||
HashSet<Long> map = loaded.get(world);
|
||||
if (map != null) {
|
||||
map.add(id);
|
||||
} else {
|
||||
map = new HashSet<>(Arrays.asList(id));
|
||||
loaded.put(world, map);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeLoaded(Chunk chunk) {
|
||||
String world = chunk.getWorld().getName();
|
||||
long x = chunk.getX();
|
||||
long z = chunk.getZ();
|
||||
long id = x << 32 | z & 0xFFFFFFFFL;
|
||||
HashSet<Long> map = loaded.get(world);
|
||||
if (map != null) {
|
||||
map.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkLoaded(String world, int x, int z) {
|
||||
long id = (long) x << 32 | z & 0xFFFFFFFFL;
|
||||
HashSet<Long> map = loaded.get(world);
|
||||
if (map != null) {
|
||||
return map.contains(id);
|
||||
}
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
Location loc = event.getTo();
|
||||
if (!loc.getChunk().equals(event.getFrom().getChunk())) {
|
||||
Chunk chunk = loc.getChunk();
|
||||
ChunkLoc cl = new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||
FaweChunk<Chunk> fc = toLight.remove(cl);
|
||||
if (fc != null) {
|
||||
if (fixLighting(fc, Settings.FIX_ALL_LIGHTING)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
Chunk chunk = event.getChunk();
|
||||
addLoaded(chunk);
|
||||
if (toLight.size() == 0) {
|
||||
return;
|
||||
}
|
||||
Chunk chunk = event.getChunk();
|
||||
ChunkLoc loc = new ChunkLoc(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
ChunkLoc a = new ChunkLoc(loc.world, loc.x + x, loc.z + z);
|
||||
if (toLight.containsKey(a)) {
|
||||
if (fixLighting(toLight.get(a), Settings.FIX_ALL_LIGHTING)) {
|
||||
toLight.remove(a);
|
||||
FaweChunk<Chunk> fc = toLight.remove(a);
|
||||
if (fc != null) {
|
||||
if (fixLighting(fc, Settings.FIX_ALL_LIGHTING)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
removeLoaded(event.getChunk());
|
||||
}
|
||||
|
||||
private final ConcurrentHashMap<ChunkLoc, FaweChunk<Chunk>> blocks = new ConcurrentHashMap<>();
|
||||
|
||||
@ -118,7 +193,7 @@ public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
||||
}
|
||||
final Iterator<Entry<ChunkLoc, FaweChunk<Chunk>>> iter = blocks.entrySet().iterator();
|
||||
final FaweChunk<Chunk> toReturn = iter.next().getValue();
|
||||
if (SetBlockQueue.IMP.isWaiting()) {
|
||||
if (SetQueue.IMP.isWaiting()) {
|
||||
return null;
|
||||
}
|
||||
iter.remove();
|
||||
@ -145,7 +220,7 @@ public abstract class BukkitQueue_0 extends FaweQueue implements Listener {
|
||||
}
|
||||
toUpdate.add(fc);
|
||||
// Fix lighting
|
||||
SetBlockQueue.IMP.addTask(new Runnable() {
|
||||
SetQueue.IMP.addTask(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -2,8 +2,10 @@ package com.boydti.fawe.object;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.boydti.fawe.util.SetBlockQueue;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
@ -28,14 +30,21 @@ public class FastWorldEditExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
synchronized (thread) {
|
||||
return super.createEntity(location, entity);
|
||||
}
|
||||
public Entity createEntity(final Location location, final BaseEntity entity) {
|
||||
TaskManager.IMP.task(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FastWorldEditExtent.super.createEntity(location, entity);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
if (!SetQueue.IMP.isChunkLoaded(world, position.getBlockX() >> 4, position.getBlockZ() >> 4)) {
|
||||
return EditSession.nullBiome;
|
||||
}
|
||||
synchronized (thread) {
|
||||
return super.getBiome(position);
|
||||
}
|
||||
@ -49,6 +58,9 @@ public class FastWorldEditExtent extends AbstractDelegateExtent {
|
||||
if (lastBlock != null && lastVector.equals(position.toBlockVector())) {
|
||||
return lastBlock;
|
||||
}
|
||||
if (!SetQueue.IMP.isChunkLoaded(world, position.getBlockX() >> 4, position.getBlockZ() >> 4)) {
|
||||
return EditSession.nullBlock;
|
||||
}
|
||||
synchronized (thread) {
|
||||
lastVector = position.toBlockVector();
|
||||
return lastBlock = super.getBlock(position);
|
||||
@ -71,14 +83,12 @@ public class FastWorldEditExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
public BaseBlock getBlock(Vector position) {
|
||||
synchronized (thread) {
|
||||
return super.getLazyBlock(position);
|
||||
}
|
||||
return getLazyBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
SetBlockQueue.IMP.setBiome(world, position.getBlockX(), position.getBlockZ(), biome);
|
||||
SetQueue.IMP.setBiome(world, position.getBlockX(), position.getBlockZ(), biome);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -173,11 +183,11 @@ public class FastWorldEditExtent extends AbstractDelegateExtent {
|
||||
case 190:
|
||||
case 191:
|
||||
case 192: {
|
||||
SetBlockQueue.IMP.setBlock(world, x, y, z, id);
|
||||
SetQueue.IMP.setBlock(world, x, y, z, id);
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
SetBlockQueue.IMP.setBlock(world, x, y, z, id, (byte) block.getData());
|
||||
SetQueue.IMP.setBlock(world, x, y, z, id, (byte) block.getData());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.boydti.fawe.object;
|
||||
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.util.SetBlockQueue;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
public abstract class FaweChunk<T> {
|
||||
@ -27,11 +27,11 @@ public abstract class FaweChunk<T> {
|
||||
if (chunk == null) {
|
||||
throw new IllegalArgumentException("Chunk location cannot be null!");
|
||||
}
|
||||
SetBlockQueue.IMP.queue.setChunk(this);
|
||||
SetQueue.IMP.queue.setChunk(this);
|
||||
}
|
||||
|
||||
public void fixLighting() {
|
||||
SetBlockQueue.IMP.queue.fixLighting(this, Settings.FIX_ALL_LIGHTING);
|
||||
SetQueue.IMP.queue.fixLighting(this, Settings.FIX_ALL_LIGHTING);
|
||||
}
|
||||
|
||||
public void fill(int id, byte data) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.boydti.fawe.object;
|
||||
|
||||
import com.boydti.fawe.util.SetBlockQueue;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -40,6 +40,6 @@ public class FaweLocation {
|
||||
}
|
||||
|
||||
public void setBlockAsync(short id, byte data) {
|
||||
SetBlockQueue.IMP.setBlock(world, x, y, z, id, data);
|
||||
SetQueue.IMP.setBlock(world, x, y, z, id, data);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.boydti.fawe.object;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
@ -17,23 +18,19 @@ import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
public class NullExtent implements Extent {
|
||||
|
||||
private final BaseBiome nullBiome = new BaseBiome(0);
|
||||
|
||||
private final BaseBlock nullBlock = new BaseBlock(0);
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(final Vector2D arg0) {
|
||||
return nullBiome;
|
||||
return EditSession.nullBiome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getBlock(final Vector arg0) {
|
||||
return nullBlock;
|
||||
return EditSession.nullBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getLazyBlock(final Vector arg0) {
|
||||
return nullBlock;
|
||||
return EditSession.nullBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,9 +6,11 @@ import java.util.List;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.SetBlockQueue;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.boydti.fawe.util.WEManager;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
@ -55,7 +57,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity createEntity(Location location, BaseEntity entity) {
|
||||
public Entity createEntity(final Location location, final BaseEntity entity) {
|
||||
if (Eblocked) {
|
||||
return null;
|
||||
}
|
||||
@ -65,15 +67,21 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
MainUtil.sendAdmin(BBC.WORLDEDIT_DANGEROUS_WORLDEDIT.format(world + ": " + location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ(), user));
|
||||
}
|
||||
if (WEManager.IMP.maskContains(mask, location.getBlockX(), location.getBlockZ())) {
|
||||
synchronized (thread) {
|
||||
return super.createEntity(location, entity);
|
||||
}
|
||||
TaskManager.IMP.task(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProcessedWEExtent.super.createEntity(location, entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
if (!SetQueue.IMP.isChunkLoaded(world, position.getBlockX() >> 4, position.getBlockZ() >> 4)) {
|
||||
return EditSession.nullBiome;
|
||||
}
|
||||
synchronized (thread) {
|
||||
return super.getBiome(position);
|
||||
}
|
||||
@ -87,6 +95,9 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
if (lastBlock != null && lastVector.equals(position.toBlockVector())) {
|
||||
return lastBlock;
|
||||
}
|
||||
if (!SetQueue.IMP.isChunkLoaded(world, position.getBlockX() >> 4, position.getBlockZ() >> 4)) {
|
||||
return EditSession.nullBlock;
|
||||
}
|
||||
synchronized (thread) {
|
||||
lastVector = position.toBlockVector();
|
||||
return lastBlock = super.getLazyBlock(position);
|
||||
@ -109,9 +120,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
public BaseBlock getBlock(Vector position) {
|
||||
synchronized (thread) {
|
||||
return super.getLazyBlock(position);
|
||||
}
|
||||
return getLazyBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -172,7 +181,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
SetBlockQueue.IMP.setBlock(world, x, location.getBlockY(), z, id, (byte) block.getData());
|
||||
SetQueue.IMP.setBlock(world, x, location.getBlockY(), z, id, (byte) block.getData());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -271,11 +280,11 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
case 190:
|
||||
case 191:
|
||||
case 192: {
|
||||
SetBlockQueue.IMP.setBlock(world, x, y, z, id);
|
||||
SetQueue.IMP.setBlock(world, x, y, z, id);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
SetBlockQueue.IMP.setBlock(world, x, y, z, id, (byte) block.getData());
|
||||
SetQueue.IMP.setBlock(world, x, y, z, id, (byte) block.getData());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -290,7 +299,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
@Override
|
||||
public boolean setBiome(final Vector2D position, final BaseBiome biome) {
|
||||
if (WEManager.IMP.maskContains(mask, position.getBlockX(), position.getBlockZ())) {
|
||||
SetBlockQueue.IMP.setBiome(world, position.getBlockX(), position.getBlockZ(), biome);
|
||||
SetQueue.IMP.setBiome(world, position.getBlockX(), position.getBlockZ(), biome);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ public abstract class FaweQueue {
|
||||
public abstract void setChunk(FaweChunk<?> chunk);
|
||||
|
||||
public abstract boolean fixLighting(FaweChunk<?> chunk, boolean fixAll);
|
||||
|
||||
public abstract boolean isChunkLoaded(String world, int x, int z);
|
||||
|
||||
/**
|
||||
* Gets the FaweChunk and sets the requested blocks
|
||||
@ -28,7 +30,7 @@ public abstract class FaweQueue {
|
||||
// Set memory limited
|
||||
MemUtil.memoryLimitedTask();
|
||||
// Clear block placement
|
||||
SetBlockQueue.IMP.queue.clear();
|
||||
SetQueue.IMP.queue.clear();
|
||||
Fawe.get().getWorldEdit().clearSessions();
|
||||
// GC
|
||||
System.gc();
|
||||
|
@ -6,9 +6,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import com.boydti.fawe.object.FaweChunk;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
public class SetBlockQueue {
|
||||
public class SetQueue {
|
||||
|
||||
public static final SetBlockQueue IMP = new SetBlockQueue();
|
||||
public static final SetQueue IMP = new SetQueue();
|
||||
|
||||
public FaweQueue queue;
|
||||
|
||||
@ -18,7 +18,7 @@ public class SetBlockQueue {
|
||||
private long last;
|
||||
private long last2;
|
||||
|
||||
public SetBlockQueue() {
|
||||
public SetQueue() {
|
||||
TaskManager.IMP.repeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -110,7 +110,7 @@ public class SetBlockQueue {
|
||||
* @return
|
||||
*/
|
||||
public boolean setBlock(final String world, final int x, final int y, final int z, final short id, final byte data) {
|
||||
SetBlockQueue.IMP.setWaiting();
|
||||
SetQueue.IMP.setWaiting();
|
||||
return queue.setBlock(world, x, y, z, id, data);
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ public class SetBlockQueue {
|
||||
* @return
|
||||
*/
|
||||
public boolean setBlock(final String world, final int x, final int y, final int z, final short id) {
|
||||
SetBlockQueue.IMP.setWaiting();
|
||||
SetQueue.IMP.setWaiting();
|
||||
return queue.setBlock(world, x, y, z, id, (byte) 0);
|
||||
}
|
||||
|
||||
@ -137,7 +137,11 @@ public class SetBlockQueue {
|
||||
* @return
|
||||
*/
|
||||
public boolean setBiome(final String world, final int x, final int z, BaseBiome biome) {
|
||||
SetBlockQueue.IMP.setWaiting();
|
||||
SetQueue.IMP.setWaiting();
|
||||
return queue.setBiome(world, x, z, biome);
|
||||
}
|
||||
|
||||
public boolean isChunkLoaded(String world, int x, int z) {
|
||||
return queue.isChunkLoaded(world, x, z);
|
||||
}
|
||||
}
|
@ -86,7 +86,7 @@ public class WEManager {
|
||||
TaskManager.IMP.later(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SetBlockQueue.IMP.addTask(new Runnable() {
|
||||
SetQueue.IMP.addTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if ((System.currentTimeMillis() - start) > 1000) {
|
||||
@ -106,7 +106,7 @@ public class WEManager {
|
||||
}
|
||||
|
||||
public boolean delay(final FawePlayer<?> player, final Runnable whenDone, final boolean delayed, final boolean onlyDelayedExecution) {
|
||||
final boolean free = SetBlockQueue.IMP.addTask(null);
|
||||
final boolean free = SetQueue.IMP.addTask(null);
|
||||
if (free) {
|
||||
if (delayed) {
|
||||
if (whenDone != null) {
|
||||
@ -123,7 +123,7 @@ public class WEManager {
|
||||
if (!delayed && (player != null)) {
|
||||
BBC.WORLDEDIT_DELAYED.send(player);
|
||||
}
|
||||
SetBlockQueue.IMP.addTask(whenDone);
|
||||
SetQueue.IMP.addTask(whenDone);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -161,6 +161,9 @@ public class EditSession implements Extent {
|
||||
private boolean fastmode;
|
||||
private Mask oldMask;
|
||||
|
||||
public static BaseBiome nullBiome = new BaseBiome(0);
|
||||
public static BaseBlock nullBlock = new BaseBlock(0);
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
|
@ -33,7 +33,7 @@ import java.util.Comparator;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.boydti.fawe.util.SetBlockQueue;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
@ -98,7 +98,7 @@ public class SchematicCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
SetBlockQueue.IMP.addTask(new Runnable() {
|
||||
SetQueue.IMP.addTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@ -167,7 +167,7 @@ public class SchematicCommands {
|
||||
target = clipboard;
|
||||
}
|
||||
|
||||
SetBlockQueue.IMP.addTask(new Runnable() {
|
||||
SetQueue.IMP.addTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
|
@ -24,7 +24,7 @@ import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.boydti.fawe.util.SetBlockQueue;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
@ -69,7 +69,7 @@ public class ScriptingCommands {
|
||||
|
||||
final File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().scriptsDir);
|
||||
final File f = worldEdit.getSafeOpenFile(player, dir, name, "js", "js");
|
||||
SetBlockQueue.IMP.addTask(new Runnable() {
|
||||
SetQueue.IMP.addTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@ -107,7 +107,7 @@ public class ScriptingCommands {
|
||||
final File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().scriptsDir);
|
||||
final File f = worldEdit.getSafeOpenFile(player, dir, lastScript, "js", "js");
|
||||
|
||||
SetBlockQueue.IMP.addTask(new Runnable() {
|
||||
SetQueue.IMP.addTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.function.operation;
|
||||
|
||||
import com.boydti.fawe.util.SetBlockQueue;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
@ -85,7 +85,7 @@ public final class Operations {
|
||||
}
|
||||
return;
|
||||
}
|
||||
SetBlockQueue.IMP.addTask(new Runnable() {
|
||||
SetQueue.IMP.addTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
|
Loading…
Reference in New Issue
Block a user