geforkt von Mirrors/FastAsyncWorldEdit
I like change
Dieser Commit ist enthalten in:
Ursprung
86ce762982
Commit
c997a2583c
@ -103,7 +103,7 @@ public class BukkitImageListener implements Listener {
|
||||
if (event.getHand() == EquipmentSlot.OFF_HAND) return;
|
||||
} catch (NoSuchFieldError | NoSuchMethodError ignored) {}
|
||||
|
||||
List<Block> target = player.getLastTwoTargetBlocks((Set<Material>) null, 100);
|
||||
List<Block> target = player.getLastTwoTargetBlocks(null, 100);
|
||||
if (target.isEmpty()) return;
|
||||
|
||||
Block targetBlock = target.get(0);
|
||||
@ -151,7 +151,7 @@ public class BukkitImageListener implements Listener {
|
||||
if (generator == null) return null;
|
||||
|
||||
ImageViewer viewer = generator.getImageViewer();
|
||||
if (viewer == null || !(viewer instanceof BukkitImageViewer)) return null;
|
||||
if (!(viewer instanceof BukkitImageViewer)) return null;
|
||||
|
||||
BukkitImageViewer biv = (BukkitImageViewer) viewer;
|
||||
return biv;
|
||||
@ -185,12 +185,7 @@ public class BukkitImageListener implements Listener {
|
||||
if (frames == null || tool == null) {
|
||||
viewer.selectFrame(itemFrame);
|
||||
player.updateInventory();
|
||||
TaskManager.IMP.laterAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
viewer.view(generator);
|
||||
}
|
||||
}, 1);
|
||||
TaskManager.IMP.laterAsync(() -> viewer.view(generator), 1);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -250,26 +245,23 @@ public class BukkitImageListener implements Listener {
|
||||
if (worldX < 0 || worldX > width || worldZ < 0 || worldZ > length) return;
|
||||
|
||||
|
||||
fp.runAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ);
|
||||
viewer.refresh();
|
||||
int topY = generator.getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255, 0, 255);
|
||||
wPos = wPos.withY(topY);
|
||||
fp.runAction(() -> {
|
||||
BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ);
|
||||
viewer.refresh();
|
||||
int topY = generator.getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255, 0, 255);
|
||||
wPos = wPos.withY(topY);
|
||||
|
||||
EditSession es = new EditSessionBuilder(fp.getWorld()).player(fp).combineStages(false).autoQueue(false).blockBag(null).limitUnlimited().build();
|
||||
ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
||||
if (last.get() instanceof FastWorldEditExtent) last = last.previous();
|
||||
last.setNext(generator);
|
||||
try {
|
||||
brush.build(es, wPos, context.getMaterial(), context.getSize());
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
es.flushQueue();
|
||||
viewer.view(generator);
|
||||
EditSession es = new EditSessionBuilder(fp.getWorld()).player(fp).combineStages(false).autoQueue(false).blockBag(null).limitUnlimited().build();
|
||||
ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
|
||||
if (last.get() instanceof FastWorldEditExtent) last = last.previous();
|
||||
last.setNext(generator);
|
||||
try {
|
||||
brush.build(es, wPos, context.getMaterial(), context.getSize());
|
||||
} catch (WorldEditException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
es.flushQueue();
|
||||
viewer.view(generator);
|
||||
}, true, true);
|
||||
|
||||
|
||||
|
@ -90,17 +90,13 @@ public class CFIPacketListener implements Listener {
|
||||
PlayerInventory inv = plr.getInventory();
|
||||
ItemStack hand = enumHand == EnumWrappers.Hand.MAIN_HAND ? inv.getItemInMainHand() : inv.getItemInOffHand();
|
||||
if (hand != null && hand.getType().isBlock()) {
|
||||
switch (hand.getType()) {
|
||||
case AIR:
|
||||
case CAVE_AIR:
|
||||
case VOID_AIR:
|
||||
break;
|
||||
default:
|
||||
BlockStateHolder block = BukkitAdapter.asBlockState(hand);
|
||||
if (block != null) {
|
||||
gen.setBlock(pt, block);
|
||||
return;
|
||||
}
|
||||
Material type = hand.getType();
|
||||
if (!type.isEmpty()) {
|
||||
BlockStateHolder block = BukkitAdapter.asBlockState(hand);
|
||||
if (block != null) {
|
||||
gen.setBlock(pt, block);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
pt = getRelPos(event, gen);
|
||||
@ -201,9 +197,7 @@ public class CFIPacketListener implements Listener {
|
||||
reply.getIntegers().write(0, id);
|
||||
try {
|
||||
protocolmanager.recieveClientPacket(player, reply);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
@ -8,7 +8,8 @@ public class VaultUtil {
|
||||
public final Permission permission;
|
||||
|
||||
public VaultUtil() {
|
||||
final RegisteredServiceProvider<Permission> permissionProvider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||
final RegisteredServiceProvider<Permission> permissionProvider =
|
||||
Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
this.permission = permissionProvider.getProvider();
|
||||
} else {
|
||||
|
@ -104,7 +104,7 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
|
||||
int[][] sections = getCombinedIdArrays();
|
||||
final int bx = getX() << 4;
|
||||
final int bz = getZ() << 4;
|
||||
boolean update = adapter != null ? adapter.isChunkInUse(chunk) : true;
|
||||
boolean update = adapter == null || adapter.isChunkInUse(chunk);
|
||||
if (layer == -1) {
|
||||
if (adapter != null)
|
||||
{
|
||||
|
@ -113,14 +113,15 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
||||
WirePacket packet = null;
|
||||
int viewDistance = Bukkit.getViewDistance();
|
||||
try {
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
for (FawePlayer fawePlayer : players) {
|
||||
int cx = chunk.getX();
|
||||
int cz = chunk.getZ();
|
||||
|
||||
Player player = ((BukkitPlayer) players[i]).parent;
|
||||
Player player = ((BukkitPlayer) fawePlayer).parent;
|
||||
Location loc = player.getLocation();
|
||||
|
||||
if (Math.abs((loc.getBlockX() >> 4) - cx) <= viewDistance && Math.abs((loc.getBlockZ() >> 4) - cz) <= viewDistance) {
|
||||
if (Math.abs((loc.getBlockX() >> 4) - cx) <= viewDistance
|
||||
&& Math.abs((loc.getBlockZ() >> 4) - cz) <= viewDistance) {
|
||||
if (packet == null) {
|
||||
byte[] data;
|
||||
byte[] buffer = new byte[8192];
|
||||
@ -128,12 +129,12 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
|
||||
chunk = (FaweChunk) chunk.getChunk();
|
||||
}
|
||||
// TODO FIXME
|
||||
// if (chunk instanceof MCAChunk) {
|
||||
// data = new MCAChunkPacket((MCAChunk) chunk, true, true, hasSky()).apply(buffer);
|
||||
// } else {
|
||||
// data = new FaweChunkPacket(chunk, true, true, hasSky()).apply(buffer);
|
||||
// }
|
||||
// packet = new WirePacket(PacketType.Play.Server.MAP_CHUNK, data);
|
||||
// if (chunk instanceof MCAChunk) {
|
||||
// data = new MCAChunkPacket((MCAChunk) chunk, true, true, hasSky()).apply(buffer);
|
||||
// } else {
|
||||
// data = new FaweChunkPacket(chunk, true, true, hasSky()).apply(buffer);
|
||||
// }
|
||||
// packet = new WirePacket(PacketType.Play.Server.MAP_CHUNK, data);
|
||||
}
|
||||
manager.sendWirePacket(player, packet);
|
||||
}
|
||||
|
@ -181,19 +181,16 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
|
||||
|
||||
if (load && unloaded != null) {
|
||||
final ArrayDeque<Chunk> finalUnloaded = unloaded;
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Chunk chunk : finalUnloaded) {
|
||||
int cx = chunk.getX();
|
||||
int cz = chunk.getZ();
|
||||
if (world.isChunkLoaded(cx, cz)) continue;
|
||||
SetQueue.IMP.addTask(() -> {
|
||||
world.loadChunk(chunk.getX(), chunk.getZ(), false);
|
||||
world.refreshChunk(chunk.getX(), chunk.getZ());
|
||||
});
|
||||
TaskManager.IMP.async(() -> {
|
||||
for (Chunk chunk : finalUnloaded) {
|
||||
int cx = chunk.getX();
|
||||
int cz = chunk.getZ();
|
||||
if (world.isChunkLoaded(cx, cz)) continue;
|
||||
SetQueue.IMP.addTask(() -> {
|
||||
world.loadChunk(chunk.getX(), chunk.getZ(), false);
|
||||
world.refreshChunk(chunk.getX(), chunk.getZ());
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
// load chunks
|
||||
|
@ -58,26 +58,23 @@ public abstract class ChunkListener implements Listener {
|
||||
Plugin plugin = Fawe.<FaweBukkit>imp().getPlugin();
|
||||
plm.registerEvents(this, plugin);
|
||||
try { plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {}
|
||||
TaskManager.IMP.repeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
rateLimit--;
|
||||
physicsFreeze = false;
|
||||
itemFreeze = false;
|
||||
lastZ = Integer.MIN_VALUE;
|
||||
physSkip = 0;
|
||||
physCancelPair = Long.MIN_VALUE;
|
||||
physCancel = false;
|
||||
TaskManager.IMP.repeat(() -> {
|
||||
rateLimit--;
|
||||
physicsFreeze = false;
|
||||
itemFreeze = false;
|
||||
lastZ = Integer.MIN_VALUE;
|
||||
physSkip = 0;
|
||||
physCancelPair = Long.MIN_VALUE;
|
||||
physCancel = false;
|
||||
|
||||
counter.clear();
|
||||
for (Long2ObjectMap.Entry<Boolean> entry : badChunks.long2ObjectEntrySet()) {
|
||||
long key = entry.getLongKey();
|
||||
int x = MathMan.unpairIntX(key);
|
||||
int z = MathMan.unpairIntY(key);
|
||||
counter.put(key, badLimit);
|
||||
}
|
||||
badChunks.clear();
|
||||
counter.clear();
|
||||
for (Long2ObjectMap.Entry<Boolean> entry : badChunks.long2ObjectEntrySet()) {
|
||||
long key = entry.getLongKey();
|
||||
int x = MathMan.unpairIntX(key);
|
||||
int z = MathMan.unpairIntY(key);
|
||||
counter.put(key, badLimit);
|
||||
}
|
||||
badChunks.clear();
|
||||
}, Settings.IMP.TICK_LIMITER.INTERVAL);
|
||||
}
|
||||
}
|
||||
|
@ -204,9 +204,10 @@ public class AsyncBlock implements Block {
|
||||
@Override
|
||||
public BlockFace getFace(Block block) {
|
||||
BlockFace[] directions = BlockFace.values();
|
||||
for(int i = 0; i < directions.length; ++i) {
|
||||
BlockFace face = directions[i];
|
||||
if(this.getX() + face.getModX() == block.getX() && this.getY() + face.getModY() == block.getY() && this.getZ() + face.getModZ() == block.getZ()) {
|
||||
for (BlockFace face : directions) {
|
||||
if (this.getX() + face.getModX() == block.getX()
|
||||
&& this.getY() + face.getModY() == block.getY()
|
||||
&& this.getZ() + face.getModZ() == block.getZ()) {
|
||||
return face;
|
||||
}
|
||||
}
|
||||
@ -272,14 +273,7 @@ public class AsyncBlock implements Block {
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
switch (getType()) {
|
||||
case AIR:
|
||||
case CAVE_AIR:
|
||||
case VOID_AIR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return getType().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,7 +29,7 @@ public class AsyncChunk implements Chunk {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof Chunk)) {
|
||||
if (!(obj instanceof Chunk)) {
|
||||
return false;
|
||||
}
|
||||
Chunk other = (Chunk) obj;
|
||||
@ -88,14 +88,14 @@ public class AsyncChunk implements Chunk {
|
||||
BukkitQueue_0 bq = (BukkitQueue_0) queue;
|
||||
if (world.isChunkLoaded(x, z)) {
|
||||
long pair = MathMan.pairInt(x, z);
|
||||
Long originalKeep = bq.keepLoaded.get(pair);
|
||||
bq.keepLoaded.put(pair, Long.MAX_VALUE);
|
||||
Long originalKeep = BukkitQueue_0.keepLoaded.get(pair);
|
||||
BukkitQueue_0.keepLoaded.put(pair, Long.MAX_VALUE);
|
||||
if (world.isChunkLoaded(x, z)) {
|
||||
task.run();
|
||||
if (originalKeep != null) {
|
||||
bq.keepLoaded.put(pair, originalKeep);
|
||||
BukkitQueue_0.keepLoaded.put(pair, originalKeep);
|
||||
} else {
|
||||
bq.keepLoaded.remove(pair);
|
||||
BukkitQueue_0.keepLoaded.remove(pair);
|
||||
}
|
||||
return task.value;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
this.parent = parent;
|
||||
this.queue = queue;
|
||||
if (queue instanceof BukkitQueue_0) {
|
||||
this.adapter = (BukkitImplAdapter) ((BukkitQueue_0) queue).getAdapter();
|
||||
this.adapter = BukkitQueue_0.getAdapter();
|
||||
} else {
|
||||
try {
|
||||
this.adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
@ -141,12 +141,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
if (queue != this.queue) {
|
||||
if (this.queue != null) {
|
||||
final FaweQueue oldQueue = this.queue;
|
||||
TaskManager.IMP.async(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
oldQueue.flush();
|
||||
}
|
||||
});
|
||||
TaskManager.IMP.async(oldQueue::flush);
|
||||
}
|
||||
this.queue = queue;
|
||||
}
|
||||
@ -354,7 +349,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || !(obj instanceof World)) {
|
||||
if (!(obj instanceof World)) {
|
||||
return false;
|
||||
}
|
||||
World other = (World) obj;
|
||||
@ -571,7 +566,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
return TaskManager.IMP.sync(new RunnableVal<Collection<T>>() {
|
||||
@Override
|
||||
public void run(Collection<T> value) {
|
||||
this.value = (Collection<T>) parent.getEntitiesByClass(classes);
|
||||
this.value = parent.getEntitiesByClass(classes);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -581,7 +576,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
return TaskManager.IMP.sync(new RunnableVal<Collection<T>>() {
|
||||
@Override
|
||||
public void run(Collection<T> value) {
|
||||
this.value = (Collection<T>) parent.getEntitiesByClass(cls);
|
||||
this.value = parent.getEntitiesByClass(cls);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -799,22 +794,12 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
|
||||
@Override
|
||||
@Deprecated
|
||||
public FallingBlock spawnFallingBlock(Location location, Material material, byte data) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(new Supplier<FallingBlock>() {
|
||||
@Override
|
||||
public FallingBlock get() {
|
||||
return parent.spawnFallingBlock(location, material, data);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, material, data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FallingBlock spawnFallingBlock(Location location, BlockData blockData) throws IllegalArgumentException {
|
||||
return TaskManager.IMP.sync(new Supplier<FallingBlock>() {
|
||||
@Override
|
||||
public FallingBlock get() {
|
||||
return parent.spawnFallingBlock(location, blockData);
|
||||
}
|
||||
});
|
||||
return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, blockData));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren