mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Fixed a null pointer. Merged in a bunch of CLI stuff.
This commit is contained in:
parent
aa4c443358
commit
c20f4c6b7f
@ -13,7 +13,7 @@ logger.lifecycle("""
|
|||||||
1) Read COMPILING.md if you haven't yet
|
1) Read COMPILING.md if you haven't yet
|
||||||
2) Try running 'build' in a separate Gradle run
|
2) Try running 'build' in a separate Gradle run
|
||||||
3) Use gradlew and not gradle
|
3) Use gradlew and not gradle
|
||||||
4) If you still need help, ask on Discord! https://discord.gg/cSMxtGn
|
4) If you still need help, ask on Discord! https://discord.gg/enginehub
|
||||||
|
|
||||||
Output files will be in [subproject]/build/libs
|
Output files will be in [subproject]/build/libs
|
||||||
*******************************************
|
*******************************************
|
||||||
|
@ -12,6 +12,7 @@ repositories {
|
|||||||
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
|
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
|
||||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
||||||
maven { url = uri("http://empcraft.com/maven2") }
|
maven { url = uri("http://empcraft.com/maven2") }
|
||||||
|
maven { url = uri("https://maven.enginehub.org/repo/") }
|
||||||
maven { url = uri("http://ci.frostcast.net/plugin/repository/everything") }
|
maven { url = uri("http://ci.frostcast.net/plugin/repository/everything") }
|
||||||
maven { url = uri("http://dl.bintray.com/tastybento/maven-repo") }
|
maven { url = uri("http://dl.bintray.com/tastybento/maven-repo") }
|
||||||
maven { url = uri("http://ci.emc.gs/nexus/content/groups/aikar/") }
|
maven { url = uri("http://ci.emc.gs/nexus/content/groups/aikar/") }
|
||||||
@ -38,10 +39,15 @@ dependencies {
|
|||||||
"implementation"("io.papermc:paperlib:1.0.2")
|
"implementation"("io.papermc:paperlib:1.0.2")
|
||||||
"compileOnly"("com.sk89q:dummypermscompat:1.10")
|
"compileOnly"("com.sk89q:dummypermscompat:1.10")
|
||||||
"implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
"implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
|
||||||
"implementation"("org.bstats:bstats-bukkit:1.5")
|
"testCompile"("org.mockito:mockito-core:1.9.0-rc1") {
|
||||||
"testCompile"("org.mockito:mockito-core:1.9.0-rc1")
|
exclude("junit", "junit")
|
||||||
"implementation"("com.sk89q.worldguard:worldguard-core:7.0.0-20190215.210421-39") { isTransitive = false }
|
}
|
||||||
"implementation"("com.sk89q.worldguard:worldguard-legacy:7.0.0-20190215.210421-39") { isTransitive = false }
|
"compileOnly"("com.sk89q.worldguard:worldguard-bukkit:7.0.0") {
|
||||||
|
exclude("com.sk89q.worldedit", "worldedit-bukkit")
|
||||||
|
exclude("com.sk89q.worldedit", "worldedit-core")
|
||||||
|
exclude("com.sk89q.worldedit.worldedit-libs", "bukkit")
|
||||||
|
exclude("com.sk89q.worldedit.worldedit-libs", "core")
|
||||||
|
}
|
||||||
"implementation"("com.massivecraft:factions:2.8.0") { isTransitive = false }
|
"implementation"("com.massivecraft:factions:2.8.0") { isTransitive = false }
|
||||||
"implementation"("com.drtshock:factions:1.6.9.5") { isTransitive = false }
|
"implementation"("com.drtshock:factions:1.6.9.5") { isTransitive = false }
|
||||||
"implementation"("com.factionsone:FactionsOne:1.2.2") { isTransitive = false }
|
"implementation"("com.factionsone:FactionsOne:1.2.2") { isTransitive = false }
|
||||||
|
@ -1,273 +0,0 @@
|
|||||||
package com.boydti.fawe.bukkit.chat;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.gson.stream.JsonWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
|
||||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a textual component of a message part.
|
|
||||||
* This can be used to not only represent string literals in a JSON message,
|
|
||||||
* but also to represent localized strings and other text values.
|
|
||||||
* <p>Different instances of this class can be created with static constructor methods.</p>
|
|
||||||
*/
|
|
||||||
public abstract class TextualComponent implements Cloneable {
|
|
||||||
|
|
||||||
static {
|
|
||||||
ConfigurationSerialization.registerClass(ArbitraryTextTypeComponent.class);
|
|
||||||
ConfigurationSerialization.registerClass(ComplexTextTypeComponent.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
static TextualComponent deserialize(Map<String, Object> map) {
|
|
||||||
if (map.containsKey("key") && map.size() == 2 && map.containsKey("value")) {
|
|
||||||
// Arbitrary text component
|
|
||||||
return ArbitraryTextTypeComponent.deserialize(map);
|
|
||||||
} else if (map.size() >= 2 && map.containsKey("key") && !map.containsKey("value") /* It contains keys that START WITH value */) {
|
|
||||||
// Complex JSON object
|
|
||||||
return ComplexTextTypeComponent.deserialize(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean isTextKey(String key) {
|
|
||||||
return key.equals("translate") || key.equals("text") || key.equals("score") || key.equals("selector");
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean isTranslatableText(TextualComponent component) {
|
|
||||||
return component instanceof ComplexTextTypeComponent && component.getKey().equals("translate");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a textual component representing a string literal.
|
|
||||||
*
|
|
||||||
* <p>This is the default type of textual component when a single string
|
|
||||||
* literal is given to a method.
|
|
||||||
*
|
|
||||||
* @param textValue The text which will be represented.
|
|
||||||
* @return The text component representing the specified literal text.
|
|
||||||
*/
|
|
||||||
public static TextualComponent rawText(String textValue) {
|
|
||||||
return new ArbitraryTextTypeComponent("text", textValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a textual component representing a localized string.
|
|
||||||
* The client will see this text component as their localized version of the specified string <em>key</em>, which can be overridden by a
|
|
||||||
* resource pack.
|
|
||||||
* <p>
|
|
||||||
* If the specified translation key is not present on the client resource pack, the translation key will be displayed as a string literal to
|
|
||||||
* the client.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param translateKey The string key which maps to localized text.
|
|
||||||
* @return The text component representing the specified localized text.
|
|
||||||
*/
|
|
||||||
public static TextualComponent localizedText(String translateKey) {
|
|
||||||
return new ArbitraryTextTypeComponent("translate", translateKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void throwUnsupportedSnapshot() {
|
|
||||||
throw new UnsupportedOperationException("This feature is only supported in snapshot releases.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a textual component representing a player name, retrievable by using a standard minecraft selector.
|
|
||||||
* The client will see the players or entities captured by the specified selector as the text represented by this component.
|
|
||||||
* <p>
|
|
||||||
* <b>This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients.</b>
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param selector The minecraft player or entity selector which will capture the entities whose string representations will be displayed in
|
|
||||||
* the place of this text component.
|
|
||||||
* @return The text component representing the name of the entities captured by the selector.
|
|
||||||
*/
|
|
||||||
public static TextualComponent selector(String selector) {
|
|
||||||
throwUnsupportedSnapshot(); // Remove this line when the feature is released to non-snapshot versions, in addition to updating ALL THE
|
|
||||||
// OVERLOADS documentation accordingly
|
|
||||||
|
|
||||||
return new ArbitraryTextTypeComponent("selector", selector);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getReadableString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The JSON key used to represent text components of this type.
|
|
||||||
*/
|
|
||||||
public abstract String getKey();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return A readable String
|
|
||||||
*/
|
|
||||||
public abstract String getReadableString();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clones a textual component instance.
|
|
||||||
* The returned object should not reference this textual component instance, but should maintain the same key and value.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public abstract TextualComponent clone() throws CloneNotSupportedException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the text data represented by this textual component to the specified JSON writer object.
|
|
||||||
* A new object within the writer is not started.
|
|
||||||
*
|
|
||||||
* @param writer The object to which to write the JSON data.
|
|
||||||
* @throws IOException If an error occurs while writing to the stream.
|
|
||||||
*/
|
|
||||||
public abstract void writeJson(JsonWriter writer) throws IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal class used to represent all types of text components.
|
|
||||||
* Exception validating done is on keys and values.
|
|
||||||
*/
|
|
||||||
private static final class ArbitraryTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
|
|
||||||
|
|
||||||
private String key;
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
public ArbitraryTextTypeComponent(String key, String value) {
|
|
||||||
setKey(key);
|
|
||||||
setValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArbitraryTextTypeComponent deserialize(Map<String, Object> map) {
|
|
||||||
return new ArbitraryTextTypeComponent(map.get("key").toString(), map.get("value").toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKey(String key) {
|
|
||||||
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(String value) {
|
|
||||||
Preconditions.checkArgument(value != null, "The value must be specified.");
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TextualComponent clone() throws CloneNotSupportedException {
|
|
||||||
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
|
|
||||||
return new ArbitraryTextTypeComponent(getKey(), getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeJson(JsonWriter writer) throws IOException {
|
|
||||||
writer.name(getKey()).value(getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public Map<String, Object> serialize() {
|
|
||||||
return new HashMap<String, Object>() {
|
|
||||||
{
|
|
||||||
put("key", getKey());
|
|
||||||
put("value", getValue());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getReadableString() {
|
|
||||||
return getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal class used to represent a text component with a nested JSON
|
|
||||||
* value.
|
|
||||||
*
|
|
||||||
* <p>Exception validating done is on keys and values.
|
|
||||||
*/
|
|
||||||
private static final class ComplexTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
|
|
||||||
|
|
||||||
private String key;
|
|
||||||
private Map<String, String> value;
|
|
||||||
|
|
||||||
public ComplexTextTypeComponent(String key, Map<String, String> values) {
|
|
||||||
setKey(key);
|
|
||||||
setValue(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ComplexTextTypeComponent deserialize(Map<String, Object> map) {
|
|
||||||
String key = null;
|
|
||||||
Map<String, String> value = new HashMap<>();
|
|
||||||
for (Map.Entry<String, Object> valEntry : map.entrySet()) {
|
|
||||||
if (valEntry.getKey().equals("key")) {
|
|
||||||
key = (String) valEntry.getValue();
|
|
||||||
} else if (valEntry.getKey().startsWith("value.")) {
|
|
||||||
value.put(valEntry.getKey().substring(6) /* Strips out the value prefix */, valEntry.getValue().toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new ComplexTextTypeComponent(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKey(String key) {
|
|
||||||
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, String> getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(Map<String, String> value) {
|
|
||||||
Preconditions.checkArgument(value != null, "The value must be specified.");
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TextualComponent clone() {
|
|
||||||
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
|
|
||||||
return new ComplexTextTypeComponent(getKey(), getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeJson(JsonWriter writer) throws IOException {
|
|
||||||
writer.name(getKey());
|
|
||||||
writer.beginObject();
|
|
||||||
for (Map.Entry<String, String> jsonPair : value.entrySet()) {
|
|
||||||
writer.name(jsonPair.getKey()).value(jsonPair.getValue());
|
|
||||||
}
|
|
||||||
writer.endObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public Map<String, Object> serialize() {
|
|
||||||
return new HashMap<String, Object>() {
|
|
||||||
{
|
|
||||||
put("key", getKey());
|
|
||||||
for (Entry<String, String> valEntry : getValue().entrySet()) {
|
|
||||||
put("value." + valEntry.getKey(), valEntry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getReadableString() {
|
|
||||||
return getKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,6 +19,7 @@ import org.bukkit.block.data.BlockData;
|
|||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
import org.bukkit.metadata.MetadataValue;
|
import org.bukkit.metadata.MetadataValue;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class AsyncBlockState implements BlockState {
|
public class AsyncBlockState implements BlockState {
|
||||||
|
|
||||||
@ -99,6 +100,7 @@ public class AsyncBlockState implements BlockState {
|
|||||||
return block.getLocation(loc);
|
return block.getLocation(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Chunk getChunk() {
|
public Chunk getChunk() {
|
||||||
return block.getChunk();
|
return block.getChunk();
|
||||||
|
@ -32,6 +32,7 @@ import java.io.File;
|
|||||||
public class BukkitConfiguration extends YAMLConfiguration {
|
public class BukkitConfiguration extends YAMLConfiguration {
|
||||||
|
|
||||||
public boolean noOpPermissions = false;
|
public boolean noOpPermissions = false;
|
||||||
|
public boolean commandBlockSupport = false;
|
||||||
@Unreported private final WorldEditPlugin plugin;
|
@Unreported private final WorldEditPlugin plugin;
|
||||||
|
|
||||||
public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) {
|
public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) {
|
||||||
@ -43,6 +44,7 @@ public class BukkitConfiguration extends YAMLConfiguration {
|
|||||||
public void load() {
|
public void load() {
|
||||||
super.load();
|
super.load();
|
||||||
noOpPermissions = config.getBoolean("no-op-permissions", false);
|
noOpPermissions = config.getBoolean("no-op-permissions", false);
|
||||||
|
commandBlockSupport = config.getBoolean("command-block-support", false);
|
||||||
migrateLegacyFolders();
|
migrateLegacyFolders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ class BukkitRegistries extends BundledRegistries {
|
|||||||
|
|
||||||
private static final BukkitRegistries INSTANCE = new BukkitRegistries();
|
private static final BukkitRegistries INSTANCE = new BukkitRegistries();
|
||||||
private final BlockRegistry blockRegistry = new BukkitBlockRegistry();
|
private final BlockRegistry blockRegistry = new BukkitBlockRegistry();
|
||||||
private final ItemRegistry itemRegistry = new BukkitItemRegistry();
|
|
||||||
private final BiomeRegistry biomeRegistry = new BukkitBiomeRegistry();
|
private final BiomeRegistry biomeRegistry = new BukkitBiomeRegistry();
|
||||||
private final EntityRegistry entityRegistry = new BukkitEntityRegistry();
|
private final EntityRegistry entityRegistry = new BukkitEntityRegistry();
|
||||||
private final BlockCategoryRegistry blockCategoryRegistry = new BukkitBlockCategoryRegistry();
|
private final BlockCategoryRegistry blockCategoryRegistry = new BukkitBlockCategoryRegistry();
|
||||||
@ -56,11 +55,6 @@ class BukkitRegistries extends BundledRegistries {
|
|||||||
return biomeRegistry;
|
return biomeRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemRegistry getItemRegistry() {
|
|
||||||
return itemRegistry;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockCategoryRegistry getBlockCategoryRegistry() {
|
public BlockCategoryRegistry getBlockCategoryRegistry() {
|
||||||
return blockCategoryRegistry;
|
return blockCategoryRegistry;
|
||||||
|
@ -23,9 +23,11 @@ import com.boydti.fawe.Fawe;
|
|||||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
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.Direction;
|
||||||
import com.sk89q.worldedit.world.DataFixer;
|
import com.sk89q.worldedit.world.DataFixer;
|
||||||
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;
|
||||||
@ -33,6 +35,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
|
|
||||||
|
import java.util.OptionalInt;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -154,7 +157,30 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
void sendFakeOP(Player player);
|
void sendFakeOP(Player player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulates a player using an item.
|
||||||
|
*
|
||||||
|
* @param world the world
|
||||||
|
* @param position the location
|
||||||
|
* @param item the item to be used
|
||||||
|
* @param face the direction in which to "face" when using the item
|
||||||
|
* @return whether the usage was successful
|
||||||
|
*/
|
||||||
|
default boolean simulateItemUse(World world, BlockVector3 position, BaseItem item, Direction face) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
default @org.jetbrains.annotations.Nullable World createWorld(WorldCreator creator) {
|
default @org.jetbrains.annotations.Nullable World createWorld(WorldCreator creator) {
|
||||||
return ((FaweBukkit) Fawe.imp()).createWorldUnloaded(creator::createWorld);
|
return ((FaweBukkit) Fawe.imp()).createWorldUnloaded(creator::createWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the internal ID for a given state, if possible.
|
||||||
|
*
|
||||||
|
* @param state The block state
|
||||||
|
* @return the internal ID of the state
|
||||||
|
*/
|
||||||
|
default OptionalInt getInternalBlockStateId(BlockState state) {
|
||||||
|
return OptionalInt.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ public final class StringUtil {
|
|||||||
}
|
}
|
||||||
StringBuilder buffer = new StringBuilder(Integer.toString(str[initialIndex]));
|
StringBuilder buffer = new StringBuilder(Integer.toString(str[initialIndex]));
|
||||||
for (int i = initialIndex + 1; i < str.length; ++i) {
|
for (int i = initialIndex + 1; i < str.length; ++i) {
|
||||||
buffer.append(delimiter).append(str[i]);
|
buffer.append(delimiter).append(Integer.toString(str[i]));
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -1010,7 +1010,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Entity createEntity(Location location, final BaseEntity entity) {
|
public Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
|
||||||
return getExtent().createEntity(location, entity);
|
return getExtent().createEntity(location, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1233,7 +1233,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
|||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public <B extends BlockStateHolder<B>> int fillXZ(BlockVector3 origin, B block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
public <B extends BlockStateHolder<B>> int fillXZ(BlockVector3 origin, B block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
||||||
return fillXZ(origin, block, radius, depth, recursive);
|
return fillXZ(origin, (Pattern) block, radius, depth, recursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -65,10 +66,10 @@ public class EditSessionFactory {
|
|||||||
*
|
*
|
||||||
* @param world the world
|
* @param world the world
|
||||||
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
|
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
|
||||||
* @param player the player that the {@link EditSession} is for
|
* @param actor the actor that the {@link EditSession} is for
|
||||||
* @return an instance
|
* @return an instance
|
||||||
*/
|
*/
|
||||||
public EditSession getEditSession(World world, int maxBlocks, Player player) {
|
public EditSession getEditSession(World world, int maxBlocks, Actor actor) {
|
||||||
|
|
||||||
// ============ READ ME ============
|
// ============ READ ME ============
|
||||||
|
|
||||||
@ -114,10 +115,10 @@ public class EditSessionFactory {
|
|||||||
* @param world the world
|
* @param world the world
|
||||||
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
|
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
|
||||||
* @param blockBag an optional {@link BlockBag} to use, otherwise null
|
* @param blockBag an optional {@link BlockBag} to use, otherwise null
|
||||||
* @param player the player that the {@link EditSession} is for
|
* @param actor the actor that the {@link EditSession} is for
|
||||||
* @return an instance
|
* @return an instance
|
||||||
*/
|
*/
|
||||||
public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag, Player player) {
|
public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag, Actor actor) {
|
||||||
|
|
||||||
// ============ READ ME ============
|
// ============ READ ME ============
|
||||||
|
|
||||||
@ -156,8 +157,8 @@ public class EditSessionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditSession getEditSession(World world, int maxBlocks, Player player) {
|
public EditSession getEditSession(World world, int maxBlocks, Actor actor) {
|
||||||
return getEditSession(world, maxBlocks, null, player);
|
return getEditSession(world, maxBlocks, null, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -166,11 +167,11 @@ public class EditSessionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag, Player player) {
|
public EditSession getEditSession(World world, int maxBlocks, BlockBag blockBag, Actor actor) {
|
||||||
if (WorldEdit.getInstance().getConfiguration().traceUnflushedSessions) {
|
if (WorldEdit.getInstance().getConfiguration().traceUnflushedSessions) {
|
||||||
return new TracedEditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, player, maxBlocks, null));
|
return new TracedEditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, actor, maxBlocks, null));
|
||||||
}
|
}
|
||||||
return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, player, maxBlocks, null));
|
return new EditSession(eventBus, world, maxBlocks, blockBag, new EditSessionEvent(world, actor, maxBlocks, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -152,6 +152,7 @@ public class LocalSession implements TextureHolder {
|
|||||||
private transient VirtualWorld virtual;
|
private transient VirtualWorld virtual;
|
||||||
private transient BlockVector3 cuiTemporaryBlock;
|
private transient BlockVector3 cuiTemporaryBlock;
|
||||||
private transient List<Countable<BlockState>> lastDistribution;
|
private transient List<Countable<BlockState>> lastDistribution;
|
||||||
|
private transient World worldOverride;
|
||||||
|
|
||||||
// Saved properties
|
// Saved properties
|
||||||
private String lastScript;
|
private String lastScript;
|
||||||
@ -569,6 +570,19 @@ public class LocalSession implements TextureHolder {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasWorldOverride() {
|
||||||
|
return this.worldOverride != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public World getWorldOverride() {
|
||||||
|
return this.worldOverride;
|
||||||
|
}
|
||||||
|
public void setWorldOverride(@Nullable World worldOverride) {
|
||||||
|
this.worldOverride = worldOverride;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void unregisterTools(Player player) {
|
public void unregisterTools(Player player) {
|
||||||
for (Tool tool : tools) {
|
for (Tool tool : tools) {
|
||||||
if (tool instanceof BrushTool) {
|
if (tool instanceof BrushTool) {
|
||||||
@ -614,6 +628,9 @@ public class LocalSession implements TextureHolder {
|
|||||||
if (selector.getWorld() == null || !selector.getWorld().equals(world)) {
|
if (selector.getWorld() == null || !selector.getWorld().equals(world)) {
|
||||||
selector.setWorld(world);
|
selector.setWorld(world);
|
||||||
selector.clear();
|
selector.clear();
|
||||||
|
if (hasWorldOverride() && !world.equals(getWorldOverride())) {
|
||||||
|
setWorldOverride(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable ignore) {
|
} catch (Throwable ignore) {
|
||||||
selector.clear();
|
selector.clear();
|
||||||
@ -632,6 +649,9 @@ public class LocalSession implements TextureHolder {
|
|||||||
checkNotNull(selector);
|
checkNotNull(selector);
|
||||||
selector.setWorld(world);
|
selector.setWorld(world);
|
||||||
this.selector = selector;
|
this.selector = selector;
|
||||||
|
if (hasWorldOverride() && !world.equals(getWorldOverride())) {
|
||||||
|
setWorldOverride(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1328,17 +1348,23 @@ public class LocalSession implements TextureHolder {
|
|||||||
/**
|
/**
|
||||||
* Construct a new edit session.
|
* Construct a new edit session.
|
||||||
*
|
*
|
||||||
* @param player the actor
|
* @param actor the actor
|
||||||
* @return an edit session
|
* @return an edit session
|
||||||
*/
|
*/
|
||||||
public EditSession createEditSession(Player player) {
|
public EditSession createEditSession(Actor actor) {
|
||||||
checkNotNull(player);
|
checkNotNull(actor);
|
||||||
|
BlockBag blockBag = null;
|
||||||
BlockBag blockBag = getBlockBag(player);
|
if (actor.isPlayer() && actor instanceof Player) {
|
||||||
|
blockBag = getBlockBag((Player) actor);
|
||||||
World world = player.getWorld();
|
}
|
||||||
|
World world = null;
|
||||||
|
if (hasWorldOverride()) {
|
||||||
|
world = getWorldOverride();
|
||||||
|
} else if (actor instanceof Locatable && ((Locatable) actor).getExtent() instanceof World) {
|
||||||
|
world = (World) ((Locatable) actor).getExtent();
|
||||||
|
}
|
||||||
EditSessionBuilder builder = new EditSessionBuilder(world);
|
EditSessionBuilder builder = new EditSessionBuilder(world);
|
||||||
if (player.isPlayer()) builder.player(FawePlayer.wrap(player));
|
if (actor.isPlayer() && actor instanceof Player) builder.player(FawePlayer.wrap(actor));
|
||||||
builder.blockBag(blockBag);
|
builder.blockBag(blockBag);
|
||||||
builder.fastmode(fastMode);
|
builder.fastmode(fastMode);
|
||||||
|
|
||||||
|
@ -72,6 +72,27 @@ public class ApplyBrushCommands {
|
|||||||
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
.ofTypes(ImmutableList.of(Key.of(double.class)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
public static void register(CommandManagerService service, CommandManager commandManager, CommandRegistrationHandler registration) {
|
||||||
|
commandManager.register("apply", builder -> {
|
||||||
|
builder.description(TextComponent.of("Apply brush, apply a function to every block"));
|
||||||
|
builder.action(org.enginehub.piston.Command.Action.NULL_ACTION);
|
||||||
|
|
||||||
|
CommandManager manager = service.newCommandManager();
|
||||||
|
registration.register(
|
||||||
|
manager,
|
||||||
|
ApplyBrushCommandsRegistration.builder(),
|
||||||
|
new ApplyBrushCommands()
|
||||||
|
);
|
||||||
|
|
||||||
|
builder.condition(new PermissionCondition(ImmutableSet.of("worldedit.brush.apply")));
|
||||||
|
|
||||||
|
builder.addParts(REGION_FACTORY, RADIUS);
|
||||||
|
builder.addPart(SubCommandPart.builder(TranslatableComponent.of("type"), TextComponent.of("Type of brush to use"))
|
||||||
|
.withCommands(manager.getAllCommands().collect(Collectors.toList()))
|
||||||
|
.required()
|
||||||
|
.build());
|
||||||
|
});
|
||||||
|
}
|
||||||
private void setApplyBrush(CommandParameters parameters, Player player, LocalSession localSession,
|
private void setApplyBrush(CommandParameters parameters, Player player, LocalSession localSession,
|
||||||
Contextual<? extends RegionFunction> generatorFactory) throws WorldEditException {
|
Contextual<? extends RegionFunction> generatorFactory) throws WorldEditException {
|
||||||
double radius = requireNonNull(RADIUS.value(parameters).asSingle(double.class));
|
double radius = requireNonNull(RADIUS.value(parameters).asSingle(double.class));
|
||||||
|
@ -30,6 +30,7 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||||
import com.sk89q.worldedit.command.util.Logging;
|
import com.sk89q.worldedit.command.util.Logging;
|
||||||
|
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
|
||||||
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.internal.anvil.ChunkDeleter;
|
import com.sk89q.worldedit.internal.anvil.ChunkDeleter;
|
||||||
@ -39,6 +40,7 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
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.ClickEvent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||||
@ -51,8 +53,8 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import org.enginehub.piston.annotation.Command;
|
import org.enginehub.piston.annotation.Command;
|
||||||
import org.enginehub.piston.annotation.CommandContainer;
|
import org.enginehub.piston.annotation.CommandContainer;
|
||||||
import org.enginehub.piston.annotation.param.ArgFlag;
|
import org.enginehub.piston.annotation.param.ArgFlag;
|
||||||
@ -94,10 +96,11 @@ public class ChunkCommands {
|
|||||||
@CommandPermissions("worldedit.listchunks")
|
@CommandPermissions("worldedit.listchunks")
|
||||||
public void listChunks(Actor actor, World world, LocalSession session,
|
public void listChunks(Actor actor, World world, LocalSession session,
|
||||||
@ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException {
|
@ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException {
|
||||||
Set<BlockVector2> chunks = session.getSelection(world).getChunks();
|
final Region region = session.getSelection(world);
|
||||||
|
|
||||||
PaginationBox paginationBox = PaginationBox.fromStrings("Selected Chunks", "/listchunks -p %page%", chunks);
|
WorldEditAsyncCommandBuilder.createAndSendMessage(actor,
|
||||||
actor.print(paginationBox.create(page));
|
() -> new ChunkListPaginationBox(region).create(page),
|
||||||
|
"Listing chunks for " + actor.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -168,4 +171,27 @@ public class ChunkCommands {
|
|||||||
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/stop"))));
|
.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, "/stop"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class ChunkListPaginationBox extends PaginationBox {
|
||||||
|
//private final Region region;
|
||||||
|
private final List<BlockVector2> chunks;
|
||||||
|
|
||||||
|
ChunkListPaginationBox(Region region) {
|
||||||
|
super("Selected Chunks", "/listchunks -p %page%");
|
||||||
|
// TODO make efficient/streamable/calculable implementations of this
|
||||||
|
// for most region types, so we can just store the region and random-access get one page of chunks
|
||||||
|
// (this is non-trivial for some types of selections...)
|
||||||
|
//this.region = region.clone();
|
||||||
|
this.chunks = new ArrayList<>(region.getChunks());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getComponent(int number) {
|
||||||
|
return TextComponent.of(chunks.get(number).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getComponentsSize() {
|
||||||
|
return chunks.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
import com.sk89q.worldedit.command.util.Logging;
|
import com.sk89q.worldedit.command.util.Logging;
|
||||||
import com.sk89q.worldedit.command.util.PermissionCondition;
|
import com.sk89q.worldedit.command.util.PermissionCondition;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
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.internal.command.CommandRegistrationHandler;
|
import com.sk89q.worldedit.internal.command.CommandRegistrationHandler;
|
||||||
@ -37,6 +38,7 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.enginehub.piston.Command;
|
import org.enginehub.piston.Command;
|
||||||
import org.enginehub.piston.CommandManager;
|
import org.enginehub.piston.CommandManager;
|
||||||
@ -119,7 +121,7 @@ public class ExpandCommands {
|
|||||||
desc = "Expand the selection area"
|
desc = "Expand the selection area"
|
||||||
)
|
)
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void expand(Player player, LocalSession session,
|
public void expand(Actor actor, World world, LocalSession session,
|
||||||
@Arg(desc = "Amount to expand the selection by, can be `vert` to expand to the whole vertical column")
|
@Arg(desc = "Amount to expand the selection by, can be `vert` to expand to the whole vertical column")
|
||||||
int amount,
|
int amount,
|
||||||
@Arg(desc = "Amount to expand the selection by in the other direction", def = "0")
|
@Arg(desc = "Amount to expand the selection by in the other direction", def = "0")
|
||||||
@ -127,7 +129,7 @@ public class ExpandCommands {
|
|||||||
@Arg(desc = "Direction to expand", def = Direction.AIM)
|
@Arg(desc = "Direction to expand", def = Direction.AIM)
|
||||||
@MultiDirection
|
@MultiDirection
|
||||||
List<BlockVector3> direction) throws WorldEditException {
|
List<BlockVector3> direction) throws WorldEditException {
|
||||||
Region region = session.getSelection(player.getWorld());
|
Region region = session.getSelection(world);
|
||||||
int oldSize = region.getArea();
|
int oldSize = region.getArea();
|
||||||
|
|
||||||
if (reverseAmount == 0) {
|
if (reverseAmount == 0) {
|
||||||
@ -140,12 +142,12 @@ public class ExpandCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
session.getRegionSelector(world).learnChanges();
|
||||||
int newSize = region.getArea();
|
int newSize = region.getArea();
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||||
|
|
||||||
player.print("Region expanded " + (newSize - oldSize) + " block(s).");
|
actor.print("Region expanded " + (newSize - oldSize) + " block(s).");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -85,23 +85,23 @@ public class GeneralCommands {
|
|||||||
desc = "Modify block change limit"
|
desc = "Modify block change limit"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.limit")
|
@CommandPermissions("worldedit.limit")
|
||||||
public void limit(Player player, LocalSession session,
|
public void limit(Actor actor, LocalSession session,
|
||||||
@Arg(desc = "The limit to set", def = "")
|
@Arg(desc = "The limit to set", def = "")
|
||||||
Integer limit) {
|
Integer limit) {
|
||||||
|
|
||||||
LocalConfiguration config = worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
boolean mayDisable = player.hasPermission("worldedit.limit.unrestricted");
|
boolean mayDisable = actor.hasPermission("worldedit.limit.unrestricted");
|
||||||
|
|
||||||
limit = limit == null ? config.defaultChangeLimit : Math.max(-1, limit);
|
limit = limit == null ? config.defaultChangeLimit : Math.max(-1, limit);
|
||||||
if (!mayDisable && config.maxChangeLimit > -1) {
|
if (!mayDisable && config.maxChangeLimit > -1) {
|
||||||
if (limit > config.maxChangeLimit) {
|
if (limit > config.maxChangeLimit) {
|
||||||
player.printError("Your maximum allowable limit is " + config.maxChangeLimit + ".");
|
actor.printError("Your maximum allowable limit is " + config.maxChangeLimit + ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session.setBlockChangeLimit(limit);
|
session.setBlockChangeLimit(limit);
|
||||||
player.print("Block change limit set to " + limit + "."
|
actor.print("Block change limit set to " + limit + "."
|
||||||
+ (limit == config.defaultChangeLimit ? "" : " (Use //limit to go back to the default.)"));
|
+ (limit == config.defaultChangeLimit ? "" : " (Use //limit to go back to the default.)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,22 +110,22 @@ public class GeneralCommands {
|
|||||||
desc = "Modify evaluation timeout time."
|
desc = "Modify evaluation timeout time."
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.timeout")
|
@CommandPermissions("worldedit.timeout")
|
||||||
public void timeout(Player player, LocalSession session,
|
public void timeout(Actor actor, LocalSession session,
|
||||||
@Arg(desc = "The timeout time to set", def = "")
|
@Arg(desc = "The timeout time to set", def = "")
|
||||||
Integer limit) {
|
Integer limit) {
|
||||||
LocalConfiguration config = worldEdit.getConfiguration();
|
LocalConfiguration config = worldEdit.getConfiguration();
|
||||||
boolean mayDisable = player.hasPermission("worldedit.timeout.unrestricted");
|
boolean mayDisable = actor.hasPermission("worldedit.timeout.unrestricted");
|
||||||
|
|
||||||
limit = limit == null ? config.calculationTimeout : Math.max(-1, limit);
|
limit = limit == null ? config.calculationTimeout : Math.max(-1, limit);
|
||||||
if (!mayDisable && config.maxCalculationTimeout > -1) {
|
if (!mayDisable && config.maxCalculationTimeout > -1) {
|
||||||
if (limit > config.maxCalculationTimeout) {
|
if (limit > config.maxCalculationTimeout) {
|
||||||
player.printError("Your maximum allowable timeout is " + config.maxCalculationTimeout + " ms.");
|
actor.printError("Your maximum allowable timeout is " + config.maxCalculationTimeout + " ms.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session.setTimeout(limit);
|
session.setTimeout(limit);
|
||||||
player.print("Timeout time set to " + limit + " ms."
|
actor.print("Timeout time set to " + limit + " ms."
|
||||||
+ (limit == config.calculationTimeout ? "" : " (Use //timeout to go back to the default.)"));
|
+ (limit == config.calculationTimeout ? "" : " (Use //timeout to go back to the default.)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,18 +134,20 @@ public class GeneralCommands {
|
|||||||
desc = "Toggle fast mode"
|
desc = "Toggle fast mode"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.fast")
|
@CommandPermissions("worldedit.fast")
|
||||||
public void fast(Player player, LocalSession session, @Arg(desc = "The new fast mode state", def = "") Boolean fastMode) {
|
public void fast(Actor actor, LocalSession session,
|
||||||
|
@Arg(desc = "The new fast mode state", def = "")
|
||||||
|
Boolean fastMode) {
|
||||||
boolean hasFastMode = session.hasFastMode();
|
boolean hasFastMode = session.hasFastMode();
|
||||||
if (fastMode != null && fastMode == hasFastMode) {
|
if (fastMode != null && fastMode == hasFastMode) {
|
||||||
player.printError("Fast mode already " + (fastMode ? "enabled" : "disabled") + ".");
|
actor.printError("Fast mode already " + (fastMode ? "enabled" : "disabled") + ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hasFastMode) {
|
if (hasFastMode) {
|
||||||
session.setFastMode(false);
|
session.setFastMode(false);
|
||||||
BBC.FAST_DISABLED.send(player);
|
BBC.FAST_DISABLED.send(actor);
|
||||||
} else {
|
} else {
|
||||||
session.setFastMode(true);
|
session.setFastMode(true);
|
||||||
BBC.FAST_ENABLED.send(player);
|
BBC.FAST_ENABLED.send(actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,14 +156,14 @@ public class GeneralCommands {
|
|||||||
desc = "Sets the reorder mode of WorldEdit"
|
desc = "Sets the reorder mode of WorldEdit"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.reorder")
|
@CommandPermissions("worldedit.reorder")
|
||||||
public void reorderMode(Player player, LocalSession session,
|
public void reorderMode(Actor actor, LocalSession session,
|
||||||
@Arg(desc = "The reorder mode", def = "")
|
@Arg(desc = "The reorder mode", def = "")
|
||||||
EditSession.ReorderMode reorderMode) {
|
EditSession.ReorderMode reorderMode) {
|
||||||
if (reorderMode == null) {
|
if (reorderMode == null) {
|
||||||
player.print("The reorder mode is " + session.getReorderMode().getDisplayName());
|
actor.print("The reorder mode is " + session.getReorderMode().getDisplayName());
|
||||||
} else {
|
} else {
|
||||||
session.setReorderMode(reorderMode);
|
session.setReorderMode(reorderMode);
|
||||||
player.print("The reorder mode is now " + session.getReorderMode().getDisplayName());
|
actor.print("The reorder mode is now " + session.getReorderMode().getDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,18 +195,33 @@ public class GeneralCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "/gmask",
|
name = "/world",
|
||||||
aliases = {"gmask", "globalmask", "/globalmask"},
|
desc = "Sets the world override"
|
||||||
|
)
|
||||||
|
@CommandPermissions("worldedit.world")
|
||||||
|
public void world(Actor actor, LocalSession session,
|
||||||
|
@Arg(desc = "The world override", def = "") World world) {
|
||||||
|
session.setWorldOverride(world);
|
||||||
|
if (world == null) {
|
||||||
|
actor.print("Removed world override.");
|
||||||
|
} else {
|
||||||
|
actor.print("Set the world override to " + world.getId() + ". (Use //world to go back to default)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "gmask",
|
||||||
|
aliases = {"/gmask"},
|
||||||
descFooter = "The global destination mask applies to all edits you do and masks based on the destination blocks (i.e. the blocks in the world).",
|
descFooter = "The global destination mask applies to all edits you do and masks based on the destination blocks (i.e. the blocks in the world).",
|
||||||
desc = "Set the global mask"
|
desc = "Set the global mask"
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.global-mask", "worldedit.mask.global"})
|
@CommandPermissions({"worldedit.global-mask", "worldedit.mask.global"})
|
||||||
public void gmask(Player player, LocalSession session, @Arg(desc = "The mask to set", def = "") Mask maskOpt) {
|
public void gmask(Actor actor, LocalSession session, @Arg(desc = "The mask to set", def = "") Mask mask) {
|
||||||
session.setMask(maskOpt);
|
session.setMask(mask);
|
||||||
if (maskOpt == null) {
|
if (mask == null) {
|
||||||
BBC.MASK_DISABLED.send(player);
|
BBC.MASK_DISABLED.send(actor);
|
||||||
} else {
|
} else {
|
||||||
BBC.MASK.send(player);
|
BBC.MASK.send(actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public final class RegistryConverter<V extends Keyed> implements ArgumentConvert
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static void register(CommandManager commandManager) {
|
public static void register(CommandManager commandManager) {
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
BlockTypes.class,
|
BlockType.class,
|
||||||
BlockCategory.class,
|
BlockCategory.class,
|
||||||
ItemType.class,
|
ItemType.class,
|
||||||
ItemCategory.class,
|
ItemCategory.class,
|
||||||
|
@ -27,6 +27,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
|||||||
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.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
@ -91,8 +92,13 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Location getTargetFace(Player player) {
|
private Location getTargetFace(Player player) {
|
||||||
Location target = player.getBlockTraceFace(getRange(), true);
|
Location target;
|
||||||
target = player.getBlockTrace(getRange(), true);
|
Mask mask = getTraceMask();
|
||||||
|
if (this.range > -1) {
|
||||||
|
target = player.getBlockTrace(getRange(), true, mask);
|
||||||
|
} else {
|
||||||
|
target = player.getBlockTrace(MAX_RANGE, false, mask);
|
||||||
|
}
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
BBC.NO_BLOCK.send(player);
|
BBC.NO_BLOCK.send(player);
|
||||||
return null;
|
return null;
|
||||||
|
@ -37,7 +37,7 @@ public class HollowCylinderBrush implements Brush {
|
|||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
pattern = (BlockTypes.COBBLESTONE.getDefaultState());
|
pattern = BlockTypes.COBBLESTONE.getDefaultState();
|
||||||
}
|
}
|
||||||
editSession.makeCylinder(position, pattern, size, size, height, false);
|
editSession.makeCylinder(position, pattern, size, size, height, false);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class HollowSphereBrush implements Brush {
|
|||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||||
if (pattern == null) {
|
if (pattern == null) {
|
||||||
pattern = (BlockTypes.COBBLESTONE.getDefaultState());
|
pattern = BlockTypes.COBBLESTONE.getDefaultState();
|
||||||
}
|
}
|
||||||
editSession.makeSphere(position, pattern, size, size, size, false);
|
editSession.makeSphere(position, pattern, size, size, size, false);
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getBlockOn() {
|
public Location getBlockOn() {
|
||||||
return getLocation().setPosition(getLocation().setY(getLocation().getY() - 1).toVector().floor());
|
final Location location = getLocation();
|
||||||
|
return location.setPosition(location.setY(location.getY() - 1).toVector().floor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -524,7 +525,8 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPosition(Vector3 pos) {
|
public void setPosition(Vector3 pos) {
|
||||||
setPosition(pos, getLocation().getPitch(), getLocation().getYaw());
|
final Location location = getLocation();
|
||||||
|
setPosition(pos, location.getPitch(), location.getYaw());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -393,7 +393,7 @@ public final class PlatformCommandManager {
|
|||||||
registerSubCommands(
|
registerSubCommands(
|
||||||
"brush",
|
"brush",
|
||||||
ImmutableList.of("br", "/brush", "/br", "/tool", "tool"),
|
ImmutableList.of("br", "/brush", "/br", "/tool", "tool"),
|
||||||
"Tool commands",
|
"Brushing commands",
|
||||||
BrushOptionsCommandsRegistration.builder(),
|
BrushOptionsCommandsRegistration.builder(),
|
||||||
new BrushOptionsCommands(worldEdit)
|
new BrushOptionsCommands(worldEdit)
|
||||||
);
|
);
|
||||||
@ -729,6 +729,7 @@ public final class PlatformCommandManager {
|
|||||||
// exceptions without writing a hook into every dispatcher, we need to unwrap these
|
// exceptions without writing a hook into every dispatcher, we need to unwrap these
|
||||||
// exceptions and rethrow their converted form, if their is one.
|
// exceptions and rethrow their converted form, if their is one.
|
||||||
try {
|
try {
|
||||||
|
//Why the hell do we need to return an object if we aren't doing anything with it?
|
||||||
Object result = task.get();
|
Object result = task.get();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
// Use the exception converter to convert the exception if any of its causes
|
// Use the exception converter to convert the exception if any of its causes
|
||||||
|
@ -125,7 +125,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
|
public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
|
||||||
checkNotNull(position);
|
checkNotNull(position);
|
||||||
|
|
||||||
if (position.equals(position1)) {
|
if (position1 != null && position.equals(position1)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
|
public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
|
||||||
checkNotNull(position);
|
checkNotNull(position);
|
||||||
|
|
||||||
if (position.equals(position2)) {
|
if (position2 != null && position.equals(position2)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||||
|
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.PriorityQueue;
|
import java.util.PriorityQueue;
|
||||||
@ -132,6 +134,23 @@ public abstract class AbstractWorld implements World {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WeatherType getWeather() {
|
||||||
|
return WeatherTypes.CLEAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getRemainingWeatherDuration() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWeather(WeatherType weatherType) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWeather(WeatherType weatherType, long duration) {
|
||||||
|
}
|
||||||
private class QueuedEffect implements Comparable<QueuedEffect> {
|
private class QueuedEffect implements Comparable<QueuedEffect> {
|
||||||
private final Vector3 position;
|
private final Vector3 position;
|
||||||
private final BlockType blockType;
|
private final BlockType blockType;
|
||||||
|
@ -63,6 +63,10 @@ public class NullWorld extends AbstractWorld {
|
|||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException {
|
||||||
return false;
|
return false;
|
||||||
|
@ -106,10 +106,6 @@ public class ItemType implements RegistryItem, Keyed {
|
|||||||
return this.blockType;
|
return this.blockType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockType(BlockType blockType) {
|
|
||||||
this.blockType = blockType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseItem getDefaultState() {
|
public BaseItem getDefaultState() {
|
||||||
if (defaultState == null) {
|
if (defaultState == null) {
|
||||||
this.defaultState = new BaseItemStack(this);
|
this.defaultState = new BaseItemStack(this);
|
||||||
|
@ -37,5 +37,7 @@ public interface CategoryRegistry<T extends Keyed> {
|
|||||||
*/
|
*/
|
||||||
Set<T> getCategorisedByName(String category);
|
Set<T> getCategorisedByName(String category);
|
||||||
|
|
||||||
Set<T> getAll(final Category<T> category);
|
default Set<T> getAll(final Category<T> category) {
|
||||||
|
return getCategorisedByName(category.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
9
worldedit-libs/README.md
Normal file
9
worldedit-libs/README.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
This project shades _API_ libraries, i.e. those libraries
|
||||||
|
whose classes are publicly referenced from `-core` classes.
|
||||||
|
|
||||||
|
This project _does not_ 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.
|
@ -11,8 +11,7 @@ dependencies {
|
|||||||
"shade"("com.github.luben:zstd-jni:1.4.3-1")
|
"shade"("com.github.luben:zstd-jni:1.4.3-1")
|
||||||
"shade"("com.thoughtworks.paranamer:paranamer:2.6")
|
"shade"("com.thoughtworks.paranamer:paranamer:2.6")
|
||||||
"shade"("com.sk89q.lib:jlibnoise:1.0.0")
|
"shade"("com.sk89q.lib:jlibnoise:1.0.0")
|
||||||
|
"shade"("FAWE-Piston:core/build/libs/core-${Versions.PISTON}:lastSuccessfulBuild@jar")
|
||||||
"shade"("FAWE-Piston:core/build/libs/core-${Versions.PISTON}:lastSuccessfulBuild@jar")
|
|
||||||
"shade"("FAWE-Piston:core-ap/runtime/build/libs/runtime-${Versions.PISTON}:lastSuccessfulBuild@jar")
|
"shade"("FAWE-Piston:core-ap/runtime/build/libs/runtime-${Versions.PISTON}:lastSuccessfulBuild@jar")
|
||||||
"shade"("FAWE-Piston:default-impl/build/libs/default-impl-${Versions.PISTON}:lastSuccessfulBuild@jar")
|
"shade"("FAWE-Piston:default-impl/build/libs/default-impl-${Versions.PISTON}:lastSuccessfulBuild@jar")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user