Merge branch 'master' into breaking

Dieser Commit ist enthalten in:
Jesse Boyd 2019-04-05 15:47:04 +11:00
Commit 94d5d8df8e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
43 geänderte Dateien mit 985 neuen und 919 gelöschten Zeilen

Datei anzeigen

@ -8,6 +8,8 @@ buildscript {
configurations.all { configurations.all {
resolutionStrategy { resolutionStrategy {
force 'com.google.guava:guava:21.0'
force 'org.ow2.asm:asm:6.0_BETA'
force 'commons-io:commons-io:2.4' force 'commons-io:commons-io:2.4'
} }
} }

Datei anzeigen

@ -7,7 +7,7 @@
| | / _____ \ \ /\ / | |____ | | / _____ \ \ /\ / | |____
|__| /__/ \__\ \__/ \__/ |_______| |__| /__/ \__\ \__/ \__/ |_______|
======= By Empire92 and WorldEdit team ======= ======== Authors https://git.io/fjIDU ========
If you encounter trouble: If you encounter trouble:
- Run `build` in a separate Gradle run - Run `build` in a separate Gradle run

Datei anzeigen

@ -50,20 +50,21 @@ import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity; import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements BukkitImplAdapter<NBTBase>{ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements BukkitImplAdapter<NBTBase>{
private final Logger logger = Logger.getLogger(getClass().getCanonicalName()); private final Logger logger = LoggerFactory.getLogger(getClass());
private final Field nbtListTagListField; private final Field nbtListTagListField;
private final Method nbtCreateTagMethod; private final Method nbtCreateTagMethod;
@ -337,7 +338,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
return Collections.emptyMap(); return Collections.emptyMap();
} }
if (block == null) { if (block == null) {
logger.warning("Failed to find properties for " + blockType.getId()); logger.warn("Failed to find properties for " + blockType.getId());
return Collections.emptyMap(); return Collections.emptyMap();
} }
Map<String, Property<?>> properties = Maps.newLinkedHashMap(); Map<String, Property<?>> properties = Maps.newLinkedHashMap();
@ -403,7 +404,7 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
try { try {
return toNativeList((NBTTagList) foreign); return toNativeList((NBTTagList) foreign);
} catch (Throwable e) { } catch (Throwable e) {
logger.log(Level.WARNING, "Failed to convert NBTTagList", e); logger.warn("Failed to convert NBTTagList", e);
return new ListTag(ByteTag.class, new ArrayList<ByteTag>()); return new ListTag(ByteTag.class, new ArrayList<ByteTag>());
} }
} else if (foreign instanceof NBTTagLong) { } else if (foreign instanceof NBTTagLong) {

Datei anzeigen

@ -35,11 +35,7 @@ import java.util.Set;
public class CommandRegistration { public class CommandRegistration {
static { static {
try {
Bukkit.getServer().getHelpMap().registerHelpTopicFactory(DynamicPluginCommand.class, new DynamicPluginCommandHelpTopic.Factory()); Bukkit.getServer().getHelpMap().registerHelpTopicFactory(DynamicPluginCommand.class, new DynamicPluginCommandHelpTopic.Factory());
} catch (Throwable e) {
e.printStackTrace();
}
} }
protected final Plugin plugin; protected final Plugin plugin;

Datei anzeigen

@ -54,18 +54,18 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
BlockMaterial result = adapter.getMaterial(blockType); BlockMaterial result = adapter.getMaterial(blockType);
if (result != null) return result; if (result != null) return result;
} }
Material type = BukkitAdapter.adapt(blockType); Material mat = BukkitAdapter.adapt(blockType);
if (type == null) { if (mat == null) {
if (blockType == BlockTypes.__RESERVED__) return new PassthroughBlockMaterial(super.getMaterial(BlockTypes.AIR)); if (blockType == BlockTypes.__RESERVED__) return new PassthroughBlockMaterial(super.getMaterial(BlockTypes.AIR));
return new PassthroughBlockMaterial(null); return new PassthroughBlockMaterial(null);
} }
if (materialMap == null) { if (materialMap == null) {
materialMap = new BukkitBlockMaterial[Material.values().length]; materialMap = new BukkitBlockMaterial[Material.values().length];
} }
BukkitBlockMaterial result = materialMap[type.ordinal()]; BukkitBlockMaterial result = materialMap[mat.ordinal()];
if (result == null) { if (result == null) {
result = new BukkitBlockMaterial(BukkitBlockRegistry.super.getMaterial(blockType), type); result = new BukkitBlockMaterial(BukkitBlockRegistry.super.getMaterial(blockType), mat);
materialMap[type.ordinal()] = result; materialMap[mat.ordinal()] = result;
} }
return result; return result;
} }
@ -84,9 +84,8 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
@Nullable @Nullable
@Override @Override
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) { public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
if (adapter != null) { return WorldEditPlugin.getInstance().getBukkitImplAdapter().getProperties(blockType);
return adapter.getProperties(blockType);
} }
return super.getProperties(blockType); return super.getProperties(blockType);
} }

Datei anzeigen

@ -294,7 +294,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
} }
@Override @Override
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) { public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ()); Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ());
if (block == null) { if (block == null) {
player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData()); player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData());

Datei anzeigen

@ -149,7 +149,7 @@ public class BukkitServerInterface implements MultiUserPlatform {
@Override @Override
public String getPlatformName() { public String getPlatformName() {
return "bukkit"; return "Bukkit";
} }
@Override @Override

Datei anzeigen

@ -33,31 +33,35 @@ import com.sk89q.worldedit.bukkit.adapter.AdapterLoadException;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader; import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader;
import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
import com.sk89q.worldedit.event.platform.PlatformReadyEvent; import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.InputParseException;
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.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.NoCapablePlatformException;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.FuzzyBlockState; import com.sk89q.worldedit.world.block.FuzzyBlockState;
import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.item.ItemCategory; import com.sk89q.worldedit.world.item.ItemCategory;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Tag; import org.bukkit.Tag;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.*; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader; import org.bukkit.plugin.java.JavaPluginLoader;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -84,8 +88,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Plugin for Bukkit. * Plugin for Bukkit.
*/ */
public class WorldEditPlugin extends JavaPlugin //implements TabCompleter public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
{
private static final Logger log = LoggerFactory.getLogger(WorldEditPlugin.class); private static final Logger log = LoggerFactory.getLogger(WorldEditPlugin.class);
public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui"; public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui";
@ -300,7 +303,7 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter
} }
} }
// { // {
// java.util.logging.Logger logger = getLogger(); // Logger logger = getLogger();
// if (logger != null) { // if (logger != null) {
// try { // try {
// Field nameField = Logger.class.getDeclaredField("name"); // Field nameField = Logger.class.getDeclaredField("name");
@ -324,7 +327,7 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter
e.printStackTrace(); e.printStackTrace();
} }
} }
log.info("Please restart the server if you have any plugins which depend on FAWE."); getLogger().info("Please restart the server if you have any plugins which depend on FAWE.");
} }
} }
@ -332,7 +335,7 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter
try { try {
run.run(); run.run();
} catch (Throwable e) { } catch (Throwable e) {
log.error(message); getLogger().severe(message);
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -343,7 +346,7 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-legacy.yml"), true), this); config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config-legacy.yml"), true), this);
config.load(); config.load();
} catch (Throwable e) { } catch (Throwable e) {
log.error("Failed to load config.yml"); getLogger().severe("Failed to load config.yml");
e.printStackTrace(); e.printStackTrace();
} }
// Create schematics folder // Create schematics folder
@ -359,8 +362,8 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter
BukkitImplLoader adapterLoader = new BukkitImplLoader(); BukkitImplLoader adapterLoader = new BukkitImplLoader();
try { try {
adapterLoader.addClass(Spigot_v1_13_R2.class); adapterLoader.addClass(Spigot_v1_13_R2.class);
} catch (Throwable ignore) { } catch (Throwable throwable) {
ignore.printStackTrace(); throwable.printStackTrace();
} }
try { try {
@ -378,18 +381,14 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter
bukkitAdapter = adapterLoader.loadAdapter(); bukkitAdapter = adapterLoader.loadAdapter();
log.info("Using " + bukkitAdapter.getClass().getCanonicalName() + " as the Bukkit adapter"); log.info("Using " + bukkitAdapter.getClass().getCanonicalName() + " as the Bukkit adapter");
} catch (AdapterLoadException e) { } catch (AdapterLoadException e) {
try {
Platform platform = worldEdit.getPlatformManager().queryCapability(Capability.WORLD_EDITING); Platform platform = worldEdit.getPlatformManager().queryCapability(Capability.WORLD_EDITING);
if (platform instanceof BukkitServerInterface) { if (platform instanceof BukkitServerInterface) {
log.warn(e.getMessage()); log.warn(e.getMessage());
return;
} else { } else {
log.info("WorldEdit could not find a Bukkit adapter for this MC version, " + log.info("WorldEdit could not find a Bukkit adapter for this MC version, " +
"but it seems that you have another implementation of WorldEdit installed (" + platform.getPlatformName() + ") " + "but it seems that you have another implementation of WorldEdit installed (" + platform.getPlatformName() + ") " +
"that handles the world editing."); "that handles the world editing.");
} }
} catch (NoCapablePlatformException ignore) {}
log.info("WorldEdit could not find a Bukkit adapter for this MC version");
} }
} }

Datei anzeigen

@ -25,6 +25,7 @@ import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.util.gson.GsonUtil; import com.sk89q.worldedit.util.gson.GsonUtil;
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;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

Datei anzeigen

@ -1,16 +1,16 @@
package com.boydti.fawe.configuration.serialization; package com.boydti.fawe.configuration.serialization;
import com.boydti.fawe.configuration.Configuration;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Utility class for storing and retrieving classes for {@link com.boydti.fawe.configuration.Configuration}. * Utility class for storing and retrieving classes for {@link Configuration}.
*/ */
public class ConfigurationSerialization { public class ConfigurationSerialization {
@ -27,7 +27,7 @@ public class ConfigurationSerialization {
* Attempts to deserialize the given arguments into a new instance of the * Attempts to deserialize the given arguments into a new instance of the
* given class. * given class.
* <p> * <p>
* <p>The class must implement {@link com.boydti.fawe.configuration.serialization.ConfigurationSerializable}, including * <p>The class must implement {@link ConfigurationSerializable}, including
* the extra methods as specified in the javadoc of * the extra methods as specified in the javadoc of
* ConfigurationSerializable.</p> * ConfigurationSerializable.</p>
* <p> * <p>
@ -39,7 +39,7 @@ public class ConfigurationSerialization {
* @return New instance of the specified class * @return New instance of the specified class
*/ */
public static ConfigurationSerializable deserializeObject(Map<String, ?> args, Class<? extends ConfigurationSerializable> clazz) { public static ConfigurationSerializable deserializeObject(Map<String, ?> args, Class<? extends ConfigurationSerializable> clazz) {
return new com.boydti.fawe.configuration.serialization.ConfigurationSerialization(clazz).deserialize(args); return new ConfigurationSerialization(clazz).deserialize(args);
} }
/** /**
@ -47,7 +47,7 @@ public class ConfigurationSerialization {
* <p> * <p>
* given class. * given class.
* <p> * <p>
* The class must implement {@link com.boydti.fawe.configuration.serialization.ConfigurationSerializable}, including * The class must implement {@link ConfigurationSerializable}, including
* the extra methods as specified in the javadoc of * the extra methods as specified in the javadoc of
* ConfigurationSerializable.</p> * ConfigurationSerializable.</p>
* <p> * <p>
@ -80,17 +80,17 @@ public class ConfigurationSerialization {
throw new IllegalArgumentException("Args doesn't contain type key ('" + SERIALIZED_TYPE_KEY + "')"); throw new IllegalArgumentException("Args doesn't contain type key ('" + SERIALIZED_TYPE_KEY + "')");
} }
return new com.boydti.fawe.configuration.serialization.ConfigurationSerialization(clazz).deserialize(args); return new ConfigurationSerialization(clazz).deserialize(args);
} }
/** /**
* Registers the given {@link com.boydti.fawe.configuration.serialization.ConfigurationSerializable} class by its * Registers the given {@link ConfigurationSerializable} class by its
* alias. * alias.
* *
* @param clazz Class to register * @param clazz Class to register
*/ */
public static void registerClass(Class<? extends ConfigurationSerializable> clazz) { public static void registerClass(Class<? extends ConfigurationSerializable> clazz) {
com.boydti.fawe.configuration.serialization.DelegateDeserialization delegate = clazz.getAnnotation(com.boydti.fawe.configuration.serialization.DelegateDeserialization.class); DelegateDeserialization delegate = clazz.getAnnotation(DelegateDeserialization.class);
if (delegate == null) { if (delegate == null) {
registerClass(clazz, getAlias(clazz)); registerClass(clazz, getAlias(clazz));
@ -99,19 +99,18 @@ public class ConfigurationSerialization {
} }
/** /**
* Registers the given alias to the specified {@link * Registers the given alias to the specified {@link ConfigurationSerializable} class.
* com.boydti.fawe.configuration.serialization.ConfigurationSerializable} class.
* *
* @param clazz Class to register * @param clazz Class to register
* @param alias Alias to register as * @param alias Alias to register as
* @see com.boydti.fawe.configuration.serialization.SerializableAs * @see SerializableAs
*/ */
public static void registerClass(Class<? extends ConfigurationSerializable> clazz, String alias) { public static void registerClass(Class<? extends ConfigurationSerializable> clazz, String alias) {
aliases.put(alias, clazz); aliases.put(alias, clazz);
} }
/** /**
* Unregisters the specified alias to a {@link com.boydti.fawe.configuration.serialization.ConfigurationSerializable} * Unregisters the specified alias to a {@link ConfigurationSerializable}
* *
* @param alias Alias to unregister * @param alias Alias to unregister
*/ */
@ -120,8 +119,7 @@ public class ConfigurationSerialization {
} }
/** /**
* Unregisters any aliases for the specified {@link * Unregisters any aliases for the specified {@link ConfigurationSerializable} class.
* com.boydti.fawe.configuration.serialization.ConfigurationSerializable} class.
* *
* @param clazz Class to unregister * @param clazz Class to unregister
*/ */
@ -131,7 +129,7 @@ public class ConfigurationSerialization {
} }
/** /**
* Attempts to get a registered {@link com.boydti.fawe.configuration.serialization.ConfigurationSerializable} class by * Attempts to get a registered {@link ConfigurationSerializable} class by
* its alias. * its alias.
* *
* @param alias Alias of the serializable * @param alias Alias of the serializable
@ -142,14 +140,14 @@ public class ConfigurationSerialization {
} }
/** /**
* Gets the correct alias for the given {@link com.boydti.fawe.configuration.serialization.ConfigurationSerializable} * Gets the correct alias for the given {@link ConfigurationSerializable}
* class. * class.
* *
* @param clazz Class to get alias for * @param clazz Class to get alias for
* @return Alias to use for the class * @return Alias to use for the class
*/ */
public static String getAlias(Class<? extends ConfigurationSerializable> clazz) { public static String getAlias(Class<? extends ConfigurationSerializable> clazz) {
com.boydti.fawe.configuration.serialization.DelegateDeserialization delegate = clazz.getAnnotation(DelegateDeserialization.class); DelegateDeserialization delegate = clazz.getAnnotation(DelegateDeserialization.class);
if (delegate != null) { if (delegate != null) {
if ((delegate.value() == null) || (delegate.value() == clazz)) { if ((delegate.value() == null) || (delegate.value() == clazz)) {
@ -180,9 +178,7 @@ public class ConfigurationSerialization {
} }
return method; return method;
} catch (NoSuchMethodException ex) { } catch (NoSuchMethodException | SecurityException ex) {
return null;
} catch (SecurityException ex) {
return null; return null;
} }
} }
@ -190,9 +186,7 @@ public class ConfigurationSerialization {
protected Constructor<? extends ConfigurationSerializable> getConstructor() { protected Constructor<? extends ConfigurationSerializable> getConstructor() {
try { try {
return this.clazz.getConstructor(Map.class); return this.clazz.getConstructor(Map.class);
} catch (NoSuchMethodException ex) { } catch (NoSuchMethodException | SecurityException ex) {
return null;
} catch (SecurityException ex) {
return null; return null;
} }
} }
@ -202,14 +196,13 @@ public class ConfigurationSerialization {
ConfigurationSerializable result = (ConfigurationSerializable) method.invoke(null, args); ConfigurationSerializable result = (ConfigurationSerializable) method.invoke(null, args);
if (result == null) { if (result == null) {
Logger.getLogger(com.boydti.fawe.configuration.serialization.ConfigurationSerialization.class.getName()).log(Level.SEVERE, LoggerFactory.getLogger(ConfigurationSerialization.class).error(
"Could not call method '" + method.toString() + "' of " + this.clazz + " for deserialization: method returned null"); "Could not call method '" + method.toString() + "' of " + this.clazz + " for deserialization: method returned null");
} else { } else {
return result; return result;
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Logger.getLogger(com.boydti.fawe.configuration.serialization.ConfigurationSerialization.class.getName()) LoggerFactory.getLogger(ConfigurationSerialization.class).error("Could not call method '" + method.toString() + "' of " + this.clazz
.log(Level.SEVERE, "Could not call method '" + method.toString() + "' of " + this.clazz
+ " for deserialization", + " for deserialization",
ex instanceof InvocationTargetException ? ex.getCause() : ex); ex instanceof InvocationTargetException ? ex.getCause() : ex);
} }
@ -221,8 +214,7 @@ public class ConfigurationSerialization {
try { try {
return ctor.newInstance(args); return ctor.newInstance(args);
} catch (Throwable ex) { } catch (Throwable ex) {
Logger.getLogger(com.boydti.fawe.configuration.serialization.ConfigurationSerialization.class.getName()) LoggerFactory.getLogger(ConfigurationSerialization.class).error("Could not call constructor '" + ctor.toString() + "' of " + this.clazz
.log(Level.SEVERE, "Could not call constructor '" + ctor.toString() + "' of " + this.clazz
+ " for deserialization", + " for deserialization",
ex instanceof InvocationTargetException ? ex.getCause() : ex); ex instanceof InvocationTargetException ? ex.getCause() : ex);
} }

Datei anzeigen

@ -168,7 +168,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.*; import com.sk89q.worldedit.world.block.*;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherType;
import javafx.stage.Stage;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -186,7 +185,7 @@ import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
/** /**
* An {@link Extent} that handles history, {@link BlockBag}s, change limits, * An {@link Extent} that handles history, {@link BlockBag}s, change limits,
* block re-ordering, and much more. Most operations in WorldEdit use this class. * block re-ordering, and much more. Most operations in WorldEdit use this class.
* <p> *
* <p>Most of the actual functionality is implemented with a number of other * <p>Most of the actual functionality is implemented with a number of other
* {@link Extent}s that are chained together. For example, history is logged * {@link Extent}s that are chained together. For example, history is logged
* using the {@link ChangeSetExtent}.</p> * using the {@link ChangeSetExtent}.</p>
@ -195,6 +194,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
private static final Logger log = LoggerFactory.getLogger(EditSession.class); private static final Logger log = LoggerFactory.getLogger(EditSession.class);
/**
* Used by {@link EditSession#setBlock(BlockVector3, BlockStateHolder, Stage)} to
* determine which {@link Extent}s should be bypassed.
*/
public enum Stage { public enum Stage {
BEFORE_HISTORY, BEFORE_HISTORY,
BEFORE_REORDER, BEFORE_REORDER,
@ -1490,7 +1493,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @return the number of blocks that matched the pattern * @return the number of blocks that matched the pattern
*/ */
public int countBlocks(final Region region, final Set<BlockStateHolder> searchBlocks) { public int countBlocks(final Region region, final Set<BlockStateHolder> searchBlocks) {
final Mask mask = new BlockMaskBuilder().addBlocks(searchBlocks).build(extent); Mask mask = new BlockMaskBuilder().addBlocks(searchBlocks).build(extent);
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() { RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
@Override @Override
public boolean apply(BlockVector3 position) throws WorldEditException { public boolean apply(BlockVector3 position) throws WorldEditException {
@ -1582,7 +1585,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @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, new BlockPattern(block), radius, depth, recursive); return fillXZ(origin, block, radius, depth, recursive);
} }
/** /**
* Fills an area recursively in the X/Z directions. * Fills an area recursively in the X/Z directions.
@ -1636,10 +1639,11 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
checkArgument(apothem >= 1, "apothem >= 1"); checkArgument(apothem >= 1, "apothem >= 1");
checkArgument(height >= 1, "height >= 1"); checkArgument(height >= 1, "height >= 1");
final Region region = new CuboidRegion(this.getWorld(), // Causes clamping of Y range Region region = new CuboidRegion(
getWorld(), // Causes clamping of Y range
position.add(-apothem + 1, 0, -apothem + 1), position.add(apothem - 1, height - 1, apothem - 1)); position.add(-apothem + 1, 0, -apothem + 1), position.add(apothem - 1, height - 1, apothem - 1));
final Pattern pattern = BlockTypes.AIR.getDefaultState(); Pattern pattern = BlockTypes.AIR.getDefaultState();
return this.setBlocks(region, pattern); return setBlocks(region, pattern);
} }
/** /**
@ -1656,10 +1660,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
checkArgument(apothem >= 1, "apothem >= 1"); checkArgument(apothem >= 1, "apothem >= 1");
checkArgument(height >= 1, "height >= 1"); checkArgument(height >= 1, "height >= 1");
final Region region = new CuboidRegion(this.getWorld(), // Causes clamping of Y range Region region = new CuboidRegion(getWorld(), // Causes clamping of Y range
position.add(-apothem + 1, 0, -apothem + 1), position.add(apothem - 1, -height + 1, apothem - 1)); position.add(-apothem + 1, 0, -apothem + 1), position.add(apothem - 1, -height + 1, apothem - 1));
final Pattern pattern = BlockTypes.AIR.getDefaultState(); Pattern pattern = (BlockTypes.AIR.getDefaultState());
return this.setBlocks(region, pattern); return setBlocks(region, pattern);
} }
/** /**
@ -1724,7 +1728,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
getWorld(), // Causes clamping of Y range getWorld(), // Causes clamping of Y range
position.add(adjustment.multiply(-1)), position.add(adjustment.multiply(-1)),
position.add(adjustment)); position.add(adjustment));
Pattern pattern = new BlockPattern(BlockTypes.AIR.getDefaultState()); Pattern pattern = (BlockTypes.AIR.getDefaultState());
return replaceBlocks(region, mask, pattern); return replaceBlocks(region, mask, pattern);
} }
@ -1750,9 +1754,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);
this.changes += visitor.getAffected(); this.changes += visitor.getAffected();
} else { } else {
Iterator<BlockVector3> iter = region.iterator(); for (BlockVector3 blockVector3 : region) {
while (iter.hasNext()) { if (this.extent.setBlock(blockVector3, block)) {
if (this.extent.setBlock(iter.next(), block)) {
changes++; changes++;
} }
} }
@ -1797,7 +1800,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @throws MaxChangedBlocksException thrown if too many blocks are changed * @throws MaxChangedBlocksException thrown if too many blocks are changed
*/ */
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException { public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
return replaceBlocks(region, filter, new BlockPattern(replacement)); return replaceBlocks(region, filter, (replacement));
} }
/** /**
@ -1825,8 +1828,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
* @return number of blocks affected * @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed * @throws MaxChangedBlocksException thrown if too many blocks are changed
*/ */
@SuppressWarnings("deprecation") public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
public int replaceBlocks(final Region region, final Mask mask, final Pattern pattern) {
checkNotNull(region); checkNotNull(region);
checkNotNull(mask); checkNotNull(mask);
checkNotNull(pattern); checkNotNull(pattern);
@ -1989,7 +1991,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
*/ */
public <B extends BlockStateHolder<B>> int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException { public <B extends BlockStateHolder<B>> int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException {
checkNotNull(block); checkNotNull(block);
return overlayCuboidBlocks(region, new BlockPattern(block)); return overlayCuboidBlocks(region, (block));
} }
/** /**
@ -2992,8 +2994,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} }
return BlockTypes.get((int) typeVariable.getValue()).withPropertyId((int) dataVariable.getValue()).toBaseBlock(); return BlockTypes.get((int) typeVariable.getValue()).withPropertyId((int) dataVariable.getValue()).toBaseBlock();
} catch (final Exception e) { } catch (Exception e) {
Fawe.debug("Failed to create shape: " + e); log.warn("Failed to create shape", e);
return null; return null;
} }
} }
@ -3369,8 +3371,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} }
return defaultBiomeType; return defaultBiomeType;
} catch (final Exception e) { } catch (Exception e) {
Fawe.debug("Failed to create shape: " + e); log.warn("Failed to create shape", e);
return null; return null;
} }
} }
@ -3428,9 +3430,9 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
} }
private void setExistingBlocks(BlockVector3 pos1, BlockVector3 pos2) { private void setExistingBlocks(BlockVector3 pos1, BlockVector3 pos2) {
for (int x = (int) pos1.getX(); x <= (int) pos2.getX(); x++) { for (int x = pos1.getX(); x <= pos2.getX(); x++) {
for (int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) { for (int z = pos1.getBlockZ(); z <= pos2.getBlockZ(); z++) {
for (int y = (int) pos1.getY(); y <= (int) pos2.getY(); y++) { for (int y = pos1.getY(); y <= pos2.getY(); y++) {
int from = queue.getCombinedId4Data(x, y, z); int from = queue.getCombinedId4Data(x, y, z);
queue.setBlock(x, y, z, from); queue.setBlock(x, y, z, from);
if (BlockTypes.getFromStateId(from).getMaterial().hasContainer()) { if (BlockTypes.getFromStateId(from).getMaterial().hasContainer()) {

Datei anzeigen

@ -96,7 +96,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/ */
public class LocalSession implements TextureHolder { public class LocalSession implements TextureHolder {
@Deprecated
public transient static int MAX_HISTORY_SIZE = 15; public transient static int MAX_HISTORY_SIZE = 15;
// Non-session related fields // Non-session related fields

Datei anzeigen

@ -21,11 +21,14 @@ package com.sk89q.worldedit.blocks;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* Block-related utility methods. * Block-related utility methods.

Datei anzeigen

@ -35,6 +35,7 @@ import com.sk89q.worldedit.math.MathUtils;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.storage.LegacyChunkStore; import com.sk89q.worldedit.world.storage.LegacyChunkStore;
import com.sk89q.worldedit.world.storage.McRegionChunkStore; import com.sk89q.worldedit.world.storage.McRegionChunkStore;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
@ -184,4 +185,5 @@ public class ChunkCommands {
player.printError(BBC.getPrefix() + "Shell script type must be configured: 'bat' or 'bash' expected."); player.printError(BBC.getPrefix() + "Shell script type must be configured: 'bat' or 'bash' expected.");
} }
} }
} }

Datei anzeigen

@ -19,6 +19,9 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
@ -35,10 +38,6 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.command.parametric.Optional; import com.sk89q.worldedit.util.command.parametric.Optional;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
/** /**
* Commands for moving the player around. * Commands for moving the player around.
*/ */

Datei anzeigen

@ -299,8 +299,8 @@ public class RegionCommands extends MethodCommands {
} }
@Command( @Command(
aliases = {"/replace", "/re", "/rep", "/r"}, aliases = { "/replace", "/re", "/rep" },
usage = "[from-mask] <to-pattern>", usage = "[from-block] <to-block>",
desc = "Replace all blocks in the selection with another", desc = "Replace all blocks in the selection with another",
flags = "f", flags = "f",
min = 1, min = 1,
@ -528,7 +528,7 @@ public class RegionCommands extends MethodCommands {
desc = "Move the contents of the selection", desc = "Move the contents of the selection",
help = help =
"Moves the contents of the selection.\n" + "Moves the contents of the selection.\n" +
" -s flag shifts the selection to the target location.\n" + "The -s flag shifts the selection to the target location.\n" +
" -b also copies biomes\n" + " -b also copies biomes\n" +
" -e ignores entities\n" + " -e ignores entities\n" +
" -a ignores air\n" + " -a ignores air\n" +
@ -622,7 +622,7 @@ public class RegionCommands extends MethodCommands {
if (moveSelection) { if (moveSelection) {
try { try {
final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1);
BlockVector3 shiftVector = BlockVector3.at(direction.getX() * size.getX() * count, direction.getY() * size.getY() * count, direction.getZ() * size.getZ() * count); final BlockVector3 shiftVector = BlockVector3.at(direction.getX() * size.getX() * count, direction.getY() * size.getY() * count, direction.getZ() * size.getZ() * count);
region.shift(shiftVector); region.shift(shiftVector);
session.getRegionSelector(player.getWorld()).learnChanges(); session.getRegionSelector(player.getWorld()).learnChanges();

Datei anzeigen

@ -49,12 +49,14 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.command.binding.Switch; import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.util.command.parametric.Optional; import com.sk89q.worldedit.util.command.parametric.Optional;
import com.sk89q.worldedit.util.io.Closer;
import com.sk89q.worldedit.util.io.file.FilenameException; import com.sk89q.worldedit.util.io.file.FilenameException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

Datei anzeigen

@ -33,6 +33,7 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException; import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
import com.sk89q.worldedit.world.snapshot.Snapshot; import com.sk89q.worldedit.world.snapshot.Snapshot;
import com.sk89q.worldedit.world.storage.MissingWorldException; import com.sk89q.worldedit.world.storage.MissingWorldException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.DateFormat; import java.text.DateFormat;
@ -259,7 +260,8 @@ public class SnapshotCommands {
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, player.getWorld().getName()); Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, player.getWorld().getName());
if (snapshot == null) { if (snapshot == null) {
dateFormat.setTimeZone(session.getTimeZone()); dateFormat.setTimeZone(session.getTimeZone());
player.printError("Couldn't find a snapshot after " + dateFormat.format(date.getTime()) + "."); player.printError("Couldn't find a snapshot after "
+ dateFormat.format(date.getTime()) + ".");
} else { } else {
session.setSnapshot(snapshot); session.setSnapshot(snapshot);
BBC.SNAPSHOT_SET.send(player, snapshot.getName()); BBC.SNAPSHOT_SET.send(player, snapshot.getName());
@ -269,4 +271,5 @@ public class SnapshotCommands {
} }
} }
} }
} }

Datei anzeigen

@ -37,10 +37,10 @@ import com.sk89q.worldedit.world.snapshot.Snapshot;
import com.sk89q.worldedit.world.snapshot.SnapshotRestore; import com.sk89q.worldedit.world.snapshot.SnapshotRestore;
import com.sk89q.worldedit.world.storage.ChunkStore; import com.sk89q.worldedit.world.storage.ChunkStore;
import com.sk89q.worldedit.world.storage.MissingWorldException; import com.sk89q.worldedit.world.storage.MissingWorldException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION; import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
@Command(aliases = {}, desc = "[More Info](http://wiki.sk89q.com/wiki/WorldEdit/Snapshots)") @Command(aliases = {}, desc = "[More Info](http://wiki.sk89q.com/wiki/WorldEdit/Snapshots)")

Datei anzeigen

@ -81,17 +81,21 @@ public class SelectionCommand extends SimpleCommand<Operation> {
if (!testPermission(locals)) { if (!testPermission(locals)) {
throw new CommandPermissionsException(); throw new CommandPermissionsException();
} }
Contextual<? extends Operation> operationFactory = delegate.call(args, locals); Contextual<? extends Operation> operationFactory = delegate.call(args, locals);
Actor actor = locals.get(Actor.class); Actor actor = locals.get(Actor.class);
if (actor instanceof Player) { if (actor instanceof Player) {
try { try {
Player player = (Player) actor; Player player = (Player) actor;
LocalSession session = WorldEdit.getInstance().getSessionManager().get(player); LocalSession session = WorldEdit.getInstance().getSessionManager().get(player);
Region selection = session.getSelection(player.getWorld()); Region selection = session.getSelection(player.getWorld());
EditSession editSession = session.createEditSession(player); EditSession editSession = session.createEditSession(player);
editSession.enableStandardMode(); editSession.enableStandardMode();
locals.put(EditSession.class, editSession); locals.put(EditSession.class, editSession);
session.tellVersion(player); session.tellVersion(player);
EditContext editContext = new EditContext(); EditContext editContext = new EditContext();
editContext.setDestination(locals.get(EditSession.class)); editContext.setDestination(locals.get(EditSession.class));
editContext.setRegion(selection); editContext.setRegion(selection);

Datei anzeigen

@ -19,11 +19,6 @@
package com.sk89q.worldedit.command.tool; package com.sk89q.worldedit.command.tool;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
@ -38,6 +33,11 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/** /**
* A mode that cycles the data values of supported blocks. * A mode that cycles the data values of supported blocks.
*/ */
@ -104,6 +104,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
player.print("Now cycling " + currentProperty.getName()); player.print("Now cycling " + currentProperty.getName());
} }
} }
return true; return true;
} }

Datei anzeigen

@ -19,9 +19,6 @@
package com.sk89q.worldedit.command.tool; package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
@ -31,7 +28,11 @@ 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.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
/** /**
*/ */

Datei anzeigen

@ -21,7 +21,6 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.BlockPattern;
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;

Datei anzeigen

@ -21,7 +21,6 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.BlockPattern;
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;

Datei anzeigen

@ -60,6 +60,8 @@ import com.sk89q.worldedit.util.command.fluent.CommandGraph;
import com.sk89q.worldedit.util.command.fluent.DispatcherNode; import com.sk89q.worldedit.util.command.fluent.DispatcherNode;
import com.sk89q.worldedit.util.command.parametric.*; import com.sk89q.worldedit.util.command.parametric.*;
import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.util.formatting.ColorCodeBuilder;
import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
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;
@ -74,7 +76,6 @@ import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
import java.util.logging.FileHandler; import java.util.logging.FileHandler;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -84,7 +85,7 @@ import static com.sk89q.worldedit.util.command.composition.LegacyCommandAdapter.
/** /**
* Handles the registration and invocation of commands. * Handles the registration and invocation of commands.
* <p> *
* <p>This class is primarily for internal usage.</p> * <p>This class is primarily for internal usage.</p>
*/ */
public final class CommandManager { public final class CommandManager {
@ -129,6 +130,7 @@ public final class CommandManager {
commandLog.addHandler(dynamicHandler); commandLog.addHandler(dynamicHandler);
dynamicHandler.setFormatter(new LogFormat()); dynamicHandler.setFormatter(new LogFormat());
// Set up the commands manager
builder = new ParametricBuilder(); builder = new ParametricBuilder();
builder.setAuthorizer(new ActorAuthorizer()); builder.setAuthorizer(new ActorAuthorizer());
builder.setDefaultCompleter(new UserCommandCompleter(platformManager)); builder.setDefaultCompleter(new UserCommandCompleter(platformManager));
@ -430,7 +432,8 @@ public final class CommandManager {
return handleCommandTask(task, locals, null, null, null, null); return handleCommandTask(task, locals, null, null, null, null);
} }
private Object handleCommandTask(ThrowableSupplier<Throwable> task, CommandLocals locals, @Nullable Actor actor, @Nullable LocalSession session, @Nullable Set<String> failedPermissions, @Nullable FawePlayer fp) { private Object handleCommandTask(ThrowableSupplier<Throwable> task, CommandLocals locals, @Nullable
Actor actor, @Nullable LocalSession session, @Nullable Set<String> failedPermissions, @Nullable FawePlayer fp) {
Request.reset(); Request.reset();
if (actor == null) actor = locals.get(Actor.class); if (actor == null) actor = locals.get(Actor.class);
if (session == null) session = locals.get(LocalSession.class); if (session == null) session = locals.get(LocalSession.class);

Datei anzeigen

@ -64,6 +64,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Manages registered {@link Platform}s for WorldEdit. Platforms are * Manages registered {@link Platform}s for WorldEdit. Platforms are
* implementations of WorldEdit. * implementations of WorldEdit.
*
* <p>This class is thread-safe.</p> * <p>This class is thread-safe.</p>
*/ */
public class PlatformManager { public class PlatformManager {
@ -120,7 +121,7 @@ public class PlatformManager {
/** /**
* Unregister a platform from WorldEdit. * Unregister a platform from WorldEdit.
* <p> *
* <p>If the platform has been chosen for any capabilities, then a new * <p>If the platform has been chosen for any capabilities, then a new
* platform will be found.</p> * platform will be found.</p>
* *
@ -223,7 +224,7 @@ public class PlatformManager {
/** /**
* Get a list of loaded platforms. * Get a list of loaded platforms.
* <p> *
* <p>The returned list is a copy of the original and is mutable.</p> * <p>The returned list is a copy of the original and is mutable.</p>
* *
* @return a list of platforms * @return a list of platforms
@ -277,7 +278,7 @@ public class PlatformManager {
/** /**
* Get the current configuration. * Get the current configuration.
* <p> *
* <p>If no platform has been registered yet, then a default configuration * <p>If no platform has been registered yet, then a default configuration
* will be returned.</p> * will be returned.</p>
* *
@ -305,67 +306,66 @@ public class PlatformManager {
public void handleBlockInteract(BlockInteractEvent event) { public void handleBlockInteract(BlockInteractEvent event) {
// Create a proxy actor with a potentially different world for // Create a proxy actor with a potentially different world for
// making changes to the world // making changes to the world
Request.reset(); Actor actor = createProxyActor(event.getCause());
final Actor actor = createProxyActor(event.getCause());
Location location = event.getLocation();
try { try {
final Location location = event.getLocation(); Vector3 vector = location.toVector();
final BlockVector3 vector = location.toBlockPoint();
// At this time, only handle interaction from players // At this time, only handle interaction from players
if (actor instanceof Player) { if (actor instanceof Player) {
final LocalSession session = worldEdit.getSessionManager().get(actor); Player player = (Player) actor;
Player playerActor = (Player) actor; LocalSession session = worldEdit.getSessionManager().get(actor);
Request.reset();
VirtualWorld virtual = session.getVirtualWorld(); VirtualWorld virtual = session.getVirtualWorld();
if (virtual != null) { if (virtual != null) {
virtual.handleBlockInteract(playerActor, vector, event); virtual.handleBlockInteract(player, vector.toBlockPoint(), event);
if (event.isCancelled()) return; if (event.isCancelled()) return;
} }
if (event.getType() == Interaction.HIT) { if (event.getType() == Interaction.HIT) {
if (session.isToolControlEnabled() && playerActor.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) { if (session.isToolControlEnabled() && player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) {
FawePlayer<?> fp = FawePlayer.wrap(playerActor);
if (!actor.hasPermission("worldedit.selection.pos")) { if (!actor.hasPermission("worldedit.selection.pos")) {
return; return;
} }
final RegionSelector selector = session.getRegionSelector(playerActor.getWorld()); FawePlayer<?> fp = FawePlayer.wrap(player);
final Player player = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor), ((Player) actor).getLocation()); RegionSelector selector = session.getRegionSelector(player.getWorld());
fp.runAction(new Runnable() { final Player maskedPlayerWrapper =
@Override new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor),
public void run() { ((Player) actor).getLocation());
if (selector.selectPrimary(vector, ActorSelectorLimits.forActor(player))) { BlockVector3 blockPoint = vector.toBlockPoint();
selector.explainPrimarySelection(actor, session, vector); fp.runAction(() -> {
} if (selector.selectPrimary(blockPoint,
ActorSelectorLimits.forActor(maskedPlayerWrapper))) {
selector
.explainPrimarySelection(actor, session, blockPoint);
} }
}, false, true); }, false, true);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (session.hasSuperPickAxe() && playerActor.isHoldingPickAxe()) { if (session.hasSuperPickAxe() && player.isHoldingPickAxe()) {
final BlockTool superPickaxe = session.getSuperPickaxe(); final BlockTool superPickaxe = session.getSuperPickaxe();
if (superPickaxe != null && superPickaxe.canUse(playerActor)) { if (superPickaxe != null && superPickaxe.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(playerActor); FawePlayer<?> fp = FawePlayer.wrap(player);
final Player player = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor), ((Player) actor).getLocation()); final Player maskedPlayerWrapper = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor), ((Player) actor).getLocation());
fp.runAction(new Runnable() { fp.runAction(() -> reset(superPickaxe).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), maskedPlayerWrapper, session, location), false, true);
@Override
public void run() {
reset(superPickaxe).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
}
}, false, true);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
final Tool tool = session.getTool(playerActor); final Tool tool = session.getTool(player);
if (tool != null && tool instanceof DoubleActionBlockTool) { if (tool != null && tool instanceof DoubleActionBlockTool) {
if (tool.canUse(playerActor)) { if (tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(playerActor); FawePlayer<?> fp = FawePlayer.wrap(player);
final Player player = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor), ((Player) actor).getLocation()); final Player maskedPlayerWrapper = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor), ((Player) actor).getLocation());
fp.runAction(new Runnable() { fp.runAction(new Runnable() {
@Override @Override
public void run() { public void run() {
reset(((DoubleActionBlockTool) tool)).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location); reset(((DoubleActionBlockTool) tool)).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), maskedPlayerWrapper, session, location);
} }
}, false, true); }, false, true);
event.setCancelled(true); event.setCancelled(true);
@ -373,20 +373,22 @@ public class PlatformManager {
} }
} }
} else if (event.getType() == Interaction.OPEN) { } else if (event.getType() == Interaction.OPEN) {
if (session.isToolControlEnabled() && playerActor.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) { if (session.isToolControlEnabled() && player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().wandItem)) {
FawePlayer<?> fp = FawePlayer.wrap(playerActor);
if (!actor.hasPermission("worldedit.selection.pos")) { if (!actor.hasPermission("worldedit.selection.pos")) {
return; return;
} }
FawePlayer<?> fp = FawePlayer.wrap(player);
if (fp.checkAction()) { if (fp.checkAction()) {
final RegionSelector selector = session.getRegionSelector(playerActor.getWorld()); RegionSelector selector = session.getRegionSelector(player.getWorld());
final Player player = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor), ((Player) actor).getLocation()); Player maskedPlayerWrapper = new LocationMaskedPlayerWrapper(
fp.runAction(new Runnable() { PlayerWrapper.wrap((Player) actor),
@Override ((Player) actor).getLocation());
public void run() { BlockVector3 blockPoint = vector.toBlockPoint();
if (selector.selectSecondary(vector, ActorSelectorLimits.forActor(player))) { fp.runAction(() -> {
selector.explainSecondarySelection(actor, session, vector); if (selector.selectSecondary(blockPoint,
} ActorSelectorLimits.forActor(maskedPlayerWrapper))) {
selector.explainSecondarySelection(actor, session,
blockPoint);
} }
}, false, true); }, false, true);
} }
@ -394,20 +396,17 @@ public class PlatformManager {
return; return;
} }
final Tool tool = session.getTool(playerActor); final Tool tool = session.getTool(player);
if (tool != null && tool instanceof BlockTool) { if (tool != null && tool instanceof BlockTool) {
if (tool.canUse(playerActor)) { if (tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(playerActor); FawePlayer<?> fp = FawePlayer.wrap(player);
if (fp.checkAction()) { if (fp.checkAction()) {
final Player player = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor), ((Player) actor).getLocation()); final Player maskedPlayerWrapper = new LocationMaskedPlayerWrapper(PlayerWrapper.wrap((Player) actor), ((Player) actor).getLocation());
fp.runAction(new Runnable() { fp.runAction(() -> {
@Override
public void run() {
if (tool instanceof BrushTool) { if (tool instanceof BrushTool) {
((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location); ((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), maskedPlayerWrapper, session, location);
} else { } else {
reset((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location); reset((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), maskedPlayerWrapper, session, location);
}
} }
}, false, true); }, false, true);
event.setCancelled(true); event.setCancelled(true);
@ -435,7 +434,6 @@ public class PlatformManager {
} }
} }
@SuppressWarnings("deprecation")
@Subscribe @Subscribe
public void handlePlayerInput(PlayerInputEvent event) { public void handlePlayerInput(PlayerInputEvent event) {
// Create a proxy actor with a potentially different world for // Create a proxy actor with a potentially different world for
@ -453,11 +451,7 @@ public class PlatformManager {
try { try {
switch (event.getInputType()) { switch (event.getInputType()) {
case PRIMARY: { case PRIMARY: {
if (player.getItemInHand(HandSide.MAIN_HAND).getType().equals(getConfiguration().navigationWand)) { if (getConfiguration().navigationWandMaxDistance > 0 && player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().navigationWand)) {
if (getConfiguration().navigationWandMaxDistance <= 0) {
return;
}
if (!player.hasPermission("worldedit.navigation.jumpto.tool")) { if (!player.hasPermission("worldedit.navigation.jumpto.tool")) {
return; return;
} }
@ -473,16 +467,11 @@ public class PlatformManager {
return; return;
} }
final Tool tool = session.getTool(player); Tool tool = session.getTool(player);
if (tool != null && tool instanceof DoubleActionTraceTool) { if (tool instanceof DoubleActionTraceTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(player); FawePlayer<?> fp = FawePlayer.wrap(player);
fp.runAsyncIfFree(new Runnable() { fp.runAsyncIfFree(() -> reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session));
@Override
public void run() {
reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
}
});
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -491,11 +480,7 @@ public class PlatformManager {
} }
case SECONDARY: { case SECONDARY: {
if (player.getItemInHand(HandSide.MAIN_HAND).getType().equals(getConfiguration().navigationWand)) { if (getConfiguration().navigationWandMaxDistance > 0 && player.getItemInHand(HandSide.MAIN_HAND).getType().getId().equals(getConfiguration().navigationWand)) {
if (getConfiguration().navigationWandMaxDistance <= 0) {
return;
}
if (!player.hasPermission("worldedit.navigation.thru.tool")) { if (!player.hasPermission("worldedit.navigation.thru.tool")) {
return; return;
} }
@ -508,16 +493,11 @@ public class PlatformManager {
return; return;
} }
final Tool tool = session.getTool(player); Tool tool = session.getTool(player);
if (tool != null && tool instanceof TraceTool) { if (tool instanceof TraceTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(player); FawePlayer<?> fp = FawePlayer.wrap(player);
fp.runAction(new Runnable() { fp.runAction(() -> reset((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session), false, true);
@Override
public void run() {
reset((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
}
}, false, true);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }

Datei anzeigen

@ -26,11 +26,13 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Logger;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -41,7 +43,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/ */
public class SchematicReader implements ClipboardReader { public class SchematicReader implements ClipboardReader {
private static final Logger log = Logger.getLogger(SchematicReader.class.getCanonicalName());
private NBTInputStream inputStream; private NBTInputStream inputStream;
private InputStream rootStream; private InputStream rootStream;

Datei anzeigen

@ -27,8 +27,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
/** /**
* A pattern that returns the same {@link BaseBlock} each time. * A pattern that returns the same {@link BaseBlock} each time.
*/ */
@Deprecated public class BlockPattern extends AbstractPattern {
public class BlockPattern implements Pattern {
private BaseBlock block; private BaseBlock block;

Datei anzeigen

@ -40,6 +40,21 @@ public class Vector3 {
public static final Vector3 ONE = new Vector3(1, 1, 1); public static final Vector3 ONE = new Vector3(1, 1, 1);
public static Vector3 at(double x, double y, double z) { public static Vector3 at(double x, double y, double z) {
// switch for efficiency on typical cases
// in MC y is rarely 0/1 on selections
int yTrunc = (int) y;
switch (yTrunc) {
case 0:
if (x == 0 && y == 0 && z == 0) {
return ZERO;
}
break;
case 1:
if (x == 1 && y == 1 && z == 1) {
return ONE;
}
break;
}
return new Vector3(x, y, z); return new Vector3(x, y, z);
} }
@ -632,14 +647,15 @@ public class Vector3 {
@Override @Override
public int hashCode() { public int hashCode() {
return ((int) getX() ^ ((int) getZ() << 16)) ^ ((int) getY() << 30); int hash = 17;
hash = 31 * hash + Double.hashCode(x);
hash = 31 * hash + Double.hashCode(y);
hash = 31 * hash + Double.hashCode(z);
return hash;
} }
@Override @Override
public String toString() { public String toString() {
String x = (getX() == getBlockX() ? "" + getBlockX() : "" + getX());
String y = (getY() == getBlockY() ? "" + getBlockY() : "" + getY());
String z = (getZ() == getBlockZ() ? "" + getBlockZ() : "" + getZ());
return "(" + x + ", " + y + ", " + z + ")"; return "(" + x + ", " + y + ", " + z + ")";
} }

Datei anzeigen

@ -47,7 +47,8 @@ import java.util.Map;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;

Datei anzeigen

@ -25,6 +25,8 @@ import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.util.report.Unreported; import com.sk89q.worldedit.util.report.Unreported;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.snapshot.SnapshotRepository; import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -78,6 +80,8 @@ public class PropertiesConfiguration extends LocalConfiguration {
profile = getBool("profile", profile); profile = getBool("profile", profile);
traceUnflushedSessions = getBool("trace-unflushed-sessions", traceUnflushedSessions); traceUnflushedSessions = getBool("trace-unflushed-sessions", traceUnflushedSessions);
disallowedBlocks = getStringSet("disallowed-blocks", getDefaultDisallowedBlocks()); disallowedBlocks = getStringSet("disallowed-blocks", getDefaultDisallowedBlocks());
allowedDataCycleBlocks =
new HashSet<>(getStringSet("limits.allowed-data-cycle-blocks", null));
defaultChangeLimit = getInt("default-max-changed-blocks", defaultChangeLimit); defaultChangeLimit = getInt("default-max-changed-blocks", defaultChangeLimit);
maxChangeLimit = getInt("max-changed-blocks", maxChangeLimit); maxChangeLimit = getInt("max-changed-blocks", maxChangeLimit);
defaultMaxPolygonalPoints = getInt("default-max-polygon-points", defaultMaxPolygonalPoints); defaultMaxPolygonalPoints = getInt("default-max-polygon-points", defaultMaxPolygonalPoints);

Datei anzeigen

@ -0,0 +1,60 @@
/*
* 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.logging;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
/**
* Adds a WorldEdit prefix to WorldEdit's logger messages using a handler.
*/
public final class WorldEditPrefixHandler extends Handler {
private WorldEditPrefixHandler() {
}
@Override
public void publish(LogRecord record) {
String message = record.getMessage();
if (!message.startsWith("WorldEdit: ") && !message.startsWith("[WorldEdit] ")) {
record.setMessage("[WorldEdit] " + message);
}
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
}
/**
* Add the handler to the following logger name.
*
* @param name the logger name
*/
public static void register(String name) {
//todo fix this
//Logger.getLogger(name).addHandler(new WorldEditPrefixHandler());
}
}

Datei anzeigen

@ -904,8 +904,8 @@ public final class BlockTypes {
try { try {
BlockStateHolder block = LegacyMapper.getInstance().getBlockFromLegacy(input); BlockStateHolder block = LegacyMapper.getInstance().getBlockFromLegacy(input);
if (block != null) return block.getBlockType(); if (block != null) return block.getBlockType();
} catch (NumberFormatException e) { } catch (NumberFormatException | IndexOutOfBoundsException e) {
} catch (IndexOutOfBoundsException e) {} }
throw new SuggestInputParseException("Does not match a valid block type: " + inputLower, inputLower, () -> Stream.of(BlockTypes.values) throw new SuggestInputParseException("Does not match a valid block type: " + inputLower, inputLower, () -> Stream.of(BlockTypes.values)
.filter(b -> b.getId().contains(inputLower)) .filter(b -> b.getId().contains(inputLower))

Datei anzeigen

@ -40,8 +40,6 @@ 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.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.util.gson.VectorAdapter;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -50,6 +48,7 @@ import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Map; import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;

Datei anzeigen

@ -37,6 +37,7 @@ public class WeatherTypes {
private WeatherTypes() { private WeatherTypes() {
} }
public static @Nullable WeatherType get(final String id) { public static @Nullable WeatherType get(final String id) {
return WeatherType.REGISTRY.get(id); return WeatherType.REGISTRY.get(id);
} }

Datei anzeigen

@ -33,8 +33,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.junit.Assert.*;
public class CommandContextTest { public class CommandContextTest {
private static final Logger log = LoggerFactory.getLogger(CommandContextTest.class); private static final Logger log = LoggerFactory.getLogger(CommandContextTest.class);