Dieser Commit ist enthalten in:
matt 2019-04-01 21:28:49 -04:00
Ursprung 86ce762982
Commit c997a2583c
10 geänderte Dateien mit 81 neuen und 120 gelöschten Zeilen

Datei anzeigen

@ -103,7 +103,7 @@ public class BukkitImageListener implements Listener {
if (event.getHand() == EquipmentSlot.OFF_HAND) return; if (event.getHand() == EquipmentSlot.OFF_HAND) return;
} catch (NoSuchFieldError | NoSuchMethodError ignored) {} } catch (NoSuchFieldError | NoSuchMethodError ignored) {}
List<Block> target = player.getLastTwoTargetBlocks((Set<Material>) null, 100); List<Block> target = player.getLastTwoTargetBlocks(null, 100);
if (target.isEmpty()) return; if (target.isEmpty()) return;
Block targetBlock = target.get(0); Block targetBlock = target.get(0);
@ -151,7 +151,7 @@ public class BukkitImageListener implements Listener {
if (generator == null) return null; if (generator == null) return null;
ImageViewer viewer = generator.getImageViewer(); ImageViewer viewer = generator.getImageViewer();
if (viewer == null || !(viewer instanceof BukkitImageViewer)) return null; if (!(viewer instanceof BukkitImageViewer)) return null;
BukkitImageViewer biv = (BukkitImageViewer) viewer; BukkitImageViewer biv = (BukkitImageViewer) viewer;
return biv; return biv;
@ -185,12 +185,7 @@ public class BukkitImageListener implements Listener {
if (frames == null || tool == null) { if (frames == null || tool == null) {
viewer.selectFrame(itemFrame); viewer.selectFrame(itemFrame);
player.updateInventory(); player.updateInventory();
TaskManager.IMP.laterAsync(new Runnable() { TaskManager.IMP.laterAsync(() -> viewer.view(generator), 1);
@Override
public void run() {
viewer.view(generator);
}
}, 1);
return; return;
} }
@ -250,26 +245,23 @@ public class BukkitImageListener implements Listener {
if (worldX < 0 || worldX > width || worldZ < 0 || worldZ > length) return; if (worldX < 0 || worldX > width || worldZ < 0 || worldZ > length) return;
fp.runAction(new Runnable() { fp.runAction(() -> {
@Override BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ);
public void run() { viewer.refresh();
BlockVector3 wPos = BlockVector3.at(worldX, 0, worldZ); int topY = generator.getNearestSurfaceTerrainBlock(wPos.getBlockX(), wPos.getBlockZ(), 255, 0, 255);
viewer.refresh(); wPos = wPos.withY(topY);
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(); EditSession es = new EditSessionBuilder(fp.getWorld()).player(fp).combineStages(false).autoQueue(false).blockBag(null).limitUnlimited().build();
ExtentTraverser last = new ExtentTraverser(es.getExtent()).last(); ExtentTraverser last = new ExtentTraverser(es.getExtent()).last();
if (last.get() instanceof FastWorldEditExtent) last = last.previous(); if (last.get() instanceof FastWorldEditExtent) last = last.previous();
last.setNext(generator); last.setNext(generator);
try { try {
brush.build(es, wPos, context.getMaterial(), context.getSize()); brush.build(es, wPos, context.getMaterial(), context.getSize());
} catch (WorldEditException e) { } catch (WorldEditException e) {
e.printStackTrace(); e.printStackTrace();
}
es.flushQueue();
viewer.view(generator);
} }
es.flushQueue();
viewer.view(generator);
}, true, true); }, true, true);

Datei anzeigen

@ -90,17 +90,13 @@ public class CFIPacketListener implements Listener {
PlayerInventory inv = plr.getInventory(); PlayerInventory inv = plr.getInventory();
ItemStack hand = enumHand == EnumWrappers.Hand.MAIN_HAND ? inv.getItemInMainHand() : inv.getItemInOffHand(); ItemStack hand = enumHand == EnumWrappers.Hand.MAIN_HAND ? inv.getItemInMainHand() : inv.getItemInOffHand();
if (hand != null && hand.getType().isBlock()) { if (hand != null && hand.getType().isBlock()) {
switch (hand.getType()) { Material type = hand.getType();
case AIR: if (!type.isEmpty()) {
case CAVE_AIR: BlockStateHolder block = BukkitAdapter.asBlockState(hand);
case VOID_AIR: if (block != null) {
break; gen.setBlock(pt, block);
default: return;
BlockStateHolder block = BukkitAdapter.asBlockState(hand); }
if (block != null) {
gen.setBlock(pt, block);
return;
}
} }
} }
pt = getRelPos(event, gen); pt = getRelPos(event, gen);
@ -201,9 +197,7 @@ public class CFIPacketListener implements Listener {
reply.getIntegers().write(0, id); reply.getIntegers().write(0, id);
try { try {
protocolmanager.recieveClientPacket(player, reply); protocolmanager.recieveClientPacket(player, reply);
} catch (IllegalAccessException e) { } catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
event.setCancelled(true); event.setCancelled(true);

Datei anzeigen

@ -8,7 +8,8 @@ public class VaultUtil {
public final Permission permission; public final Permission permission;
public VaultUtil() { 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) { if (permissionProvider != null) {
this.permission = permissionProvider.getProvider(); this.permission = permissionProvider.getProvider();
} else { } else {

Datei anzeigen

@ -104,7 +104,7 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
int[][] sections = getCombinedIdArrays(); int[][] sections = getCombinedIdArrays();
final int bx = getX() << 4; final int bx = getX() << 4;
final int bz = getZ() << 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 (layer == -1) {
if (adapter != null) if (adapter != null)
{ {

Datei anzeigen

@ -113,14 +113,15 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
WirePacket packet = null; WirePacket packet = null;
int viewDistance = Bukkit.getViewDistance(); int viewDistance = Bukkit.getViewDistance();
try { try {
for (int i = 0; i < players.length; i++) { for (FawePlayer fawePlayer : players) {
int cx = chunk.getX(); int cx = chunk.getX();
int cz = chunk.getZ(); int cz = chunk.getZ();
Player player = ((BukkitPlayer) players[i]).parent; Player player = ((BukkitPlayer) fawePlayer).parent;
Location loc = player.getLocation(); 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) { if (packet == null) {
byte[] data; byte[] data;
byte[] buffer = new byte[8192]; byte[] buffer = new byte[8192];
@ -128,12 +129,12 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
chunk = (FaweChunk) chunk.getChunk(); chunk = (FaweChunk) chunk.getChunk();
} }
// TODO FIXME // TODO FIXME
// if (chunk instanceof MCAChunk) { // if (chunk instanceof MCAChunk) {
// data = new MCAChunkPacket((MCAChunk) chunk, true, true, hasSky()).apply(buffer); // data = new MCAChunkPacket((MCAChunk) chunk, true, true, hasSky()).apply(buffer);
// } else { // } else {
// data = new FaweChunkPacket(chunk, true, true, hasSky()).apply(buffer); // data = new FaweChunkPacket(chunk, true, true, hasSky()).apply(buffer);
// } // }
// packet = new WirePacket(PacketType.Play.Server.MAP_CHUNK, data); // packet = new WirePacket(PacketType.Play.Server.MAP_CHUNK, data);
} }
manager.sendWirePacket(player, packet); manager.sendWirePacket(player, packet);
} }

Datei anzeigen

@ -181,19 +181,16 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
if (load && unloaded != null) { if (load && unloaded != null) {
final ArrayDeque<Chunk> finalUnloaded = unloaded; final ArrayDeque<Chunk> finalUnloaded = unloaded;
TaskManager.IMP.async(new Runnable() { TaskManager.IMP.async(() -> {
@Override for (Chunk chunk : finalUnloaded) {
public void run() { int cx = chunk.getX();
for (Chunk chunk : finalUnloaded) { int cz = chunk.getZ();
int cx = chunk.getX(); if (world.isChunkLoaded(cx, cz)) continue;
int cz = chunk.getZ(); SetQueue.IMP.addTask(() -> {
if (world.isChunkLoaded(cx, cz)) continue; world.loadChunk(chunk.getX(), chunk.getZ(), false);
SetQueue.IMP.addTask(() -> { world.refreshChunk(chunk.getX(), chunk.getZ());
world.loadChunk(chunk.getX(), chunk.getZ(), false); });
world.refreshChunk(chunk.getX(), chunk.getZ());
});
}
} }
}); });
// load chunks // load chunks

Datei anzeigen

@ -58,26 +58,23 @@ public abstract class ChunkListener implements Listener {
Plugin plugin = Fawe.<FaweBukkit>imp().getPlugin(); Plugin plugin = Fawe.<FaweBukkit>imp().getPlugin();
plm.registerEvents(this, plugin); plm.registerEvents(this, plugin);
try { plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {} try { plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {}
TaskManager.IMP.repeat(new Runnable() { TaskManager.IMP.repeat(() -> {
@Override rateLimit--;
public void run() { physicsFreeze = false;
rateLimit--; itemFreeze = false;
physicsFreeze = false; lastZ = Integer.MIN_VALUE;
itemFreeze = false; physSkip = 0;
lastZ = Integer.MIN_VALUE; physCancelPair = Long.MIN_VALUE;
physSkip = 0; physCancel = false;
physCancelPair = Long.MIN_VALUE;
physCancel = false;
counter.clear(); counter.clear();
for (Long2ObjectMap.Entry<Boolean> entry : badChunks.long2ObjectEntrySet()) { for (Long2ObjectMap.Entry<Boolean> entry : badChunks.long2ObjectEntrySet()) {
long key = entry.getLongKey(); long key = entry.getLongKey();
int x = MathMan.unpairIntX(key); int x = MathMan.unpairIntX(key);
int z = MathMan.unpairIntY(key); int z = MathMan.unpairIntY(key);
counter.put(key, badLimit); counter.put(key, badLimit);
}
badChunks.clear();
} }
badChunks.clear();
}, Settings.IMP.TICK_LIMITER.INTERVAL); }, Settings.IMP.TICK_LIMITER.INTERVAL);
} }
} }
@ -381,4 +378,4 @@ public abstract class ChunkListener implements Listener {
return; return;
} }
} }
} }

Datei anzeigen

@ -204,9 +204,10 @@ public class AsyncBlock implements Block {
@Override @Override
public BlockFace getFace(Block block) { public BlockFace getFace(Block block) {
BlockFace[] directions = BlockFace.values(); BlockFace[] directions = BlockFace.values();
for(int i = 0; i < directions.length; ++i) { for (BlockFace face : directions) {
BlockFace face = directions[i]; if (this.getX() + face.getModX() == block.getX()
if(this.getX() + face.getModX() == block.getX() && this.getY() + face.getModY() == block.getY() && this.getZ() + face.getModZ() == block.getZ()) { && this.getY() + face.getModY() == block.getY()
&& this.getZ() + face.getModZ() == block.getZ()) {
return face; return face;
} }
} }
@ -272,14 +273,7 @@ public class AsyncBlock implements Block {
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
switch (getType()) { return getType().isEmpty();
case AIR:
case CAVE_AIR:
case VOID_AIR:
return true;
default:
return false;
}
} }
@Override @Override

Datei anzeigen

@ -29,7 +29,7 @@ public class AsyncChunk implements Chunk {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null || !(obj instanceof Chunk)) { if (!(obj instanceof Chunk)) {
return false; return false;
} }
Chunk other = (Chunk) obj; Chunk other = (Chunk) obj;
@ -88,14 +88,14 @@ public class AsyncChunk implements Chunk {
BukkitQueue_0 bq = (BukkitQueue_0) queue; BukkitQueue_0 bq = (BukkitQueue_0) queue;
if (world.isChunkLoaded(x, z)) { if (world.isChunkLoaded(x, z)) {
long pair = MathMan.pairInt(x, z); long pair = MathMan.pairInt(x, z);
Long originalKeep = bq.keepLoaded.get(pair); Long originalKeep = BukkitQueue_0.keepLoaded.get(pair);
bq.keepLoaded.put(pair, Long.MAX_VALUE); BukkitQueue_0.keepLoaded.put(pair, Long.MAX_VALUE);
if (world.isChunkLoaded(x, z)) { if (world.isChunkLoaded(x, z)) {
task.run(); task.run();
if (originalKeep != null) { if (originalKeep != null) {
bq.keepLoaded.put(pair, originalKeep); BukkitQueue_0.keepLoaded.put(pair, originalKeep);
} else { } else {
bq.keepLoaded.remove(pair); BukkitQueue_0.keepLoaded.remove(pair);
} }
return task.value; return task.value;
} }

Datei anzeigen

@ -114,7 +114,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
this.parent = parent; this.parent = parent;
this.queue = queue; this.queue = queue;
if (queue instanceof BukkitQueue_0) { if (queue instanceof BukkitQueue_0) {
this.adapter = (BukkitImplAdapter) ((BukkitQueue_0) queue).getAdapter(); this.adapter = BukkitQueue_0.getAdapter();
} else { } else {
try { try {
this.adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); this.adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
@ -141,12 +141,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
if (queue != this.queue) { if (queue != this.queue) {
if (this.queue != null) { if (this.queue != null) {
final FaweQueue oldQueue = this.queue; final FaweQueue oldQueue = this.queue;
TaskManager.IMP.async(new Runnable() { TaskManager.IMP.async(oldQueue::flush);
@Override
public void run() {
oldQueue.flush();
}
});
} }
this.queue = queue; this.queue = queue;
} }
@ -354,7 +349,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null || !(obj instanceof World)) { if (!(obj instanceof World)) {
return false; return false;
} }
World other = (World) obj; World other = (World) obj;
@ -571,7 +566,7 @@ public class AsyncWorld extends DelegateFaweQueue implements World, HasFaweQueue
return TaskManager.IMP.sync(new RunnableVal<Collection<T>>() { return TaskManager.IMP.sync(new RunnableVal<Collection<T>>() {
@Override @Override
public void run(Collection<T> value) { 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>>() { return TaskManager.IMP.sync(new RunnableVal<Collection<T>>() {
@Override @Override
public void run(Collection<T> value) { 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 @Override
@Deprecated @Deprecated
public FallingBlock spawnFallingBlock(Location location, Material material, byte data) throws IllegalArgumentException { public FallingBlock spawnFallingBlock(Location location, Material material, byte data) throws IllegalArgumentException {
return TaskManager.IMP.sync(new Supplier<FallingBlock>() { return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, material, data));
@Override
public FallingBlock get() {
return parent.spawnFallingBlock(location, material, data);
}
});
} }
@Override @Override
public FallingBlock spawnFallingBlock(Location location, BlockData blockData) throws IllegalArgumentException { public FallingBlock spawnFallingBlock(Location location, BlockData blockData) throws IllegalArgumentException {
return TaskManager.IMP.sync(new Supplier<FallingBlock>() { return TaskManager.IMP.sync(() -> parent.spawnFallingBlock(location, blockData));
@Override
public FallingBlock get() {
return parent.spawnFallingBlock(location, blockData);
}
});
} }
@Override @Override