add git revision to jar
fix fixlighting
fix fallback bukkit queue
(currently not stable for forge/sponge)
This commit is contained in:
Jesse Boyd 2016-05-13 18:19:04 +10:00
parent b5a8eb2176
commit 00c685cd93
16 changed files with 106 additions and 75 deletions

View File

@ -6,14 +6,21 @@ buildscript {
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
classpath 'org.ajoberstar:grgit:1.1.0'
}
}
apply plugin: 'java'
clean { delete "target" }
group = 'com.boydti.fawe'
version = '3.4.3'
def revision = ""
ext {
git = org.ajoberstar.grgit.Grgit.open(file(".git/"))
revision = "-${git.head().abbreviatedId}"
}
version = "3.5.0${revision}"
description = """FastAsyncWorldEdit"""
subprojects {

View File

@ -191,6 +191,9 @@ public class FaweBukkit implements IFawe, Listener {
try {
return plugin.getQueue(world);
} catch (Throwable ignore) {}
// Disable incompatible settings
Settings.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level
Settings.COMBINE_HISTORY_STAGE = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI
if (hasNMS) {
debug("====== NO NMS BLOCK PLACER FOUND ======");
debug("FAWE couldn't find a fast block placer");

View File

@ -35,6 +35,14 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
setupAdapter(null);
}
public void checkVersion(String supported) {
String version = Bukkit.getServer().getClass().getPackage().getName();
if (!version.contains(supported)) {
Fawe.debug("This version of FAWE is for: " + supported);
throw new IllegalStateException("Unsupported version: " + version + " (supports: " + supported + ")");
}
}
public void setupAdapter(BukkitImplAdapter adapter) {
try {
WorldEditPlugin instance = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
@ -58,7 +66,6 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
}
}
} catch (Throwable e) {
e.printStackTrace();
Fawe.debug("====== NO NATIVE WORLDEDIT ADAPTER ======");
Fawe.debug("Try updating WorldEdit: ");
Fawe.debug(" - http://builds.enginehub.org/job/worldedit?branch=master");
@ -208,6 +215,7 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
}
if (more) {
fc.addToQueue();
return true;
}
// Biomes

View File

@ -11,7 +11,7 @@ shadowJar {
include(dependency(':bukkit0'))
include(dependency(':core'))
}
archiveName = "${parent.name}-${project.name}.jar"
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
destinationDir = file '../target'
}
shadowJar.doLast {

View File

@ -49,6 +49,7 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
public BukkitQueue18R3(final String world) {
super(world);
checkVersion("v1_8_R3");
}
@Override
@ -256,6 +257,7 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
}
int k = FaweCache.CACHE_J[ly][lx][lz];
if (array[k] != 0) {
tile.getValue().E();
iterator.remove();
}
}
@ -342,7 +344,7 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
} catch (Throwable e) {
e.printStackTrace();
}
sendChunk(fc);
sendChunk(fc, null);
return true;
}
@ -387,6 +389,9 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
@Override
public boolean fixLighting(FaweChunk chunk, RelightMode mode) {
if (mode == RelightMode.NONE) {
return true;
}
try {
CharFaweChunk<Chunk> fc = (CharFaweChunk<Chunk>) chunk;
CraftChunk craftChunk = (CraftChunk) fc.getChunk();
@ -395,13 +400,11 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
return false;
}
ChunkSection[] sections = nmsChunk.getSections();
if (mode != RelightMode.MINIMAL) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
if (section != null) {
if (mode == RelightMode.ALL) {
section.a(new NibbleArray());
}
section.b(new NibbleArray());
}
}
@ -421,24 +424,34 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
if (section == null) {
continue;
}
if ((fc.getRelight(j) == 0 && mode == RelightMode.MINIMAL) || (fc.getCount(j) == 0 && mode != RelightMode.ALL) || (fc.getCount(j) >= 4096 && fc.getAir(j) == 0)) {
if (((fc.getRelight(j) == 0) && mode == RelightMode.MINIMAL) || (fc.getCount(j) == 0 && mode != RelightMode.ALL) || ((fc.getCount(j) >= 4096) && (fc.getAir(j) == 0)) || fc.getAir(j) == 4096) {
continue;
}
char[] array = section.getIdArray();
int l = PseudoRandom.random.random(2);
for (int k = 0; k < array.length; k++) {
int i = array[k];
if (i < 16) {
if (mode == RelightMode.ALL) {
for (int k = array.length - 1; k >= 0; k--) {
final int x = FaweCache.CACHE_X[j][k];
final int y = FaweCache.CACHE_Y[j][k];
final int z = FaweCache.CACHE_Z[j][k];
if (isSurrounded(sections, x, y, z)) {
continue;
}
short id = (short) (i >> 4);
pos.c(X + x, y, Z + z);
nmsWorld.x(pos);
}
continue;
}
for (int k = array.length - 1; k >= 0; k--) {
final int i = array[k];
final short id = (short) (i >> 4);
switch (id) { // Lighting
case 0:
continue;
default:
if (mode == RelightMode.MINIMAL) {
continue;
}
if ((k & 1) == l) {
l = 1 - l;
if (PseudoRandom.random.random(3) != 0) {
continue;
}
case 10:
@ -456,9 +469,9 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
case 130:
case 138:
case 169:
int x = FaweCache.CACHE_X[j][k];
int y = FaweCache.CACHE_Y[j][k];
int z = FaweCache.CACHE_Z[j][k];
final int x = FaweCache.CACHE_X[j][k];
final int y = FaweCache.CACHE_Y[j][k];
final int z = FaweCache.CACHE_Z[j][k];
if (isSurrounded(sections, x, y, z)) {
continue;
}

View File

@ -4,6 +4,7 @@ dependencies {
}
apply plugin: 'com.github.johnrengelman.shadow'
// We only want the shadow jar produced
jar.enabled = false
shadowJar {
@ -11,7 +12,7 @@ shadowJar {
include(dependency(':bukkit0'))
include(dependency(':core'))
}
archiveName = "${parent.name}-${project.name}.jar"
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
destinationDir = file '../target'
}
shadowJar.doLast {

View File

@ -46,7 +46,6 @@ import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Biome;
import org.bukkit.craftbukkit.v1_9_R2.CraftChunk;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent;
public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], DataPaletteBlock> {
@ -55,20 +54,19 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
public BukkitQueue_1_9_R1(final String world) {
super(world);
checkVersion("v1_9_R2");
try {
Field fieldAir = DataPaletteBlock.class.getDeclaredField("a");
fieldAir.setAccessible(true);
air = (IBlockData) fieldAir.get(null);
if (adapter == null) {
setupAdapter(new FaweAdapter_1_9());
Fawe.debug("=========================================");
Fawe.debug("Using adapter: " + adapter);
Fawe.debug("=========================================");
}
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException(e);
}
Player player = null;
}
@Override
@ -102,6 +100,9 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
@Override
public boolean fixLighting(final FaweChunk pc, RelightMode mode) {
if (mode == RelightMode.NONE) {
return true;
}
try {
CharFaweChunk bc = (CharFaweChunk) pc;
Chunk chunk = (Chunk) bc.getChunk();
@ -113,13 +114,11 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
}
net.minecraft.server.v1_9_R2.Chunk c = ((CraftChunk) chunk).getHandle();
ChunkSection[] sections = c.getSections();
if (mode != RelightMode.MINIMAL) {
if (mode == RelightMode.ALL) {
for (int i = 0; i < sections.length; i++) {
ChunkSection section = sections[i];
if (section != null) {
if (mode == RelightMode.ALL) {
section.a(new NibbleArray());
}
section.b(new NibbleArray());
}
}
@ -136,24 +135,33 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
final int X = chunk.getX() << 4;
final int Z = chunk.getZ() << 4;
BlockPosition.MutableBlockPosition pos = new BlockPosition.MutableBlockPosition(0, 0, 0);
for (int j = 0; j < sections.length; j++) {
for (int j = sections.length - 1; j >= 0; j--) {
final Object section = sections[j];
if (section == null) {
continue;
}
if (((bc.getRelight(j) == 0) && mode == RelightMode.MINIMAL) || (bc.getCount(j) == 0 && mode != RelightMode.ALL) || ((bc.getCount(j) >= 4096) && (bc.getAir(j) == 0))) {
if (((bc.getRelight(j) == 0) && mode == RelightMode.MINIMAL) || (bc.getCount(j) == 0 && mode != RelightMode.ALL) || ((bc.getCount(j) >= 4096) && (bc.getAir(j) == 0)) || bc.getAir(j) == 4096) {
continue;
}
final char[] array = bc.getIdArray(j);
if (array == null) {
continue;
}
int l = PseudoRandom.random.random(2);
for (int k = 0; k < array.length; k++) {
final int i = array[k];
if (i < 16) {
if (mode == RelightMode.ALL) {
for (int k = array.length - 1; k >= 0; k--) {
final int x = FaweCache.CACHE_X[j][k];
final int y = FaweCache.CACHE_Y[j][k];
final int z = FaweCache.CACHE_Z[j][k];
if (this.isSurrounded(bc.getCombinedIdArrays(), x, y, z)) {
continue;
}
pos.c(X + x, y, Z + z);
w.w(pos);
}
continue;
}
for (int k = array.length - 1; k >= 0; k--) {
final int i = array[k];
final short id = (short) (i >> 4);
switch (id) { // Lighting
case 0:
@ -162,8 +170,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
if (mode == RelightMode.MINIMAL) {
continue;
}
if ((k & 1) == l) {
l = 1 - l;
if (PseudoRandom.random.random(3) != 0) {
continue;
}
case 10:
@ -461,6 +468,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
}
int k = FaweCache.CACHE_J[ly][lx][lz];
if (array[k] != 0) {
tile.getValue().invalidateBlockCache();
iterator.remove();
}
}
@ -579,7 +587,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
}
}
}
sendChunk(fs);
sendChunk(fs, null);
return true;
}

View File

@ -1,6 +1,5 @@
package com.boydti.fawe.command;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweCommand;
import com.boydti.fawe.object.FaweLocation;
@ -43,7 +42,7 @@ public class FixLighting extends FaweCommand {
FaweQueue queue = SetQueue.IMP.getNewQueue(loc.world, true, false);
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
queue.fixLighting(queue.getChunk(x, z), FaweQueue.RelightMode.ALL);
queue.sendChunk(queue.getChunk(x, z), FaweQueue.RelightMode.ALL);
count++;
}
}

View File

@ -19,8 +19,7 @@ public enum BBC {
*/
PREFIX("&8(&4&lFAWE&8)&7", "Info"),
SCHEMATIC_PASTING("&7The schematic is pasting. This cannot be undone.", "Info"),
FIX_LIGHTING_CHUNK("&7Lighting has been fixed in your current chunk. Relog to see the affect.", "Info"),
FIX_LIGHTING_SELECTION("&7Lighting has been fixed in %s0 chunks. Relog to see the affect.", "Info"),
FIX_LIGHTING_SELECTION("&7Lighting has been fixed in %s0 chunks. (It may take a second for the packets to send)", "Info"),
SET_REGION("&7Selection set to your current WorldEdit region", "Info"),
WORLDEDIT_COMMAND_LIMIT("&7Please wait until your current action completes", "Info"),
WORLDEDIT_DELAYED("&7Please wait while we process your WorldEdit action...", "Info"),

View File

@ -13,7 +13,6 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.biome.BaseBiome;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingDeque;
@ -75,8 +74,6 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
public abstract boolean regenerateChunk(WORLD world, int x, int z);
public abstract void sendChunk(FaweChunk chunk);
public abstract boolean setComponents(FaweChunk fc, RunnableVal<FaweChunk> changeTask);
@Override
@ -344,13 +341,6 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
chunks.add((FaweChunk) chunk);
}
public Collection<FaweChunk> sendChunk(Collection<FaweChunk> fcs) {
for (final FaweChunk fc : fcs) {
sendChunk(fc);
}
return new ArrayList<>();
}
public int lastChunkX = Integer.MIN_VALUE;
public int lastChunkZ = Integer.MIN_VALUE;
public int lastChunkY = Integer.MIN_VALUE;

View File

@ -15,16 +15,20 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
}
@Override
public void sendChunk(final FaweChunk fc) {
public void sendChunk(final FaweChunk fc, RelightMode mode) {
if (mode == null) {
mode = Settings.FIX_ALL_LIGHTING ? FaweQueue.RelightMode.OPTIMAL : FaweQueue.RelightMode.MINIMAL;
}
final RelightMode finalMode = mode;
TaskManager.IMP.taskSyncSoon(new Runnable() {
@Override
public void run() {
final boolean result = fixLighting(fc, Settings.FIX_ALL_LIGHTING ? FaweQueue.RelightMode.OPTIMAL : FaweQueue.RelightMode.MINIMAL) || !Settings.ASYNC_LIGHTING;
final boolean result = finalMode == RelightMode.NONE || fixLighting(fc, finalMode);
TaskManager.IMP.taskSyncNow(new Runnable() {
@Override
public void run() {
if (!result) {
fixLighting(fc, Settings.FIX_ALL_LIGHTING ? FaweQueue.RelightMode.OPTIMAL : FaweQueue.RelightMode.MINIMAL);
fixLighting(fc, finalMode);
}
CHUNK chunk = (CHUNK) fc.getChunk();
refreshChunk(getWorld(), chunk);

View File

@ -55,12 +55,11 @@ public class DiskOptimizedClipboard extends FaweClipboard {
this(width, height, length, new File(Fawe.imp().getDirectory(), "clipboard" + File.separator + uuid));
}
public DiskOptimizedClipboard(File file) {
public DiskOptimizedClipboard(File file) throws IOException {
nbtMap = new HashMap<>();
entities = new HashSet<>();this.buffer = new byte[2];
this.file = file;
this.lastAccessed = System.currentTimeMillis();
try {
this.raf = new BufferedRandomAccessFile(file, "rw", Settings.BUFFER_SIZE);
raf.setLength(file.length());
long size = (raf.length() - HEADER_SIZE) >> 1;
@ -72,9 +71,6 @@ public class DiskOptimizedClipboard extends FaweClipboard {
length = (((buffer[1] & 0xFF) << 8) + ((buffer[0] & 0xFF)));
height = (int) (size / (width * length));
area = width * length;
} catch (IOException e) {
e.printStackTrace();
}
autoCloseTask();
}

View File

@ -22,6 +22,7 @@ public abstract class FaweQueue {
}
public enum RelightMode {
NONE,
MINIMAL,
OPTIMAL,
ALL,
@ -124,6 +125,8 @@ public abstract class FaweQueue {
// Unload chunks
}
public abstract void sendChunk(FaweChunk chunk, RelightMode mode);
/**
* This method is called when the server is < 1% available memory
*/

View File

@ -52,7 +52,7 @@ shadowJar {
include(dependency(':core'))
include(dependency('org.yaml:snakeyaml:1.16'))
}
archiveName = "${parent.name}-${project.name}.jar"
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
destinationDir = file '../target'
}
shadowJar.doLast {

View File

@ -61,7 +61,7 @@ shadowJar {
include(dependency(':core'))
include(dependency('org.yaml:snakeyaml:1.16'))
}
archiveName = "${parent.name}-${project.name}.jar"
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
destinationDir = file '../target'
}
shadowJar.doLast {

View File

@ -67,7 +67,7 @@ shadowJar {
include(dependency(':core'))
include(dependency('org.yaml:snakeyaml:1.16'))
}
archiveName = "${parent.name}-${project.name}.jar"
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
destinationDir = file '../target'
}
shadowJar.doLast {