Merge master, update to texts

Dieser Commit ist enthalten in:
Kenzie Togami 2019-04-25 22:11:46 -07:00
Commit 853bfab022
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 5D200B325E157A81
63 geänderte Dateien mit 731 neuen und 1332 gelöschten Zeilen

Datei anzeigen

@ -82,6 +82,16 @@ artifactory {
artifactoryPublish.skip = true artifactoryPublish.skip = true
subprojects { subprojects {
repositories {
mavenCentral()
maven { url "http://maven.sk89q.com/repo/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
// temporary, for Piston
mavenLocal()
}
}
configure(['core', 'bukkit', 'forge', 'sponge'].collect { project(":worldedit-$it") }) {
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven'
apply plugin: 'checkstyle' apply plugin: 'checkstyle'
@ -97,14 +107,6 @@ subprojects {
checkstyle.configFile = new File(rootProject.projectDir, "config/checkstyle/checkstyle.xml") checkstyle.configFile = new File(rootProject.projectDir, "config/checkstyle/checkstyle.xml")
checkstyle.toolVersion = '7.6.1' checkstyle.toolVersion = '7.6.1'
repositories {
mavenCentral()
maven { url "http://maven.sk89q.com/repo/" }
maven { url "http://repo.maven.apache.org/maven2" }
// temporary, for Piston
mavenLocal()
}
if (JavaVersion.current().isJava8Compatible()) { if (JavaVersion.current().isJava8Compatible()) {
// Java 8 turns on doclint which we fail // Java 8 turns on doclint which we fail
tasks.withType(Javadoc) { tasks.withType(Javadoc) {
@ -138,18 +140,6 @@ subprojects {
build.dependsOn(checkstyleTest) build.dependsOn(checkstyleTest)
build.dependsOn(javadocJar) build.dependsOn(javadocJar)
shadowJar {
classifier 'dist'
dependencies {
include(dependency('com.sk89q:jchronic:0.2.4a'))
include(dependency('com.thoughtworks.paranamer:paranamer:2.6'))
include(dependency('com.sk89q.lib:jlibnoise:1.0.0'))
}
exclude 'GradleStart**'
exclude '.cache'
exclude 'LICENSE*'
}
artifactoryPublish { artifactoryPublish {
publishConfigs('archives') publishConfigs('archives')
} }
@ -159,3 +149,17 @@ subprojects {
include '**/*.java' include '**/*.java'
} }
} }
configure(['bukkit', 'forge', 'sponge'].collect { project(":worldedit-$it") }) {
shadowJar {
classifier 'dist'
dependencies {
include(project(":worldedit-libs:core"))
include(project(":worldedit-libs:${project.name.replace("worldedit-", "")}"))
include(project(":worldedit-core"))
}
exclude 'GradleStart**'
exclude '.cache'
exclude 'LICENSE*'
}
}

Datei anzeigen

@ -1,3 +1,9 @@
rootProject.name = 'worldedit' rootProject.name = 'worldedit'
include 'worldedit-core', 'worldedit-bukkit', 'worldedit-forge', 'worldedit-sponge' include 'worldedit-libs'
['bukkit', 'core', 'forge', 'sponge'].forEach {
include "worldedit-libs:$it"
include "worldedit-$it"
}
include "worldedit-libs:core:ap"

Datei anzeigen

@ -16,11 +16,12 @@ configurations.all { Configuration it ->
dependencies { dependencies {
compile project(':worldedit-core') compile project(':worldedit-core')
compile project(':worldedit-libs:bukkit')
compile 'com.sk89q:dummypermscompat:1.10' compile 'com.sk89q:dummypermscompat:1.10'
compile 'org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT' // zzz compile 'org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT' // zzz
compile 'org.bstats:bstats-bukkit:1.4'
compile "io.papermc:paperlib:1.0.1" compile "io.papermc:paperlib:1.0.1"
compile 'org.slf4j:slf4j-jdk14:1.7.26' compile 'org.slf4j:slf4j-jdk14:1.7.26'
compile 'org.bstats:bstats-bukkit:1.4'
testCompile 'org.mockito:mockito-core:1.9.0-rc1' testCompile 'org.mockito:mockito-core:1.9.0-rc1'
} }

Datei anzeigen

@ -19,7 +19,6 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.google.common.collect.ImmutableMap;
import com.sk89q.bukkit.util.CommandInspector; import com.sk89q.bukkit.util.CommandInspector;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -37,6 +36,7 @@ import org.slf4j.LoggerFactory;
import java.util.Optional; import java.util.Optional;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.bukkit.BukkitTextAdapter.reduceToText;
class BukkitCommandInspector implements CommandInspector { class BukkitCommandInspector implements CommandInspector {
@ -55,7 +55,7 @@ class BukkitCommandInspector implements CommandInspector {
public String getShortText(Command command) { public String getShortText(Command command) {
Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName()); Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName());
if (mapping.isPresent()) { if (mapping.isPresent()) {
return mapping.get().getDescription(); return reduceToText(mapping.get().getDescription());
} else { } else {
logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available"; return "Help text not available";
@ -66,7 +66,7 @@ class BukkitCommandInspector implements CommandInspector {
public String getFullText(Command command) { public String getFullText(Command command) {
Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName()); Optional<org.enginehub.piston.Command> mapping = dispatcher.getCommand(command.getName());
if (mapping.isPresent()) { if (mapping.isPresent()) {
return mapping.get().getFullHelp(); return reduceToText(mapping.get().getFullHelp());
} else { } else {
logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available"; return "Help text not available";

Datei anzeigen

@ -26,6 +26,8 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.auth.AuthorizationException; import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -91,6 +93,11 @@ public class BukkitCommandSender implements Actor {
} }
} }
@Override
public void print(TextComponent component) {
TextAdapter.sendComponent(sender, component);
}
@Override @Override
public boolean canDestroyBedrock() { public boolean canDestroyBedrock() {
return true; return true;

Datei anzeigen

@ -37,7 +37,8 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -125,6 +126,11 @@ public class BukkitPlayer extends AbstractPlayerActor {
} }
} }
@Override
public void print(TextComponent component) {
TextAdapter.sendComponent(player, component);
}
@Override @Override
public void setPosition(Vector3 pos, float pitch, float yaw) { public void setPosition(Vector3 pos, float pitch, float yaw) {
player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(), player.teleport(new Location(player.getWorld(), pos.getX(), pos.getY(),

Datei anzeigen

@ -28,7 +28,6 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.MultiUserPlatform; import com.sk89q.worldedit.extension.platform.MultiUserPlatform;
import com.sk89q.worldedit.extension.platform.Preference; import com.sk89q.worldedit.extension.platform.Preference;
import com.sk89q.worldedit.util.command.CommandMapping;
import com.sk89q.worldedit.world.registry.Registries; import com.sk89q.worldedit.world.registry.Registries;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Server; import org.bukkit.Server;
@ -45,6 +44,8 @@ import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static com.sk89q.worldedit.bukkit.BukkitTextAdapter.reduceToText;
public class BukkitServerInterface implements MultiUserPlatform { public class BukkitServerInterface implements MultiUserPlatform {
public Server server; public Server server;
public WorldEditPlugin plugin; public WorldEditPlugin plugin;
@ -132,8 +133,8 @@ public class BukkitServerInterface implements MultiUserPlatform {
Stream.of(command.getName()), Stream.of(command.getName()),
command.getAliases().stream() command.getAliases().stream()
).toArray(String[]::new); ).toArray(String[]::new);
return new CommandInfo(command.getUsage(), return new CommandInfo(reduceToText(command.getUsage()),
command.getDescription(), aliases, reduceToText(command.getDescription()), aliases,
inspector, permissionsArray); inspector, permissionsArray);
}).collect(Collectors.toList())); }).collect(Collectors.toList()));
} }

Datei anzeigen

@ -0,0 +1,48 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
public class BukkitTextAdapter {
public static String reduceToText(Component component) {
StringBuilder text = new StringBuilder();
appendTextTo(text, component);
return text.toString();
}
private static void appendTextTo(StringBuilder builder, Component component) {
if (component instanceof TextComponent) {
builder.append(((TextComponent) component).content());
} else if (component instanceof TranslatableComponent) {
builder.append(((TranslatableComponent) component).key());
}
for (Component child : component.children()) {
appendTextTo(builder, child);
}
}
private BukkitTextAdapter() {
}
}

Datei anzeigen

@ -52,7 +52,7 @@ public class BukkitImplLoader {
"**\n" + "**\n" +
"** When working with blocks or undoing, chests will be empty, signs\n" + "** When working with blocks or undoing, chests will be empty, signs\n" +
"** will be blank, and so on. There will be no support for entity\n" + "** will be blank, and so on. There will be no support for entity\n" +
"** and biome-related functions.\n" + "** and block property-related functions.\n" +
"**\n" + "**\n" +
"** Please see http://wiki.sk89q.com/wiki/WorldEdit/Bukkit_adapters\n" + "** Please see http://wiki.sk89q.com/wiki/WorldEdit/Bukkit_adapters\n" +
"**********************************************\n"; "**********************************************\n";

Datei anzeigen

@ -15,24 +15,19 @@ configurations.all { Configuration it ->
} }
dependencies { dependencies {
compile project(':worldedit-libs:core')
compile 'de.schlichtherle:truezip:6.8.3' compile 'de.schlichtherle:truezip:6.8.3'
compile 'rhino:js:1.7R2' compile 'rhino:js:1.7R2'
compile 'org.yaml:snakeyaml:1.9' compile 'org.yaml:snakeyaml:1.9'
compile 'com.google.guava:guava:21.0' 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.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.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 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'org.slf4j:slf4j-api:1.7.26' compile 'org.slf4j:slf4j-api:1.7.26'
def pistonVersion = '0.0.1-SNAPSHOT' compileOnly project(':worldedit-libs:core:ap')
api "org.enginehub.piston:core:$pistonVersion" annotationProcessor project(':worldedit-libs:core:ap')
compileOnly "org.enginehub.piston.core-ap:annotations:$pistonVersion" annotationProcessor "com.google.guava:guava:21.0"
implementation "org.enginehub.piston.core-ap:runtime:$pistonVersion"
annotationProcessor "org.enginehub.piston.core-ap:processor:$pistonVersion"
api "org.enginehub.piston:default-impl:$pistonVersion"
def avVersion = "1.6.5" def avVersion = "1.6.5"
compileOnly "com.google.auto.value:auto-value-annotations:$avVersion" compileOnly "com.google.auto.value:auto-value-annotations:$avVersion"
annotationProcessor "com.google.auto.value:auto-value:$avVersion" annotationProcessor "com.google.auto.value:auto-value:$avVersion"
@ -51,5 +46,3 @@ sourceSets {
} }
} }
} }
build.dependsOn(shadowJar)

Datei anzeigen

@ -54,10 +54,9 @@ import com.sk89q.worldedit.regions.selector.SphereRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder;
import com.sk89q.worldedit.util.formatting.Style;
import com.sk89q.worldedit.util.formatting.StyledFragment;
import com.sk89q.worldedit.util.formatting.component.CommandListBox; import com.sk89q.worldedit.util.formatting.component.CommandListBox;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.component.TextComponentProducer;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -626,19 +625,18 @@ public class SelectionCommands {
case UNKNOWN: case UNKNOWN:
default: default:
CommandListBox box = new CommandListBox("Selection modes"); CommandListBox box = new CommandListBox("Selection modes");
StyledFragment contents = box.getContents(); TextComponentProducer contents = box.getContents();
StyledFragment tip = contents.createFragment(Style.RED); contents.append(SubtleFormat.wrap("Select one of the modes below:")).newline();
tip.append("Select one of the modes below:").newLine();
box.appendCommand("cuboid", "Select two corners of a cuboid"); box.appendCommand("cuboid", "Select two corners of a cuboid", "//sel cuboid");
box.appendCommand("extend", "Fast cuboid selection mode"); box.appendCommand("extend", "Fast cuboid selection mode", "//sel extend");
box.appendCommand("poly", "Select a 2D polygon with height"); box.appendCommand("poly", "Select a 2D polygon with height", "//sel poly");
box.appendCommand("ellipsoid", "Select an ellipsoid"); box.appendCommand("ellipsoid", "Select an ellipsoid", "//sel ellipsoid");
box.appendCommand("sphere", "Select a sphere"); box.appendCommand("sphere", "Select a sphere", "//sel sphere");
box.appendCommand("cyl", "Select a cylinder"); box.appendCommand("cyl", "Select a cylinder", "//sel cyl");
box.appendCommand("convex", "Select a convex polyhedral"); box.appendCommand("convex", "Select a convex polyhedral", "//sel convex");
player.printRaw(ColorCodeBuilder.asColorCodes(box)); player.print(box.create());
return; return;
} }

Datei anzeigen

@ -513,5 +513,4 @@ public class UtilityCommands {
PrintCommandHelp.help(command, page, we, actor); PrintCommandHelp.help(command, page, we, actor);
} }
} }

Datei anzeigen

@ -20,6 +20,8 @@
package com.sk89q.worldedit.command.argument; package com.sk89q.worldedit.command.argument;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverter;
import org.enginehub.piston.converter.ConversionResult; import org.enginehub.piston.converter.ConversionResult;
@ -48,8 +50,8 @@ public class BooleanConverter implements ArgumentConverter<Boolean> {
} }
@Override @Override
public String describeAcceptableArguments() { public Component describeAcceptableArguments() {
return "on|off|true|false"; return TextComponent.of("on|off|true|false");
} }
@Override @Override

Datei anzeigen

@ -22,6 +22,8 @@ package com.sk89q.worldedit.command.argument;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverter;
import org.enginehub.piston.converter.ConversionResult; import org.enginehub.piston.converter.ConversionResult;
import org.enginehub.piston.converter.SuccessfulConversion; import org.enginehub.piston.converter.SuccessfulConversion;
@ -30,6 +32,7 @@ import org.enginehub.piston.inject.InjectedValueAccess;
import java.util.List; import java.util.List;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.sk89q.worldedit.util.formatting.text.Component.space;
public class CommaSeparatedValuesConverter<T> implements ArgumentConverter<T> { public class CommaSeparatedValuesConverter<T> implements ArgumentConverter<T> {
@ -54,14 +57,16 @@ public class CommaSeparatedValuesConverter<T> implements ArgumentConverter<T> {
} }
@Override @Override
public String describeAcceptableArguments() { public Component describeAcceptableArguments() {
StringBuilder result = new StringBuilder(); TextComponent.Builder result = TextComponent.builder("");
if (maximum > -1) { if (maximum > -1) {
result.append("up to ").append(maximum).append(' '); result.append(TextComponent.of("up to "))
.append(Component.of(maximum))
.append(space());
} }
result.append("comma separated values of: ") result.append(TextComponent.of("comma separated values of: "))
.append(delegate.describeAcceptableArguments()); .append(delegate.describeAcceptableArguments());
return result.toString(); return result.build();
} }
@Override @Override

Datei anzeigen

@ -28,6 +28,8 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.internal.annotation.Direction; import com.sk89q.worldedit.internal.annotation.Direction;
import com.sk89q.worldedit.internal.annotation.MultiDirection; import com.sk89q.worldedit.internal.annotation.MultiDirection;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverter;
import org.enginehub.piston.converter.ConversionResult; import org.enginehub.piston.converter.ConversionResult;
@ -104,9 +106,9 @@ public class DirectionConverter implements ArgumentConverter<BlockVector3> {
} }
@Override @Override
public String describeAcceptableArguments() { public Component describeAcceptableArguments() {
return "`me` to use facing direction, or any " return TextComponent.of("`me` to use facing direction, or any "
+ (includeDiagonals ? "direction" : "non-diagonal direction"); + (includeDiagonals ? "direction" : "non-diagonal direction"));
} }
@Override @Override

Datei anzeigen

@ -20,6 +20,8 @@
package com.sk89q.worldedit.command.argument; package com.sk89q.worldedit.command.argument;
import com.sk89q.worldedit.command.util.EntityRemover; import com.sk89q.worldedit.command.util.EntityRemover;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverter;
import org.enginehub.piston.converter.ConversionResult; import org.enginehub.piston.converter.ConversionResult;
@ -38,8 +40,10 @@ public class EntityRemoverConverter implements ArgumentConverter<EntityRemover>
} }
@Override @Override
public String describeAcceptableArguments() { public Component describeAcceptableArguments() {
return "projectiles, items, paintings, itemframes, boats, minecarts, tnt, xp, or all"; return TextComponent.of(
"projectiles, items, paintings, itemframes, boats, minecarts, tnt, xp, or all"
);
} }
@Override @Override

Datei anzeigen

@ -24,6 +24,8 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedMap;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverter;
import org.enginehub.piston.converter.ConversionResult; import org.enginehub.piston.converter.ConversionResult;
@ -70,7 +72,7 @@ public class EnumConverter<E extends Enum<E>> implements ArgumentConverter<E> {
return new EnumConverter<>(enumClass, lookupKeys, unknownValue); return new EnumConverter<>(enumClass, lookupKeys, unknownValue);
} }
private final String choices; private final Component choices;
private final ImmutableMap<String, E> map; private final ImmutableMap<String, E> map;
@Nullable @Nullable
private final E unknownValue; private final E unknownValue;
@ -92,15 +94,15 @@ public class EnumConverter<E extends Enum<E>> implements ArgumentConverter<E> {
map.put(key, e); map.put(key, e);
} }
} }
this.choices = choices.build() this.choices = TextComponent.of(choices.build()
.map(choice -> choice.stream().collect(joining("|", "[", "]"))) .map(choice -> choice.stream().collect(joining("|", "[", "]")))
.collect(joining("|")); .collect(joining("|")));
this.map = map.build(); this.map = map.build();
this.unknownValue = unknownValue; this.unknownValue = unknownValue;
} }
@Override @Override
public String describeAcceptableArguments() { public Component describeAcceptableArguments() {
return choices; return choices;
} }

Datei anzeigen

@ -20,6 +20,8 @@
package com.sk89q.worldedit.command.argument; package com.sk89q.worldedit.command.argument;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverter;
import org.enginehub.piston.converter.ArgumentConverters; import org.enginehub.piston.converter.ArgumentConverters;
@ -45,8 +47,8 @@ public class ExpandAmountConverter implements ArgumentConverter<ExpandAmount> {
} }
@Override @Override
public String describeAcceptableArguments() { public Component describeAcceptableArguments() {
return "`vert` or " + integerConverter.describeAcceptableArguments(); return TextComponent.of("`vert` or " + integerConverter.describeAcceptableArguments());
} }
@Override @Override

Datei anzeigen

@ -22,11 +22,12 @@ package com.sk89q.worldedit.command.argument;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.NoMatchException;
import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverter;
@ -71,7 +72,7 @@ public class MaskConverter implements ArgumentConverter<Mask> {
} }
@Override @Override
public String describeAcceptableArguments() { public Component describeAcceptableArguments() {
return "any mask"; return TextComponent.of("any mask");
} }
} }

Datei anzeigen

@ -27,6 +27,8 @@ import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverter;
@ -73,7 +75,7 @@ public class PatternConverter implements ArgumentConverter<Pattern> {
} }
@Override @Override
public String describeAcceptableArguments() { public Component describeAcceptableArguments() {
return "any pattern"; return TextComponent.of("any pattern");
} }
} }

Datei anzeigen

@ -25,12 +25,13 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector2; import com.sk89q.worldedit.math.Vector2;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverter;
import org.enginehub.piston.converter.ArgumentConverters; import org.enginehub.piston.converter.ArgumentConverters;
import org.enginehub.piston.converter.ConversionResult; import org.enginehub.piston.converter.ConversionResult;
import org.enginehub.piston.converter.FailedConversion; import org.enginehub.piston.converter.FailedConversion;
import org.enginehub.piston.converter.SimpleArgumentConverter;
import org.enginehub.piston.converter.SuccessfulConversion; import org.enginehub.piston.converter.SuccessfulConversion;
import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.InjectedValueAccess;
import org.enginehub.piston.inject.Key; import org.enginehub.piston.inject.Key;
@ -89,8 +90,8 @@ public class VectorConverter<C, T> implements ArgumentConverter<T> {
} }
@Override @Override
public String describeAcceptableArguments() { public Component describeAcceptableArguments() {
return "any " + acceptableArguments; return TextComponent.of("any " + acceptableArguments);
} }
@Override @Override

Datei anzeigen

@ -20,6 +20,8 @@
package com.sk89q.worldedit.command.argument; package com.sk89q.worldedit.command.argument;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverter;
import org.enginehub.piston.converter.ConversionResult; import org.enginehub.piston.converter.ConversionResult;
@ -42,8 +44,8 @@ public class ZonedDateTimeConverter implements ArgumentConverter<ZonedDateTime>
} }
@Override @Override
public String describeAcceptableArguments() { public Component describeAcceptableArguments() {
return "any date"; return TextComponent.of("any date");
} }
@Override @Override

Datei anzeigen

@ -23,12 +23,11 @@ import com.google.common.base.Joiner;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder; import com.sk89q.worldedit.util.formatting.component.CodeFormat;
import com.sk89q.worldedit.util.formatting.Style;
import com.sk89q.worldedit.util.formatting.StyledFragment;
import com.sk89q.worldedit.util.formatting.component.Code;
import com.sk89q.worldedit.util.formatting.component.CommandListBox; import com.sk89q.worldedit.util.formatting.component.CommandListBox;
import com.sk89q.worldedit.util.formatting.component.CommandUsageBox; import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import org.enginehub.piston.Command; import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
@ -116,7 +115,7 @@ public class PrintCommandHelp {
if (subCommands.isEmpty()) { if (subCommands.isEmpty()) {
// Create the message // Create the message
CommandUsageBox box = new CommandUsageBox(currentCommand, String.join(" ", visited)); CommandUsageBox box = new CommandUsageBox(currentCommand, String.join(" ", visited));
actor.printRaw(ColorCodeBuilder.asColorCodes(box)); actor.print(box.create());
} else { } else {
printAllCommands(page, perPage, subCommands.values().stream(), actor, false); printAllCommands(page, perPage, subCommands.values().stream(), actor, false);
} }
@ -134,17 +133,17 @@ public class PrintCommandHelp {
// Box // Box
CommandListBox box = new CommandListBox(String.format("Help: page %d/%d ", page, pageTotal)); CommandListBox box = new CommandListBox(String.format("Help: page %d/%d ", page, pageTotal));
StyledFragment contents = box.getContents(); TextComponent.Builder tip = box.getContents().getBuilder().color(TextColor.GRAY);
StyledFragment tip = contents.createFragment(Style.GRAY);
if (offset >= commands.size()) { if (offset >= commands.size()) {
tip.createFragment(Style.RED).append(String.format("There is no page %d (total number of pages is %d).", page, pageTotal)).newLine(); tip.color(TextColor.RED)
.append(TextComponent.of(String.format("There is no page %d (total number of pages is %d).\n", page, pageTotal)));
} else { } else {
List<Command> list = commands.subList(offset, Math.min(offset + perPage, commands.size())); List<Command> list = commands.subList(offset, Math.min(offset + perPage, commands.size()));
tip.append("Type "); tip.append(TextComponent.of("Type "));
tip.append(new Code().append("//help ").append("[<page>] <command...>")); tip.append(CodeFormat.wrap("//help [<page>] <command...>"));
tip.append(" for more information.").newLine(); tip.append(TextComponent.of(" for more information.\n"));
// Add each command // Add each command
for (Command mapping : list) { for (Command mapping : list) {
@ -152,7 +151,7 @@ public class PrintCommandHelp {
} }
} }
actor.printRaw(ColorCodeBuilder.asColorCodes(box)); actor.print(box.create());
} }
private PrintCommandHelp() { private PrintCommandHelp() {

Datei anzeigen

@ -19,6 +19,7 @@
package com.sk89q.worldedit.extension.factory.parser; package com.sk89q.worldedit.extension.factory.parser;
import com.google.common.collect.Maps;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.NotABlockException; import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -38,6 +39,7 @@ import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.formatting.component.ErrorFormat;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -148,7 +150,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
} }
} }
private static Map<Property<?>, Object> parseProperties(BlockType type, String[] stateProperties) throws NoMatchException { private static Map<Property<?>, Object> parseProperties(BlockType type, String[] stateProperties, ParserContext context) throws NoMatchException {
Map<Property<?>, Object> blockStates = new HashMap<>(); Map<Property<?>, Object> blockStates = new HashMap<>();
if (stateProperties.length > 0) { // Block data not yet detected if (stateProperties.length > 0) { // Block data not yet detected
@ -163,7 +165,14 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Property<Object> propertyKey = (Property<Object>) type.getPropertyMap().get(parts[0]); Property<Object> propertyKey = (Property<Object>) type.getPropertyMap().get(parts[0]);
if (propertyKey == null) { if (propertyKey == null) {
throw new NoMatchException("Unknown property " + parts[0] + " for block " + type.getName()); if (context.getActor() != null) {
context.getActor().print(ErrorFormat.wrap("Unknown property ", parts[0], " for block ", type.getName(),
". Defaulting to base."));
} else {
WorldEdit.logger.warn("Unknown property " + parts[0] + " for block " + type.getName());
// throw new NoMatchException("Unknown property " + parts[0] + " for block " + type.getName());
}
return Maps.newHashMap();
} }
if (blockStates.containsKey(propertyKey)) { if (blockStates.containsKey(propertyKey)) {
throw new NoMatchException("Duplicate property " + parts[0]); throw new NoMatchException("Duplicate property " + parts[0]);
@ -222,7 +231,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
typeString = blockAndExtraData[0].substring(0, stateStart); typeString = blockAndExtraData[0].substring(0, stateStart);
stateString = blockAndExtraData[0].substring(stateStart + 1, blockAndExtraData[0].length() - 1); stateString = blockAndExtraData[0].substring(stateStart + 1, blockAndExtraData[0].length() - 1);
} }
if (typeString == null || typeString.isEmpty()) { if (typeString.isEmpty()) {
throw new InputParseException("Invalid format"); throw new InputParseException("Invalid format");
} }
String[] stateProperties = EMPTY_STRING_ARRAY; String[] stateProperties = EMPTY_STRING_ARRAY;
@ -270,7 +279,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
} }
} }
blockStates.putAll(parseProperties(blockType, stateProperties)); blockStates.putAll(parseProperties(blockType, stateProperties, context));
if (!context.isPreferringWildcard()) { if (!context.isPreferringWildcard()) {
// No wildcards allowed => eliminate them. (Start with default state) // No wildcards allowed => eliminate them. (Start with default state)

Datei anzeigen

@ -23,6 +23,7 @@ import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionOwner; import com.sk89q.worldedit.session.SessionOwner;
import com.sk89q.worldedit.util.Identifiable; import com.sk89q.worldedit.util.Identifiable;
import com.sk89q.worldedit.util.auth.Subject; import com.sk89q.worldedit.util.auth.Subject;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import java.io.File; import java.io.File;
@ -75,6 +76,13 @@ public interface Actor extends Identifiable, SessionOwner, Subject {
*/ */
void printError(String msg); void printError(String msg);
/**
* Print a {@link TextComponent}.
*
* @param component The component to print
*/
void print(TextComponent component);
/** /**
* Returns true if the actor can destroy bedrock. * Returns true if the actor can destroy bedrock.
* *

Datei anzeigen

@ -89,6 +89,8 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.command.parametric.ExceptionConverter; import com.sk89q.worldedit.util.command.parametric.ExceptionConverter;
import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.logging.DynamicStreamHandler; import com.sk89q.worldedit.util.logging.DynamicStreamHandler;
import com.sk89q.worldedit.util.logging.LogFormat; import com.sk89q.worldedit.util.logging.LogFormat;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
@ -240,97 +242,65 @@ public final class PlatformCommandMananger {
}); });
} }
private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
CommandRegistration<CI> registration, CI instance) {
commandManager.register(name, cmd -> {
cmd.aliases(aliases);
cmd.description(TextComponent.of(desc));
cmd.action(Command.Action.NULL_ACTION);
CommandManager manager = DefaultCommandManagerService.getInstance()
.newCommandManager();
register(
manager,
registration,
instance
);
cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"),
TextComponent.of("Sub-command to run."))
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
.required()
.build());
});
}
private void registerAllCommands() { private void registerAllCommands() {
commandManager.register("schematic", cmd -> { registerSubCommands(
cmd.aliases(ImmutableList.of("schem", "/schematic", "/schem")); "schematic",
cmd.description("Schematic commands for saving/loading areas"); ImmutableList.of("schem", "/schematic", "/schem"),
cmd.action(Command.Action.NULL_ACTION); "Schematic commands for saving/loading areas",
SchematicCommandsRegistration.builder(),
CommandManager manager = DefaultCommandManagerService.getInstance() new SchematicCommands(worldEdit)
.newCommandManager(); );
register( registerSubCommands(
manager, "snapshot",
SchematicCommandsRegistration.builder(), ImmutableList.of("snap"),
new SchematicCommands(worldEdit) "Snapshot commands for saving/loading snapshots",
); SnapshotCommandsRegistration.builder(),
new SnapshotCommands(worldEdit)
cmd.addPart(SubCommandPart.builder("action", "Sub-command to run.") );
.withCommands(manager.getAllCommands().collect(Collectors.toList())) registerSubCommands(
.required() "superpickaxe",
.build()); ImmutableList.of("pickaxe", "sp"),
}); "Super-pickaxe commands",
commandManager.register("snapshot", cmd -> { SuperPickaxeCommandsRegistration.builder(),
cmd.aliases(ImmutableList.of("snap")); new SuperPickaxeCommands(worldEdit)
cmd.description("Snapshot commands for saving/loading snapshots"); );
cmd.action(Command.Action.NULL_ACTION); registerSubCommands(
"brush",
CommandManager manager = DefaultCommandManagerService.getInstance() ImmutableList.of("br"),
.newCommandManager(); "Brushing commands",
register( BrushCommandsRegistration.builder(),
manager, new BrushCommands(worldEdit)
SnapshotCommandsRegistration.builder(), );
new SnapshotCommands(worldEdit) registerSubCommands(
); "worldedit",
ImmutableList.of("we"),
cmd.addPart(SubCommandPart.builder("action", "Sub-command to run.") "WorldEdit commands",
.withCommands(manager.getAllCommands().collect(Collectors.toList())) WorldEditCommandsRegistration.builder(),
.required() new WorldEditCommands(worldEdit)
.build()); );
});
commandManager.register("superpickaxe", cmd -> {
cmd.aliases(ImmutableList.of("pickaxe", "sp"));
cmd.description("Super-pickaxe commands");
cmd.action(Command.Action.NULL_ACTION);
CommandManager manager = DefaultCommandManagerService.getInstance()
.newCommandManager();
register(
manager,
SuperPickaxeCommandsRegistration.builder(),
new SuperPickaxeCommands(worldEdit)
);
cmd.addPart(SubCommandPart.builder("action", "Sub-command to run.")
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
.required()
.build());
});
commandManager.register("brush", cmd -> {
cmd.aliases(ImmutableList.of("br"));
cmd.description("Brushing commands");
cmd.action(Command.Action.NULL_ACTION);
CommandManager manager = DefaultCommandManagerService.getInstance()
.newCommandManager();
register(
manager,
BrushCommandsRegistration.builder(),
new BrushCommands(worldEdit)
);
cmd.addPart(SubCommandPart.builder("action", "Sub-command to run.")
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
.required()
.build());
});
commandManager.register("worldedit", cmd -> {
cmd.aliases(ImmutableList.of("we"));
cmd.description("WorldEdit commands");
cmd.action(Command.Action.NULL_ACTION);
CommandManager manager = DefaultCommandManagerService.getInstance()
.newCommandManager();
register(
manager,
WorldEditCommandsRegistration.builder(),
new WorldEditCommands(worldEdit)
);
cmd.addPart(SubCommandPart.builder("action", "Sub-command to run.")
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
.required()
.build());
});
register( register(
commandManager, commandManager,
BiomeCommandsRegistration.builder(), BiomeCommandsRegistration.builder(),

Datei anzeigen

@ -34,6 +34,7 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import java.util.UUID; import java.util.UUID;
@ -132,6 +133,11 @@ class PlayerProxy extends AbstractPlayerActor {
basePlayer.printError(msg); basePlayer.printError(msg);
} }
@Override
public void print(TextComponent component) {
basePlayer.print(component);
}
@Override @Override
public String[] getGroups() { public String[] getGroups() {
return permActor.getGroups(); return permActor.getGroups();

Datei anzeigen

@ -80,7 +80,7 @@ public class NoiseFilter extends AbstractMask {
*/ */
public void setDensity(double density) { public void setDensity(double density) {
checkArgument(density >= 0, "density must be >= 0"); checkArgument(density >= 0, "density must be >= 0");
checkArgument(density <= 1, "density must be >= 1"); checkArgument(density <= 1, "density must be <= 1");
this.density = density; this.density = density;
} }

Datei anzeigen

@ -78,7 +78,7 @@ public class NoiseFilter2D extends AbstractMask2D {
*/ */
public void setDensity(double density) { public void setDensity(double density) {
checkArgument(density >= 0, "density must be >= 0"); checkArgument(density >= 0, "density must be >= 0");
checkArgument(density <= 1, "density must be >= 1"); checkArgument(density <= 1, "density must be <= 1");
this.density = density; this.density = density;
} }

Datei anzeigen

@ -32,6 +32,7 @@ import com.sk89q.worldedit.internal.expression.runtime.Functions;
import com.sk89q.worldedit.internal.expression.runtime.RValue; import com.sk89q.worldedit.internal.expression.runtime.RValue;
import com.sk89q.worldedit.internal.expression.runtime.ReturnException; import com.sk89q.worldedit.internal.expression.runtime.ReturnException;
import com.sk89q.worldedit.internal.expression.runtime.Variable; import com.sk89q.worldedit.internal.expression.runtime.Variable;
import com.sk89q.worldedit.session.request.Request;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -142,7 +143,18 @@ public class Expression {
} }
private double evaluateRootTimed(int timeout) throws EvaluationException { private double evaluateRootTimed(int timeout) throws EvaluationException {
Future<Double> result = evalThread.submit(this::evaluateRoot); Request request = Request.request();
Future<Double> result = evalThread.submit(() -> {
Request local = Request.request();
local.setSession(request.getSession());
local.setWorld(request.getWorld());
local.setEditSession(request.getEditSession());
try {
return Expression.this.evaluateRoot();
} finally {
Request.reset();
}
});
try { try {
return result.get(timeout, TimeUnit.MILLISECONDS); return result.get(timeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) { } catch (InterruptedException e) {

Datei anzeigen

@ -243,12 +243,7 @@ public class SessionManager {
* @return the key object * @return the key object
*/ */
protected UUID getKey(SessionKey key) { protected UUID getKey(SessionKey key) {
String forcedKey = System.getProperty("worldedit.session.uuidOverride"); return key.getUniqueId();
if (forcedKey != null) {
return UUID.fromString(forcedKey);
} else {
return key.getUniqueId();
}
} }
/** /**

Datei anzeigen

@ -48,7 +48,7 @@ public class Location {
* @param extent the extent * @param extent the extent
*/ */
public Location(Extent extent) { public Location(Extent extent) {
this(extent, Vector3.ZERO, Vector3.ZERO); this(extent, Vector3.ZERO, 0f, 90f);
} }
/** /**
@ -61,7 +61,7 @@ public class Location {
* @param z the Z coordinate * @param z the Z coordinate
*/ */
public Location(Extent extent, double x, double y, double z) { public Location(Extent extent, double x, double y, double z) {
this(extent, Vector3.at(x, y, z), Vector3.ZERO); this(extent, Vector3.at(x, y, z), 0f, 90f);
} }
/** /**
@ -72,7 +72,7 @@ public class Location {
* @param position the position vector * @param position the position vector
*/ */
public Location(Extent extent, Vector3 position) { public Location(Extent extent, Vector3 position) {
this(extent, position, Vector3.ZERO); this(extent, position, 0f, 90f);
} }
/** /**

Datei anzeigen

@ -1,271 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.formatting;
import com.google.common.base.Joiner;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class ColorCodeBuilder {
private static final ColorCodeBuilder instance = new ColorCodeBuilder();
private static final Joiner newLineJoiner = Joiner.on("\n");
public static final int GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH = 47;
/**
* Convert a message into color-coded text.
*
* @param message the message
* @return a list of lines
*/
public String[] build(StyledFragment message) {
StringBuilder builder = new StringBuilder();
buildFragment(builder, message, message.getStyle(), new StyleSet());
return builder.toString().split("\r?\n");
}
/**
* Build a fragment.
*
* @param builder the string builder
* @param message the message
* @param parentStyle the parent style
* @param lastStyle the last style
* @return the last style used
*/
private StyleSet buildFragment(StringBuilder builder, StyledFragment message, StyleSet parentStyle, StyleSet lastStyle) {
for (Fragment node : message.getChildren()) {
if (node instanceof StyledFragment) {
StyledFragment fragment = (StyledFragment) node;
lastStyle = buildFragment(
builder, fragment,
parentStyle.extend(message.getStyle()), lastStyle);
} else {
StyleSet style = parentStyle.extend(message.getStyle());
builder.append(getAdditive(style, lastStyle));
builder.append(node);
lastStyle = style;
}
}
return lastStyle;
}
/**
* Get the formatting codes.
*
* @param style the style
* @return the color codes
*/
public static String getFormattingCode(StyleSet style) {
StringBuilder builder = new StringBuilder();
if (style.isBold()) {
builder.append(Style.BOLD);
}
if (style.isItalic()) {
builder.append(Style.ITALIC);
}
if (style.isUnderline()) {
builder.append(Style.UNDERLINE);
}
if (style.isStrikethrough()) {
builder.append(Style.STRIKETHROUGH);
}
return builder.toString();
}
/**
* Get the formatting and color codes.
*
* @param style the style
* @return the color codes
*/
public static String getCode(StyleSet style) {
StringBuilder builder = new StringBuilder();
builder.append(getFormattingCode(style));
if (style.getColor() != null) {
builder.append(style.getColor());
}
return builder.toString();
}
/**
* Get the additional color codes needed to set the given style when the current
* style is the other given one.
*
* @param resetTo the style to reset to
* @param resetFrom the style to reset from
* @return the color codes
*/
public static String getAdditive(StyleSet resetTo, StyleSet resetFrom) {
if (!resetFrom.hasFormatting() && resetTo.hasFormatting()) {
StringBuilder builder = new StringBuilder();
builder.append(getFormattingCode(resetTo));
if (resetFrom.getColor() != resetTo.getColor()) {
builder.append(resetTo.getColor());
}
return builder.toString();
} else if (!resetFrom.hasEqualFormatting(resetTo) ||
(resetFrom.getColor() != null && resetTo.getColor() == null)) {
// Have to set reset code and add back all the formatting codes
return Style.RESET + getCode(resetTo);
} else {
if (resetFrom.getColor() != resetTo.getColor()) {
return String.valueOf(resetTo.getColor());
}
}
return "";
}
/**
* Word wrap the given text and maintain color codes throughout lines.
*
* <p>This is borrowed from Bukkit.</p>
*
* @param rawString the raw string
* @param lineLength the maximum line length
* @return a list of lines
*/
private String[] wordWrap(String rawString, int lineLength) {
// A null string is a single line
if (rawString == null) {
return new String[] {""};
}
// A string shorter than the lineWidth is a single line
if (rawString.length() <= lineLength && !rawString.contains("\n")) {
return new String[] {rawString};
}
char[] rawChars = (rawString + ' ').toCharArray(); // add a trailing space to trigger pagination
StringBuilder word = new StringBuilder();
StringBuilder line = new StringBuilder();
List<String> lines = new LinkedList<>();
int lineColorChars = 0;
for (int i = 0; i < rawChars.length; i++) {
char c = rawChars[i];
// skip chat color modifiers
if (c == Style.COLOR_CHAR) {
word.append(Style.getByChar(rawChars[i + 1]));
lineColorChars += 2;
i++; // Eat the next character as we have already processed it
continue;
}
if (c == ' ' || c == '\n') {
if (line.length() == 0 && word.length() > lineLength) { // special case: extremely long word begins a line
String wordStr = word.toString();
String transformed;
if ((transformed = transform(wordStr)) != null) {
line.append(transformed);
} else {
lines.addAll(Arrays.asList(word.toString().split("(?<=\\G.{" + lineLength + "})")));
}
} else if (line.length() + word.length() - lineColorChars == lineLength) { // Line exactly the correct length...newline
line.append(' ');
line.append(word);
lines.add(line.toString());
line = new StringBuilder();
lineColorChars = 0;
} else if (line.length() + 1 + word.length() - lineColorChars > lineLength) { // Line too long...break the line
String wordStr = word.toString();
String transformed;
if (word.length() > lineLength && (transformed = transform(wordStr)) != null) {
if (line.length() + 1 + transformed.length() - lineColorChars > lineLength) {
lines.add(line.toString());
line = new StringBuilder(transformed);
lineColorChars = 0;
} else {
if (line.length() > 0) {
line.append(' ');
}
line.append(transformed);
}
} else {
for (String partialWord : wordStr.split("(?<=\\G.{" + lineLength + "})")) {
lines.add(line.toString());
line = new StringBuilder(partialWord);
}
lineColorChars = 0;
}
} else {
if (line.length() > 0) {
line.append(' ');
}
line.append(word);
}
word = new StringBuilder();
if (c == '\n') { // Newline forces the line to flush
lines.add(line.toString());
line = new StringBuilder();
}
} else {
word.append(c);
}
}
if(line.length() > 0) { // Only add the last line if there is anything to add
lines.add(line.toString());
}
// Iterate over the wrapped lines, applying the last color from one line to the beginning of the next
if (lines.get(0).isEmpty() || lines.get(0).charAt(0) != Style.COLOR_CHAR) {
lines.set(0, Style.WHITE + lines.get(0));
}
for (int i = 1; i < lines.size(); i++) {
final String pLine = lines.get(i-1);
final String subLine = lines.get(i);
char color = pLine.charAt(pLine.lastIndexOf(Style.COLOR_CHAR) + 1);
if (subLine.isEmpty() || subLine.charAt(0) != Style.COLOR_CHAR) {
lines.set(i, Style.getByChar(color) + subLine);
}
}
return lines.toArray(new String[lines.size()]);
}
/**
* Callback for transforming a word, such as a URL.
*
* @param word the word
* @return the transformed value, or null to do nothing
*/
protected String transform(String word) {
return null;
}
/**
* Convert the given styled fragment into color codes.
*
* @param fragment the fragment
* @return color codes
*/
public static String asColorCodes(StyledFragment fragment) {
return newLineJoiner.join(instance.build(fragment));
}
}

Datei anzeigen

@ -1,92 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.formatting;
/**
* A fragment of text.
*/
public class Fragment {
private final StringBuilder builder = new StringBuilder();
Fragment() {
}
public Fragment append(String str) {
builder.append(Style.stripColor(str));
return this;
}
public Fragment append(Object obj) {
append(String.valueOf(obj));
return this;
}
public Fragment append(StringBuffer sb) {
append(String.valueOf(sb));
return this;
}
public Fragment append(CharSequence s) {
append(String.valueOf(s));
return this;
}
public Fragment append(boolean b) {
append(String.valueOf(b));
return this;
}
public Fragment append(char c) {
append(String.valueOf(c));
return this;
}
public Fragment append(int i) {
append(String.valueOf(i));
return this;
}
public Fragment append(long lng) {
append(String.valueOf(lng));
return this;
}
public Fragment append(float f) {
append(String.valueOf(f));
return this;
}
public Fragment append(double d) {
append(String.valueOf(d));
return this;
}
public Fragment newLine() {
append("\n");
return this;
}
@Override
public String toString() {
return builder.toString();
}
}

Datei anzeigen

@ -1,276 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.formatting;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.regex.Pattern;
/**
* All supported color values for chat.
*
* <p>From Bukkit.</p>
*/
public enum Style {
/**
* Represents black
*/
BLACK('0', 0x00),
/**
* Represents dark blue
*/
BLUE_DARK('1', 0x1),
/**
* Represents dark green
*/
GREEN_DARK('2', 0x2),
/**
* Represents dark blue (aqua)
*/
CYAN_DARK('3', 0x3),
/**
* Represents dark red
*/
RED_DARK('4', 0x4),
/**
* Represents dark purple
*/
PURPLE_DARK('5', 0x5),
/**
* Represents gold
*/
YELLOW_DARK('6', 0x6),
/**
* Represents gray
*/
GRAY('7', 0x7),
/**
* Represents dark gray
*/
GRAY_DARK('8', 0x8),
/**
* Represents blue
*/
BLUE('9', 0x9),
/**
* Represents green
*/
GREEN('a', 0xA),
/**
* Represents aqua
*/
CYAN('b', 0xB),
/**
* Represents red
*/
RED('c', 0xC),
/**
* Represents light purple
*/
PURPLE('d', 0xD),
/**
* Represents yellow
*/
YELLOW('e', 0xE),
/**
* Represents white
*/
WHITE('f', 0xF),
/**
* Represents magical characters that change around randomly
*/
RANDOMIZE('k', 0x10, true),
/**
* Makes the text bold.
*/
BOLD('l', 0x11, true),
/**
* Makes a line appear through the text.
*/
STRIKETHROUGH('m', 0x12, true),
/**
* Makes the text appear underlined.
*/
UNDERLINE('n', 0x13, true),
/**
* Makes the text italic.
*/
ITALIC('o', 0x14, true),
/**
* Resets all previous chat colors or formats.
*/
RESET('r', 0x15);
/**
* The special character which prefixes all chat color codes. Use this if you need to dynamically
* convert color codes from your custom format.
*/
public static final char COLOR_CHAR = '\u00A7';
private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + COLOR_CHAR + "[0-9A-FK-OR]");
private final int intCode;
private final char code;
private final boolean isFormat;
private final String toString;
private final static Map<Integer, Style> BY_ID = Maps.newHashMap();
private final static Map<Character, Style> BY_CHAR = Maps.newHashMap();
Style(char code, int intCode) {
this(code, intCode, false);
}
Style(char code, int intCode, boolean isFormat) {
this.code = code;
this.intCode = intCode;
this.isFormat = isFormat;
this.toString = new String(new char[] {COLOR_CHAR, code});
}
/**
* Gets the char value associated with this color
*
* @return A char value of this color code
*/
public char getChar() {
return code;
}
@Override
public String toString() {
return toString;
}
/**
* Checks if this code is a format code as opposed to a color code.
*
* @return the if the code is a formatting code
*/
public boolean isFormat() {
return isFormat;
}
/**
* Checks if this code is a color code as opposed to a format code.
*
* @return the if the code is a color
*/
public boolean isColor() {
return !isFormat && this != RESET;
}
/**
* Gets the color represented by the specified color code
*
* @param code Code to check
* @return Associative Style with the given code, or null if it doesn't exist
*/
public static Style getByChar(char code) {
return BY_CHAR.get(code);
}
/**
* Gets the color represented by the specified color code
*
* @param code Code to check
* @return Associative Style with the given code, or null if it doesn't exist
*/
public static Style getByChar(String code) {
checkNotNull(code);
checkArgument(!code.isEmpty(), "Code must have at least one character");
return BY_CHAR.get(code.charAt(0));
}
/**
* Strips the given message of all color codes
*
* @param input String to strip of color
* @return A copy of the input string, without any coloring
*/
public static String stripColor(final String input) {
if (input == null) {
return null;
}
return STRIP_COLOR_PATTERN.matcher(input).replaceAll("");
}
/**
* Translates a string using an alternate color code character into a string that uses the internal
* ChatColor.COLOR_CODE color code character. The alternate color code character will only be replaced
* if it is immediately followed by 0-9, A-F, a-f, K-O, k-o, R or r.
*
* @param altColorChar The alternate color code character to replace. Ex: &amp;
* @param textToTranslate Text containing the alternate color code character.
* @return Text containing the ChatColor.COLOR_CODE color code character.
*/
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) {
char[] b = textToTranslate.toCharArray();
for (int i = 0; i < b.length - 1; i++) {
if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1) {
b[i] = Style.COLOR_CHAR;
b[i+1] = Character.toLowerCase(b[i+1]);
}
}
return new String(b);
}
/**
* Gets the ChatColors used at the end of the given input string.
*
* @param input Input string to retrieve the colors from.
* @return Any remaining ChatColors to pass onto the next line.
*/
public static String getLastColors(String input) {
String result = "";
int length = input.length();
// Search backwards from the end as it is faster
for (int index = length - 1; index > -1; index--) {
char section = input.charAt(index);
if (section == COLOR_CHAR && index < length - 1) {
char c = input.charAt(index + 1);
Style color = getByChar(c);
if (color != null) {
result = color + result;
// Once we find a color or reset we can stop searching
if (color.isColor() || color == RESET) {
break;
}
}
}
}
return result;
}
static {
for (Style color : values()) {
BY_ID.put(color.intCode, color);
BY_CHAR.put(color.code, color);
}
}
}

Datei anzeigen

@ -1,249 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.formatting;
/**
* Represents set of styles, such as color, bold, etc.
*/
public class StyleSet {
private Boolean bold;
private Boolean italic;
private Boolean underline;
private Boolean strikethrough;
private Style color;
/**
* Create a new style set with no properties set.
*/
public StyleSet() {
}
/**
* Create a new style set with the given styles.
*
* <p>{@link Style#RESET} will be ignored if provided.</p>
*
* @param styles a list of styles
*/
public StyleSet(Style... styles) {
for (Style style : styles) {
if (style.isColor()) {
color = style;
} else if (style == Style.BOLD) {
bold = true;
} else if (style == Style.ITALIC) {
italic = true;
} else if (style == Style.UNDERLINE) {
underline = true;
} else if (style == Style.STRIKETHROUGH) {
strikethrough = true;
}
}
}
/**
* Get whether this style set is bold.
*
* @return true, false, or null if unset
*/
public Boolean getBold() {
return bold;
}
/**
* Get whether the text is bold.
*
* @return true if bold
*/
public boolean isBold() {
return getBold() != null && getBold();
}
/**
* Set whether the text is bold.
*
* @param bold true, false, or null to unset
*/
public void setBold(Boolean bold) {
this.bold = bold;
}
/**
* Get whether this style set is italicized.
*
* @return true, false, or null if unset
*/
public Boolean getItalic() {
return italic;
}
/**
* Get whether the text is italicized.
*
* @return true if italicized
*/
public boolean isItalic() {
return getItalic() != null && getItalic();
}
/**
* Set whether the text is italicized.
*
* @param italic false, or null to unset
*/
public void setItalic(Boolean italic) {
this.italic = italic;
}
/**
* Get whether this style set is underlined.
*
* @return true, false, or null if unset
*/
public Boolean getUnderline() {
return underline;
}
/**
* Get whether the text is underlined.
*
* @return true if underlined
*/
public boolean isUnderline() {
return getUnderline() != null && getUnderline();
}
/**
* Set whether the text is underline.
*
* @param underline false, or null to unset
*/
public void setUnderline(Boolean underline) {
this.underline = underline;
}
/**
* Get whether this style set is stricken through.
*
* @return true, false, or null if unset
*/
public Boolean getStrikethrough() {
return strikethrough;
}
/**
* Get whether the text is stricken through.
*
* @return true if there is strikethrough applied
*/
public boolean isStrikethrough() {
return getStrikethrough() != null && getStrikethrough();
}
/**
* Set whether the text is stricken through.
*
* @param strikethrough false, or null to unset
*/
public void setStrikethrough(Boolean strikethrough) {
this.strikethrough = strikethrough;
}
/**
* Get the color of the text.
*
* @return true, false, or null if unset
*/
public Style getColor() {
return color;
}
/**
* Set the color of the text.
*
* @param color the color
*/
public void setColor(Style color) {
this.color = color;
}
/**
* Return whether text formatting (bold, italics, underline, strikethrough) is set.
*
* @return true if formatting is set
*/
public boolean hasFormatting() {
return getBold() != null || getItalic() != null
|| getUnderline() != null || getStrikethrough() != null;
}
/**
* Return where the text formatting of the given style set is different from
* that assigned to this one.
*
* @param other the other style set
* @return true if there is a difference
*/
public boolean hasEqualFormatting(StyleSet other) {
return getBold() == other.getBold() && getItalic() == other.getItalic()
&& getUnderline() == other.getUnderline() &&
getStrikethrough() == other.getStrikethrough();
}
/**
* Create a new instance with styles inherited from this one but with new styles
* from the given style set.
*
* @param style the style set
* @return a new style set instance
*/
public StyleSet extend(StyleSet style) {
StyleSet newStyle = clone();
if (style.getBold() != null) {
newStyle.setBold(style.getBold());
}
if (style.getItalic() != null) {
newStyle.setItalic(style.getItalic());
}
if (style.getUnderline() != null) {
newStyle.setUnderline(style.getUnderline());
}
if (style.getStrikethrough() != null) {
newStyle.setStrikethrough(style.getStrikethrough());
}
if (style.getColor() != null) {
newStyle.setColor(style.getColor());
}
return newStyle;
}
@Override
public StyleSet clone() {
StyleSet style = new StyleSet();
style.setBold(getBold());
style.setItalic(getItalic());
style.setUnderline(getUnderline());
style.setStrikethrough(getStrikethrough());
style.setColor(getColor());
return style;
}
}

Datei anzeigen

@ -1,150 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.formatting;
import java.util.ArrayList;
import java.util.List;
/**
* A fragment of text that can be styled.
*/
public class StyledFragment extends Fragment {
private final List<Fragment> children = new ArrayList<>();
private StyleSet style;
private Fragment lastText;
public StyledFragment() {
style = new StyleSet();
}
public StyledFragment(StyleSet style) {
this.style = style;
}
public StyledFragment(Style... styles) {
this.style = new StyleSet(styles);
}
public StyleSet getStyle() {
return style;
}
public void setStyles(StyleSet style) {
this.style = style;
}
public List<Fragment> getChildren() {
return children;
}
protected Fragment lastText() {
Fragment text;
if (!children.isEmpty()) {
text = children.get(children.size() - 1);
if (text == lastText) {
return text;
}
}
text = new Fragment();
this.lastText = text;
children.add(text);
return text;
}
public StyledFragment createFragment(Style... styles) {
StyledFragment fragment = new StyledFragment(styles);
append(fragment);
return fragment;
}
public StyledFragment append(StyledFragment fragment) {
children.add(fragment);
return this;
}
@Override
public StyledFragment append(String str) {
lastText().append(str);
return this;
}
@Override
public StyledFragment append(Object obj) {
append(String.valueOf(obj));
return this;
}
@Override
public StyledFragment append(StringBuffer sb) {
append(String.valueOf(sb));
return this;
}
@Override
public StyledFragment append(CharSequence s) {
append(String.valueOf(s));
return this;
}
@Override
public StyledFragment append(boolean b) {
append(String.valueOf(b));
return this;
}
@Override
public StyledFragment append(char c) {
append(String.valueOf(c));
return this;
}
@Override
public StyledFragment append(int i) {
append(String.valueOf(i));
return this;
}
@Override
public StyledFragment append(long lng) {
append(String.valueOf(lng));
return this;
}
@Override
public StyledFragment append(float f) {
append(String.valueOf(f));
return this;
}
@Override
public StyledFragment append(double d) {
append(String.valueOf(d));
return this;
}
@Override
public StyledFragment newLine() {
append("\n");
return this;
}
}

Datei anzeigen

@ -19,19 +19,30 @@
package com.sk89q.worldedit.util.formatting.component; package com.sk89q.worldedit.util.formatting.component;
import com.sk89q.worldedit.util.formatting.Style; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.StyledFragment; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
/** /**
* Represents a fragment representing a command that is to be typed. * Represents a fragment representing a command that is to be typed.
*/ */
public class Code extends StyledFragment { public class CodeFormat extends TextComponentProducer {
/** private CodeFormat() {
* Create a new instance. getBuilder().content("").color(TextColor.AQUA);
*/
public Code() {
super(Style.CYAN);
} }
/**
* Creates a CodeFormat with the given message.
*
* @param texts The text
* @return The Component
*/
public static TextComponent wrap(String ... texts) {
CodeFormat code = new CodeFormat();
for (String text: texts) {
code.append(text);
}
return code.create();
}
} }

Datei anzeigen

@ -19,7 +19,11 @@
package com.sk89q.worldedit.util.formatting.component; package com.sk89q.worldedit.util.formatting.component;
import com.sk89q.worldedit.util.formatting.Style; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
public class CommandListBox extends MessageBox { public class CommandListBox extends MessageBox {
@ -31,14 +35,28 @@ public class CommandListBox extends MessageBox {
* @param title the title * @param title the title
*/ */
public CommandListBox(String title) { public CommandListBox(String title) {
super(title); super(title, new TextComponentProducer());
} }
public CommandListBox appendCommand(String alias, String description) { public CommandListBox appendCommand(String alias, Component description) {
return appendCommand(alias, description, null);
}
public CommandListBox appendCommand(String alias, String description, String insertion) {
return appendCommand(alias, TextComponent.of(description), insertion);
}
public CommandListBox appendCommand(String alias, Component description, String insertion) {
if (!first) { if (!first) {
getContents().newLine(); getContents().newline();
} }
getContents().createFragment(Style.YELLOW_DARK).append(alias).append(": "); TextComponent commandName = TextComponent.of(alias, TextColor.GOLD);
if (insertion != null) {
commandName = commandName
.clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, insertion))
.hoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to select")));
}
getContents().append(commandName.append(TextComponent.of(": ")));
getContents().append(description); getContents().append(description);
first = false; first = false;
return this; return this;

Datei anzeigen

@ -19,7 +19,6 @@
package com.sk89q.worldedit.util.formatting.component; package com.sk89q.worldedit.util.formatting.component;
import com.sk89q.worldedit.util.formatting.StyledFragment;
import org.enginehub.piston.Command; import org.enginehub.piston.Command;
import org.enginehub.piston.CommandParameters; import org.enginehub.piston.CommandParameters;
@ -35,7 +34,7 @@ import static com.sk89q.worldedit.util.command.CommandUtil.getSubCommands;
/** /**
* A box to describe usage of a command. * A box to describe usage of a command.
*/ */
public class CommandUsageBox extends StyledFragment { public class CommandUsageBox extends TextComponentProducer {
/** /**
* Create a new usage box. * Create a new usage box.
@ -79,15 +78,14 @@ public class CommandUsageBox extends StyledFragment {
} }
} }
append(box); append(box.create());
} }
private void attachCommandUsage(Command description, String commandString) { private void attachCommandUsage(Command description, String commandString) {
MessageBox box = new MessageBox("Help for " + commandString); MessageBox box = new MessageBox("Help for " + commandString,
new TextComponentProducer().append(description.getFullHelp()));
box.getContents().append(description.getFullHelp()); append(box.create());
append(box);
} }
} }

Datei anzeigen

@ -0,0 +1,51 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.formatting.component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
/**
* Represents a fragment representing an error.
*/
public class ErrorFormat extends TextComponentProducer {
/**
* Create a new instance.
*/
private ErrorFormat() {
getBuilder().content("").color(TextColor.RED);
}
/**
* Creates an ErrorFormat with the given message.
*
* @param texts The text
* @return The Component
*/
public static TextComponent wrap(String ... texts) {
ErrorFormat error = new ErrorFormat();
for (String component : texts) {
error.append(component);
}
return error.create();
}
}

Datei anzeigen

@ -0,0 +1,51 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.formatting.component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
/**
* Represents a fragment representing a label.
*/
public class LabelFormat extends TextComponentProducer {
/**
* Create a new instance.
*/
private LabelFormat() {
getBuilder().content("").color(TextColor.YELLOW);
}
/**
* Creates a LabelFormat with the given message.
*
* @param texts The text
* @return The Component
*/
public static TextComponent wrap(String ... texts) {
LabelFormat label = new LabelFormat();
for (String component : texts) {
label.append(component);
}
return label.create();
}
}

Datei anzeigen

@ -21,37 +21,39 @@ package com.sk89q.worldedit.util.formatting.component;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.Style; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.StyledFragment; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
/** /**
* Makes for a box with a border above and below. * Makes for a box with a border above and below.
*/ */
public class MessageBox extends StyledFragment { public class MessageBox extends TextComponentProducer {
private final StyledFragment contents = new StyledFragment(); private static final int GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH = 47;
private final TextComponentProducer contents;
/** /**
* Create a new box. * Create a new box.
*/ */
public MessageBox(String title) { public MessageBox(String title, TextComponentProducer contents) {
checkNotNull(title); checkNotNull(title);
int leftOver = ColorCodeBuilder.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH - title.length() - 2; int leftOver = GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH - title.length() - 2;
int leftSide = (int) Math.floor(leftOver * 1.0/3); int leftSide = (int) Math.floor(leftOver * 1.0/3);
int rightSide = (int) Math.floor(leftOver * 2.0/3); int rightSide = (int) Math.floor(leftOver * 2.0/3);
if (leftSide > 0) { if (leftSide > 0) {
createFragment(Style.YELLOW).append(createBorder(leftSide)); append(TextComponent.of(createBorder(leftSide), TextColor.YELLOW));
} }
append(" "); append(Component.space());
append(title); append(title);
append(" "); append(Component.space());
if (rightSide > 0) { if (rightSide > 0) {
createFragment(Style.YELLOW).append(createBorder(rightSide)); append(TextComponent.of(createBorder(rightSide), TextColor.YELLOW));
} }
newLine(); newline();
append(contents); this.contents = contents;
} }
private String createBorder(int count) { private String createBorder(int count) {
@ -63,12 +65,17 @@ public class MessageBox extends StyledFragment {
} }
/** /**
* Get the internal contents. * Gets the message box contents producer.
* *
* @return the contents * @return The contents producer
*/ */
public StyledFragment getContents() { public TextComponentProducer getContents() {
return contents; return contents;
} }
@Override
public TextComponent create() {
append(contents.create());
return super.create();
}
} }

Datei anzeigen

@ -19,19 +19,33 @@
package com.sk89q.worldedit.util.formatting.component; package com.sk89q.worldedit.util.formatting.component;
import com.sk89q.worldedit.util.formatting.Style; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.StyledFragment; import com.sk89q.worldedit.util.formatting.text.format.TextColor;
/** /**
* Represents a subtle part of the message. * Represents a subtle part of the message.
*/ */
public class Subtle extends StyledFragment { public class SubtleFormat extends TextComponentProducer {
/** /**
* Create a new instance. * Create a new instance.
*/ */
public Subtle() { private SubtleFormat() {
super(Style.GRAY); getBuilder().content("").color(TextColor.GRAY);
} }
/**
* Creates a SubtleFormat with the given message.
*
* @param texts The text
* @return The Component
*/
public static TextComponent wrap(String ... texts) {
SubtleFormat subtle = new SubtleFormat();
for (String component : texts) {
subtle.append(component);
}
return subtle.create();
}
} }

Datei anzeigen

@ -0,0 +1,68 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.formatting.component;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
public class TextComponentProducer {
private TextComponent.Builder builder = TextComponent.builder().content("");
public TextComponent.Builder getBuilder() {
return builder;
}
/**
* Adds a component as a child to this Producer.
*
* @param component The component
* @return The producer, for chaining
*/
public TextComponentProducer append(Component component) {
getBuilder().append(component);
return this;
}
/**
* Adds a string as a child to this Producer.
*
* @param string The text
* @return The producer, for chaining
*/
public TextComponentProducer append(String string) {
getBuilder().append(TextComponent.of(string));
return this;
}
/**
* Adds a newline as a child to this Producer.
*
* @return The producer, for chaining
*/
public TextComponentProducer newline() {
getBuilder().append(Component.newline());
return this;
}
public TextComponent create() {
return builder.build();
}
}

Datei anzeigen

@ -93,11 +93,11 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
} else { } else {
Pattern pattern = Pattern.compile(".*\\.mc[ra]$"); Pattern pattern = Pattern.compile(".*\\.mc[ra]$");
// World pattern // World pattern
Pattern worldPattern = Pattern.compile(worldName + "\\$"); Pattern worldPattern = Pattern.compile(worldName + "[\\\\/].*");
for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) { for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
ZipEntry testEntry = e.nextElement(); ZipEntry testEntry = e.nextElement();
// Check for world // Check for world
if (worldPattern.matcher(worldName).matches()) { if (worldPattern.matcher(testEntry.getName()).matches()) {
// Check for file // Check for file
if (pattern.matcher(testEntry.getName()).matches()) { if (pattern.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/')); folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));

Datei anzeigen

@ -14,7 +14,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle' apply plugin: 'net.minecraftforge.gradle'
def minecraftVersion = "1.13.2" def minecraftVersion = "1.13.2"
def forgeVersion = "25.0.76" def forgeVersion = "25.0.146"
configurations.all { Configuration it -> configurations.all { Configuration it ->
it.resolutionStrategy { ResolutionStrategy rs -> it.resolutionStrategy { ResolutionStrategy rs ->
@ -35,7 +35,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
minecraft { minecraft {
mappings channel: 'snapshot', version: '20190311-1.13.2' mappings channel: 'snapshot', version: '20190415-1.13.2'
runs { runs {
client = { client = {
@ -93,7 +93,6 @@ shadowJar {
relocate "org.slf4j", "com.sk89q.worldedit.slf4j" relocate "org.slf4j", "com.sk89q.worldedit.slf4j"
relocate "org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge" relocate "org.apache.logging.slf4j", "com.sk89q.worldedit.log4jbridge"
include(dependency(':worldedit-core'))
include(dependency('org.slf4j:slf4j-api')) include(dependency('org.slf4j:slf4j-api'))
include(dependency("org.apache.logging.log4j:log4j-slf4j-impl")) include(dependency("org.apache.logging.log4j:log4j-slf4j-impl"))
} }

Datei anzeigen

@ -31,9 +31,11 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
@ -42,6 +44,7 @@ import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.util.EnumHand; import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
@ -49,8 +52,6 @@ import java.util.UUID;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import io.netty.buffer.Unpooled;
public class ForgePlayer extends AbstractPlayerActor { public class ForgePlayer extends AbstractPlayerActor {
private final EntityPlayerMP player; private final EntityPlayerMP player;
@ -141,6 +142,11 @@ public class ForgePlayer extends AbstractPlayerActor {
sendColorized(msg, TextFormatting.RED); sendColorized(msg, TextFormatting.RED);
} }
@Override
public void print(TextComponent component) {
this.player.sendMessage(ITextComponent.Serializer.fromJson(GsonComponentSerializer.INSTANCE.serialize(component)));
}
private void sendColorized(String msg, TextFormatting formatting) { private void sendColorized(String msg, TextFormatting formatting) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
TextComponentString component = new TextComponentString(part); TextComponentString component = new TextComponentString(part);

Datei anzeigen

@ -178,7 +178,7 @@ public class ForgeWorld extends AbstractWorld {
} }
if (successful && notifyAndLight) { if (successful && notifyAndLight) {
//world.checkLight(pos); world.checkLight(pos);
world.markAndNotifyBlock(pos, chunk, old, newState, UPDATE | NOTIFY); world.markAndNotifyBlock(pos, chunk, old, newState, UPDATE | NOTIFY);
} }
@ -426,6 +426,11 @@ public class ForgeWorld extends AbstractWorld {
} }
} }
@Override
public int getMaxY() {
return getWorld().getHeight() - 1;
}
@Override @Override
public BlockVector3 getSpawnPosition() { public BlockVector3 getSpawnPosition() {
return ForgeAdapter.adapt(getWorld().getSpawnPoint()); return ForgeAdapter.adapt(getWorld().getSpawnPoint());

Datei anzeigen

@ -22,9 +22,9 @@ package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.forge.gui.GuiReferenceCard; import com.sk89q.worldedit.forge.gui.GuiReferenceCard;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
public class KeyHandler { public class KeyHandler {
@ -37,11 +37,9 @@ public class KeyHandler {
} }
@SubscribeEvent @SubscribeEvent
public void onKey(KeyInputEvent evt) { public void onKey(InputEvent.KeyInputEvent evt) {
if (mc.player != null && mc.world != null && mainKey.isPressed()) { if (mc.player != null && mc.world != null && mainKey.isPressed()) {
mc.displayGuiScreen(new GuiReferenceCard()); mc.displayGuiScreen(new GuiReferenceCard());
// TODO Seems GuiHandlers don't work on client right now
// NetworkHooks.openGui(mc.player, new ResourceLocationInteractionObject(ServerProxy.REFERENCE_GUI));
} }
} }

Datei anzeigen

@ -25,16 +25,8 @@ import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.DEDICATED_SERVER) @OnlyIn(Dist.DEDICATED_SERVER)
public class ServerProxy implements CommonProxy { public class ServerProxy implements CommonProxy {
// public static ResourceLocation REFERENCE_GUI = new ResourceLocation("worldedit", "resource_gui");
@Override @Override
public void registerHandlers() { public void registerHandlers() {
// ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, () -> openContainer -> {
// if (openContainer.getId().equals(REFERENCE_GUI)) {
// return new GuiReferenceCard();
// }
// return null;
// });
} }
} }

128
worldedit-libs/build.gradle Normale Datei
Datei anzeigen

@ -0,0 +1,128 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
/*
This project shades <em>API</em> libraries, i.e. those libraries
whose classes are publicly referenced from `-core` classes.
This project <em>does not</em> shade implementation libraries, i.e.
those libraries whose classes are internally depended on.
This is because the main reason for shading those libraries is for
their internal usage in each platform, not because we need them available to
dependents of `-core` to compile and work with WorldEdit's API.
*/
configure(subprojects + project("core:ap")) {
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'com.jfrog.artifactory'
configurations {
create("shade")
getByName("archives").extendsFrom(getByName("default"))
}
group = rootProject.group + ".worldedit-libs"
tasks.register("jar", ShadowJar) {
configurations = [project.configurations.shade]
classifier = ""
dependencies {
exclude(dependency("com.google.guava:guava"))
exclude(dependency("com.google.code.gson:gson"))
exclude(dependency("org.checkerframework:checker-qual"))
}
relocate('net.kyori.text', 'com.sk89q.worldedit.util.formatting.text')
}
def altConfigFiles = { String artifactType ->
def deps = configurations.shade.incoming.dependencies
.collect { it.copy() }
.collect { dependency ->
dependency.artifact { artifact ->
artifact.name = dependency.name
artifact.type = artifactType
artifact.extension = 'jar'
artifact.classifier = artifactType
}
dependency
}
return files(configurations.detachedConfiguration(deps as Dependency[])
.resolvedConfiguration.lenientConfiguration.getArtifacts()
.findAll { it.classifier == artifactType }
.collect { zipTree(it.file) })
}
tasks.register("sourcesJar", Jar) {
from {
altConfigFiles('sources')
}
def filePattern = ~'(.*)net/kyori/text((?:/|$).*)'
def textPattern = ~/net\.kyori\.text/
eachFile {
it.filter { String line ->
line.replaceFirst(textPattern, 'com.sk89q.worldedit.util.formatting.text')
}
it.path = it.path.replaceFirst(filePattern, '$1com/sk89q/worldedit/util/formatting/text$2')
}
classifier = "sources"
}
artifacts {
add("default", jar)
add("archives", sourcesJar)
}
tasks.register("install", Upload) {
configuration = configurations.archives
repositories.mavenInstaller {
pom.version = project.version
pom.artifactId = project.name
}
}
artifactoryPublish {
publishConfigs('default')
}
build.dependsOn(jar, sourcesJar)
}
project("core") {
def pistonVersion = '0.0.1-SNAPSHOT'
dependencies {
shade 'net.kyori:text-api:2.0.0'
shade 'net.kyori:text-serializer-gson:2.0.0'
shade 'net.kyori:text-serializer-legacy:2.0.0'
shade('com.sk89q:jchronic:0.2.4a') {
exclude(group: "junit", module: "junit")
}
shade 'com.thoughtworks.paranamer:paranamer:2.6'
shade 'com.sk89q.lib:jlibnoise:1.0.0'
shade "org.enginehub.piston:core:$pistonVersion"
shade "org.enginehub.piston.core-ap:runtime:$pistonVersion"
shade "org.enginehub.piston:default-impl:$pistonVersion"
}
project("ap") {
dependencies {
shade "org.enginehub.piston.core-ap:annotations:$pistonVersion"
shade "org.enginehub.piston.core-ap:processor:$pistonVersion"
}
}
}
project("bukkit") {
dependencies {
shade 'net.kyori:text-adapter-bukkit:2.0.0-SNAPSHOT'
}
}
project("sponge") {
dependencies {
shade 'net.kyori:text-adapter-spongeapi:2.0.0-SNAPSHOT'
}
}
tasks.register("build") {
dependsOn(subprojects.collect { it.tasks.named("build") })
}

Datei anzeigen

@ -17,6 +17,7 @@ repositories {
dependencies { dependencies {
compile project(':worldedit-core') compile project(':worldedit-core')
compile project(':worldedit-libs:sponge')
compile 'org.spongepowered:spongeapi:7.1.0' compile 'org.spongepowered:spongeapi:7.1.0'
compile 'org.bstats:bstats-sponge:1.4' compile 'org.bstats:bstats-sponge:1.4'
testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0-rc1' testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0-rc1'
@ -40,15 +41,12 @@ jar {
shadowJar { shadowJar {
dependencies { dependencies {
include(dependency(':worldedit-core')) relocate ("org.bstats", "com.sk89q.worldedit.sponge.bstats") {
include(dependency('org.bstats:bstats-sponge:1.4')) include(dependency('org.bstats:bstats-sponge:1.4'))
}
} }
} }
artifacts {
archives shadowJar
}
if (project.hasProperty("signing")) { if (project.hasProperty("signing")) {
apply plugin: 'signing' apply plugin: 'signing'

Datei anzeigen

@ -29,6 +29,8 @@ import java.util.Collections;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import static com.sk89q.worldedit.sponge.SpongeTextAdapter.convert;
public abstract class CommandAdapter implements CommandCallable { public abstract class CommandAdapter implements CommandCallable {
private Command command; private Command command;
@ -51,24 +53,18 @@ public abstract class CommandAdapter implements CommandCallable {
@Override @Override
public Optional<Text> getShortDescription(CommandSource source) { public Optional<Text> getShortDescription(CommandSource source) {
String description = command.getDescription(); return Optional.of(command.getDescription())
if (!description.isEmpty()) { .map(SpongeTextAdapter::convert);
return Optional.of(Text.of(description));
}
return Optional.empty();
} }
@Override @Override
public Optional<Text> getHelp(CommandSource source) { public Optional<Text> getHelp(CommandSource source) {
String help = command.getFullHelp(); return Optional.of(command.getFullHelp())
if (!help.isEmpty()) { .map(SpongeTextAdapter::convert);
return Optional.of(Text.of(help));
}
return Optional.empty();
} }
@Override @Override
public Text getUsage(CommandSource source) { public Text getUsage(CommandSource source) {
return Text.of(command.getUsage()); return convert(command.getUsage());
} }
} }

Datei anzeigen

@ -26,6 +26,8 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.util.auth.AuthorizationException; import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.adapter.spongeapi.TextAdapter;
import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text; import org.spongepowered.api.text.Text;
@ -89,6 +91,11 @@ public class SpongeCommandSender implements Actor {
sendColorized(msg, TextColors.RED); sendColorized(msg, TextColors.RED);
} }
@Override
public void print(TextComponent component) {
TextAdapter.sendComponent(sender, component);
}
private void sendColorized(String msg, TextColor formatting) { private void sendColorized(String msg, TextColor formatting) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
sender.sendMessage(Text.of(formatting, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(part))); sender.sendMessage(Text.of(formatting, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(part)));

Datei anzeigen

@ -36,6 +36,8 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.adapter.spongeapi.TextAdapter;
import org.spongepowered.api.Sponge; import org.spongepowered.api.Sponge;
import org.spongepowered.api.data.type.HandTypes; import org.spongepowered.api.data.type.HandTypes;
import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.entity.living.player.Player;
@ -149,6 +151,11 @@ public class SpongePlayer extends AbstractPlayerActor {
sendColorized(msg, TextColors.RED); sendColorized(msg, TextColors.RED);
} }
@Override
public void print(TextComponent component) {
TextAdapter.sendComponent(player, component);
}
private void sendColorized(String msg, TextColor formatting) { private void sendColorized(String msg, TextColor formatting) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
this.player.sendMessage(Text.of(formatting, TextSerializers.FORMATTING_CODE.deserialize(part))); this.player.sendMessage(Text.of(formatting, TextSerializers.FORMATTING_CODE.deserialize(part)));

Datei anzeigen

@ -17,21 +17,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldedit.util.formatting.component; package com.sk89q.worldedit.sponge;
import com.sk89q.worldedit.util.formatting.Style; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.StyledFragment; import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.serializer.TextSerializers;
/** public class SpongeTextAdapter {
* Represents a fragment representing a label.
*/
public class Label extends StyledFragment {
/** public static Text convert(Component component) {
* Create a new instance. return TextSerializers.JSON.deserialize(GsonComponentSerializer.INSTANCE.serialize(component));
*/
public Label() {
super(Style.YELLOW);
} }
private SpongeTextAdapter() {
}
} }