mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Gradle Upgrades and Clipboard Refactoring
This commit is contained in:
parent
e1b946d0da
commit
b7b11cc478
@ -35,6 +35,5 @@ dependencies {
|
||||
implementation("com.github.jengelman.gradle.plugins:shadow:5.1.0")
|
||||
implementation("net.ltgt.apt-eclipse:net.ltgt.apt-eclipse.gradle.plugin:0.21")
|
||||
implementation("net.ltgt.apt-idea:net.ltgt.apt-idea.gradle.plugin:0.21")
|
||||
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7")
|
||||
implementation("gradle.plugin.com.mendhak.gradlecrowdin:plugin:0.1.0")
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.named
|
||||
import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
|
||||
import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask
|
||||
|
||||
private const val ARTIFACTORY_CONTEXT_URL = "artifactory_contextUrl"
|
||||
private const val ARTIFACTORY_USER = "artifactory_user"
|
||||
private const val ARTIFACTORY_PASSWORD = "artifactory_password"
|
||||
|
||||
fun Project.applyRootArtifactoryConfig() {
|
||||
if (!project.hasProperty(ARTIFACTORY_CONTEXT_URL)) ext[ARTIFACTORY_CONTEXT_URL] = "http://localhost"
|
||||
if (!project.hasProperty(ARTIFACTORY_USER)) ext[ARTIFACTORY_USER] = "guest"
|
||||
if (!project.hasProperty(ARTIFACTORY_PASSWORD)) ext[ARTIFACTORY_PASSWORD] = ""
|
||||
|
||||
apply(plugin = "com.jfrog.artifactory")
|
||||
configure<ArtifactoryPluginConvention> {
|
||||
setContextUrl("${project.property(ARTIFACTORY_CONTEXT_URL)}")
|
||||
clientConfig.publisher.run {
|
||||
repoKey = when {
|
||||
"${project.version}".contains("SNAPSHOT") -> "libs-snapshot-local"
|
||||
else -> "libs-release-local"
|
||||
}
|
||||
username = "${project.property(ARTIFACTORY_USER)}"
|
||||
password = "${project.property(ARTIFACTORY_PASSWORD)}"
|
||||
isMaven = true
|
||||
isIvy = false
|
||||
}
|
||||
}
|
||||
tasks.named<ArtifactoryTask>("artifactoryPublish") {
|
||||
isSkip = true
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.applyCommonArtifactoryConfig() {
|
||||
tasks.named<ArtifactoryTask>("artifactoryPublish") {
|
||||
publishConfigs("archives")
|
||||
}
|
||||
}
|
@ -20,12 +20,10 @@ import org.gradle.kotlin.dsl.withType
|
||||
fun Project.applyPlatformAndCoreConfiguration() {
|
||||
applyCommonConfiguration()
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "eclipse")
|
||||
apply(plugin = "idea")
|
||||
apply(plugin = "maven")
|
||||
//apply(plugin = "checkstyle")
|
||||
apply(plugin = "com.github.johnrengelman.shadow")
|
||||
//apply(plugin = "com.jfrog.artifactory")
|
||||
|
||||
ext["internalVersion"] = "$version;${rootProject.ext["gitCommitHash"]}"
|
||||
|
||||
@ -44,7 +42,7 @@ fun Project.applyPlatformAndCoreConfiguration() {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
"compileOnly"("org.jetbrains:annotations:18.0.0")
|
||||
"compileOnly"("org.jetbrains:annotations:19.0.0")
|
||||
"testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}")
|
||||
"testImplementation"("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}")
|
||||
"testImplementation"("org.mockito:mockito-core:${Versions.MOCKITO}")
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -114,7 +114,7 @@ tasks.named<ShadowJar>("shadowJar") {
|
||||
|
||||
val crowdinApiKey = "crowdin_apikey"
|
||||
|
||||
if (project.hasProperty(crowdinApiKey)) {
|
||||
if (project.hasProperty(crowdinApiKey) && !gradle.startParameter.isOffline) {
|
||||
tasks.named<UploadSourceFileTask>("crowdinUpload") {
|
||||
apiKey = "${project.property(crowdinApiKey)}"
|
||||
projectId = "worldedit-core"
|
||||
@ -126,12 +126,19 @@ if (project.hasProperty(crowdinApiKey)) {
|
||||
)
|
||||
}
|
||||
|
||||
tasks.named<DownloadTranslationsTask>("crowdinDownload") {
|
||||
val dlTranslationsTask = tasks.named<DownloadTranslationsTask>("crowdinDownload") {
|
||||
apiKey = "${project.property(crowdinApiKey)}"
|
||||
destination = "${file("build/resources/main/lang")}"
|
||||
destination = "${buildDir.resolve("crowdin-i18n")}"
|
||||
projectId = "worldedit-core"
|
||||
}
|
||||
|
||||
tasks.named<Copy>("processResources") {
|
||||
dependsOn(dlTranslationsTask)
|
||||
from(dlTranslationsTask.get().destination) {
|
||||
into("lang")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("classes").configure {
|
||||
dependsOn("crowdinDownload")
|
||||
}
|
||||
|
@ -1,47 +1,50 @@
|
||||
package com.boydti.fawe.object.brush;
|
||||
|
||||
import com.boydti.fawe.object.clipboard.CPUOptimizedClipboard;
|
||||
import com.boydti.fawe.object.clipboard.LinearClipboard;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ErodeBrush implements Brush {
|
||||
|
||||
private static final BlockVector3[] FACES_TO_CHECK = Direction.valuesOf(Direction.Flag.CARDINAL).stream().map(Direction::toBlockVector).toArray(BlockVector3[]::new);
|
||||
private final int erodeFaces, erodeRec, fillFaces, fillRec;
|
||||
private final int erodeFaces, erodeRecursion, fillFaces, fillRecursion;
|
||||
|
||||
public ErodeBrush() {
|
||||
this(2, 1, 5, 1);
|
||||
}
|
||||
|
||||
public ErodeBrush(int erodeFaces, int erodeRec, int fillFaces, int fillRec) {
|
||||
public ErodeBrush(int erodeFaces, int erodeRecursion, int fillFaces, int fillRecursion) {
|
||||
this.erodeFaces = erodeFaces;
|
||||
this.erodeRec = erodeRec;
|
||||
this.erodeRecursion = erodeRecursion;
|
||||
this.fillFaces = fillFaces;
|
||||
this.fillRec = fillRec;
|
||||
this.fillRecursion = fillRecursion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
this.erosion(editSession, erodeFaces, erodeRec, fillFaces, fillRec, position, size);
|
||||
this.erosion(editSession, erodeFaces, erodeRecursion, fillFaces, fillRecursion, position, size);
|
||||
}
|
||||
|
||||
public void erosion(final EditSession es, int erodeFaces, int erodeRec, int fillFaces, int fillRec, BlockVector3 target, double size) {
|
||||
int brushSize = (int) size + 1;
|
||||
public void erosion(final EditSession es, int erodeFaces, int erodeRecursion, int fillFaces, int fillRecursion, BlockVector3 target, double size) {
|
||||
int brushSize = (int) size;
|
||||
int brushSizeSquared = (int) (size * size);
|
||||
BlockVector3 dimension = BlockVector3.ONE.multiply(brushSize * 2 + 1);
|
||||
Clipboard buffer1 = new CPUOptimizedClipboard(dimension);
|
||||
Clipboard buffer2 = new CPUOptimizedClipboard(dimension);
|
||||
Location min = new Location(es.getWorld(), target.toVector3().subtract(size, size, size));
|
||||
Location max = new Location(es.getWorld(), target.toVector3().add(size, size, size));
|
||||
Region region = new CuboidRegion(es.getWorld(), min.toBlockPoint(), max.toBlockPoint());
|
||||
Clipboard buffer1 = new CPUOptimizedClipboard(region);
|
||||
Clipboard buffer2 = new CPUOptimizedClipboard(region);
|
||||
|
||||
final int bx = target.getBlockX();
|
||||
final int by = target.getBlockY();
|
||||
@ -61,12 +64,12 @@ public class ErodeBrush implements Brush {
|
||||
}
|
||||
|
||||
int swap = 0;
|
||||
for (int i = 0; i < erodeRec; ++i) {
|
||||
for (int i = 0; i < erodeRecursion; ++i) {
|
||||
erosionIteration(brushSize, brushSizeSquared, erodeFaces, swap % 2 == 0 ? buffer1 : buffer2, swap % 2 == 1 ? buffer1 : buffer2);
|
||||
swap++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < fillRec; ++i) {
|
||||
for (int i = 0; i < fillRecursion; ++i) {
|
||||
fillIteration(brushSize, brushSizeSquared, fillFaces, swap % 2 == 0 ? buffer1 : buffer2, swap % 2 == 1 ? buffer1 : buffer2);
|
||||
swap++;
|
||||
}
|
||||
@ -95,14 +98,14 @@ public class ErodeBrush implements Brush {
|
||||
if (state.getBlockType().getMaterial().isMovementBlocker()) {
|
||||
continue;
|
||||
}
|
||||
int total = 0;
|
||||
int highest = 1;
|
||||
BaseBlock highestState = state;
|
||||
if (frequency == null) {
|
||||
frequency = new int[BlockTypes.size()];
|
||||
} else {
|
||||
Arrays.fill(frequency, 0);
|
||||
}
|
||||
int total = 0;
|
||||
int highest = 1;
|
||||
for (BlockVector3 offs : FACES_TO_CHECK) {
|
||||
BaseBlock next = current.getFullBlock(relx + offs.getBlockX(), rely + offs.getBlockY(), relz + offs.getBlockZ());
|
||||
if (!next.getBlockType().getMaterial().isMovementBlocker()) {
|
||||
@ -140,14 +143,14 @@ public class ErodeBrush implements Brush {
|
||||
if (!state.getMaterial().isMovementBlocker()) {
|
||||
continue;
|
||||
}
|
||||
int total = 0;
|
||||
int highest = 1;
|
||||
BaseBlock highestState = state;
|
||||
if (frequency == null) {
|
||||
frequency = new int[BlockTypes.size()];
|
||||
} else {
|
||||
Arrays.fill(frequency, 0);
|
||||
}
|
||||
int highest = 1;
|
||||
int total = 0;
|
||||
for (BlockVector3 offs : FACES_TO_CHECK) {
|
||||
BaseBlock next = current.getFullBlock(relx + offs.getBlockX(), rely + offs.getBlockY(), relz + offs.getBlockZ());
|
||||
if (next.getMaterial().isMovementBlocker()) {
|
||||
|
@ -37,17 +37,13 @@ public class CPUOptimizedClipboard extends LinearClipboard {
|
||||
private final HashMap<Integer, CompoundTag> nbtMapIndex;
|
||||
|
||||
|
||||
public CPUOptimizedClipboard(BlockVector3 dimensions) {
|
||||
super(dimensions);
|
||||
public CPUOptimizedClipboard(Region region) {
|
||||
super(region.getDimensions());
|
||||
this.states = new char[getVolume()];
|
||||
nbtMapLoc = new HashMap<>();
|
||||
nbtMapIndex = new HashMap<>();
|
||||
}
|
||||
|
||||
public CPUOptimizedClipboard(Region region) {
|
||||
this(region.getDimensions());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasBiomes() {
|
||||
return biomes != null;
|
||||
|
@ -62,8 +62,8 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
private FileChannel fileChannel;
|
||||
private boolean hasBiomes;
|
||||
|
||||
public DiskOptimizedClipboard(BlockVector3 dimensions, UUID uuid) {
|
||||
this(dimensions, MainUtil.getFile(Fawe.get() != null ? Fawe.imp().getDirectory() : new File("."), Settings.IMP.PATHS.CLIPBOARD + File.separator + uuid + ".bd"));
|
||||
public DiskOptimizedClipboard(Region region, UUID uuid) {
|
||||
this(region.getDimensions(), MainUtil.getFile(Fawe.get() != null ? Fawe.imp().getDirectory() : new File("."), Settings.IMP.PATHS.CLIPBOARD + File.separator + uuid + ".bd"));
|
||||
}
|
||||
|
||||
public DiskOptimizedClipboard(BlockVector3 dimensions) {
|
||||
@ -108,11 +108,7 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public DiskOptimizedClipboard(Region region, UUID uuid) {
|
||||
this(region.getDimensions(), uuid);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public URI getURI() {
|
||||
return file.toURI();
|
||||
|
@ -36,23 +36,23 @@ public abstract class TaskManager {
|
||||
/**
|
||||
* Run a repeating task asynchronously
|
||||
*
|
||||
* @param runnable
|
||||
* @param runnable the task to run
|
||||
* @param interval in ticks
|
||||
* @return
|
||||
* @return the task id number
|
||||
*/
|
||||
public abstract int repeatAsync(@NotNull final Runnable runnable, final int interval);
|
||||
|
||||
/**
|
||||
* Run a task asynchronously
|
||||
*
|
||||
* @param runnable
|
||||
* @param runnable the task to run
|
||||
*/
|
||||
public abstract void async(@NotNull final Runnable runnable);
|
||||
|
||||
/**
|
||||
* Run a task on the main thread
|
||||
*
|
||||
* @param runnable
|
||||
* @param runnable the task to run
|
||||
*/
|
||||
public abstract void task(@NotNull final Runnable runnable);
|
||||
|
||||
@ -153,10 +153,10 @@ public abstract class TaskManager {
|
||||
|
||||
/**
|
||||
* Run a task on the current thread or asynchronously
|
||||
* - If it's already the main thread, it will jst call run()
|
||||
* - If it's already the main thread, it will just call run()
|
||||
*
|
||||
* @param runnable
|
||||
* @param async
|
||||
* @param runnable the task to run
|
||||
* @param async whether the task should run on the main thread
|
||||
*/
|
||||
public void taskNow(@NotNull final Runnable runnable, boolean async) {
|
||||
if (async) {
|
||||
@ -170,7 +170,7 @@ public abstract class TaskManager {
|
||||
* Run a task as soon as possible on the main thread
|
||||
* - Non blocking if not calling from the main thread
|
||||
*
|
||||
* @param runnable
|
||||
* @param runnable the task to run
|
||||
*/
|
||||
public void taskNowMain(@NotNull final Runnable runnable) {
|
||||
if (Fawe.isMainThread()) {
|
||||
@ -183,8 +183,8 @@ public abstract class TaskManager {
|
||||
/**
|
||||
* Run a task as soon as possible not on the main thread
|
||||
*
|
||||
* @param runnable
|
||||
* @see com.boydti.fawe.Fawe#isMainThread()
|
||||
* @param runnable the task to run
|
||||
* @see Fawe#isMainThread()
|
||||
*/
|
||||
public void taskNowAsync(@NotNull final Runnable runnable) {
|
||||
taskNow(runnable, Fawe.isMainThread());
|
||||
@ -193,8 +193,8 @@ public abstract class TaskManager {
|
||||
/**
|
||||
* Run a task on the main thread at the next tick or now async
|
||||
*
|
||||
* @param runnable
|
||||
* @param async
|
||||
* @param runnable the task to run.
|
||||
* @param async whether the task should run on the main thread
|
||||
*/
|
||||
public void taskSoonMain(@NotNull final Runnable runnable, boolean async) {
|
||||
if (async) {
|
||||
@ -208,7 +208,7 @@ public abstract class TaskManager {
|
||||
/**
|
||||
* Run a task later on the main thread
|
||||
*
|
||||
* @param runnable
|
||||
* @param runnable the task to run
|
||||
* @param delay in ticks
|
||||
*/
|
||||
public abstract void later(@NotNull final Runnable runnable, final int delay);
|
||||
@ -216,7 +216,7 @@ public abstract class TaskManager {
|
||||
/**
|
||||
* Run a task later asynchronously
|
||||
*
|
||||
* @param runnable
|
||||
* @param runnable the task to run
|
||||
* @param delay in ticks
|
||||
*/
|
||||
public abstract void laterAsync(@NotNull final Runnable runnable, final int delay);
|
||||
@ -224,7 +224,7 @@ public abstract class TaskManager {
|
||||
/**
|
||||
* Cancel a task
|
||||
*
|
||||
* @param task
|
||||
* @param task the id of the task to cancel
|
||||
*/
|
||||
public abstract void cancel(final int task);
|
||||
|
||||
|
@ -10,7 +10,6 @@ public interface Metadatable {
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return previous value
|
||||
*/
|
||||
void setMeta(String key, Object value);
|
||||
|
||||
|
@ -38,6 +38,7 @@ import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.DataFixer;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
|
@ -124,8 +124,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
if (pos1 == null || pos2 == null) {
|
||||
return;
|
||||
}
|
||||
pos1 = pos1.clampY(world == null ? 0 : 0, world == null ? FaweCache.IMP.WORLD_MAX_Y : world.getMaxY());
|
||||
pos2 = pos2.clampY(world == null ? 0 : 0, world == null ? FaweCache.IMP.WORLD_MAX_Y : world.getMaxY());
|
||||
pos1 = pos1.clampY(0, world == null ? 255 : world.getMaxY());
|
||||
pos2 = pos2.clampY(0, world == null ? 255 : world.getMaxY());
|
||||
minX = Math.min(pos1.getX(), pos2.getX());
|
||||
minY = Math.min(pos1.getY(), pos2.getY());
|
||||
minZ = Math.min(pos1.getZ(), pos2.getZ());
|
||||
@ -397,9 +397,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
if (o instanceof BlockVector2) {
|
||||
BlockVector2 cv = (BlockVector2) o;
|
||||
return cv.getX() >= minX && cv.getX() <= maxX && cv.getZ() >= minZ && cv.getZ() <= maxZ;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -422,15 +421,11 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
/* Slow and unnecessary
|
||||
|
||||
@Override
|
||||
public boolean contains(BlockVector3 position) {
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
|
||||
return position.containedWithin(min, max);
|
||||
return contains(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean contains(int x, int y, int z) {
|
||||
@ -442,11 +437,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(BlockVector3 position) {
|
||||
return contains(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
if (Settings.IMP.HISTORY.COMPRESSION_LEVEL >= 9) {
|
||||
@ -543,7 +533,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return hasNext;
|
||||
return (hasNext);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -596,10 +586,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
return answer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user