Remove numerical versioning
Fix queue relighting concurrency
Fixed fixlighting async error
Fixes for 1.7.10 + thermos
Fixed non disk schematic loading
This commit is contained in:
Jesse Boyd 2016-08-14 10:26:51 +10:00
parent 4ccfab5908
commit 3a3fcca8b0
29 changed files with 154 additions and 158 deletions

View File

@ -15,17 +15,23 @@ apply plugin: 'java'
clean { delete "target" }
group = 'com.boydti.fawe'
def revision = ""
def buildNumber = ""
final def date = new Date().format("yy.MM.dd")
ext {
git = org.ajoberstar.grgit.Grgit.open(file(".git"))
revision = "-${git.head().abbreviatedId}"
parents = git.head().parentIds;
index = -44; // Offset to mach CI
for (;parents != null && !parents.isEmpty();index++) {
commit = git.getResolve().toCommit(parents.get(0));
parents = commit.getParentIds();
}
buildNumber = "-${index}"
}
if ( project.hasProperty("lzNoGitHash") ) { // gradle build -PlzNoGitHash
revision = "";
}
version = "3.5.1${revision}"
version = date + revision + buildNumber
description = """FastAsyncWorldEdit"""
subprojects {

View File

@ -1,7 +1,6 @@
package com.boydti.fawe.bukkit;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.IFawe;
import com.boydti.fawe.bukkit.regions.FactionsFeature;
import com.boydti.fawe.bukkit.regions.FactionsOneFeature;
@ -22,7 +21,6 @@ import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.world.World;
@ -63,7 +61,7 @@ public class FaweBukkit implements IFawe, Listener {
this.plugin = plugin;
try {
Fawe.set(this);
if (Bukkit.getVersion().contains("git-Spigot") && FaweAPI.checkVersion(this.getVersion(), 1, 7, 10)) {
if (Bukkit.getVersion().contains("git-Spigot")) {
debug("====== USE PAPER SPIGOT ======");
debug("DOWNLOAD: https://ci.destroystokyo.com/job/PaperSpigot/");
debug("GUIDE: https://www.spigotmc.org/threads/21726/");
@ -151,27 +149,6 @@ public class FaweBukkit implements IFawe, Listener {
private int[] version;
@Override
public int[] getVersion() {
if (this.version == null) {
try {
this.version = new int[3];
final String[] split = plugin.getDescription().getVersion().split("-")[0].split("\\.");
this.version[0] = Integer.parseInt(split[0]);
this.version[1] = Integer.parseInt(split[1]);
if (split.length == 3) {
this.version[2] = Integer.parseInt(split[2]);
}
} catch (final NumberFormatException e) {
MainUtil.handleError(e);
Fawe.debug(StringMan.getString(Bukkit.getBukkitVersion()));
Fawe.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
return new int[] { Integer.MAX_VALUE, 0, 0 };
}
}
return this.version;
}
private boolean hasNMS = true;
/**
@ -195,9 +172,7 @@ public class FaweBukkit implements IFawe, Listener {
} catch (Throwable ignore) {}
try {
return plugin.getQueue(world);
} catch (Throwable ignore) {
// ignore.printStackTrace();
}
} catch (Throwable ignore) {}
// Disable incompatible settings
Settings.QUEUE.PARALLEL_THREADS = 1; // BukkitAPI placer is too slow to parallel thread at the chunk level
Settings.HISTORY.COMBINE_STAGES = false; // Performing a chunk copy (if possible) wouldn't be faster using the BukkitAPI
@ -323,7 +298,7 @@ public class FaweBukkit implements IFawe, Listener {
@Override
public String getPlatform() {
return "bukkit";
return Bukkit.getVersion();
}
@Override

View File

@ -250,6 +250,7 @@ public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], Chunk
@Override
public void refreshChunk(FaweChunk fc) {
BukkitChunk_1_10 fs = (BukkitChunk_1_10) fc;
ensureChunkLoaded(fc.getX(), fc.getZ());
Chunk chunk = fs.getChunk();
if (!chunk.isLoaded()) {
return;

View File

@ -456,6 +456,7 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
@Override
public void refreshChunk(FaweChunk fc) {
BukkitChunk_1_7 fs = (BukkitChunk_1_7) fc;
ensureChunkLoaded(fc.getX(), fc.getZ());
Chunk chunk = fs.getChunk();
if (!chunk.isLoaded()) {
return;

View File

@ -428,6 +428,7 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkS
@Override
public void refreshChunk(FaweChunk fc) {
BukkitChunk_1_8 fs = (BukkitChunk_1_8) fc;
ensureChunkLoaded(fc.getX(), fc.getZ());
Chunk chunk = fs.getChunk();
if (!chunk.isLoaded()) {
return;

View File

@ -126,6 +126,7 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Chu
@Override
public void refreshChunk(FaweChunk fc) {
BukkitChunk_1_9 fs = (BukkitChunk_1_9) fc;
ensureChunkLoaded(fc.getX(), fc.getZ());
Chunk chunk = fs.getChunk();
if (!chunk.isLoaded()) {
return;

View File

@ -8,5 +8,15 @@ dependencies {
sourceCompatibility = 1.7
targetCompatibility = 1.7
processResources {
from('src/main/resources') {
include 'fawe.properties'
expand(
version: "${project.parent.version}",
name: project.parent.name,
)
}
}
jar.archiveName="FastAsyncWorldEdit-API.jar"
jar.destinationDir = file '../target'

View File

@ -60,14 +60,17 @@ import com.sk89q.worldedit.util.command.parametric.ParametricBuilder;
import com.sk89q.worldedit.world.registry.BundledBlockData;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryUsage;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import javax.management.InstanceAlreadyExistsException;
import javax.management.Notification;
import javax.management.NotificationEmitter;
@ -120,6 +123,7 @@ public class Fawe {
* TPS timer
*/
private final FaweTimer timer;
private FaweVersion version;
/**
* Get the implementation specific class
@ -213,10 +217,23 @@ public class Fawe {
this.setupMemoryListener();
}
/**
* The FaweTimer is a useful class for monitoring TPS
* @return FaweTimer
*/
public FaweTimer getTimer() {
return timer;
}
/**
* The FAWE version
* - Unofficial jars may be lacking version information
* @return FaweVersion
*/
public @Nullable FaweVersion getVersion() {
return version;
}
public double getTPS() {
return timer.getTPS();
}
@ -233,10 +250,20 @@ public class Fawe {
}
public void setupConfigs() {
// Setting up config.yml
File file = new File(this.IMP.getDirectory(), "config.yml");
Settings.VERSION = StringMan.join(IMP.getVersion(), ".");
Settings.PLATFORM = IMP.getPlatform();
try {
InputStream stream = getClass().getResourceAsStream("/fawe.properties");
java.util.Scanner scanner = new java.util.Scanner(stream).useDelimiter("\\A");
String versionString = scanner.next().trim();
scanner.close();
this.version = new FaweVersion(versionString);
Settings.DATE = new Date(version.year, version.month, version.day).toLocaleString();
Settings.BUILD = "http://ci.athion.net/job/FastAsyncWorldEdit/" + version.build;
Settings.COMMIT = "https://github.com/boy0001/FastAsyncWorldedit/commit/" + Integer.toHexString(version.hash);
} catch (Throwable ignore) {}
Settings.load(file);
Settings.save(file);
// Setting up message.yml
@ -376,7 +403,7 @@ public class Fawe {
debug(" - Report this issue if you cannot resolve it");
debug("===============================================");
}
if (getJavaVersion() < 1.8) {
if (MainUtil.getJavaVersion() < 1.8) {
debug("====== UPGRADE TO JAVA 8 ======");
debug("You are running " + System.getProperty("java.version"));
debug(" - This is only a recommendation");
@ -384,13 +411,6 @@ public class Fawe {
}
}
static double getJavaVersion () {
String version = System.getProperty("java.version");
int pos = version.indexOf('.');
pos = version.indexOf('.', pos+1);
return Double.parseDouble (version.substring (0, pos));
}
private void setupMemoryListener() {
if (Settings.MAX_MEMORY_PERCENT < 1) {
return;
@ -470,8 +490,6 @@ public class Fawe {
/*
* TODO FIXME
* - Async packet sending
* - Redo WEManager delay / command queue
* - Support older versions of bukkit
* - Optimize lighting updates / chunk sending
*/
}

View File

@ -0,0 +1,15 @@
package com.boydti.fawe;
public class FaweVersion {
public final int year, month, day, hash, build;
public FaweVersion(String version) {
String[] split = version.substring(version.indexOf('=') + 1).split("-");
String[] date = split[0].split("\\.");
this.year = Integer.parseInt(date[0]);
this.month = Integer.parseInt(date[1]);
this.day = Integer.parseInt(date[2]);
this.hash = Integer.parseInt(split[1], 16);
this.build = Integer.parseInt(split[2]);
}
}

View File

@ -23,8 +23,6 @@ public interface IFawe {
public TaskManager getTaskManager();
public int[] getVersion();
public FaweQueue getNewQueue(String world, boolean fast);
public String getWorldName(World world);

View File

@ -10,15 +10,19 @@ import java.util.List;
public class Settings extends Config {
@Comment("These first 4 aren't configurable") // This is a comment
@Comment("These first 6 aren't configurable") // This is a comment
@Final // Indicates that this value isn't configurable
public static final String ISSUES = "https://github.com/boy0001/FastAsyncWorldedit/issues";
@Final
public static final String WIKI = "https://github.com/boy0001/FastAsyncWorldedit/wiki/";
@Final
public static String VERSION = null; // These values are set from PS before loading
public static String DATE = null; // These values are set from FAWE before loading
@Final
public static String PLATFORM = null; // These values are set from PS before loading
public static String BUILD = null; // These values are set from FAWE before loading
@Final
public static String COMMIT = null; // These values are set from FAWE before loading
@Final
public static String PLATFORM = null; // These values are set from FAWE before loading
@Comment("Send anonymous usage statistics to MCStats.org")
public static boolean METRICS = true;

View File

@ -324,10 +324,11 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
@Override
public int size() {
if (chunks.size() == 0 && SetQueue.IMP.getStage(this) != SetQueue.QueueStage.INACTIVE) {
int size = chunks.size();
if (size == 0 && SetQueue.IMP.getStage(this) != SetQueue.QueueStage.INACTIVE) {
runTasks();
}
return chunks.size();
return size;
}
private ConcurrentLinkedDeque<FaweChunk> toUpdate = new ConcurrentLinkedDeque<>();

View File

@ -55,12 +55,7 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
public void runTasks() {
super.runTasks();
if (relighter != null) {
boolean sky = hasSky();
if (sky) {
relighter.fixSkyLighting();
}
relighter.fixBlockLighting();
relighter.sendChunks();
relighter.fixLightingSafe(hasSky());
}
}

View File

@ -15,6 +15,7 @@ public class NMSRelighter {
private final NMSMappedFaweQueue queue;
private final HashMap<Long, RelightSkyEntry> skyToRelight;
private final HashMap<Long, RelightBlockEntry> blocksToRelight;
private volatile boolean relighting = false;
private static final int DISPATCH_SIZE = 64;
@ -68,6 +69,23 @@ public class NMSRelighter {
}
}
public void fixLightingSafe(boolean sky) {
if (relighting) {
return;
}
relighting = true;
try {
if (sky) {
fixSkyLighting();
}
fixBlockLighting();
sendChunks();
} catch (Throwable e) {
e.printStackTrace();
}
relighting = false;
}
public void fixBlockLighting() {
while (!blocksToRelight.isEmpty()) {
RelightBlockEntry current = blocksToRelight.entrySet().iterator().next().getValue();

View File

@ -54,6 +54,12 @@ public class CPUOptimizedClipboard extends FaweClipboard {
height = dimensions.getBlockY();
length = dimensions.getBlockZ();
area = width * length;
int newVolume = area * height;
if (newVolume != volume) {
volume = newVolume;
ids = new byte[volume];
datas = new byte[volume];
}
}
@Override

View File

@ -140,6 +140,18 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
height = dimensions.getBlockY();
length = dimensions.getBlockZ();
area = width * length;
int newVolume = area * height;
if (newVolume != volume) {
volume = newVolume;
ids = new byte[1 + (volume >> BLOCK_SHIFT)][];
datas = new byte[1 + (volume >> BLOCK_SHIFT)][];
lastAddI = -1;
lastIdsI = -1;
lastDatasI = -1;
saveIds = false;
saveAdd = false;
saveDatas = false;
}
}
@Override

View File

@ -96,6 +96,21 @@ public class MainUtil {
return size.get();
}
public static double getJavaVersion () {
String version = System.getProperty("java.version");
int pos = version.indexOf('.');
pos = version.indexOf('.', pos+1);
return Double.parseDouble (version.substring (0, pos));
}
public static void stacktrace() {
try {
int i = 1/0;
} catch (Exception e) {
e.printStackTrace();
}
}
public static long traverse(Path path, final RunnableVal2<Path, BasicFileAttributes> onEach) {
final AtomicLong size = new AtomicLong(0);
try {

View File

@ -194,6 +194,9 @@ public class LocalSession {
if (world == null || uuid == null) {
return false;
}
if (Settings.HISTORY.USE_DISK) {
MAX_HISTORY_SIZE = Integer.MAX_VALUE;
}
if (!world.equals(currentWorld)) {
this.uuid = uuid;
// Save history
@ -273,9 +276,7 @@ public class LocalSession {
sizes.put(id, existingSize);
}
existingSize.addAndGet(size);
} catch (NumberFormatException ignore){
ignore.printStackTrace();
}
} catch (NumberFormatException ignore){}
}
});
if (totalSize.get() < maxBytes) {

View File

@ -0,0 +1,2 @@
version=${version}

View File

@ -100,12 +100,6 @@ public class FaweForge implements IFawe {
return new com.boydti.fawe.forge.ForgeTaskMan(512);
}
@Override
public int[] getVersion() {
String[] version = this.mod.version.split("\\.");
return new int[] {Integer.parseInt(version[0]), Integer.parseInt(version[1]), Integer.parseInt(version[2])};
}
@Override
public String getWorldName(World world) {
if (world instanceof WorldWrapper) {

View File

@ -511,6 +511,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc;
ensureChunkLoaded(fc.getX(), fc.getZ());
Chunk nmsChunk = fs.getChunk();
if (!nmsChunk.isLoaded()) {
return;

View File

@ -97,12 +97,6 @@ public class FaweForge implements IFawe {
return new ForgeTaskMan(512);
}
@Override
public int[] getVersion() {
String[] version = this.mod.version.split("\\.");
return new int[] {Integer.parseInt(version[0]), Integer.parseInt(version[1]), Integer.parseInt(version[2])};
}
@Override
public String getWorldName(World world) {
if (world instanceof WorldWrapper) {

View File

@ -48,8 +48,7 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk> {
this.count[i]++;
switch (id) {
case 0:
this.air[i]++;
vs[j] = -1;
vs[j] = 0;
vs2[j] = (char) 1;
return;
case 11:
@ -63,74 +62,12 @@ public class ForgeChunk_All extends CharFaweChunk<Chunk> {
case 138:
case 169:
case 213:
this.relight[i]++;
case 2:
case 4:
case 13:
case 14:
case 15:
case 20:
case 21:
case 22:
case 30:
case 32:
case 37:
case 41:
case 42:
case 45:
case 46:
case 47:
case 48:
case 49:
case 55:
case 56:
case 57:
case 58:
case 60:
case 7:
case 73:
case 79:
case 80:
case 81:
case 82:
case 83:
case 85:
case 87:
case 88:
case 101:
case 102:
case 103:
case 110:
case 112:
case 113:
case 121:
case 129:
case 133:
case 165:
case 166:
case 170:
case 172:
case 173:
case 174:
case 188:
case 189:
case 190:
case 191:
case 192:
vs[j] = (byte) (id);
vs2[j] = (char) (id << 4);
return;
case 130:
case 76:
case 62:
case 50:
case 10:
this.relight[i]++;
case 54:
case 146:
case 61:
case 65:
case 68: // removed
default:
vs2[j] = (char) ((id << 4) + data);
vs[j] = (byte) id;

View File

@ -213,6 +213,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc;
ensureChunkLoaded(fc.getX(), fc.getZ());
Chunk nmsChunk = fs.getChunk();
if (!nmsChunk.isChunkLoaded) {
return;
@ -390,13 +391,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
}
boolean fill = true;
int solid = 0;
char[] charArray = fs.getIdArray(j);
for (int k = 0; k < newIdArray.length; k++) {
byte n = newIdArray[k];
switch (n) {
char combined = charArray[k];
switch (combined) {
case 0:
fill = false;
continue;
case -1:
case 1:
fill = false;
if (currentIdArray[k] != 0) {
solid++;
@ -405,16 +407,14 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
continue;
default:
solid++;
currentIdArray[k] = n;
currentIdArray[k] = newIdArray[k];
if (data) {
int dataByte = FaweCache.getData(combined);
int x = FaweCache.CACHE_X[0][k];
int y = FaweCache.CACHE_Y[0][k];
int z = FaweCache.CACHE_Z[0][k];
int newData = newDataArray == null ? 0 : newDataArray.get(x, y, z);
int currentData = currentDataArray == null ? 0 : currentDataArray.get(x, y, z);
if (newData != currentData) {
currentDataArray.set(x, y, z, newData);
}
int newData = newDataArray.get(x, y, z);
currentDataArray.set(x, y, z, newData);
}
continue;
}

View File

@ -100,12 +100,6 @@ public class FaweForge implements IFawe {
return new com.boydti.fawe.forge.ForgeTaskMan(512);
}
@Override
public int[] getVersion() {
String[] version = this.mod.version.split("\\.");
return new int[] {Integer.parseInt(version[0]), Integer.parseInt(version[1]), Integer.parseInt(version[2])};
}
@Override
public String getWorldName(World world) {
if (world instanceof WorldWrapper) {

View File

@ -450,6 +450,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc;
ensureChunkLoaded(fc.getX(), fc.getZ());
Chunk nmsChunk = fs.getChunk();
if (!nmsChunk.isLoaded()) {
return;

View File

@ -100,12 +100,6 @@ public class FaweForge implements IFawe {
return new com.boydti.fawe.forge.ForgeTaskMan(512);
}
@Override
public int[] getVersion() {
String[] version = this.mod.version.split("\\.");
return new int[] {Integer.parseInt(version[0]), Integer.parseInt(version[1]), Integer.parseInt(version[2])};
}
@Override
public String getWorldName(World world) {
if (world instanceof WorldWrapper) {

View File

@ -511,6 +511,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public void refreshChunk(FaweChunk fc) {
ForgeChunk_All fs = (ForgeChunk_All) fc;
ensureChunkLoaded(fc.getX(), fc.getZ());
Chunk nmsChunk = fs.getChunk();
if (!nmsChunk.isLoaded()) {
return;

View File

@ -1,6 +1,6 @@
#org.gradle.java.home=C:/PROGRA~2/Java/jdk1.7.0_79
#org.gradle.java.home=C:/PROGRA~1/Java/jdk1.8.0_51
org.gradle.daemon=true
org.gradle.daemon=false
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.configureondemand=true
org.gradle.parallel=true