From c31161d0686855262550e5dad615975a718edad7 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Wed, 15 Aug 2018 12:45:18 +1000 Subject: [PATCH] Moved report framework to WorldEdit and fixed a few bugs. --- .../sk89q/worldedit/bukkit/BukkitWorld.java | 2 +- .../worldedit/util/report/DataReport.java | 177 +++++++++++++++++ .../sk89q/worldedit/util/report/Report.java | 26 +++ .../worldedit/util/report/ReportList.java | 186 ++++++++++++++++++ .../util/report/ShallowObjectReport.java | 58 ++++++ .../util/report/StackTraceReport.java | 64 ++++++ .../util/report/SystemInfoReport.java | 91 +++++++++ .../worldedit/util/report/Unreported.java | 33 ++++ .../com/sk89q/worldedit/world/NullWorld.java | 2 +- .../worldedit/world/block/BaseBlock.java | 18 +- .../com/sk89q/worldedit/forge/ForgeWorld.java | 1 + 11 files changed, 640 insertions(+), 18 deletions(-) create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/util/report/DataReport.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/util/report/Report.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ReportList.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ShallowObjectReport.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/util/report/StackTraceReport.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/util/report/SystemInfoReport.java create mode 100644 worldedit-core/src/main/java/com/sk89q/worldedit/util/report/Unreported.java diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java index c0d16dddb..d8956542d 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java @@ -27,7 +27,6 @@ import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.entity.BaseEntity; @@ -36,6 +35,7 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.world.AbstractWorld; import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherTypes; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/DataReport.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/DataReport.java new file mode 100644 index 000000000..93dc8a90c --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/DataReport.java @@ -0,0 +1,177 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.util.report; + +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; + +import java.util.*; + +import static com.google.common.base.Preconditions.checkNotNull; + +public class DataReport implements Report { + + private final String title; + private final List lines = Lists.newArrayList(); + + public DataReport(String title) { + checkNotNull(title, "title"); + this.title = title; + } + + public void append(String key, String message) { + checkNotNull(key, "key"); + lines.add(new Line(key, message)); + } + + public void append(String key, String message, Object... values) { + checkNotNull(message, "values"); + checkNotNull(values, "values"); + append(key, String.format(message, values)); + } + + public void append(String key, byte value) { + append(key, String.valueOf(value)); + } + + public void append(String key, short value) { + append(key, String.valueOf(value)); + } + + public void append(String key, int value) { + append(key, String.valueOf(value)); + } + + public void append(String key, long value) { + append(key, String.valueOf(value)); + } + + public void append(String key, float value) { + append(key, String.valueOf(value)); + } + + public void append(String key, double value) { + append(key, String.valueOf(value)); + } + + public void append(String key, boolean value) { + append(key, String.valueOf(value)); + } + + public void append(String key, char value) { + append(key, String.valueOf(value)); + } + + public void append(String key, Object value) { + append(key, getStringValue(value, Sets.newHashSet())); + } + + private static String getStringValue(Object value, Set seen) { + if (seen.contains(value)) { + return ""; + } else { + seen.add(value); + } + + if (value instanceof Object[]) { + value = Arrays.asList(value); + } + + if (value instanceof Collection) { + StringBuilder builder = new StringBuilder(); + boolean first = true; + for (Object entry : (Collection) value) { + if (first) { + first = false; + } else { + builder.append("\n"); + } + builder.append(getStringValue(entry, Sets.newHashSet(seen))); + } + return builder.toString(); + } else if (value instanceof Map) { + StringBuilder builder = new StringBuilder(); + boolean first = true; + for (Map.Entry entry : ((Map) value).entrySet()) { + if (first) { + first = false; + } else { + builder.append("\n"); + } + + String key = getStringValue(entry.getKey(), Sets.newHashSet(seen)).replaceAll("[\r\n]", ""); + if (key.length() > 60) { + key = key.substring(0, 60) + "..."; + } + + builder + .append(key) + .append(": ") + .append(getStringValue(entry.getValue(), Sets.newHashSet(seen))); + } + return builder.toString(); + } else { + return String.valueOf(value); + } + } + + @Override + public String getTitle() { + return title; + } + + @Override + public String toString() { + if (!lines.isEmpty()) { + StringBuilder builder = new StringBuilder(); + boolean first = true; + for (Line line : lines) { + if (first) { + first = false; + } else { + builder.append("\n"); + } + builder.append(line.key).append(": "); + if (line.value == null) { + builder.append("null"); + } else if (line.value.contains("\n")) { + builder.append("\n"); + builder.append(line.value.replaceAll("(?m)^", "\t")); + } else { + builder.append(line.value); + } + } + return builder.toString(); + } else { + return "No data."; + } + } + + private static class Line { + private final String key; + private final String value; + + public Line(String key, String value) { + this.key = key; + this.value = value; + } + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/Report.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/Report.java new file mode 100644 index 000000000..877bf2b83 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/Report.java @@ -0,0 +1,26 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.util.report; + +public interface Report { + + String getTitle(); + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ReportList.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ReportList.java new file mode 100644 index 000000000..25128375b --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ReportList.java @@ -0,0 +1,186 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.util.report; + +import com.google.common.collect.Lists; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +public class ReportList implements Report, List { + + private final String title; + private final List reports = Lists.newArrayList(); + + public ReportList(String title) { + this.title = title; + } + + @Override + public String getTitle() { + return title; + } + + @Override + public int size() { + return reports.size(); + } + + @Override + public boolean isEmpty() { + return reports.isEmpty(); + } + + @Override + public boolean contains(Object o) { + return reports.contains(o); + } + + @Override + public Iterator iterator() { + return reports.iterator(); + } + + @Override + public Object[] toArray() { + return reports.toArray(); + } + + @Override + public T[] toArray(T[] a) { + return reports.toArray(a); + } + + @Override + public boolean add(Report report) { + return reports.add(report); + } + + @Override + public boolean remove(Object o) { + return reports.remove(o); + } + + @Override + public boolean containsAll(Collection c) { + return reports.containsAll(c); + } + + @Override + public boolean addAll(Collection c) { + return reports.addAll(c); + } + + @Override + public boolean addAll(int index, Collection c) { + return reports.addAll(index, c); + } + + @Override + public boolean removeAll(Collection c) { + return reports.removeAll(c); + } + + @Override + public boolean retainAll(Collection c) { + return reports.retainAll(c); + } + + @Override + public void clear() { + reports.clear(); + } + + @Override + public boolean equals(Object o) { + return reports.equals(o); + } + + @Override + public int hashCode() { + return reports.hashCode(); + } + + @Override + public Report get(int index) { + return reports.get(index); + } + + @Override + public Report set(int index, Report element) { + return reports.set(index, element); + } + + @Override + public void add(int index, Report element) { + reports.add(index, element); + } + + @Override + public Report remove(int index) { + return reports.remove(index); + } + + @Override + public int indexOf(Object o) { + return reports.indexOf(o); + } + + @Override + public int lastIndexOf(Object o) { + return reports.lastIndexOf(o); + } + + @Override + public ListIterator listIterator() { + return reports.listIterator(); + } + + @Override + public ListIterator listIterator(int index) { + return reports.listIterator(index); + } + + @Override + public List subList(int fromIndex, int toIndex) { + return reports.subList(fromIndex, toIndex); + } + + @Override + public String toString() { + if (!reports.isEmpty()) { + StringBuilder builder = new StringBuilder(); + for (Report report : reports) { + builder.append("================================\n") + .append(report.getTitle()) + .append("\n================================") + .append("\n\n") + .append(report.toString()) + .append("\n\n"); + } + return builder.toString(); + } else { + return "No reports."; + } + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ShallowObjectReport.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ShallowObjectReport.java new file mode 100644 index 000000000..b94b63e65 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/ShallowObjectReport.java @@ -0,0 +1,58 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.util.report; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static com.google.common.base.Preconditions.checkNotNull; + +public class ShallowObjectReport extends DataReport { + + private static final Logger log = Logger.getLogger(ShallowObjectReport.class.getCanonicalName()); + + public ShallowObjectReport(String title, Object object) { + super(title); + checkNotNull(object, "object"); + + Class type = object.getClass(); + + for (Field field : type.getDeclaredFields()) { + if (Modifier.isStatic(field.getModifiers())) { + continue; + } + + if (field.getAnnotation(Unreported.class) != null) { + continue; + } + + field.setAccessible(true); + try { + Object value = field.get(object); + append(field.getName(), String.valueOf(value)); + } catch (IllegalAccessException e) { + log.log(Level.WARNING, "Failed to get value of '" + field.getName() + "' on " + type); + } + } + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/StackTraceReport.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/StackTraceReport.java new file mode 100644 index 000000000..224a87e70 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/StackTraceReport.java @@ -0,0 +1,64 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.util.report; + +import static com.google.common.base.Preconditions.checkNotNull; + +public class StackTraceReport implements Report { + + private final StackTraceElement[] stackTrace; + + public StackTraceReport(StackTraceElement[] stackTrace) { + checkNotNull(stackTrace, "stackTrace"); + this.stackTrace = stackTrace; + } + + @Override + public String getTitle() { + return "Stack Trace"; + } + + @Override + public String toString() { + if (stackTrace.length > 0) { + StringBuilder builder = new StringBuilder(); + boolean first = true; + for (StackTraceElement element : stackTrace) { + if (first) { + first = false; + } else { + builder.append("\n"); + } + builder.append(element.getClassName()) + .append(".") + .append(element.getMethodName()) + .append("() (") + .append(element.getFileName()) + .append(":") + .append(element.getLineNumber()) + .append(")"); + } + return builder.toString(); + } else { + return "No stack trace available."; + } + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/SystemInfoReport.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/SystemInfoReport.java new file mode 100644 index 000000000..91f14c2fd --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/SystemInfoReport.java @@ -0,0 +1,91 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.util.report; + +import java.lang.management.*; +import java.util.List; +import java.util.concurrent.TimeUnit; + +public class SystemInfoReport extends DataReport { + + public SystemInfoReport() { + super("System Information"); + + Runtime runtime = Runtime.getRuntime(); + RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); + ClassLoadingMXBean classLoadingBean = ManagementFactory.getClassLoadingMXBean(); + List gcBeans = ManagementFactory.getGarbageCollectorMXBeans(); + OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean(); + ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); + + append("Java", "%s %s (%s)", + System.getProperty("java.vendor"), + System.getProperty("java.version"), + System.getProperty("java.vendor.url")); + append("Operating System", "%s %s (%s)", + System.getProperty("os.name"), + System.getProperty("os.version"), + System.getProperty("os.arch")); + append("Available Processors", runtime.availableProcessors()); + append("Free Memory", runtime.freeMemory() / 1024 / 1024 + " MB"); + append("Max Memory", runtime.maxMemory() / 1024 / 1024 + " MB"); + append("Total Memory", runtime.totalMemory() / 1024 / 1024 + " MB"); + append("System Load Average", osBean.getSystemLoadAverage()); + append("Java Uptime", TimeUnit.MINUTES.convert(runtimeBean.getUptime(), TimeUnit.MILLISECONDS) + " minutes"); + + DataReport startup = new DataReport("Startup"); + startup.append("Input Arguments", runtimeBean.getInputArguments()); + append(startup.getTitle(), startup); + + DataReport vm = new DataReport("Virtual Machine"); + vm.append("Name", runtimeBean.getVmName()); + vm.append("Vendor", runtimeBean.getVmVendor()); + vm.append("Version", runtimeBean.getVmVendor()); + append(vm.getTitle(), vm); + + DataReport spec = new DataReport("Specification"); + spec.append("Name", runtimeBean.getSpecName()); + spec.append("Vendor", runtimeBean.getSpecVendor()); + spec.append("Version", runtimeBean.getSpecVersion()); + append(spec.getTitle(), spec); + + DataReport classLoader = new DataReport("Class Loader"); + classLoader.append("Loaded Class Count", classLoadingBean.getLoadedClassCount()); + classLoader.append("Total Loaded Class Count", classLoadingBean.getTotalLoadedClassCount()); + classLoader.append("Unloaded Class Count", classLoadingBean.getUnloadedClassCount()); + append(classLoader.getTitle(), classLoader); + + DataReport gc = new DataReport("Garbage Collectors"); + for (GarbageCollectorMXBean bean : gcBeans) { + DataReport thisGC = new DataReport(bean.getName()); + thisGC.append("Collection Count", bean.getCollectionCount()); + thisGC.append("Collection Time", bean.getCollectionTime() + "ms"); + gc.append(thisGC.getTitle(), thisGC); + } + append(gc.getTitle(), gc); + + DataReport threads = new DataReport("Threads"); + for (ThreadInfo threadInfo : threadBean.dumpAllThreads(false, false)) { + threads.append("#" + threadInfo.getThreadId() + " " + threadInfo.getThreadName(), threadInfo.getThreadState()); + } + append(threads.getTitle(), threads); + } + +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/Unreported.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/Unreported.java new file mode 100644 index 000000000..c10161932 --- /dev/null +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/report/Unreported.java @@ -0,0 +1,33 @@ +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * Copyright (C) WorldEdit team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldedit.util.report; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotates properties that should not be exposed in the report. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface Unreported { +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java index 8161957e8..4542d19e2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java @@ -24,7 +24,6 @@ import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.Entity; @@ -32,6 +31,7 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.world.biome.BaseBiome; +import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java index 58d8d1235..ed9261e64 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java @@ -34,18 +34,13 @@ import java.util.Objects; import javax.annotation.Nullable; /** - * Represents a mutable "snapshot" of a block. + * Represents a "snapshot" of a block with NBT Data. * *

An instance of this block contains all the information needed to * accurately reproduce the block, provided that the instance was * made correctly. In some implementations, it may not be possible to get a * snapshot of blocks correctly, so, for example, the NBT data for a block * may be missing.

- * - *

A peculiar detail of this class is that it accepts {@code -1} as a - * valid data value. This is due to legacy reasons: WorldEdit uses -1 - * as a "wildcard" block value, even though a {@link Mask} would be - * more appropriate.

*/ public class BaseBlock implements BlockStateHolder, TileEntityBlock { @@ -73,15 +68,6 @@ public class BaseBlock implements BlockStateHolder, TileEntityBlock { this.nbtData = nbtData; } - /** - * Create a clone of another block. - * - * @param other the other block - */ - public BaseBlock(BaseBlock other) { - this(other.toImmutableState(), other.getNbtData()); - } - /** * Gets a map of state to statevalue * @@ -99,7 +85,7 @@ public class BaseBlock implements BlockStateHolder, TileEntityBlock { @Override public BaseBlock with(Property property, V value) { - return new BaseBlock(this.blockState.with(property, value), getNbtData()); + return this.blockState.with(property, value).toBaseBlock(getNbtData()); } /** diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java index b7bf6cd76..e5cbcaf4d 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java @@ -93,6 +93,7 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.UUID; import javax.annotation.Nullable;