Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-06 16:12:51 +02:00
Moved report framework to WorldEdit and fixed a few bugs.
Dieser Commit ist enthalten in:
Ursprung
96388df4b0
Commit
c31161d068
@ -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;
|
||||
|
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.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<Line> 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<Object> seen) {
|
||||
if (seen.contains(value)) {
|
||||
return "<Recursive>";
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.report;
|
||||
|
||||
public interface Report {
|
||||
|
||||
String getTitle();
|
||||
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.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<Report> {
|
||||
|
||||
private final String title;
|
||||
private final List<Report> 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<Report> iterator() {
|
||||
return reports.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return reports.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> 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<? extends Report> c) {
|
||||
return reports.addAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends Report> 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<Report> listIterator() {
|
||||
return reports.listIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<Report> listIterator(int index) {
|
||||
return reports.listIterator(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Report> 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.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.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.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.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<GarbageCollectorMXBean> 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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.util.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 {
|
||||
}
|
@ -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;
|
||||
|
@ -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.
|
||||
*
|
||||
* <p>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.</p>
|
||||
*
|
||||
* <p>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.</p>
|
||||
*/
|
||||
public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
|
||||
@ -73,15 +68,6 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, 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<BaseBlock>, TileEntityBlock {
|
||||
|
||||
@Override
|
||||
public <V> BaseBlock with(Property<V> property, V value) {
|
||||
return new BaseBlock(this.blockState.with(property, value), getNbtData());
|
||||
return this.blockState.with(property, value).toBaseBlock(getNbtData());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren