Migrate to SLF4J

Dieser Commit ist enthalten in:
matt 2019-04-02 18:21:02 -04:00
Ursprung 47e66913e3
Commit 29692f3fbe
62 geänderte Dateien mit 1346 neuen und 1305 gelöschten Zeilen

Datei anzeigen

@ -4,6 +4,8 @@ apply plugin: 'maven'
repositories { repositories {
maven { url "https://hub.spigotmc.org/nexus/content/groups/public" } maven { url "https://hub.spigotmc.org/nexus/content/groups/public" }
maven { url "https://repo.codemc.org/repository/maven-public" }
maven { url 'https://papermc.io/repo/repository/maven-public/' }
} }
dependencies { dependencies {
@ -12,6 +14,7 @@ dependencies {
compile 'com.sk89q:dummypermscompat:1.10' compile 'com.sk89q:dummypermscompat:1.10'
compile 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT' compile 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT'
compile 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT' compile 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT'
compile 'org.slf4j:slf4j-jdk14:1.7.26'
testCompile 'org.mockito:mockito-core:1.9.0-rc1' testCompile 'org.mockito:mockito-core:1.9.0-rc1'
compile 'com.massivecraft:factions:2.8.0' compile 'com.massivecraft:factions:2.8.0'
compile 'com.drtshock:factions:1.6.9.5' compile 'com.drtshock:factions:1.6.9.5'

Datei anzeigen

@ -49,20 +49,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;
@ -348,7 +349,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();
@ -414,7 +415,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

@ -22,6 +22,8 @@ package com.sk89q.wepif;
import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.util.yaml.YAMLProcessor;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.Server; import org.bukkit.Server;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
@ -32,12 +34,10 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
public class FlatFilePermissionsResolver implements PermissionsResolver { public class FlatFilePermissionsResolver implements PermissionsResolver {
private static final Logger log = Logger.getLogger(FlatFilePermissionsResolver.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(FlatFilePermissionsResolver.class);
private Map<String, Set<String>> userPermissionsCache; private Map<String, Set<String>> userPermissionsCache;
private Set<String> defaultPermissionsCache; private Set<String> defaultPermissionsCache;
@ -98,7 +98,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
} }
} }
} catch (IOException e) { } catch (IOException e) {
log.log(Level.WARNING, "Failed to load permissions", e); log.warn("Failed to load permissions", e);
} finally { } finally {
try { try {
if (buff != null) { if (buff != null) {
@ -164,7 +164,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
} }
} }
} catch (IOException e) { } catch (IOException e) {
log.log(Level.WARNING, "Failed to load permissions", e); log.warn("Failed to load permissions", e);
} finally { } finally {
try { try {
if (buff != null) { if (buff != null) {

Datei anzeigen

@ -28,13 +28,12 @@ import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.slf4j.Logger;
import java.util.logging.Level; import org.slf4j.LoggerFactory;
import java.util.logging.Logger;
public class NijiPermissionsResolver implements PermissionsResolver { public class NijiPermissionsResolver implements PermissionsResolver {
private static final Logger log = Logger.getLogger(NijiPermissionsResolver.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(NijiPermissionsResolver.class);
private Server server; private Server server;
private Permissions api; private Permissions api;
@ -84,7 +83,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
return api.Security.permission(player, permission); return api.Security.permission(player, permission);
} }
} catch (Throwable t) { } catch (Throwable t) {
log.log(Level.WARNING, "Failed to check permissions", t); log.warn("Failed to check permissions", t);
return false; return false;
} }
} }
@ -98,7 +97,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
return api.getHandler().has(server.getPlayerExact(name), permission); return api.getHandler().has(server.getPlayerExact(name), permission);
} }
} catch (Throwable t) { } catch (Throwable t) {
log.log(Level.WARNING, "Failed to check permissions", t); log.warn("Failed to check permissions", t);
return false; return false;
} }
} }
@ -115,7 +114,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
return api.Security.inGroup(name, group); return api.Security.inGroup(name, group);
} }
} catch (Throwable t) { } catch (Throwable t) {
log.log(Level.WARNING, "Failed to check groups", t); log.warn("Failed to check groups", t);
return false; return false;
} }
} }
@ -139,7 +138,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
return groups; return groups;
} }
} catch (Throwable t) { } catch (Throwable t) {
log.log(Level.WARNING, "Failed to get groups", t); log.warn("Failed to get groups", t);
return new String[0]; return new String[0];
} }
} }

Datei anzeigen

@ -27,6 +27,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -35,8 +37,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public class PermissionsResolverManager implements PermissionsResolver { public class PermissionsResolverManager implements PermissionsResolver {
@ -85,7 +85,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
private Server server; private Server server;
private PermissionsResolver permissionResolver; private PermissionsResolver permissionResolver;
private YAMLProcessor config; private YAMLProcessor config;
private Logger logger = Logger.getLogger(getClass().getCanonicalName()); private Logger logger = LoggerFactory.getLogger(getClass());
private List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<>(); private List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<>();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -119,7 +119,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
break; break;
} }
} catch (Throwable e) { } catch (Throwable e) {
logger.log(Level.WARNING, "Error in factory method for " + resolverClass.getSimpleName(), e); logger.warn("Error in factory method for " + resolverClass.getSimpleName(), e);
continue; continue;
} }
} }
@ -195,14 +195,14 @@ public class PermissionsResolverManager implements PermissionsResolver {
try { try {
file.createNewFile(); file.createNewFile();
} catch (IOException e) { } catch (IOException e) {
logger.log(Level.WARNING, "Failed to create new configuration file", e); logger.warn("Failed to create new configuration file", e);
} }
} }
config = new YAMLProcessor(file, false, YAMLFormat.EXTENDED); config = new YAMLProcessor(file, false, YAMLFormat.EXTENDED);
try { try {
config.load(); config.load();
} catch (IOException e) { } catch (IOException e) {
logger.log(Level.WARNING, "Error loading WEPIF configuration", e); logger.warn("Error loading WEPIF configuration", e);
} }
List<String> keys = config.getKeys(null); List<String> keys = config.getKeys(null);
config.setHeader(CONFIG_HEADER); config.setHeader(CONFIG_HEADER);
@ -232,7 +232,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
} catch (ClassNotFoundException e) {} } catch (ClassNotFoundException e) {}
if (next == null || !PermissionsResolver.class.isAssignableFrom(next)) { if (next == null || !PermissionsResolver.class.isAssignableFrom(next)) {
logger.warning("WEPIF: Invalid or unknown class found in enabled resolvers: " logger.warn("WEPIF: Invalid or unknown class found in enabled resolvers: "
+ nextName + ". Moving to disabled resolvers list."); + nextName + ". Moving to disabled resolvers list.");
i.remove(); i.remove();
disabledResolvers.add(nextName); disabledResolvers.add(nextName);

Datei anzeigen

@ -35,9 +35,6 @@ public class VaultResolver implements PermissionsResolver {
return null; return null;
} }
RegisteredServiceProvider<Permission> rsp = server.getServicesManager().getRegistration(Permission.class); RegisteredServiceProvider<Permission> rsp = server.getServicesManager().getRegistration(Permission.class);
if (rsp == null) {
return null;
}
perms = rsp.getProvider(); perms = rsp.getProvider();
if (perms == null) { if (perms == null) {
return null; return null;

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

@ -19,8 +19,6 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.bukkit.util.CommandInspector; import com.sk89q.bukkit.util.CommandInspector;
import com.sk89q.minecraft.util.commands.CommandLocals; import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
@ -29,12 +27,14 @@ import com.sk89q.worldedit.util.command.Description;
import com.sk89q.worldedit.util.command.Dispatcher; import com.sk89q.worldedit.util.command.Dispatcher;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.logging.Logger; import static com.google.common.base.Preconditions.checkNotNull;
class BukkitCommandInspector implements CommandInspector { class BukkitCommandInspector implements CommandInspector {
private static final Logger logger = Logger.getLogger(BukkitCommandInspector.class.getCanonicalName()); private static final Logger logger = LoggerFactory.getLogger(BukkitCommandInspector.class);
private final WorldEditPlugin plugin; private final WorldEditPlugin plugin;
private final Dispatcher dispatcher; private final Dispatcher dispatcher;
@ -51,7 +51,7 @@ class BukkitCommandInspector implements CommandInspector {
if (mapping != null) { if (mapping != null) {
return mapping.getDescription().getDescription(); return mapping.getDescription().getDescription();
} else { } else {
logger.warning("BukkitCommandInspector doesn't know how about the command '" + command + "'"); logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available"; return "Help text not available";
} }
} }
@ -63,7 +63,7 @@ class BukkitCommandInspector implements CommandInspector {
Description description = mapping.getDescription(); Description description = mapping.getDescription();
return "Usage: " + description.getUsage() + (description.getHelp() != null ? "\n" + description.getHelp() : ""); return "Usage: " + description.getUsage() + (description.getHelp() != null ? "\n" + description.getHelp() : "");
} else { } else {
logger.warning("BukkitCommandInspector doesn't know how about the command '" + command + "'"); logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available"; return "Help text not available";
} }
} }
@ -76,7 +76,7 @@ class BukkitCommandInspector implements CommandInspector {
locals.put(Actor.class, plugin.wrapCommandSender(sender)); locals.put(Actor.class, plugin.wrapCommandSender(sender));
return mapping.getCallable().testPermission(locals); return mapping.getCallable().testPermission(locals);
} else { } else {
logger.warning("BukkitCommandInspector doesn't know how about the command '" + command + "'"); logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return false; return false;
} }
} }

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit;
import com.sk89q.util.yaml.YAMLProcessor; import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.util.YAMLConfiguration; import com.sk89q.worldedit.util.YAMLConfiguration;
import com.sk89q.worldedit.util.report.Unreported; import com.sk89q.worldedit.util.report.Unreported;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
@ -34,7 +35,7 @@ public class BukkitConfiguration extends YAMLConfiguration {
@Unreported private final WorldEditPlugin plugin; @Unreported private final WorldEditPlugin plugin;
public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) { public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) {
super(config, plugin.getLogger()); super(config, LoggerFactory.getLogger(plugin.getLogger().getName()));
this.plugin = plugin; this.plugin = plugin;
} }

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

@ -48,6 +48,7 @@ import org.bukkit.block.Chest;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.inventory.DoubleChestInventory; import org.bukkit.inventory.DoubleChestInventory;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.slf4j.Logger;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
@ -56,8 +57,7 @@ import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
public class BukkitWorld extends AbstractWorld { public class BukkitWorld extends AbstractWorld {
@ -118,9 +118,9 @@ public class BukkitWorld extends AbstractWorld {
return null; return null;
} }
} catch (Exception e) { } catch (Exception e) {
logger.warning("Corrupt entity found when creating: " + entity.getType().getId()); logger.warn("Corrupt entity found when creating: " + entity.getType().getId());
if (entity.getNbtData() != null) { if (entity.getNbtData() != null) {
logger.warning(entity.getNbtData().toString()); logger.warn(entity.getNbtData().toString());
} }
e.printStackTrace(); e.printStackTrace();
return null; return null;
@ -183,7 +183,7 @@ public class BukkitWorld extends AbstractWorld {
try { try {
getWorld().regenerateChunk(chunk.getBlockX(), chunk.getBlockZ()); getWorld().regenerateChunk(chunk.getBlockX(), chunk.getBlockZ());
} catch (Throwable t) { } catch (Throwable t) {
logger.log(Level.WARNING, "Chunk generation via Bukkit raised an error", t); logger.warn("Chunk generation via Bukkit raised an error", t);
} }
// Then restore // Then restore
@ -280,7 +280,7 @@ public class BukkitWorld extends AbstractWorld {
treeTypeMapping.put(TreeGenerator.TreeType.RANDOM_MUSHROOM, TreeType.BROWN_MUSHROOM); treeTypeMapping.put(TreeGenerator.TreeType.RANDOM_MUSHROOM, TreeType.BROWN_MUSHROOM);
for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) { for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) {
if (treeTypeMapping.get(type) == null) { if (treeTypeMapping.get(type) == null) {
WorldEdit.logger.severe("No TreeType mapping for TreeGenerator.TreeType." + type); WorldEdit.logger.error("No TreeType mapping for TreeGenerator.TreeType." + type);
} }
} }
} }
@ -426,8 +426,8 @@ public class BukkitWorld extends AbstractWorld {
return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight); return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight);
} catch (Exception e) { } catch (Exception e) {
if (block instanceof BaseBlock && ((BaseBlock) block).getNbtData() != null) { if (block instanceof BaseBlock && ((BaseBlock) block).getNbtData() != null) {
logger.warning("Tried to set a corrupt tile entity at " + position.toString()); logger.warn("Tried to set a corrupt tile entity at " + position.toString());
logger.warning(((BaseBlock)block).getNbtData().toString()); logger.warn(((BaseBlock) block).getNbtData().toString());
} }
e.printStackTrace(); e.printStackTrace();
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()); Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());

Datei anzeigen

@ -33,24 +33,46 @@ 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.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.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.FuzzyBlockState;
import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.item.ItemCategory;
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.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.LoggerFactory;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.*; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -59,7 +81,6 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -67,10 +88,9 @@ 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 = Logger.getLogger("FastAsyncWorldEdit"); 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";
private static WorldEditPlugin INSTANCE; private static WorldEditPlugin INSTANCE;
@ -220,18 +240,18 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter
} }
} }
} }
{ // {
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");
nameField.setAccessible(true); // nameField.setAccessible(true);
nameField.set(logger, "FastAsyncWorldEdit"); // nameField.set(logger, "FastAsyncWorldEdit");
} catch (Throwable ignore) { // } catch (Throwable ignore) {
ignore.printStackTrace(); // ignore.printStackTrace();
} // }
} // }
} // }
{ {
File pluginsFolder = MainUtil.getJarFile().getParentFile(); File pluginsFolder = MainUtil.getJarFile().getParentFile();
for (File file : pluginsFolder.listFiles()) { for (File file : pluginsFolder.listFiles()) {
@ -245,7 +265,7 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter
e.printStackTrace(); e.printStackTrace();
} }
} }
log.log(Level.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.");
} }
} }
@ -253,7 +273,7 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter
try { try {
run.run(); run.run();
} catch (Throwable e) { } catch (Throwable e) {
log.log(Level.SEVERE, message); getLogger().severe(message);
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -264,7 +284,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.log(Level.SEVERE, "Failed to load config.yml"); getLogger().severe("Failed to load config.yml");
e.printStackTrace(); e.printStackTrace();
} }
// Create schematics folder // Create schematics folder
@ -280,37 +300,33 @@ 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 {
adapterLoader.addFromPath(getClass().getClassLoader()); adapterLoader.addFromPath(getClass().getClassLoader());
} catch (IOException e) { } catch (IOException e) {
log.log(Level.WARNING, "Failed to search path for Bukkit adapters"); log.warn("Failed to search path for Bukkit adapters");
} }
try { try {
adapterLoader.addFromJar(getFile()); adapterLoader.addFromJar(getFile());
} catch (IOException e) { } catch (IOException e) {
log.log(Level.WARNING, "Failed to search " + getFile() + " for Bukkit adapters", e); log.warn("Failed to search " + getFile() + " for Bukkit adapters", e);
} }
try { try {
bukkitAdapter = adapterLoader.loadAdapter(); bukkitAdapter = adapterLoader.loadAdapter();
log.log(Level.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.log(Level.WARNING, e.getMessage()); log.warn(e.getMessage());
return;
} else { } else {
log.log(Level.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.log(Level.INFO, "WorldEdit could not find a Bukkit adapter for this MC version");
} }
} }

Datei anzeigen

@ -20,6 +20,8 @@
package com.sk89q.worldedit.bukkit.adapter; package com.sk89q.worldedit.bukkit.adapter;
import com.sk89q.worldedit.util.io.Closer; import com.sk89q.worldedit.util.io.Closer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -29,15 +31,13 @@ import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Loads Bukkit implementation adapters. * Loads Bukkit implementation adapters.
*/ */
public class BukkitImplLoader { public class BukkitImplLoader {
private static final Logger log = Logger.getLogger(BukkitImplLoader.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(BukkitImplLoader.class);
private final List<String> adapterCandidates = new ArrayList<>(); private final List<String> adapterCandidates = new ArrayList<>();
private String customCandidate; private String customCandidate;
@ -73,7 +73,7 @@ public class BukkitImplLoader {
if (className != null) { if (className != null) {
customCandidate = className; customCandidate = className;
adapterCandidates.add(className); adapterCandidates.add(className);
log.log(Level.INFO, "-Dworldedit.bukkit.adapter used to add " + className + " to the list of available Bukkit adapters"); log.info("-Dworldedit.bukkit.adapter used to add " + className + " to the list of available Bukkit adapters");
} }
} }
@ -161,19 +161,18 @@ public class BukkitImplLoader {
if (BukkitImplAdapter.class.isAssignableFrom(cls)) { if (BukkitImplAdapter.class.isAssignableFrom(cls)) {
return (BukkitImplAdapter) cls.newInstance(); return (BukkitImplAdapter) cls.newInstance();
} else { } else {
log.log(Level.WARNING, "Failed to load the Bukkit adapter class '" + className + log.warn("Failed to load the Bukkit adapter class '" + className +
"' because it does not implement " + BukkitImplAdapter.class.getCanonicalName()); "' because it does not implement " + BukkitImplAdapter.class.getCanonicalName());
} }
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
log.log(Level.WARNING, "Failed to load the Bukkit adapter class '" + className + log.warn("Failed to load the Bukkit adapter class '" + className +
"' that is not supposed to be missing", e); "' that is not supposed to be missing", e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
log.log(Level.WARNING, "Failed to load the Bukkit adapter class '" + className + log.warn("Failed to load the Bukkit adapter class '" + className +
"' that is not supposed to be raising this error", e); "' that is not supposed to be raising this error", e);
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace();
if (className.equals(customCandidate)) { if (className.equals(customCandidate)) {
log.log(Level.WARNING, "Failed to load the Bukkit adapter class '" + className + "'", e); log.warn("Failed to load the Bukkit adapter class '" + className + "'", e);
} }
} }
} }

Datei anzeigen

@ -13,6 +13,8 @@ dependencies {
compile 'com.google.code.gson:gson:2.8.0' compile 'com.google.code.gson:gson:2.8.0'
compile 'com.sk89q.lib:jlibnoise:1.0.0' compile 'com.sk89q.lib:jlibnoise:1.0.0'
compile 'com.googlecode.json-simple:json-simple:1.1.1' compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'org.slf4j:slf4j-api:1.7.26'
//compile 'net.sf.trove4j:trove4j:3.0.3'
testCompile 'org.mockito:mockito-core:1.9.0-rc1' testCompile 'org.mockito:mockito-core:1.9.0-rc1'
// Fawe depends // Fawe depends

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

@ -20,6 +20,8 @@
package com.sk89q.minecraft.util.commands; package com.sk89q.minecraft.util.commands;
import com.sk89q.util.StringUtil; import com.sk89q.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -30,8 +32,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Manager for handling commands. This allows you to easily process commands, * Manager for handling commands. This allows you to easily process commands,
@ -63,7 +63,7 @@ import java.util.logging.Logger;
public abstract class CommandsManager<T> { public abstract class CommandsManager<T> {
protected static final Logger logger = protected static final Logger logger =
Logger.getLogger(CommandsManager.class.getCanonicalName()); LoggerFactory.getLogger(CommandsManager.class);
/** /**
* Mapping of commands (including aliases) with a description. Root * Mapping of commands (including aliases) with a description. Root
@ -142,7 +142,7 @@ public abstract class CommandsManager<T> {
return registerMethods(cls, parent, obj); return registerMethods(cls, parent, obj);
} }
} catch (InvocationTargetException | InstantiationException | IllegalAccessException e) { } catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
logger.log(Level.SEVERE, "Failed to register commands", e); logger.error("Failed to register commands", e);
} }
return null; return null;
} }
@ -523,7 +523,7 @@ public abstract class CommandsManager<T> {
try { try {
method.invoke(instance, methodArgs); method.invoke(instance, methodArgs);
} catch (IllegalArgumentException | IllegalAccessException e) { } catch (IllegalArgumentException | IllegalAccessException e) {
logger.log(Level.SEVERE, "Failed to execute command", e); logger.error("Failed to execute command", e);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
if (e.getCause() instanceof CommandException) { if (e.getCause() instanceof CommandException) {
throw (CommandException) e.getCause(); throw (CommandException) e.getCause();

Datei anzeigen

@ -19,14 +19,15 @@
package com.sk89q.minecraft.util.commands; package com.sk89q.minecraft.util.commands;
import org.slf4j.Logger;
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.util.logging.Level;
import java.util.logging.Logger;
public class SimpleInjector implements Injector { public class SimpleInjector implements Injector {
private static final Logger log = Logger.getLogger(SimpleInjector.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(SimpleInjector.class);
private Object[] args; private Object[] args;
private Class<?>[] argClasses; private Class<?>[] argClasses;
@ -45,7 +46,7 @@ public class SimpleInjector implements Injector {
ctr.setAccessible(true); ctr.setAccessible(true);
return ctr.newInstance(args); return ctr.newInstance(args);
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
log.log(Level.SEVERE, "Error initializing commands class " + clazz, e); log.error("Error initializing commands class " + clazz, e);
return null; return null;
} }
} }

Datei anzeigen

@ -95,6 +95,8 @@ import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.block.*; import com.sk89q.worldedit.world.block.*;
import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -108,12 +110,15 @@ import static com.sk89q.worldedit.regions.Regions.*;
/** /**
* 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>
*/ */
public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, SimpleWorld, AutoCloseable { public class EditSession extends AbstractDelegateExtent implements HasFaweQueue, SimpleWorld, AutoCloseable {
private static final Logger log = LoggerFactory.getLogger(EditSession.class);
/** /**
* Used by {@link EditSession#setBlock(BlockVector3, BlockStateHolder, Stage)} to * Used by {@link EditSession#setBlock(BlockVector3, BlockStateHolder, Stage)} to
* determine which {@link Extent}s should be bypassed. * determine which {@link Extent}s should be bypassed.
@ -2901,8 +2906,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;
} }
} }
@ -3299,8 +3304,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;
} }
} }

Datei anzeigen

@ -81,7 +81,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
@ -1260,7 +1259,7 @@ public class LocalSession implements TextureHolder {
String msg = e.getMessage(); String msg = e.getMessage();
if (msg != null && msg.length() > 256) msg = msg.substring(0, 256); if (msg != null && msg.length() > 256) msg = msg.substring(0, 256);
this.failedCuiAttempts++; this.failedCuiAttempts++;
WorldEdit.logger.warning("Error while reading CUI init message for player " + uuid + ": " + msg); WorldEdit.logger.warn("Error while reading CUI init message: " + e.getMessage());
} }
} }

Datei anzeigen

@ -61,6 +61,8 @@ import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BundledBlockData; import com.sk89q.worldedit.world.registry.BundledBlockData;
import com.sk89q.worldedit.world.registry.BundledItemData; import com.sk89q.worldedit.world.registry.BundledItemData;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.script.ScriptException; import javax.script.ScriptException;
@ -76,8 +78,6 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.sk89q.worldedit.event.platform.Interaction.HIT; import static com.sk89q.worldedit.event.platform.Interaction.HIT;
import static com.sk89q.worldedit.event.platform.Interaction.OPEN; import static com.sk89q.worldedit.event.platform.Interaction.OPEN;
@ -97,9 +97,9 @@ import static com.sk89q.worldedit.event.platform.Interaction.OPEN;
*/ */
public final class WorldEdit { public final class WorldEdit {
public static final Logger logger = Logger.getLogger(WorldEdit.class.getCanonicalName()); public static final Logger logger = LoggerFactory.getLogger(WorldEdit.class);
private final static WorldEdit instance = new WorldEdit(); private static final WorldEdit instance = new WorldEdit();
private static String version; private static String version;
private final EventBus eventBus = new EventBus(); private final EventBus eventBus = new EventBus();
@ -670,13 +670,13 @@ public final class WorldEdit {
} catch (ScriptException e) { } catch (ScriptException e) {
player.printError("Failed to execute:"); player.printError("Failed to execute:");
player.printRaw(e.getMessage()); player.printRaw(e.getMessage());
logger.log(Level.WARNING, "Failed to execute script", e); logger.warn("Failed to execute script", e);
} catch (NumberFormatException | WorldEditException e) { } catch (NumberFormatException | WorldEditException e) {
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
player.printError("Failed to execute (see console):"); player.printError("Failed to execute (see console):");
player.printRaw(e.getClass().getCanonicalName()); player.printRaw(e.getClass().getCanonicalName());
logger.log(Level.WARNING, "Failed to execute script", e); logger.warn("Failed to execute script", e);
} finally { } finally {
for (EditSession editSession : scriptContext.getEditSessions()) { for (EditSession editSession : scriptContext.getEditSessions()) {
editSession.flushQueue(); editSession.flushQueue();

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

@ -48,15 +48,18 @@ 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.LoggerFactory;
import javax.annotation.Nullable;
import java.io.*; import java.io.*;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
@ -66,12 +69,10 @@ import java.nio.channels.ReadableByteChannel;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.LongAdder; import java.util.concurrent.atomic.LongAdder;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static com.boydti.fawe.util.ReflectionUtils.as; import static com.boydti.fawe.util.ReflectionUtils.as;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Commands that work with schematic files. * Commands that work with schematic files.
@ -79,7 +80,7 @@ import static com.boydti.fawe.util.ReflectionUtils.as;
@Command(aliases = {"schematic", "schem", "/schematic", "/schem", "clipboard", "/clipboard"}, desc = "Commands that work with schematic files") @Command(aliases = {"schematic", "schem", "/schematic", "/schem", "clipboard", "/clipboard"}, desc = "Commands that work with schematic files")
public class SchematicCommands extends MethodCommands { public class SchematicCommands extends MethodCommands {
private static final Logger log = Logger.getLogger(SchematicCommands.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(SchematicCommands.class);
/** /**
* Create a new instance. * Create a new instance.
@ -266,7 +267,7 @@ public class SchematicCommands extends MethodCommands {
player.printError("Unknown filename: " + filename); player.printError("Unknown filename: " + filename);
} catch (URISyntaxException | IOException e) { } catch (URISyntaxException | IOException e) {
player.printError("File could not be read or it does not exist: " + e.getMessage()); player.printError("File could not be read or it does not exist: " + e.getMessage());
log.log(Level.WARNING, "Failed to load a saved clipboard", e); log.warn("Failed to load a saved clipboard", e);
} finally { } finally {
if (in != null) { if (in != null) {
try { try {
@ -363,7 +364,7 @@ public class SchematicCommands extends MethodCommands {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
player.printError("Schematic could not written: " + e.getMessage()); player.printError("Schematic could not written: " + e.getMessage());
log.log(Level.WARNING, "Failed to write a saved clipboard", e); log.warn("Failed to write a saved clipboard", e);
} }
} }

Datei anzeigen

@ -33,13 +33,13 @@ 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;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.List; import java.util.List;
import java.util.logging.Logger;
/** /**
* Snapshot commands. * Snapshot commands.
@ -47,7 +47,6 @@ import java.util.logging.Logger;
@Command(aliases = {"snapshot", "snap"}, desc = "List, load and view information related to snapshots") @Command(aliases = {"snapshot", "snap"}, desc = "List, load and view information related to snapshots")
public class SnapshotCommands { public class SnapshotCommands {
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
private final WorldEdit we; private final WorldEdit we;
@ -93,10 +92,10 @@ public class SnapshotCommands {
File dir = config.snapshotRepo.getDirectory(); File dir = config.snapshotRepo.getDirectory();
try { try {
logger.info("WorldEdit found no snapshots: looked in: " WorldEdit.logger.info("WorldEdit found no snapshots: looked in: "
+ dir.getCanonicalPath()); + dir.getCanonicalPath());
} catch (IOException e) { } catch (IOException e) {
logger.info("WorldEdit found no snapshots: looked in " WorldEdit.logger.info("WorldEdit found no snapshots: looked in "
+ "(NON-RESOLVABLE PATH - does it exist?): " + "(NON-RESOLVABLE PATH - does it exist?): "
+ dir.getPath()); + dir.getPath());
} }
@ -261,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());
@ -271,4 +271,5 @@ public class SnapshotCommands {
} }
} }
} }
} }

Datei anzeigen

@ -37,18 +37,15 @@ 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 java.util.logging.Logger;
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)")
public class SnapshotUtilCommands { public class SnapshotUtilCommands {
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
private final WorldEdit we; private final WorldEdit we;
public SnapshotUtilCommands(WorldEdit we) { public SnapshotUtilCommands(WorldEdit we) {
@ -99,10 +96,10 @@ public class SnapshotUtilCommands {
File dir = config.snapshotRepo.getDirectory(); File dir = config.snapshotRepo.getDirectory();
try { try {
logger.info("FAWE found no snapshots: looked in: " WorldEdit.logger.info("WorldEdit found no snapshots: looked in: "
+ dir.getCanonicalPath()); + dir.getCanonicalPath());
} catch (IOException e) { } catch (IOException e) {
logger.info("FAWE found no snapshots: looked in " WorldEdit.logger.info("WorldEdit found no snapshots: looked in "
+ "(NON-RESOLVABLE PATH - does it exist?): " + "(NON-RESOLVABLE PATH - does it exist?): "
+ dir.getPath()); + dir.getPath());
} }

Datei anzeigen

@ -81,20 +81,25 @@ 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.enableQueue(); editSession.enableQueue();
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);
Operation operation = operationFactory.createFromContext(editContext); Operation operation = operationFactory.createFromContext(editContext);
// Shortcut // Shortcut
if (selection instanceof CuboidRegion && editSession.hasFastMode() && operation instanceof RegionVisitor) { if (selection instanceof CuboidRegion && editSession.hasFastMode() && operation instanceof RegionVisitor) {

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,16 +19,20 @@
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;
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.extent.inventory.BlockBag; import com.sk89q.worldedit.extent.inventory.BlockBag;
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.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
/** /**
* A mode that replaces one block. * A mode that replaces one block.

Datei anzeigen

@ -49,9 +49,9 @@ public class TreePlanter implements BlockTool {
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
EditSession editSession = session.createEditSession(player); EditSession editSession = session.createEditSession(player);
try { try {
boolean successful = false; boolean successful = false;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
if (treeType.generate(editSession, clicked.add(0, 1, 0).toBlockPoint())) { if (treeType.generate(editSession, clicked.add(0, 1, 0).toBlockPoint())) {
successful = true; successful = true;

Datei anzeigen

@ -21,10 +21,10 @@ 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.world.block.BlockTypes;
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.world.block.BlockTypes;
public class CylinderBrush implements Brush { public class CylinderBrush implements Brush {

Datei anzeigen

@ -21,9 +21,9 @@ 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.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
public class HollowCylinderBrush implements Brush { public class HollowCylinderBrush implements Brush {

Datei anzeigen

@ -21,9 +21,9 @@ 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.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
public class HollowSphereBrush implements Brush { public class HollowSphereBrush implements Brush {

Datei anzeigen

@ -21,9 +21,9 @@ 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.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
public class SphereBrush implements Brush { public class SphereBrush implements Brush {

Datei anzeigen

@ -58,8 +58,13 @@ 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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.File; import java.io.File;
@ -69,10 +74,8 @@ 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.logging.Logger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -80,14 +83,15 @@ 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 {
public static final Pattern COMMAND_CLEAN_PATTERN = Pattern.compile("^[/]+"); public static final Pattern COMMAND_CLEAN_PATTERN = Pattern.compile("^[/]+");
private static final Logger log = Logger.getLogger(CommandManager.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(CommandManager.class);
private static final Logger commandLog = Logger.getLogger(CommandManager.class.getCanonicalName() + ".CommandLog"); private static final java.util.logging.Logger commandLog =
java.util.logging.Logger.getLogger(CommandManager.class.getCanonicalName() + ".CommandLog");
private static final Pattern numberFormatExceptionPattern = Pattern.compile("^For input string: \"(.*)\"$"); private static final Pattern numberFormatExceptionPattern = Pattern.compile("^For input string: \"(.*)\"$");
private final WorldEdit worldEdit; private final WorldEdit worldEdit;
@ -124,6 +128,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));
@ -297,7 +302,7 @@ public final class CommandManager {
} }
public void register(Platform platform) { public void register(Platform platform) {
log.log(Level.FINE, "Registering commands with " + platform.getClass().getCanonicalName()); log.info("Registering commands with " + platform.getClass().getCanonicalName());
this.platform = null; this.platform = null;
try { try {
@ -318,12 +323,12 @@ public final class CommandManager {
File file = new File(config.getWorkingDirectory(), path); File file = new File(config.getWorkingDirectory(), path);
commandLog.setLevel(Level.ALL); commandLog.setLevel(Level.ALL);
log.log(Level.INFO, "Logging WorldEdit commands to " + file.getAbsolutePath()); log.info("Logging WorldEdit commands to " + file.getAbsolutePath());
try { try {
dynamicHandler.setHandler(new FileHandler(file.getAbsolutePath(), true)); dynamicHandler.setHandler(new FileHandler(file.getAbsolutePath(), true));
} catch (IOException e) { } catch (IOException e) {
log.log(Level.WARNING, "Could not use command log file " + path + ": " + e.getMessage()); log.warn("Could not use command log file " + path + ": " + e.getMessage());
} }
} }
@ -418,7 +423,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);
@ -474,8 +480,8 @@ public final class CommandManager {
if (message != null) { if (message != null) {
actor.printError(BBC.getPrefix() + e.getMessage()); actor.printError(BBC.getPrefix() + e.getMessage());
} else { } else {
actor.printError(BBC.getPrefix() + "An unknown FAWE error has occurred! Please see console."); actor.printError("An unknown error has occurred! Please see console.");
log.log(Level.SEVERE, "An unknown FAWE error occurred", e); log.error("An unknown error occurred", e);
} }
} catch (Throwable e) { } catch (Throwable e) {
Exception faweException = FaweException.get(e); Exception faweException = FaweException.get(e);
@ -485,7 +491,7 @@ public final class CommandManager {
} else { } else {
actor.printError(BBC.getPrefix() + "There was an error handling a FAWE command: [See console]"); actor.printError(BBC.getPrefix() + "There was an error handling a FAWE command: [See console]");
actor.printRaw(e.getClass().getName() + ": " + e.getMessage()); actor.printRaw(e.getClass().getName() + ": " + e.getMessage());
log.log(Level.SEVERE, "An unexpected error occurred while handling a FAWE command", e); log.error("An unexpected error occurred while handling a FAWE command", e);
} }
} finally { } finally {
final EditSession editSession = locals.get(EditSession.class); final EditSession editSession = locals.get(EditSession.class);
@ -552,7 +558,7 @@ public final class CommandManager {
return dispatcher; return dispatcher;
} }
public static Logger getLogger() { public static java.util.logging.Logger getLogger() {
return commandLog; return commandLog;
} }

Datei anzeigen

@ -49,25 +49,25 @@ import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull; 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> *
* <p>This class is thread-safe.</p> * <p>This class is thread-safe.</p>
*/ */
public class PlatformManager { public class PlatformManager {
private static final Logger logger = Logger.getLogger(PlatformManager.class.getCanonicalName()); private static final Logger logger = LoggerFactory.getLogger(PlatformManager.class);
private final WorldEdit worldEdit; private final WorldEdit worldEdit;
private final CommandManager commandManager; private final CommandManager commandManager;
@ -99,7 +99,7 @@ public class PlatformManager {
public synchronized void register(Platform platform) { public synchronized void register(Platform platform) {
checkNotNull(platform); checkNotNull(platform);
logger.log(Level.FINE, "Got request to register " + platform.getClass() + " with WorldEdit [" + super.toString() + "]"); logger.info("Got request to register " + platform.getClass() + " with WorldEdit [" + super.toString() + "]");
// Just add the platform to the list of platforms: we'll pick favorites // Just add the platform to the list of platforms: we'll pick favorites
// once all the platforms have been loaded // once all the platforms have been loaded
@ -108,7 +108,7 @@ public class PlatformManager {
// Make sure that versions are in sync // Make sure that versions are in sync
if (firstSeenVersion != null) { if (firstSeenVersion != null) {
if (!firstSeenVersion.equals(platform.getVersion())) { if (!firstSeenVersion.equals(platform.getVersion())) {
logger.log(Level.WARNING, "Multiple ports of WorldEdit are installed but they report different versions ({0} and {1}). " + logger.warn("Multiple ports of WorldEdit are installed but they report different versions ({0} and {1}). " +
"If these two versions are truly different, then you may run into unexpected crashes and errors.", "If these two versions are truly different, then you may run into unexpected crashes and errors.",
new Object[]{ firstSeenVersion, platform.getVersion() }); new Object[]{ firstSeenVersion, platform.getVersion() });
} }
@ -119,7 +119,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>
* *
@ -131,7 +131,7 @@ public class PlatformManager {
boolean removed = platforms.remove(platform); boolean removed = platforms.remove(platform);
if (removed) { if (removed) {
logger.log(Level.FINE, "Unregistering " + platform.getClass().getCanonicalName() + " from WorldEdit"); logger.info("Unregistering " + platform.getClass().getCanonicalName() + " from WorldEdit");
boolean choosePreferred = false; boolean choosePreferred = false;
@ -222,7 +222,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
@ -497,7 +497,7 @@ public class PlatformManager {
return; return;
} }
final Tool tool = session.getTool(player); Tool tool = session.getTool(player);
if (tool != null && tool instanceof DoubleActionTraceTool) { if (tool != null && tool instanceof DoubleActionTraceTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(player); FawePlayer<?> fp = FawePlayer.wrap(player);
@ -532,7 +532,7 @@ public class PlatformManager {
return; return;
} }
final Tool tool = session.getTool(player); Tool tool = session.getTool(player);
if (tool != null && tool instanceof TraceTool) { if (tool != null && tool instanceof TraceTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(player); FawePlayer<?> fp = FawePlayer.wrap(player);

Datei anzeigen

@ -74,7 +74,7 @@ public class ClipboardFormats {
ClipboardFormat old = aliasMap.put(lowKey, format); ClipboardFormat old = aliasMap.put(lowKey, format);
if (old != null) { if (old != null) {
aliasMap.put(lowKey, old); aliasMap.put(lowKey, old);
WorldEdit.logger.warning(format.getClass().getName() + " cannot override existing alias '" + lowKey + "' used by " + old.getClass().getName()); WorldEdit.logger.warn(format.getClass().getName() + " cannot override existing alias '" + lowKey + "' used by " + old.getClass().getName());
} }
} }
for (String ext : format.getFileExtensions()) { for (String ext : format.getFileExtensions()) {

Datei anzeigen

@ -46,6 +46,8 @@ import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import com.sk89q.worldedit.world.storage.NBTConversions; import com.sk89q.worldedit.world.storage.NBTConversions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -53,7 +55,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Reads schematic files that are compatible with MCEdit and other editors. * Reads schematic files that are compatible with MCEdit and other editors.
@ -67,7 +68,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
// TODO Add a handler for skulls, flower pots, note blocks, etc. // TODO Add a handler for skulls, flower pots, note blocks, etc.
} }
private static final Logger log = Logger.getLogger(MCEditSchematicReader.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(MCEditSchematicReader.class);
private final NBTInputStream inputStream; private final NBTInputStream inputStream;
/** /**
@ -231,15 +232,15 @@ public class MCEditSchematicReader extends NBTSchematicReader {
clipboard.setBlock(region.getMinimumPoint().add(pt), state); clipboard.setBlock(region.getMinimumPoint().add(pt), state);
} }
} else { } else {
log.warning("Unknown block when pasting schematic: " + blocks[index] + ":" + blockData[index] + ". Please report this issue."); log.warn("Unknown block when pasting schematic: " + blocks[index] + ":" + blockData[index] + ". Please report this issue.");
} }
} catch (WorldEditException e) { } catch (WorldEditException e) {
switch (failedBlockSets) { switch (failedBlockSets) {
case 0: case 0:
log.log(Level.WARNING, "Failed to set block on a Clipboard", e); log.warn("Failed to set block on a Clipboard", e);
break; break;
case 1: case 1:
log.log(Level.WARNING, "Failed to set block on a Clipboard (again) -- no more messages will be logged", e); log.warn("Failed to set block on a Clipboard (again) -- no more messages will be logged", e);
break; break;
default: default:
} }
@ -269,7 +270,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
BaseEntity state = new BaseEntity(entityType, compound); BaseEntity state = new BaseEntity(entityType, compound);
clipboard.createEntity(location, state); clipboard.createEntity(location, state);
} else { } else {
log.warning("Unknown entity when pasting schematic: " + id.toLowerCase()); log.warn("Unknown entity when pasting schematic: " + id.toLowerCase());
} }
} }
} }

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

@ -60,6 +60,8 @@ import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.entity.EntityTypes;
import net.jpountz.lz4.LZ4BlockInputStream; import net.jpountz.lz4.LZ4BlockInputStream;
import net.jpountz.lz4.LZ4BlockOutputStream; import net.jpountz.lz4.LZ4BlockOutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
@ -70,7 +72,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
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;
@ -86,7 +87,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
// If NBT Compat handlers are needed - add them here. // If NBT Compat handlers are needed - add them here.
} }
private static final Logger log = Logger.getLogger(SpongeSchematicReader.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(SpongeSchematicReader.class);
private final NBTInputStream inputStream; private final NBTInputStream inputStream;
/** /**

Datei anzeigen

@ -40,6 +40,8 @@ import java.lang.reflect.Method;
import java.util.logging.Handler; import java.util.logging.Handler;
import java.util.logging.Logger; import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Logs called commands to a logger. * Logs called commands to a logger.
*/ */

Datei anzeigen

@ -21,14 +21,15 @@
package com.sk89q.worldedit.math.interpolation; package com.sk89q.worldedit.math.interpolation;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Reparametrises another interpolation function by arc length. * Reparametrises another interpolation function by arc length.
@ -38,7 +39,7 @@ import java.util.logging.Logger;
*/ */
public class ReparametrisingInterpolation implements Interpolation { public class ReparametrisingInterpolation implements Interpolation {
private static final Logger log = Logger.getLogger(ReparametrisingInterpolation.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(ReparametrisingInterpolation.class);
private final Interpolation baseInterpolation; private final Interpolation baseInterpolation;
private double totalArcLength; private double totalArcLength;
@ -102,7 +103,7 @@ public class ReparametrisingInterpolation implements Interpolation {
Entry<Double, Double> ceilingEntry = cache.ceilingEntry(arc); Entry<Double, Double> ceilingEntry = cache.ceilingEntry(arc);
if (ceilingEntry == null) { if (ceilingEntry == null) {
log.warning("Error in arcToParameter: no ceiling entry for " + arc + " found!"); log.warn("Error in arcToParameter: no ceiling entry for " + arc + " found!");
return 0; return 0;
} }
final double rightArc = ceilingEntry.getKey(); final double rightArc = ceilingEntry.getKey();

Datei anzeigen

@ -27,13 +27,17 @@ import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent; import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.session.storage.JsonFileSessionStore; import com.sk89q.worldedit.session.storage.JsonFileSessionStore;
import com.sk89q.worldedit.session.storage.SessionStore; import com.sk89q.worldedit.session.storage.SessionStore;
import com.sk89q.worldedit.session.storage.VoidStore; import com.sk89q.worldedit.session.storage.VoidStore;
import com.sk89q.worldedit.util.concurrency.EvenMoreExecutors; import com.sk89q.worldedit.util.concurrency.EvenMoreExecutors;
import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.gamemode.GameModes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.ref.Reference; import java.lang.ref.Reference;
@ -41,29 +45,26 @@ import java.lang.ref.SoftReference;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Session manager for WorldEdit. * Session manager for WorldEdit.
* <p> *
* <p>Get a reference to one from {@link WorldEdit}.</p> * <p>Get a reference to one from {@link WorldEdit}.</p>
* <p> *
* <p>While this class is thread-safe, the returned session may not be.</p> * <p>While this class is thread-safe, the returned session may not be.</p>
*/ */
public class SessionManager { public class SessionManager {
@Deprecated
public static int EXPIRATION_GRACE = 600000; public static int EXPIRATION_GRACE = 600000;
private static final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 5)); private static final ListeningExecutorService executorService = MoreExecutors.listeningDecorator(EvenMoreExecutors.newBoundedCachedThreadPool(0, 1, 5));
private static final Logger log = Logger.getLogger(SessionManager.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(SessionManager.class);
private final Timer timer = new Timer(); private final Timer timer = new Timer();
private final WorldEdit worldEdit; private final WorldEdit worldEdit;
private final Map<UUID, SessionHolder> sessions = new ConcurrentHashMap<>(8, 0.9f, 1); private final Map<UUID, SessionHolder> sessions = new ConcurrentHashMap<>(8, 0.9f, 1);
@ -179,8 +180,8 @@ public class SessionManager {
try { try {
session = store.load(getKey(sessionKey)); session = store.load(getKey(sessionKey));
session.postLoad(); session.postLoad();
} catch (Throwable e) { } catch (IOException e) {
log.log(Level.WARNING, "Failed to load saved session", e); log.warn("Failed to load saved session", e);
session = new LocalSession(); session = new LocalSession();
} }
@ -239,7 +240,7 @@ public class SessionManager {
} }
} }
} catch (IOException e) { } catch (IOException e) {
log.log(Level.WARNING, "Failed to write session for UUID " + getKey(key), e); log.warn("Failed to write session for UUID " + getKey(key), e);
} }
} }
} }

Datei anzeigen

@ -19,8 +19,6 @@
package com.sk89q.worldedit.session.storage; package com.sk89q.worldedit.session.storage;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.JsonIOException; import com.google.gson.JsonIOException;
@ -28,6 +26,8 @@ import com.google.gson.JsonParseException;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.util.gson.GsonUtil; import com.sk89q.worldedit.util.gson.GsonUtil;
import com.sk89q.worldedit.util.io.Closer; import com.sk89q.worldedit.util.io.Closer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
@ -37,8 +37,8 @@ import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger; import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Stores sessions as JSON files in a directory. * Stores sessions as JSON files in a directory.
@ -47,7 +47,7 @@ import java.util.logging.Logger;
*/ */
public class JsonFileSessionStore implements SessionStore { public class JsonFileSessionStore implements SessionStore {
private static final Logger log = Logger.getLogger(JsonFileSessionStore.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(JsonFileSessionStore.class);
private final Gson gson; private final Gson gson;
private final File dir; private final File dir;
@ -61,7 +61,7 @@ public class JsonFileSessionStore implements SessionStore {
if (!dir.isDirectory()) { if (!dir.isDirectory()) {
if (!dir.mkdirs()) { if (!dir.mkdirs()) {
log.log(Level.WARNING, "Failed to create directory '" + dir.getPath() + "' for sessions"); log.warn("Failed to create directory '" + dir.getPath() + "' for sessions");
} }
} }
@ -111,12 +111,12 @@ public class JsonFileSessionStore implements SessionStore {
if (finalFile.exists()) { if (finalFile.exists()) {
if (!finalFile.delete()) { if (!finalFile.delete()) {
log.log(Level.WARNING, "Failed to delete " + finalFile.getPath() + " so the .tmp file can replace it"); log.warn("Failed to delete " + finalFile.getPath() + " so the .tmp file can replace it");
} }
} }
if (!tempFile.renameTo(finalFile)) { if (!tempFile.renameTo(finalFile)) {
log.log(Level.WARNING, "Failed to rename temporary session file to " + finalFile.getPath()); log.warn("Failed to rename temporary session file to " + finalFile.getPath());
} }
} }

Datei anzeigen

@ -21,14 +21,16 @@
package com.sk89q.worldedit.util; package com.sk89q.worldedit.util;
import com.google.common.collect.Lists;
import com.sk89q.util.StringUtil; 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.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.item.ItemTypes; 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.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -41,9 +43,6 @@ import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
/** /**
* Simple LocalConfiguration that loads settings using * Simple LocalConfiguration that loads settings using
@ -51,10 +50,10 @@ import java.util.stream.Collectors;
*/ */
public class PropertiesConfiguration extends LocalConfiguration { public class PropertiesConfiguration extends LocalConfiguration {
private static final Logger log = Logger.getLogger(PropertiesConfiguration.class.getCanonicalName()); @Unreported private static final Logger log = LoggerFactory.getLogger(PropertiesConfiguration.class);
protected Properties properties; @Unreported protected Properties properties;
protected File path; @Unreported protected File path;
/** /**
* Construct the object. The configuration isn't loaded yet. * Construct the object. The configuration isn't loaded yet.
@ -73,7 +72,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
properties.load(stream); properties.load(stream);
} catch (FileNotFoundException ignored) { } catch (FileNotFoundException ignored) {
} catch (IOException e) { } catch (IOException e) {
log.log(Level.WARNING, "Failed to read configuration", e); log.warn("Failed to read configuration", e);
} }
loadExtra(); loadExtra();
@ -101,7 +100,8 @@ public class PropertiesConfiguration extends LocalConfiguration {
wandItem = getString("wand-item", wandItem); wandItem = getString("wand-item", wandItem);
try { try {
wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId(); wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId();
} catch (Throwable e) {} } catch (Throwable e) {
}
superPickaxeDrop = getBool("super-pickaxe-drop-items", superPickaxeDrop); superPickaxeDrop = getBool("super-pickaxe-drop-items", superPickaxeDrop);
superPickaxeManyDrop = getBool("super-pickaxe-many-drop-items", superPickaxeManyDrop); superPickaxeManyDrop = getBool("super-pickaxe-many-drop-items", superPickaxeManyDrop);
noDoubleSlash = getBool("no-double-slash", noDoubleSlash); noDoubleSlash = getBool("no-double-slash", noDoubleSlash);
@ -111,7 +111,8 @@ public class PropertiesConfiguration extends LocalConfiguration {
navigationWand = getString("nav-wand-item", navigationWand); navigationWand = getString("nav-wand-item", navigationWand);
try { try {
navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).getId(); navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).getId();
} catch (Throwable e) {} } catch (Throwable e) {
}
navigationWandMaxDistance = getInt("nav-wand-distance", navigationWandMaxDistance); navigationWandMaxDistance = getInt("nav-wand-distance", navigationWandMaxDistance);
navigationUseGlass = getBool("nav-use-glass", navigationUseGlass); navigationUseGlass = getBool("nav-use-glass", navigationUseGlass);
scriptTimeout = getInt("scripting-timeout", scriptTimeout); scriptTimeout = getInt("scripting-timeout", scriptTimeout);
@ -132,7 +133,7 @@ public class PropertiesConfiguration extends LocalConfiguration {
try (OutputStream output = new FileOutputStream(path)) { try (OutputStream output = new FileOutputStream(path)) {
properties.store(output, "Don't put comments; they get removed"); properties.store(output, "Don't put comments; they get removed");
} catch (IOException e) { } catch (IOException e) {
log.log(Level.WARNING, "Failed to write configuration", e); log.warn("Failed to write configuration", e);
} }
} }

Datei anzeigen

@ -26,11 +26,10 @@ import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.session.SessionManager; import com.sk89q.worldedit.session.SessionManager;
import com.sk89q.worldedit.util.report.Unreported; import com.sk89q.worldedit.util.report.Unreported;
import com.sk89q.worldedit.world.snapshot.SnapshotRepository; import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
import org.slf4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* A less simple implementation of {@link LocalConfiguration} * A less simple implementation of {@link LocalConfiguration}
@ -51,7 +50,7 @@ public class YAMLConfiguration extends LocalConfiguration {
try { try {
config.load(); config.load();
} catch (IOException e) { } catch (IOException e) {
logger.log(Level.WARNING, "Error loading WorldEdit configuration", e); logger.warn("Error loading WorldEdit configuration", e);
} }
profile = config.getBoolean("debug", profile); profile = config.getBoolean("debug", profile);

Datei anzeigen

@ -19,13 +19,13 @@
package com.sk89q.worldedit.util.eventbus; package com.sk89q.worldedit.util.eventbus;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps; import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap; import com.google.common.collect.SetMultimap;
import com.google.common.eventbus.DeadEvent; import com.google.common.eventbus.DeadEvent;
import com.sk89q.worldedit.internal.annotation.RequiresNewerGuava; import com.sk89q.worldedit.internal.annotation.RequiresNewerGuava;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
@ -36,8 +36,8 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger; import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Dispatches events to listeners, and provides ways for listeners to register * Dispatches events to listeners, and provides ways for listeners to register
@ -53,7 +53,7 @@ import java.util.logging.Logger;
*/ */
public class EventBus { public class EventBus {
private final Logger logger = Logger.getLogger(EventBus.class.getCanonicalName()); private final Logger logger = LoggerFactory.getLogger(EventBus.class);
private final SetMultimap<Class<?>, EventHandler> handlersByType = private final SetMultimap<Class<?>, EventHandler> handlersByType =
Multimaps.newSetMultimap(new HashMap<>(), this::newHandlerSet); Multimaps.newSetMultimap(new HashMap<>(), this::newHandlerSet);
@ -186,8 +186,7 @@ public class EventBus {
try { try {
handler.handleEvent(event); handler.handleEvent(event);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
logger.log(Level.SEVERE, logger.error("Could not dispatch event: " + event + " to handler " + handler, e);
"Could not dispatch event: " + event + " to handler " + handler, e);
} }
} }

Datei anzeigen

@ -19,23 +19,23 @@
package com.sk89q.worldedit.util.io; package com.sk89q.worldedit.util.io;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.Deque; import java.util.Deque;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import static com.google.common.base.Preconditions.checkNotNull;
public final class Closer implements Closeable { public final class Closer implements Closeable {
private static final Logger logger = Logger.getLogger(Closer.class.getCanonicalName()); private static final Logger logger = LoggerFactory.getLogger(Closer.class);
/** /**
* The suppressor implementation to use for the current Java version. * The suppressor implementation to use for the current Java version.
@ -218,7 +218,7 @@ public final class Closer implements Closeable {
@Override @Override
public void suppress(Object closeable, Throwable thrown, Throwable suppressed) { public void suppress(Object closeable, Throwable thrown, Throwable suppressed) {
// log to the same place as Closeables // log to the same place as Closeables
logger.log(Level.WARNING, "Suppressing exception thrown when closing " + closeable, suppressed); logger.warn("Suppressing exception thrown when closing " + closeable, suppressed);
} }
} }

Datei anzeigen

@ -53,7 +53,8 @@ public final class WorldEditPrefixHandler extends Handler {
* @param name the logger name * @param name the logger name
*/ */
public static void register(String name) { public static void register(String name) {
Logger.getLogger(name).addHandler(new WorldEditPrefixHandler()); //todo fix this
//Logger.getLogger(name).addHandler(new WorldEditPrefixHandler());
} }
} }

Datei anzeigen

@ -26,14 +26,14 @@ import com.sk89q.worldedit.command.util.AsyncCommandHelper;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.command.parametric.ExceptionConverter; import com.sk89q.worldedit.util.command.parametric.ExceptionConverter;
import com.sk89q.worldedit.util.task.Supervisor; import com.sk89q.worldedit.util.task.Supervisor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URL; import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ActorCallbackPaste { public class ActorCallbackPaste {
private static final Logger LOGGER = Logger.getLogger(ActorCallbackPaste.class.getSimpleName()); private static final Logger LOGGER = LoggerFactory.getLogger(ActorCallbackPaste.class);
private ActorCallbackPaste() { private ActorCallbackPaste() {
} }
@ -62,7 +62,7 @@ public static void pastebin(Supervisor supervisor, final Actor sender, String co
@Override @Override
public void onFailure(Throwable throwable) { public void onFailure(Throwable throwable) {
LOGGER.log(Level.WARNING, "Failed to submit pastebin", throwable); LOGGER.warn("Failed to submit pastebin", throwable);
sender.printError("Failed to submit to a pastebin. Please see console for the error."); sender.printError("Failed to submit to a pastebin. Please see console for the error.");
} }
}); });

Datei anzeigen

@ -19,16 +19,17 @@
package com.sk89q.worldedit.util.report; package com.sk89q.worldedit.util.report;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
public class ShallowObjectReport extends DataReport { public class ShallowObjectReport extends DataReport {
private static final Logger log = Logger.getLogger(ShallowObjectReport.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(ShallowObjectReport.class);
public ShallowObjectReport(String title, Object object) { public ShallowObjectReport(String title, Object object) {
super(title); super(title);
@ -52,7 +53,7 @@ public class ShallowObjectReport extends DataReport {
Object value = field.get(object); Object value = field.get(object);
append(field.getName(), String.valueOf(value)); append(field.getName(), String.valueOf(value));
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
log.log(Level.WARNING, "Failed to get value of '" + field.getName() + "' on " + type); log.warn("Failed to get value of '" + field.getName() + "' on " + type);
} }
} }
} }

Datei anzeigen

@ -260,7 +260,7 @@ public class AnvilChunk implements Chunk {
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, data); BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, data);
if (state == null) { if (state == null) {
WorldEdit.logger.warning("Unknown legacy block " + id + ":" + data + " found when loading legacy anvil chunk."); WorldEdit.logger.warn("Unknown legacy block " + id + ":" + data + " found when loading legacy anvil chunk.");
return BlockTypes.AIR.getDefaultState().toBaseBlock(); return BlockTypes.AIR.getDefaultState().toBaseBlock();
} }
if (state.getMaterial().hasContainer()) { if (state.getMaterial().hasContainer()) {

Datei anzeigen

@ -183,7 +183,7 @@ public class OldChunk implements Chunk {
BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, dataVal); BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, dataVal);
if (state == null) { if (state == null) {
WorldEdit.logger.warning("Unknown legacy block " + id + ":" + dataVal + " found when loading legacy anvil chunk."); WorldEdit.logger.warn("Unknown legacy block " + id + ":" + dataVal + " found when loading legacy anvil chunk.");
return BlockTypes.AIR.getDefaultState().toBaseBlock(); return BlockTypes.AIR.getDefaultState().toBaseBlock();
} }
if (state.getBlockType().getMaterial().hasContainer()) { if (state.getBlockType().getMaterial().hasContainer()) {

Datei anzeigen

@ -24,7 +24,10 @@ import com.google.gson.*;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.gson.VectorAdapter; import com.sk89q.worldedit.util.gson.VectorAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.net.URL; import java.net.URL;
@ -32,10 +35,6 @@ import java.nio.charset.Charset;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
/** /**
* Provides block data based on the built-in block database that is bundled * Provides block data based on the built-in block database that is bundled
@ -50,7 +49,7 @@ import javax.annotation.Nullable;
*/ */
public class BundledBlockData { public class BundledBlockData {
private static final Logger log = Logger.getLogger(BundledBlockData.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(BundledBlockData.class);
private static BundledBlockData INSTANCE; private static BundledBlockData INSTANCE;
private final Map<String, BlockEntry> idMap = new HashMap<>(); private final Map<String, BlockEntry> idMap = new HashMap<>();
@ -62,7 +61,7 @@ public class BundledBlockData {
try { try {
loadFromResource(); loadFromResource();
} catch (Throwable e) { } catch (Throwable e) {
log.log(Level.WARNING, "Failed to load the built-in block registry", e); log.warn("Failed to load the built-in block registry", e);
} }
} }

Datei anzeigen

@ -25,17 +25,16 @@ import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.gson.VectorAdapter; import com.sk89q.worldedit.util.gson.VectorAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
/** /**
* Provides item data based on the built-in item database that is bundled * Provides item data based on the built-in item database that is bundled
@ -50,7 +49,7 @@ import javax.annotation.Nullable;
*/ */
public class BundledItemData { public class BundledItemData {
private static final Logger log = Logger.getLogger(BundledItemData.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(BundledItemData.class);
private static BundledItemData INSTANCE; private static BundledItemData INSTANCE;
private final Map<String, ItemEntry> idMap = new HashMap<>(); private final Map<String, ItemEntry> idMap = new HashMap<>();
@ -62,7 +61,7 @@ public class BundledItemData {
try { try {
loadFromResource(); loadFromResource();
} catch (Throwable e) { } catch (Throwable e) {
log.log(Level.WARNING, "Failed to load the built-in item registry", e); log.warn("Failed to load the built-in item registry", e);
} }
} }

Datei anzeigen

@ -40,22 +40,22 @@ 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.LoggerFactory;
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 java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable; import static com.google.common.base.Preconditions.checkNotNull;
public class LegacyMapper { public class LegacyMapper {
private static final Logger log = Logger.getLogger(LegacyMapper.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(LegacyMapper.class);
private static LegacyMapper INSTANCE; private static LegacyMapper INSTANCE;
private final Int2ObjectArrayMap<Integer> blockStateToLegacyId4Data = new Int2ObjectArrayMap<>(); private final Int2ObjectArrayMap<Integer> blockStateToLegacyId4Data = new Int2ObjectArrayMap<>();
@ -70,8 +70,7 @@ public class LegacyMapper {
try { try {
loadFromResource(); loadFromResource();
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); log.warn("Failed to load the built-in legacy id registry", e);
log.log(Level.WARNING, "Failed to load the built-in legacy id registry", e);
} }
} }
@ -110,7 +109,7 @@ public class LegacyMapper {
blockStateToLegacyId4Data.put(blockState.getInternalId(), (Integer) combinedId); blockStateToLegacyId4Data.put(blockState.getInternalId(), (Integer) combinedId);
blockStateToLegacyId4Data.putIfAbsent(blockState.getInternalBlockTypeId(), combinedId); blockStateToLegacyId4Data.putIfAbsent(blockState.getInternalBlockTypeId(), combinedId);
} catch (Exception e) { } catch (Exception e) {
log.fine("Unknown block: " + blockEntry.getValue()); log.warn("Unknown block: " + blockEntry.getValue());
} }
} }
for (int id = 0; id < 256; id++) { for (int id = 0; id < 256; id++) {
@ -127,7 +126,7 @@ public class LegacyMapper {
try { try {
itemMap.put(getCombinedId(itemEntry.getKey()), ItemTypes.get(itemEntry.getValue())); itemMap.put(getCombinedId(itemEntry.getKey()), ItemTypes.get(itemEntry.getValue()));
} catch (Exception e) { } catch (Exception e) {
log.fine("Unknown item: " + itemEntry.getValue()); log.warn("Unknown item: " + itemEntry.getValue());
} }
} }
} }
@ -232,7 +231,7 @@ public class LegacyMapper {
try { try {
return BlockTypes.get(plotBlock.toString()).getDefaultState().toBaseBlock(); return BlockTypes.get(plotBlock.toString()).getDefaultState().toBaseBlock();
}catch(Throwable failed) { }catch(Throwable failed) {
log.severe("Unable to convert StringPlotBlock " + plotBlock + " to BaseBlock!"); log.error("Unable to convert StringPlotBlock " + plotBlock + " to BaseBlock!");
failed.printStackTrace(); failed.printStackTrace();
return null; return null;
} }
@ -240,12 +239,12 @@ public class LegacyMapper {
try { try {
return new BaseBlock(((LegacyPlotBlock)plotBlock).getId(), ((LegacyPlotBlock)plotBlock).getData()); return new BaseBlock(((LegacyPlotBlock)plotBlock).getId(), ((LegacyPlotBlock)plotBlock).getData());
}catch(Throwable failed) { }catch(Throwable failed) {
log.severe("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!"); log.error("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!");
failed.printStackTrace(); failed.printStackTrace();
return null; return null;
} }
}else { }else {
log.severe("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!"); log.error("Unable to convert LegacyPlotBlock " + plotBlock + " to BaseBlock!");
return null; return null;
} }
} }

Datei anzeigen

@ -29,11 +29,12 @@ import com.sk89q.worldedit.world.storage.TrueZipLegacyChunkStore;
import com.sk89q.worldedit.world.storage.TrueZipMcRegionChunkStore; import com.sk89q.worldedit.world.storage.TrueZipMcRegionChunkStore;
import com.sk89q.worldedit.world.storage.ZippedLegacyChunkStore; import com.sk89q.worldedit.world.storage.ZippedLegacyChunkStore;
import com.sk89q.worldedit.world.storage.ZippedMcRegionChunkStore; import com.sk89q.worldedit.world.storage.ZippedMcRegionChunkStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Calendar; import java.util.Calendar;
import java.util.logging.Logger;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
/** /**
@ -41,7 +42,7 @@ import java.util.zip.ZipFile;
*/ */
public class Snapshot implements Comparable<Snapshot> { public class Snapshot implements Comparable<Snapshot> {
protected static Logger logger = Logger.getLogger(Snapshot.class.getCanonicalName()); protected static Logger logger = LoggerFactory.getLogger(Snapshot.class);
protected File file; protected File file;
protected String name; protected String name;

Datei anzeigen

@ -404,7 +404,6 @@
"61:11": "minecraft:furnace[facing=south,lit=false]", "61:11": "minecraft:furnace[facing=south,lit=false]",
"61:12": "minecraft:furnace[facing=west,lit=false]", "61:12": "minecraft:furnace[facing=west,lit=false]",
"61:13": "minecraft:furnace[facing=east,lit=false]", "61:13": "minecraft:furnace[facing=east,lit=false]",
"62:0": "minecraft:lit_furnace",
"62:2": "minecraft:furnace[facing=north,lit=true]", "62:2": "minecraft:furnace[facing=north,lit=true]",
"62:3": "minecraft:furnace[facing=south,lit=true]", "62:3": "minecraft:furnace[facing=south,lit=true]",
"62:4": "minecraft:furnace[facing=west,lit=true]", "62:4": "minecraft:furnace[facing=west,lit=true]",
@ -1849,7 +1848,7 @@
"48:0": "minecraft:mossy_cobblestone", "48:0": "minecraft:mossy_cobblestone",
"49:0": "minecraft:obsidian", "49:0": "minecraft:obsidian",
"50:0": "minecraft:torch", "50:0": "minecraft:torch",
"52:0": "minecraft:mob_spawner", "52:0": "minecraft:spawner",
"53:0": "minecraft:oak_stairs", "53:0": "minecraft:oak_stairs",
"54:0": "minecraft:chest", "54:0": "minecraft:chest",
"56:0": "minecraft:diamond_ore", "56:0": "minecraft:diamond_ore",

Datei anzeigen

@ -21,17 +21,21 @@ package com.sk89q.minecraft.util.commands;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.junit.Assert.*; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class CommandContextTest { public class CommandContextTest {
private static final Logger log = Logger.getLogger(CommandContextTest.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(CommandContextTest.class);
private static final String firstCmdString = "herpderp -opw testers \"mani world\" 'another thing' because something"; private static final String firstCmdString = "herpderp -opw testers \"mani world\" 'another thing' because something";
CommandContext firstCommand; CommandContext firstCommand;
@ -40,7 +44,7 @@ public class CommandContextTest {
try { try {
firstCommand = new CommandContext(firstCmdString, new HashSet<>(Arrays.asList('o', 'w'))); firstCommand = new CommandContext(firstCmdString, new HashSet<>(Arrays.asList('o', 'w')));
} catch (CommandException e) { } catch (CommandException e) {
log.log(Level.WARNING, "Error", e); log.warn("Error", e);
fail("Unexpected exception when creating CommandContext"); fail("Unexpected exception when creating CommandContext");
} }
} }
@ -79,7 +83,7 @@ public class CommandContextTest {
new CommandContext(cmd); new CommandContext(cmd);
new CommandContext(cmd2); new CommandContext(cmd2);
} catch (CommandException e) { } catch (CommandException e) {
log.log(Level.WARNING, "Error", e); log.warn("Error", e);
fail("Error creating CommandContext"); fail("Error creating CommandContext");
} }
} }
@ -90,7 +94,7 @@ public class CommandContextTest {
try { try {
new CommandContext(cmd); new CommandContext(cmd);
} catch (CommandException e) { } catch (CommandException e) {
log.log(Level.WARNING, "Error", e); log.warn("Error", e);
fail("Error creating CommandContext"); fail("Error creating CommandContext");
} }
} }
@ -101,7 +105,7 @@ public class CommandContextTest {
try { try {
new CommandContext(cmd); new CommandContext(cmd);
} catch (CommandException e) { } catch (CommandException e) {
log.log(Level.WARNING, "Error", e); log.warn("Error", e);
fail("Error creating CommandContext"); fail("Error creating CommandContext");
} }
} }
@ -115,7 +119,7 @@ public class CommandContextTest {
CommandContext context2 = new CommandContext("r hello -f world"); CommandContext context2 = new CommandContext("r hello -f world");
assertTrue(context2.hasFlag('f')); assertTrue(context2.hasFlag('f'));
} catch (CommandException e) { } catch (CommandException e) {
log.log(Level.WARNING, "Error", e); log.warn("Error", e);
fail("Error creating CommandContext"); fail("Error creating CommandContext");
} }
} }
@ -131,7 +135,7 @@ public class CommandContextTest {
CommandContext context2 = new CommandContext("pm name \"hello world\" foo bar"); CommandContext context2 = new CommandContext("pm name \"hello world\" foo bar");
assertEquals("\"hello world\" foo bar", context2.getJoinedStrings(1)); assertEquals("\"hello world\" foo bar", context2.getJoinedStrings(1));
} catch (CommandException e) { } catch (CommandException e) {
log.log(Level.WARNING, "Error", e); log.warn("Error", e);
fail("Error creating CommandContext"); fail("Error creating CommandContext");
} }
} }
@ -143,7 +147,7 @@ public class CommandContextTest {
assertArrayEquals(new String[] { "foo", "bar", "baz" }, context.getSlice(0)); assertArrayEquals(new String[] { "foo", "bar", "baz" }, context.getSlice(0));
} catch (CommandException e) { } catch (CommandException e) {
log.log(Level.WARNING, "Error", e); log.warn("Error", e);
fail("Error creating CommandContext"); fail("Error creating CommandContext");
} }
} }
@ -154,7 +158,7 @@ public class CommandContextTest {
CommandContext context = new CommandContext("region flag xmas blocked-cmds \"\""); CommandContext context = new CommandContext("region flag xmas blocked-cmds \"\"");
assertEquals(context.argsLength(), 3); assertEquals(context.argsLength(), 3);
} catch (CommandException e) { } catch (CommandException e) {
log.log(Level.WARNING, "Error", e); log.warn("Error", e);
fail("Error creating CommandContext"); fail("Error creating CommandContext");
} }
} }

Datei anzeigen

@ -16,6 +16,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
dependencies { dependencies {
compile project(':worldedit-core') compile project(':worldedit-core')
compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.11.2'
compile 'org.spongepowered:spongeapi:6.0.0-SNAPSHOT' compile 'org.spongepowered:spongeapi:6.0.0-SNAPSHOT'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.0-rc1' testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.0-rc1'
} }

Datei anzeigen

@ -21,6 +21,8 @@ package com.sk89q.worldedit.sponge.adapter;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.sk89q.worldedit.util.io.Closer; import com.sk89q.worldedit.util.io.Closer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -30,15 +32,13 @@ import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Loads Sponge implementation adapters. * Loads Sponge implementation adapters.
*/ */
public class SpongeImplLoader { public class SpongeImplLoader {
private static final Logger log = Logger.getLogger(SpongeImplLoader.class.getCanonicalName()); private static final Logger log = LoggerFactory.getLogger(SpongeImplLoader.class);
private final List<String> adapterCandidates = new ArrayList<>(); private final List<String> adapterCandidates = new ArrayList<>();
private String customCandidate; private String customCandidate;
@ -71,7 +71,7 @@ public class SpongeImplLoader {
if (className != null) { if (className != null) {
customCandidate = className; customCandidate = className;
adapterCandidates.add(className); adapterCandidates.add(className);
log.log(Level.INFO, "-Dworldedit.sponge.adapter used to add " + className + " to the list of available Sponge adapters"); log.info("-Dworldedit.sponge.adapter used to add " + className + " to the list of available Sponge adapters");
} }
} }
@ -157,18 +157,18 @@ public class SpongeImplLoader {
if (SpongeImplAdapter.class.isAssignableFrom(cls)) { if (SpongeImplAdapter.class.isAssignableFrom(cls)) {
suitableAdapters.add((SpongeImplAdapter) cls.newInstance()); suitableAdapters.add((SpongeImplAdapter) cls.newInstance());
} else { } else {
log.log(Level.WARNING, "Failed to load the Sponge adapter class '" + className + log.warn("Failed to load the Sponge adapter class '" + className +
"' because it does not implement " + SpongeImplAdapter.class.getCanonicalName()); "' because it does not implement " + SpongeImplAdapter.class.getCanonicalName());
} }
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
log.log(Level.WARNING, "Failed to load the Sponge adapter class '" + className + log.warn("Failed to load the Sponge adapter class '" + className +
"' that is not supposed to be missing", e); "' that is not supposed to be missing", e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
log.log(Level.WARNING, "Failed to load the Sponge adapter class '" + className + log.warn("Failed to load the Sponge adapter class '" + className +
"' that is not supposed to be raising this error", e); "' that is not supposed to be raising this error", e);
} catch (Throwable e) { } catch (Throwable e) {
if (className.equals(customCandidate)) { if (className.equals(customCandidate)) {
log.log(Level.WARNING, "Failed to load the Sponge adapter class '" + className + "'", e); log.warn("Failed to load the Sponge adapter class '" + className + "'", e);
} }
} }
} }