mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-09 04:30:51 +08:00
Initial Piston conversion test. Non-functional.
This commit is contained in:
parent
4de5487c51
commit
1966e5a8a2
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,6 @@
|
||||
#Thu Mar 14 00:19:48 PDT 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
|
||||
|
@ -1,3 +1,5 @@
|
||||
rootProject.name = 'worldedit'
|
||||
|
||||
include 'worldedit-core', 'worldedit-bukkit', 'worldedit-forge', 'worldedit-sponge'
|
||||
include 'worldedit-core', 'worldedit-bukkit', 'worldedit-forge', 'worldedit-sponge'
|
||||
|
||||
includeBuild("../Piston")
|
||||
|
@ -1,32 +1,41 @@
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
|
||||
dependencies {
|
||||
compile 'de.schlichtherle:truezip:6.8.3'
|
||||
compile 'rhino:js:1.7R2'
|
||||
compile 'org.yaml:snakeyaml:1.9'
|
||||
compile 'com.google.guava:guava:21.0'
|
||||
compile 'com.sk89q:jchronic:0.2.4a'
|
||||
compile 'com.google.code.findbugs:jsr305:1.3.9'
|
||||
compile 'com.thoughtworks.paranamer:paranamer:2.6'
|
||||
compile 'com.google.code.gson:gson:2.8.0'
|
||||
compile 'com.sk89q.lib:jlibnoise:1.0.0'
|
||||
compile 'com.googlecode.json-simple:json-simple:1.1.1'
|
||||
compile 'org.slf4j:slf4j-api:1.7.26'
|
||||
//compile 'net.sf.trove4j:trove4j:3.0.3'
|
||||
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir 'src/main/java'
|
||||
srcDir 'src/legacy/java'
|
||||
}
|
||||
resources {
|
||||
srcDir 'src/main/resources'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn(shadowJar)
|
||||
plugins {
|
||||
id("net.ltgt.apt") version "0.21"
|
||||
}
|
||||
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'net.ltgt.apt-eclipse'
|
||||
apply plugin: 'net.ltgt.apt-idea'
|
||||
|
||||
dependencies {
|
||||
compile 'de.schlichtherle:truezip:6.8.3'
|
||||
compile 'rhino:js:1.7R2'
|
||||
compile 'org.yaml:snakeyaml:1.9'
|
||||
compile 'com.google.guava:guava:21.0'
|
||||
compile 'com.sk89q:jchronic:0.2.4a'
|
||||
compile 'com.google.code.findbugs:jsr305:1.3.9'
|
||||
compile 'com.thoughtworks.paranamer:paranamer:2.6'
|
||||
compile 'com.google.code.gson:gson:2.8.0'
|
||||
compile 'com.sk89q.lib:jlibnoise:1.0.0'
|
||||
compile 'com.googlecode.json-simple:json-simple:1.1.1'
|
||||
compile 'org.slf4j:slf4j-api:1.7.26'
|
||||
compileOnly 'org.enginehub.piston:core-ap-annotations:0.0.1-SNAPSHOT'
|
||||
annotationProcessor 'org.enginehub.piston:core-ap-processor:0.0.1-SNAPSHOT'
|
||||
compile 'org.enginehub.piston:default-impl:0.0.1-SNAPSHOT'
|
||||
//compile 'net.sf.trove4j:trove4j:3.0.3'
|
||||
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir 'src/main/java'
|
||||
srcDir 'src/legacy/java'
|
||||
}
|
||||
resources {
|
||||
srcDir 'src/main/resources'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn(shadowJar)
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.io.Files;
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
@ -41,10 +40,13 @@
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||
import com.sk89q.worldedit.util.io.Closer;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.annotation.param.Arg;
|
||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||
import org.enginehub.piston.annotation.param.Switch;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -64,6 +66,7 @@
|
||||
/**
|
||||
* Commands that work with schematic files.
|
||||
*/
|
||||
@CommandContainer
|
||||
public class SchematicCommands {
|
||||
|
||||
/**
|
||||
@ -84,13 +87,13 @@ public SchematicCommands(WorldEdit worldEdit) {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "load" },
|
||||
usage = "[<format>] <filename>",
|
||||
desc = "Load a schematic into your clipboard",
|
||||
min = 1, max = 2
|
||||
name = "load",
|
||||
desc = "Load a schematic into your clipboard"
|
||||
)
|
||||
@CommandPermissions({ "worldedit.clipboard.load", "worldedit.schematic.load" })
|
||||
public void load(Player player, LocalSession session, @Optional("sponge") String formatName, String filename) throws FilenameException {
|
||||
@CommandPermissions({"worldedit.clipboard.load", "worldedit.schematic.load"})
|
||||
public void load(Player player, LocalSession session,
|
||||
@Arg(desc = "File name.") String filename,
|
||||
@Arg(desc = "Format name.", def = "sponge") String formatName) throws FilenameException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
@ -127,16 +130,15 @@ public void load(Player player, LocalSession session, @Optional("sponge") String
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "save" },
|
||||
flags = "f",
|
||||
usage = "[<format>] <filename>",
|
||||
desc = "Save a schematic into your clipboard",
|
||||
help = "-f is required to overwrite an existing file",
|
||||
min = 1, max = 2
|
||||
name = "save",
|
||||
desc = "Save a schematic into your clipboard"
|
||||
)
|
||||
@CommandPermissions({ "worldedit.clipboard.save", "worldedit.schematic.save" })
|
||||
public void save(Player player, LocalSession session, @Optional("sponge") String formatName,
|
||||
String filename, @Switch('f') boolean allowOverwrite) throws CommandException, WorldEditException {
|
||||
@CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save"})
|
||||
public void save(Player player, LocalSession session,
|
||||
@Arg(desc = "File name.") String filename,
|
||||
@Arg(desc = "Format name.", def = "sponge") String formatName,
|
||||
@Switch(name = 'f', desc = "Overwrite an existing file.") boolean allowOverwrite
|
||||
) throws CommandException, WorldEditException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
@ -198,15 +200,13 @@ public void save(Player player, LocalSession session, @Optional("sponge") String
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "delete", "d" },
|
||||
usage = "<filename>",
|
||||
desc = "Delete a saved schematic",
|
||||
help = "Delete a schematic from the schematic list",
|
||||
min = 1,
|
||||
max = 1
|
||||
name = "delete",
|
||||
aliases = {"d"},
|
||||
desc = "Delete a saved schematic"
|
||||
)
|
||||
@CommandPermissions("worldedit.schematic.delete")
|
||||
public void delete(Actor actor, String filename) throws WorldEditException {
|
||||
public void delete(Actor actor,
|
||||
@Arg(desc = "File name.") String filename) throws WorldEditException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
File dir = worldEdit.getWorkingDirectoryFile(config.saveDir);
|
||||
|
||||
@ -232,12 +232,12 @@ public void delete(Actor actor, String filename) throws WorldEditException {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"formats", "listformats", "f"},
|
||||
desc = "List available formats",
|
||||
max = 0
|
||||
name = "formats",
|
||||
aliases = {"listformats", "f"},
|
||||
desc = "List available formats"
|
||||
)
|
||||
@CommandPermissions("worldedit.schematic.formats")
|
||||
public void formats(Actor actor) throws WorldEditException {
|
||||
public void formats(Actor actor) {
|
||||
actor.print("Available clipboard formats (Name: Lookup names)");
|
||||
StringBuilder builder;
|
||||
boolean first = true;
|
||||
@ -257,18 +257,14 @@ public void formats(Actor actor) throws WorldEditException {
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = {"list", "all", "ls"},
|
||||
desc = "List saved schematics",
|
||||
max = 1,
|
||||
flags = "dnp",
|
||||
help = "List all schematics in the schematics directory\n" +
|
||||
" -d sorts by date, oldest first\n" +
|
||||
" -n sorts by date, newest first\n" +
|
||||
" -p <page> prints the requested page\n" +
|
||||
"Note: Format is not thoroughly verified until loading."
|
||||
name = "list",
|
||||
aliases = {"all", "ls"},
|
||||
desc = "List saved schematics",
|
||||
descFooter = "Note: Format is not fully verified until loading."
|
||||
)
|
||||
@CommandPermissions("worldedit.schematic.list")
|
||||
public void list(Actor actor, CommandContext args, @Switch('p') @Optional("1") int page) throws WorldEditException {
|
||||
public void list(Actor actor, CommandContext args,
|
||||
@ArgFlag(name = 'p', desc = "Page to view.", def = "1") int page) {
|
||||
File dir = worldEdit.getWorkingDirectoryFile(worldEdit.getConfiguration().saveDir);
|
||||
List<File> fileList = allFiles(dir);
|
||||
|
||||
@ -315,7 +311,7 @@ public void list(Actor actor, CommandContext args, @Switch('p') @Optional("1") i
|
||||
actor.print("Available schematics (Filename: Format) [" + page + "/" + pageCount + "]:");
|
||||
StringBuilder build = new StringBuilder();
|
||||
int limit = Math.min(offset + SCHEMATICS_PER_PAGE, schematics.size());
|
||||
for (int i = offset; i < limit;) {
|
||||
for (int i = offset; i < limit; ) {
|
||||
build.append(schematics.get(i));
|
||||
if (++i != limit) {
|
||||
build.append("\n");
|
||||
@ -351,10 +347,10 @@ private List<String> listFiles(String prefix, File[] files) {
|
||||
//ClipboardFormat format = ClipboardFormats.findByFile(file);
|
||||
Multimap<String, ClipboardFormat> exts = ClipboardFormats.getFileExtensionMap();
|
||||
ClipboardFormat format = exts.get(Files.getFileExtension(file.getName()))
|
||||
.stream().findFirst().orElse(null);
|
||||
.stream().findFirst().orElse(null);
|
||||
boolean inRoot = file.getParentFile().getName().equals(prefix);
|
||||
build.append(inRoot ? file.getName() : file.getPath().split(Pattern.quote(prefix + File.separator))[1])
|
||||
.append(": ").append(format == null ? "Unknown" : format.getName() + "*");
|
||||
.append(": ").append(format == null ? "Unknown" : format.getName() + "*");
|
||||
result.add(build.toString());
|
||||
}
|
||||
return result;
|
||||
|
@ -30,6 +30,7 @@
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
|
||||
public class AsyncCommandHelper {
|
||||
|
||||
@ -85,7 +86,8 @@ public AsyncCommandHelper thenRespondWith(String success, String failure) {
|
||||
.exceptionConverter(exceptionConverter)
|
||||
.onSuccess(format(success))
|
||||
.onFailure(format(failure))
|
||||
.build());
|
||||
.build(),
|
||||
ForkJoinPool.commonPool());
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -96,7 +98,8 @@ public AsyncCommandHelper thenTellErrorsOnly(String failure) {
|
||||
new MessageFutureCallback.Builder(sender)
|
||||
.exceptionConverter(exceptionConverter)
|
||||
.onFailure(format(failure))
|
||||
.build());
|
||||
.build(),
|
||||
ForkJoinPool.commonPool());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
|
||||
public class ActorCallbackPaste {
|
||||
|
||||
@ -65,7 +66,7 @@ public void onFailure(Throwable throwable) {
|
||||
LOGGER.warn("Failed to submit pastebin", throwable);
|
||||
sender.printError("Failed to submit to a pastebin. Please see console for the error.");
|
||||
}
|
||||
});
|
||||
}, ForkJoinPool.commonPool());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user