Merge branch 'IntellectualSites:main' into main

This commit is contained in:
2024-05-20 10:40:17 -05:00
committed by GitHub
64 changed files with 1888 additions and 1457 deletions

View File

@ -1,16 +1,12 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.8.20"
kotlin("jvm") version "1.9.23"
application
}
applyCommonConfiguration()
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}
application.mainClass.set("com.sk89q.worldedit.internal.util.DocumentationPrinter")
tasks.named<JavaExec>("run") {
workingDir = rootProject.projectDir

View File

@ -2,6 +2,7 @@ package com.fastasyncworldedit.core.configuration;
import com.fastasyncworldedit.core.configuration.file.YamlConfiguration;
import com.fastasyncworldedit.core.util.StringMan;
import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.internal.util.LogManagerCompat;
import org.apache.logging.log4j.Logger;
@ -14,8 +15,10 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
@ -27,6 +30,9 @@ public class Config {
private static final Logger LOGGER = LogManagerCompat.getLogger();
private final Map<String, Object> removedKeyVals = new HashMap<>();
private List<String> existingMigrateNodes = null;
public Config() {
save(new PrintWriter(new ByteArrayOutputStream(0)), getClass(), this, 0);
}
@ -43,7 +49,8 @@ public class Config {
try {
return (T) field.get(instance);
} catch (IllegalAccessException e) {
e.printStackTrace();
LOGGER.error("Failed to get config option: {}", key, e);
return null;
}
}
}
@ -67,6 +74,10 @@ public class Config {
if (field.getAnnotation(Final.class) != null) {
return;
}
Migrate migrate = field.getAnnotation(Migrate.class);
if (existingMigrateNodes != null && migrate != null) {
existingMigrateNodes.add(migrate.value());
}
if (field.getType() == String.class && !(value instanceof String)) {
value = value + "";
}
@ -74,17 +85,22 @@ public class Config {
field.set(instance, value);
return;
} catch (Throwable e) {
e.printStackTrace();
LOGGER.error("Failed to set config option: {}", key);
}
}
}
LOGGER.error("Failed to set config option: {}: {} | {} | {}.yml", key, value, instance, root.getSimpleName());
removedKeyVals.put(key, value);
LOGGER.error(
"Failed to set config option: {}: {} | {} | {}.yml. This is likely because it was removed.",
key,
value,
instance,
root.getSimpleName()
);
}
public boolean load(File file) {
if (!file.exists()) {
return false;
}
existingMigrateNodes = new ArrayList<>();
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
for (String key : yml.getKeys(true)) {
Object value = yml.get(key);
@ -93,6 +109,10 @@ public class Config {
}
set(key, value, getClass());
}
for (String node : existingMigrateNodes) {
removedKeyVals.remove(node);
}
existingMigrateNodes = null;
return true;
}
@ -113,7 +133,7 @@ public class Config {
save(writer, getClass(), instance, 0);
writer.close();
} catch (Throwable e) {
e.printStackTrace();
LOGGER.error("Failed to save config file: {}", file, e);
}
}
@ -166,6 +186,19 @@ public class Config {
}
/**
* Indicates that a field should be instantiated / created.
*
* @since 2.10.0
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface Migrate {
String value();
}
@Ignore // This is not part of the config
public static class ConfigBlock<T> {
@ -222,7 +255,6 @@ public class Config {
try {
String CTRF = System.lineSeparator();
String spacing = StringMan.repeat(" ", indent);
HashMap<Class<?>, Object> instances = new HashMap<>();
for (Field field : clazz.getFields()) {
if (field.getAnnotation(Ignore.class) != null) {
continue;
@ -239,31 +271,14 @@ public class Config {
}
if (current == ConfigBlock.class) {
current = (Class<?>) ((ParameterizedType) (field.getGenericType())).getActualTypeArguments()[0];
comment = current.getAnnotation(Comment.class);
if (comment != null) {
for (String commentLine : comment.value()) {
writer.write(spacing + "# " + commentLine + CTRF);
}
}
BlockName blockNames = current.getAnnotation(BlockName.class);
if (blockNames != null) {
writer.write(spacing + toNodeName(current.getSimpleName()) + ":" + CTRF);
ConfigBlock configBlock = (ConfigBlock) field.get(instance);
if (configBlock == null || configBlock.getInstances().isEmpty()) {
configBlock = new ConfigBlock();
field.set(instance, configBlock);
for (String blockName : blockNames.value()) {
configBlock.put(blockName, current.getDeclaredConstructor().newInstance());
}
}
// Save each instance
for (Map.Entry<String, Object> entry : ((Map<String, Object>) configBlock.getRaw()).entrySet()) {
String key = entry.getKey();
writer.write(spacing + " " + toNodeName(key) + ":" + CTRF);
save(writer, current, entry.getValue(), indent + 4);
}
}
handleConfigBlockSave(writer, instance, indent, field, spacing, CTRF, current);
continue;
} else if (!removedKeyVals.isEmpty()) {
Migrate migrate = field.getAnnotation(Migrate.class);
Object value;
if (migrate != null && (value = removedKeyVals.remove(migrate.value())) != null) {
field.set(instance, value);
}
}
Create create = field.getAnnotation(Create.class);
if (create != null) {
@ -281,7 +296,6 @@ public class Config {
writer.write(spacing + toNodeName(current.getSimpleName()) + ":" + CTRF);
if (value == null) {
field.set(instance, value = current.getDeclaredConstructor().newInstance());
instances.put(current, value);
}
save(writer, current, value, indent + 2);
} else {
@ -292,7 +306,42 @@ public class Config {
}
}
} catch (Throwable e) {
e.printStackTrace();
LOGGER.error("Failed to save config file", e);
}
}
private <T> void handleConfigBlockSave(
PrintWriter writer,
Object instance,
int indent,
Field field,
String spacing,
String CTRF,
Class<T> current
) throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException {
Comment comment = current.getAnnotation(Comment.class);
if (comment != null) {
for (String commentLine : comment.value()) {
writer.write(spacing + "# " + commentLine + CTRF);
}
}
BlockName blockNames = current.getAnnotation(BlockName.class);
if (blockNames != null) {
writer.write(spacing + toNodeName(current.getSimpleName()) + ":" + CTRF);
ConfigBlock<T> configBlock = (ConfigBlock<T>) field.get(instance);
if (configBlock == null || configBlock.getInstances().isEmpty()) {
configBlock = new ConfigBlock<>();
field.set(instance, configBlock);
for (String blockName : blockNames.value()) {
configBlock.put(blockName, current.getDeclaredConstructor().newInstance());
}
}
// Save each instance
for (Map.Entry<String, T> entry : configBlock.getRaw().entrySet()) {
String key = entry.getKey();
writer.write(spacing + " " + toNodeName(key) + ":" + CTRF);
save(writer, current, entry.getValue(), indent + 4);
}
}
}
@ -311,7 +360,7 @@ public class Config {
return field;
} catch (Throwable ignored) {
LOGGER.warn(
"Invalid config field: {} for {}",
"Invalid config field: {} for {}. It is possible this is because it has been removed.",
StringMan.join(split, "."),
toNodeName(instance.getClass().getSimpleName())
);
@ -379,7 +428,7 @@ public class Config {
return null;
}
} catch (Throwable e) {
e.printStackTrace();
LOGGER.error("Failed retrieving instance for config node: {}", StringUtil.joinString(split, "."), e);
}
return null;
}

View File

@ -79,6 +79,8 @@ public class Settings extends Config {
@Create
public REGION_RESTRICTIONS_OPTIONS REGION_RESTRICTIONS_OPTIONS;
@Create
public GENERAL GENERAL;
@Create
public ConfigBlock<LIMITS> LIMITS;
private Settings() {
@ -145,6 +147,14 @@ public class Settings extends Config {
limit.MAX_HISTORY,
newLimit.MAX_HISTORY_MB != -1 ? newLimit.MAX_HISTORY_MB : Integer.MAX_VALUE
);
limit.SCHEM_FILE_NUM_LIMIT = Math.max(
limit.SCHEM_FILE_NUM_LIMIT,
newLimit.SCHEM_FILE_NUM_LIMIT != -1 ? newLimit.SCHEM_FILE_NUM_LIMIT : Integer.MAX_VALUE
);
limit.SCHEM_FILE_SIZE_LIMIT = Math.max(
limit.SCHEM_FILE_SIZE_LIMIT,
newLimit.SCHEM_FILE_SIZE_LIMIT != -1 ? newLimit.SCHEM_FILE_SIZE_LIMIT : Integer.MAX_VALUE
);
limit.MAX_EXPRESSION_MS = Math.max(
limit.MAX_EXPRESSION_MS,
newLimit.MAX_EXPRESSION_MS != -1 ? newLimit.MAX_EXPRESSION_MS : Integer.MAX_VALUE
@ -353,6 +363,18 @@ public class Settings extends Config {
" - History on disk or memory will be deleted",
})
public int MAX_HISTORY_MB = -1;
@Comment({
"Sets a maximum limit (in kb) for the size of a player's schematics directory (per-player mode only)",
"Set to -1 to disable"
})
@Migrate("experimental.per-player-file-size-limit")
public int SCHEM_FILE_SIZE_LIMIT = -1;
@Comment({
"Sets a maximum limit for the amount of schematics in a player's schematics directory (per-player mode only)",
"Set to -1 to disable"
})
@Migrate("experimental.per-player-file-num-limit")
public int SCHEM_FILE_NUM_LIMIT = -1;
@Comment("Maximum time in milliseconds //calc can execute")
public int MAX_EXPRESSION_MS = 50;
@Comment({
@ -615,18 +637,6 @@ public class Settings extends Config {
})
public boolean ALLOW_TICK_FLUIDS = false;
@Comment({
"Sets a maximum limit (in kb) for the size of a player's schematics directory (per-player mode only)",
"Set to -1 to disable"
})
public int PER_PLAYER_FILE_SIZE_LIMIT = -1;
@Comment({
"Sets a maximum limit for the amount of schematics in a player's schematics directory (per-player mode only)",
"Set to -1 to disable"
})
public int PER_PLAYER_FILE_NUM_LIMIT = -1;
}
@Comment({"Web/HTTP connection related settings"})
@ -744,4 +754,13 @@ public class Settings extends Config {
}
public static class GENERAL {
@Comment({
"If the player should be relocated/unstuck when a generation command would bury them",
})
public boolean UNSTUCK_ON_GENERATE = true;
}
}

View File

@ -15,6 +15,8 @@ public class FaweLimit {
public int MAX_BLOCKSTATES = 0;
public int MAX_ENTITIES = 0;
public int MAX_HISTORY = 0;
public int SCHEM_FILE_SIZE_LIMIT = 0;
public int SCHEM_FILE_NUM_LIMIT = 0;
public int MAX_EXPRESSION_MS = 0;
public int INVENTORY_MODE = Integer.MAX_VALUE;
public int SPEED_REDUCTION = Integer.MAX_VALUE;
@ -111,6 +113,8 @@ public class FaweLimit {
MAX.MAX_BLOCKSTATES = Integer.MAX_VALUE;
MAX.MAX_ENTITIES = Integer.MAX_VALUE;
MAX.MAX_HISTORY = Integer.MAX_VALUE;
MAX.SCHEM_FILE_NUM_LIMIT = Integer.MAX_VALUE;
MAX.SCHEM_FILE_SIZE_LIMIT = Integer.MAX_VALUE;
MAX.MAX_EXPRESSION_MS = 50;
MAX.FAST_PLACEMENT = true;
MAX.CONFIRM_LARGE = true;
@ -237,6 +241,8 @@ public class FaweLimit {
&& MAX_BLOCKSTATES == Integer.MAX_VALUE
&& MAX_ENTITIES == Integer.MAX_VALUE
&& MAX_HISTORY == Integer.MAX_VALUE
&& SCHEM_FILE_SIZE_LIMIT == Integer.MAX_VALUE
&& SCHEM_FILE_NUM_LIMIT == Integer.MAX_VALUE
&& INVENTORY_MODE == 0
&& SPEED_REDUCTION == 0
&& FAST_PLACEMENT
@ -256,6 +262,8 @@ public class FaweLimit {
MAX_FAILS = limit.MAX_FAILS;
MAX_ITERATIONS = limit.MAX_ITERATIONS;
MAX_HISTORY = limit.MAX_HISTORY;
SCHEM_FILE_NUM_LIMIT = limit.SCHEM_FILE_NUM_LIMIT;
SCHEM_FILE_SIZE_LIMIT = limit.SCHEM_FILE_SIZE_LIMIT;
INVENTORY_MODE = limit.INVENTORY_MODE;
SPEED_REDUCTION = limit.SPEED_REDUCTION;
FAST_PLACEMENT = limit.FAST_PLACEMENT;
@ -279,6 +287,8 @@ public class FaweLimit {
limit.MAX_FAILS = MAX_FAILS;
limit.MAX_ITERATIONS = MAX_ITERATIONS;
limit.MAX_HISTORY = MAX_HISTORY;
limit.SCHEM_FILE_SIZE_LIMIT = SCHEM_FILE_SIZE_LIMIT;
limit.SCHEM_FILE_NUM_LIMIT = SCHEM_FILE_NUM_LIMIT;
limit.FAST_PLACEMENT = FAST_PLACEMENT;
limit.CONFIRM_LARGE = CONFIRM_LARGE;
limit.RESTRICT_HISTORY_TO_REGIONS = RESTRICT_HISTORY_TO_REGIONS;

View File

@ -23,7 +23,7 @@ import javax.annotation.Nullable;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URI;
import java.util.function.Supplier;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@ -73,8 +73,7 @@ public class WorldEditManifest {
}
try {
URL url = new URL(classPath);
JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
JarURLConnection jarConnection = (JarURLConnection) URI.create(classPath).toURL().openConnection();
Manifest manifest = jarConnection.getManifest();
return manifest.getMainAttributes();
} catch (IOException e) {

View File

@ -184,6 +184,9 @@ public class GenerationCommands {
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow);
if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
((Player) actor).findFreePosition();
}
actor.print(Caption.of("worldedit.cyl.created", TextComponent.of(affected)));
return affected;
}
@ -227,6 +230,9 @@ public class GenerationCommands {
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makeCone(pos, pattern, radiusX, radiusZ, height, !hollow, thickness);
if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
((Player) actor).findFreePosition();
}
actor.printInfo(Caption.of("worldedit.cone.created", TextComponent.of(affected)));
return affected;
}
@ -293,7 +299,7 @@ public class GenerationCommands {
}
int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow);
if (actor instanceof Player) {
if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
((Player) actor).findFreePosition();
}
actor.print(Caption.of("worldedit.sphere.created", TextComponent.of(affected)));
@ -379,7 +385,7 @@ public class GenerationCommands {
worldEdit.checkMaxRadius(size);
BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
if (actor instanceof Player) {
if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
((Player) actor).findFreePosition();
}
actor.print(Caption.of("worldedit.pyramid.created", TextComponent.of(affected)));
@ -457,7 +463,7 @@ public class GenerationCommands {
hollow,
session.getTimeout()
);
if (actor instanceof Player) {
if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
((Player) actor).findFreePosition();
}
actor.print(Caption.of("worldedit.generate.created", TextComponent.of(affected)));
@ -741,7 +747,7 @@ public class GenerationCommands {
radius.divide(max),
sphericity / 100
);
if (actor instanceof Player) {
if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
((Player) actor).findFreePosition();
}
actor.print(Caption.of("worldedit.sphere.created", TextComponent.of(affected)));

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.FaweCache;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode;
import com.fastasyncworldedit.core.limit.FaweLimit;
import com.fastasyncworldedit.core.util.MaskTraverser;
@ -715,6 +716,9 @@ public class RegionCommands {
session.setSourceMask(mask);
//FAWE end
}
if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
((Player) actor).findFreePosition();
}
if (success) {
actor.print(Caption.of("worldedit.regen.regenerated"));
} else {
@ -788,7 +792,7 @@ public class RegionCommands {
String.join(" ", expression),
session.getTimeout()
);
if (actor instanceof Player) {
if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
((Player) actor).findFreePosition();
}
actor.print(Caption.of("worldedit.deform.deformed", TextComponent.of(affected)));

View File

@ -26,6 +26,7 @@ import com.fastasyncworldedit.core.extent.clipboard.MultiClipboardHolder;
import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder;
import com.fastasyncworldedit.core.extent.clipboard.io.schematic.MinecraftStructure;
import com.fastasyncworldedit.core.util.MainUtil;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Multimap;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
@ -60,15 +61,19 @@ import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.util.io.Closer;
import com.sk89q.worldedit.util.io.file.FilenameException;
import org.apache.logging.log4j.Logger;
import com.sk89q.worldedit.util.paste.EngineHubPaste;
import com.sk89q.worldedit.util.paste.PasteMetadata;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;
import org.enginehub.piston.exception.CommandException;
import org.enginehub.piston.exception.StopExecutionException;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -79,9 +84,12 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@ -525,6 +533,42 @@ public class SchematicCommands {
.buildAndExec(worldEdit.getExecutorService());
}
@Command(
name = "share",
desc = "Share your clipboard as a schematic online"
)
@CommandPermissions({ "worldedit.clipboard.share", "worldedit.schematic.share" })
public void share(Actor actor, LocalSession session,
@Arg(desc = "Schematic name. Defaults to name-millis", def = "")
String schematicName,
@Arg(desc = "Format name.", def = "sponge")
String formatName) throws WorldEditException {
if (true) {
throw new UnsupportedOperationException("This feature is currently not implemented");
}
if (worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getDataVersion() == -1) {
actor.printError(TranslatableComponent.of("worldedit.schematic.unsupported-minecraft-version"));
return;
}
ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
if (format == null) {
actor.printError(TranslatableComponent.of("worldedit.schematic.unknown-format", TextComponent.of(formatName)));
return;
}
ClipboardHolder holder = session.getClipboard();
SchematicShareTask task = new SchematicShareTask(actor, format, holder, schematicName);
AsyncCommandBuilder.wrap(task, actor)
.registerWithSupervisor(worldEdit.getSupervisor(), "Sharing schematic")
.setDelayMessage(TranslatableComponent.of("worldedit.schematic.save.saving"))
.setWorkingMessage(TranslatableComponent.of("worldedit.schematic.save.still-saving"))
.onSuccess("Shared", (url -> actor.printInfo(TextComponent.of(url.toExternalForm() + ".schem").clickEvent(ClickEvent.openUrl(url.toExternalForm() + ".schem")))))
.onFailure("Failed to share schematic", worldEdit.getPlatformManager().getPlatformCommandManager().getExceptionConverter())
.buildAndExec(worldEdit.getExecutorService());
}
@Command(
name = "formats",
aliases = {"listformats", "f"},
@ -689,10 +733,10 @@ public class SchematicCommands {
String headerBytesElem = String.format("%.1fkb", totalBytes / 1000.0);
if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT > -1) {
if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && actor.getLimit().SCHEM_FILE_SIZE_LIMIT > -1) {
headerBytesElem += String.format(
" / %dkb",
Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT
actor.getLimit().SCHEM_FILE_SIZE_LIMIT
);
}
@ -793,14 +837,48 @@ public class SchematicCommands {
}
private static class SchematicSaveTask implements Callable<Void> {
private abstract static class SchematicOutputTask<T> implements Callable<T> {
protected final Actor actor;
protected final ClipboardFormat format;
protected final ClipboardHolder holder;
private final Actor actor;
private final ClipboardFormat format;
private final ClipboardHolder holder;
SchematicOutputTask(
Actor actor,
ClipboardFormat format,
ClipboardHolder holder
) {
this.actor = actor;
this.format = format;
this.holder = holder;
}
protected void writeToOutputStream(OutputStream outputStream) throws Exception {
Clipboard clipboard = holder.getClipboard();
Transform transform = holder.getTransform();
Clipboard target;
// If we have a transform, bake it into the copy
if (transform.isIdentity()) {
target = clipboard;
} else {
FlattenedClipboardTransform result = FlattenedClipboardTransform.transform(clipboard, transform);
target = new BlockArrayClipboard(result.getTransformedRegion());
target.setOrigin(clipboard.getOrigin());
Operations.completeLegacy(result.copyTo(target));
}
try (Closer closer = Closer.create()) {
OutputStream stream = closer.register(outputStream);
BufferedOutputStream bos = closer.register(new BufferedOutputStream(stream));
ClipboardWriter writer = closer.register(format.getWriter(bos));
writer.write(target);
}
}
}
private static class SchematicSaveTask extends SchematicOutputTask<Void> {
private File file;
private final boolean overwrite;
private final File rootDir;
private File file;
SchematicSaveTask(
Actor actor,
@ -810,11 +888,9 @@ public class SchematicCommands {
ClipboardHolder holder,
boolean overwrite
) {
this.actor = actor;
super(actor, format, holder);
this.file = file;
this.rootDir = rootDir;
this.format = format;
this.holder = holder;
this.overwrite = overwrite;
}
@ -826,7 +902,7 @@ public class SchematicCommands {
//FAWE start
boolean checkFilesize = Settings.settings().PATHS.PER_PLAYER_SCHEMATICS
&& Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT > -1;
&& actor.getLimit().SCHEM_FILE_SIZE_LIMIT > -1;
double directorysizeKb = 0;
String curFilepath = file.getAbsolutePath();
@ -856,7 +932,7 @@ public class SchematicCommands {
}
if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT > -1) {
if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && actor.getLimit().SCHEM_FILE_NUM_LIMIT > -1) {
if (numFiles == -1) {
numFiles = 0;
@ -869,7 +945,7 @@ public class SchematicCommands {
}
}
}
int limit = Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT;
int limit = actor.getLimit().SCHEM_FILE_NUM_LIMIT;
if (numFiles >= limit) {
TextComponent noSlotsErr = TextComponent.of( //TODO - to be moved into captions/translatablecomponents
@ -920,7 +996,7 @@ public class SchematicCommands {
if (checkFilesize) {
double curKb = filesizeKb + directorysizeKb;
int allocatedKb = Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_SIZE_LIMIT;
int allocatedKb = actor.getLimit().SCHEM_FILE_SIZE_LIMIT;
if (overwrite) {
curKb -= oldKbOverwritten;
@ -955,11 +1031,11 @@ public class SchematicCommands {
actor.print(kbRemainingNotif);
}
if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT > -1) {
if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && actor.getLimit().SCHEM_FILE_NUM_LIMIT > -1) {
TextComponent slotsRemainingNotif = TextComponent.of(
//TODO - to be moved into captions/translatablecomponents
"You have " + (Settings.settings().EXPERIMENTAL.PER_PLAYER_FILE_NUM_LIMIT - numFiles)
"You have " + (actor.getLimit().SCHEM_FILE_NUM_LIMIT - numFiles)
+ " schematic file slots left.",
TextColor.GRAY
);
@ -973,7 +1049,32 @@ public class SchematicCommands {
//FAWE end
return null;
}
}
private static class SchematicShareTask extends SchematicOutputTask<URL> {
private final String name;
SchematicShareTask(Actor actor, ClipboardFormat format, ClipboardHolder holder, String name) {
super(actor, format, holder);
this.name = name;
}
@Override
public URL call() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
writeToOutputStream(baos);
} catch (Exception e) {
throw new CommandException(TextComponent.of(e.getMessage()), e, ImmutableList.of());
}
EngineHubPaste pasteService = new EngineHubPaste();
PasteMetadata metadata = new PasteMetadata();
metadata.author = this.actor.getName();
metadata.extension = "schem";
metadata.name = name == null ? actor.getName() + "-" + System.currentTimeMillis() : name;
return pasteService.paste(new String(Base64.getEncoder().encode(baos.toByteArray()), StandardCharsets.UTF_8), metadata).call();
}
}
private static class SchematicListTask implements Callable<Component> {

View File

@ -56,6 +56,7 @@ public class BaseEntity implements NbtValued {
* @param nbtData NBT data
* @deprecated Use {@link BaseEntity#BaseEntity(EntityType, LazyReference)}
*/
@SuppressWarnings("this-escape")
@Deprecated
public BaseEntity(EntityType type, CompoundTag nbtData) {
this(type);
@ -87,6 +88,7 @@ public class BaseEntity implements NbtValued {
*
* @param other the object to clone
*/
@SuppressWarnings("this-escape")
public BaseEntity(BaseEntity other) {
checkNotNull(other);
this.type = other.getType();

View File

@ -62,6 +62,7 @@ public class BlockChangeLimiter extends AbstractDelegateExtent {
*
* @param limit the limit (&gt;= 0) or -1 for no limit
*/
@SuppressWarnings("this-escape") // Unlikely anyone is extending this in practice
public void setLimit(int limit) {
checkArgument(limit >= -1, "limit >= -1 required");
this.limit = limit;

View File

@ -19,11 +19,16 @@
package com.sk89q.worldedit.util.io;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.io.InputStream;
public class ForwardSeekableInputStream extends InputStream {
private static final Logger LOGGER = LogManager.getLogger();
protected InputStream parent;
protected long position = 0;
@ -60,7 +65,7 @@ public class ForwardSeekableInputStream extends InputStream {
@Override
public int read(byte[] b, int off, int len) throws IOException {
int read = super.read(b, off, len);
int read = parent.read(b, off, len);
position += read;
return read;
}
@ -86,6 +91,7 @@ public class ForwardSeekableInputStream extends InputStream {
public void seek(long n) throws IOException {
long diff = n - position;
LOGGER.error("Seek to {} from {} using {}", n, position, diff);
if (diff < 0) {
throw new IOException("Can't seek backwards");

View File

@ -357,7 +357,7 @@ public class HttpRequest implements Closeable {
*/
public static URL url(String url) {
try {
return new URL(url);
return URI.create(url).toURL();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
@ -371,13 +371,7 @@ public class HttpRequest implements Closeable {
*/
private static URL reformat(URL existing) {
try {
URL url = new URL(existing.toString());
URI uri = new URI(
url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(),
url.getPath(), url.getQuery(), url.getRef()
);
url = uri.toURL();
return url;
return existing.toURI().toURL();
} catch (MalformedURLException | URISyntaxException e) {
return existing;
}

View File

@ -83,4 +83,26 @@ public final class ActorCallbackPaste {
.buildAndExec(Pasters.getExecutor());
}
/**
* Submit data to a pastebin service and inform the sender of
* success or failure.
*
* @param supervisor The supervisor instance
* @param sender The sender
* @param content The content
* @param pasteMetadata The paste metadata
* @param successMessage The message builder, given the URL as an arg
*/
public static void pastebin(Supervisor supervisor, final Actor sender, String content, PasteMetadata pasteMetadata, final TranslatableComponent.Builder successMessage) {
Callable<URL> task = paster.paste(content, pasteMetadata);
AsyncCommandBuilder.wrap(task, sender)
.registerWithSupervisor(supervisor, "Submitting content to a pastebin service.")
.setDelayMessage(TranslatableComponent.of("worldedit.pastebin.uploading"))
.onSuccess((String) null, url -> sender.printInfo(successMessage.args(TextComponent.of(url.toString())).build()))
.onFailure("Failed to submit paste", null)
.buildAndExec(Pasters.getExecutor());
}
}

View File

@ -24,6 +24,7 @@ import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.util.net.HttpRequest;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.Map;
import java.util.concurrent.Callable;
@ -33,23 +34,38 @@ public class EngineHubPaste implements Paster {
private static final Gson GSON = new Gson();
@Override
public Callable<URL> paste(String content) {
return new PasteTask(content);
public Callable<URL> paste(String content, PasteMetadata metadata) {
return new PasteTask(content, metadata);
}
private static final class PasteTask implements Callable<URL> {
private final String content;
private final PasteMetadata metadata;
private PasteTask(String content) {
private PasteTask(String content, PasteMetadata metadata) {
this.content = content;
this.metadata = metadata;
}
@Override
public URL call() throws IOException, InterruptedException {
URL initialUrl = HttpRequest.url("https://paste.enginehub.org/signed_paste");
SignedPasteResponse response = GSON.fromJson(HttpRequest.get(initialUrl)
HttpRequest requestBuilder = HttpRequest.get(initialUrl);
requestBuilder.header("x-paste-meta-from", "EngineHub");
if (metadata.name != null) {
requestBuilder.header("x-paste-meta-name", metadata.name);
}
if (metadata.author != null) {
requestBuilder.header("x-paste-meta-author", metadata.author);
}
if (metadata.extension != null) {
requestBuilder.header("x-paste-meta-extension", metadata.extension);
}
SignedPasteResponse response = GSON.fromJson(requestBuilder
.execute()
.expectResponseCode(200)
.returnContent()
@ -68,7 +84,7 @@ public class EngineHubPaste implements Paster {
.execute()
.expectResponseCode(200, 204);
return new URL(response.viewUrl);
return URI.create(response.viewUrl).toURL();
}
}

View File

@ -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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.util.paste;
public class PasteMetadata {
public String name;
public String extension;
public String author;
}

View File

@ -24,6 +24,10 @@ import java.util.concurrent.Callable;
public interface Paster {
Callable<URL> paste(String content);
default Callable<URL> paste(String content) {
return paste(content, new PasteMetadata());
}
Callable<URL> paste(String content, PasteMetadata metadata);
}

View File

@ -82,21 +82,22 @@ public class FutureForwardingTask<V> extends AbstractTask<V> {
return future.get(timeout, unit);
}
// TODO: consider deprecating in favor of Future.State?
@Override
public State getState() {
public Task.State getState() {
if (isCancelled()) {
return State.CANCELLED;
return Task.State.CANCELLED;
} else if (isDone()) {
try {
get();
return State.SUCCEEDED;
return Task.State.SUCCEEDED;
} catch (InterruptedException e) {
return State.CANCELLED;
return Task.State.CANCELLED;
} catch (ExecutionException e) {
return State.FAILED;
return Task.State.FAILED;
}
} else {
return State.RUNNING;
return Task.State.RUNNING;
}
}

View File

@ -33,8 +33,10 @@ public final class BlockCategories {
public static final BlockCategory ANCIENT_CITY_REPLACEABLE = get("minecraft:ancient_city_replaceable");
public static final BlockCategory ANIMALS_SPAWNABLE_ON = get("minecraft:animals_spawnable_on");
public static final BlockCategory ANVIL = get("minecraft:anvil");
public static final BlockCategory ARMADILLO_SPAWNABLE_ON = get("minecraft:armadillo_spawnable_on");
public static final BlockCategory AXOLOTLS_SPAWNABLE_ON = get("minecraft:axolotls_spawnable_on");
public static final BlockCategory AZALEA_GROWS_ON = get("minecraft:azalea_grows_on");
public static final BlockCategory BADLANDS_TERRACOTTA = get("minecraft:badlands_terracotta");
public static final BlockCategory AZALEA_ROOT_REPLACEABLE = get("minecraft:azalea_root_replaceable");
public static final BlockCategory BAMBOO_BLOCKS = get("minecraft:bamboo_blocks");
public static final BlockCategory BAMBOO_PLANTABLE_ON = get("minecraft:bamboo_plantable_on");
@ -78,6 +80,7 @@ public final class BlockCategories {
public static final BlockCategory DIRT = get("minecraft:dirt");
@Deprecated
public static final BlockCategory DIRT_LIKE = get("minecraft:dirt_like");
public static final BlockCategory DOES_NOT_BLOCK_HOPPERS = get("minecraft:does_not_block_hoppers");
public static final BlockCategory DOORS = get("minecraft:doors");
public static final BlockCategory DRAGON_IMMUNE = get("minecraft:dragon_immune");
public static final BlockCategory DRAGON_TRANSPARENT = get("minecraft:dragon_transparent");
@ -103,6 +106,12 @@ public final class BlockCategories {
public static final BlockCategory HOGLIN_REPELLENTS = get("minecraft:hoglin_repellents");
public static final BlockCategory ICE = get("minecraft:ice");
public static final BlockCategory IMPERMEABLE = get("minecraft:impermeable");
public static final BlockCategory INCORRECT_FOR_DIAMOND_TOOL = get("minecraft:incorrect_for_diamond_tool");
public static final BlockCategory INCORRECT_FOR_GOLD_TOOL = get("minecraft:incorrect_for_gold_tool");
public static final BlockCategory INCORRECT_FOR_IRON_TOOL = get("minecraft:incorrect_for_iron_tool");
public static final BlockCategory INCORRECT_FOR_NETHERITE_TOOL = get("minecraft:incorrect_for_netherite_tool");
public static final BlockCategory INCORRECT_FOR_STONE_TOOL = get("minecraft:incorrect_for_stone_tool");
public static final BlockCategory INCORRECT_FOR_WOODEN_TOOL = get("minecraft:incorrect_for_wooden_tool");
public static final BlockCategory INFINIBURN_END = get("minecraft:infiniburn_end");
public static final BlockCategory INFINIBURN_NETHER = get("minecraft:infiniburn_nether");
public static final BlockCategory INFINIBURN_OVERWORLD = get("minecraft:infiniburn_overworld");

View File

@ -60,6 +60,7 @@ public class BlockType implements Keyed, Pattern {
private static final Logger LOGGER = LogManagerCompat.getLogger();
private final String id;
@SuppressWarnings("this-escape")
private final LazyReference<FuzzyBlockState> emptyFuzzy
= LazyReference.from(() -> new FuzzyBlockState(this));
//FAWE start

View File

@ -483,6 +483,10 @@ public final class BlockTypes {
@Nullable
public static final BlockType COPPER_GRATE = init();
@Nullable
public static final BlockType COPPER_ORE = init();
@Nullable
public static final BlockType COPPER_TRAPDOOR = init();
@Nullable
public static final BlockType CORNFLOWER = init();
@Nullable
public static final BlockType CRACKED_DEEPSLATE_BRICKS = init();
@ -495,6 +499,8 @@ public final class BlockTypes {
@Nullable
public static final BlockType CRACKED_STONE_BRICKS = init();
@Nullable
public static final BlockType CRAFTER = init();
@Nullable
public static final BlockType CRAFTING_TABLE = init();
@Nullable
public static final BlockType CREEPER_HEAD = init();
@ -685,8 +691,6 @@ public final class BlockTypes {
@Nullable
public static final BlockType DEEPSLATE_COPPER_ORE = init();
@Nullable
public static final BlockType COPPER_TRAPDOOR = init();
@Nullable
public static final BlockType DEEPSLATE_DIAMOND_ORE = init();
@Nullable
public static final BlockType DEEPSLATE_EMERALD_ORE = init();
@ -747,8 +751,6 @@ public final class BlockTypes {
@Nullable
public static final BlockType ENDER_CHEST = init();
@Nullable
public static final BlockType EXPOSED_CHISELED_COPPER = init();
@Nullable
public static final BlockType END_GATEWAY = init();
@Nullable
public static final BlockType END_PORTAL = init();
@ -767,6 +769,8 @@ public final class BlockTypes {
@Nullable
public static final BlockType END_STONE_BRICK_WALL = init();
@Nullable
public static final BlockType EXPOSED_CHISELED_COPPER = init();
@Nullable
public static final BlockType EXPOSED_COPPER = init();
@Nullable
public static final BlockType EXPOSED_COPPER_BULB = init();
@ -836,6 +840,9 @@ public final class BlockTypes {
public static final BlockType GRASS = init();
@Nullable
public static final BlockType GRASS_BLOCK = init();
@Deprecated
@Nullable
public static final BlockType GRASS_PATH = init();
@Nullable
public static final BlockType GRAVEL = init();
@Nullable
@ -901,6 +908,8 @@ public final class BlockTypes {
@Nullable
public static final BlockType HAY_BLOCK = init();
@Nullable
public static final BlockType HEAVY_CORE = init();
@Nullable
public static final BlockType HEAVY_WEIGHTED_PRESSURE_PLATE = init();
@Nullable
public static final BlockType HONEYCOMB_BLOCK = init();
@ -925,8 +934,6 @@ public final class BlockTypes {
@Nullable
public static final BlockType INFESTED_CRACKED_STONE_BRICKS = init();
@Nullable
public static final BlockType CRAFTER = init();
@Nullable
public static final BlockType INFESTED_DEEPSLATE = init();
@Nullable
public static final BlockType INFESTED_MOSSY_STONE_BRICKS = init();
@ -1954,10 +1961,12 @@ public final class BlockTypes {
@Nullable
public static final BlockType TWISTING_VINES = init();
@Nullable
public static final BlockType VERDANT_FROGLIGHT = init();
@Nullable
public static final BlockType TWISTING_VINES_PLANT = init();
@Nullable
public static final BlockType VAULT = init();
@Nullable
public static final BlockType VERDANT_FROGLIGHT = init();
@Nullable
public static final BlockType VINE = init();
@Nullable
public static final BlockType VOID_AIR = init();
@ -2026,7 +2035,7 @@ public final class BlockTypes {
public static final BlockType WAXED_CUT_COPPER_SLAB = init();
@Nullable
public static final BlockType WAXED_CUT_COPPER_STAIRS = init();
@ Nullable
@Nullable
public static final BlockType WAXED_EXPOSED_CHISELED_COPPER = init();
@Nullable
public static final BlockType WAXED_EXPOSED_COPPER = init();

View File

@ -163,7 +163,7 @@ public class AnvilChunk13 implements Chunk {
throw new InvalidFormatException("Too short block state table");
}
currentSerializedValue = blockStatesSerialized[nextSerializedItem++];
localBlockId |= (currentSerializedValue & ((1 << bitsNextLong) - 1)) << remainingBits;
localBlockId |= (int) ((currentSerializedValue & ((1 << bitsNextLong) - 1)) << remainingBits);
currentSerializedValue >>>= bitsNextLong;
remainingBits = 64 - bitsNextLong;
} else {

View File

@ -35,6 +35,8 @@ public final class EntityTypes {
@Nullable
public static final EntityType AREA_EFFECT_CLOUD = get("minecraft:area_effect_cloud");
@Nullable
public static final EntityType ARMADILLO = get("minecraft:armadillo");
@Nullable
public static final EntityType ARMOR_STAND = get("minecraft:armor_stand");
@Nullable
public static final EntityType ARROW = get("minecraft:arrow");
@ -51,8 +53,12 @@ public final class EntityTypes {
@Nullable
public static final EntityType BOAT = get("minecraft:boat");
@Nullable
public static final EntityType BOGGED = get("minecraft:bogged");
@Nullable
public static final EntityType BREEZE = get("minecraft:breeze");
@Nullable
public static final EntityType BREEZE_WIND_CHARGE = get("minecraft:breeze_wind_charge");
@Nullable
public static final EntityType CAMEL = get("minecraft:camel");
@Nullable
public static final EntityType CAT = get("minecraft:cat");
@ -171,6 +177,8 @@ public final class EntityTypes {
@Nullable
public static final EntityType OCELOT = get("minecraft:ocelot");
@Nullable
public static final EntityType OMINOUS_ITEM_SPAWNER = get("minecraft:ominous_item_spawner");
@Nullable
public static final EntityType PAINTING = get("minecraft:painting");
@Nullable
public static final EntityType PANDA = get("minecraft:panda");

View File

@ -29,28 +29,36 @@ public final class ItemCategories {
public static final ItemCategory ACACIA_LOGS = get("minecraft:acacia_logs");
public static final ItemCategory ANVIL = get("minecraft:anvil");
public static final ItemCategory ARMADILLO_FOOD = get("minecraft:armadillo_food");
public static final ItemCategory ARROWS = get("minecraft:arrows");
public static final ItemCategory AXES = get("minecraft:axes");
public static final ItemCategory AXOLOTL_TEMPT_ITEMS = get("minecraft:axolotl_tempt_items");
public static final ItemCategory AXOLOTL_FOOD = get("minecraft:axolotl_food");
@Deprecated public static final ItemCategory AXOLOTL_TEMPT_ITEMS = get("minecraft:axolotl_tempt_items");
public static final ItemCategory BAMBOO_BLOCKS = get("minecraft:bamboo_blocks");
public static final ItemCategory BANNERS = get("minecraft:banners");
public static final ItemCategory BEACON_PAYMENT_ITEMS = get("minecraft:beacon_payment_items");
public static final ItemCategory BEDS = get("minecraft:beds");
public static final ItemCategory BEE_FOOD = get("minecraft:bee_food");
public static final ItemCategory BIRCH_LOGS = get("minecraft:birch_logs");
public static final ItemCategory BOATS = get("minecraft:boats");
public static final ItemCategory BOOKSHELF_BOOKS = get("minecraft:bookshelf_books");
public static final ItemCategory BREAKS_DECORATED_POTS = get("minecraft:breaks_decorated_pots");
public static final ItemCategory BUTTONS = get("minecraft:buttons");
public static final ItemCategory CAMEL_FOOD = get("minecraft:camel_food");
public static final ItemCategory CANDLES = get("minecraft:candles");
@Deprecated public static final ItemCategory CARPETS = get("minecraft:carpets");
public static final ItemCategory CAT_FOOD = get("minecraft:cat_food");
public static final ItemCategory CHERRY_LOGS = get("minecraft:cherry_logs");
public static final ItemCategory CHEST_ARMOR = get("minecraft:chest_armor");
public static final ItemCategory CHEST_BOATS = get("minecraft:chest_boats");
public static final ItemCategory CHICKEN_FOOD = get("minecraft:chicken_food");
public static final ItemCategory CLUSTER_MAX_HARVESTABLES = get("minecraft:cluster_max_harvestables");
public static final ItemCategory COAL_ORES = get("minecraft:coal_ores");
public static final ItemCategory COALS = get("minecraft:coals");
public static final ItemCategory COMPASSES = get("minecraft:compasses");
public static final ItemCategory COMPLETES_FIND_TREE_TUTORIAL = get("minecraft:completes_find_tree_tutorial");
public static final ItemCategory COPPER_ORES = get("minecraft:copper_ores");
public static final ItemCategory COW_FOOD = get("minecraft:cow_food");
public static final ItemCategory CREEPER_DROP_MUSIC_DISCS = get("minecraft:creeper_drop_music_discs");
public static final ItemCategory CREEPER_IGNITERS = get("minecraft:creeper_igniters");
public static final ItemCategory CRIMSON_STEMS = get("minecraft:crimson_stems");
@ -61,44 +69,82 @@ public final class ItemCategories {
public static final ItemCategory DIAMOND_ORES = get("minecraft:diamond_ores");
public static final ItemCategory DIRT = get("minecraft:dirt");
public static final ItemCategory DOORS = get("minecraft:doors");
public static final ItemCategory DYEABLE = get("minecraft:dyeable");
public static final ItemCategory EMERALD_ORES = get("minecraft:emerald_ores");
public static final ItemCategory ENCHANTABLE_ARMOR = get("minecraft:enchantable/armor");
public static final ItemCategory ENCHANTABLE_BOW = get("minecraft:enchantable/bow");
public static final ItemCategory ENCHANTABLE_CHEST_ARMOR = get("minecraft:enchantable/chest_armor");
public static final ItemCategory ENCHANTABLE_CROSSBOW = get("minecraft:enchantable/crossbow");
public static final ItemCategory ENCHANTABLE_DURABILITY = get("minecraft:enchantable/durability");
public static final ItemCategory ENCHANTABLE_EQUIPPABLE = get("minecraft:enchantable/equippable");
public static final ItemCategory ENCHANTABLE_FIRE_ASPECT = get("minecraft:enchantable/fire_aspect");
public static final ItemCategory ENCHANTABLE_FISHING = get("minecraft:enchantable/fishing");
public static final ItemCategory ENCHANTABLE_FOOT_ARMOR = get("minecraft:enchantable/foot_armor");
public static final ItemCategory ENCHANTABLE_HEAD_ARMOR = get("minecraft:enchantable/head_armor");
public static final ItemCategory ENCHANTABLE_LEG_ARMOR = get("minecraft:enchantable/leg_armor");
public static final ItemCategory ENCHANTABLE_MINING = get("minecraft:enchantable/mining");
public static final ItemCategory ENCHANTABLE_MINING_LOOT = get("minecraft:enchantable/mining_loot");
public static final ItemCategory ENCHANTABLE_SHARP_WEAPON = get("minecraft:enchantable/sharp_weapon");
public static final ItemCategory ENCHANTABLE_SWORD = get("minecraft:enchantable/sword");
public static final ItemCategory ENCHANTABLE_TRIDENT = get("minecraft:enchantable/trident");
public static final ItemCategory ENCHANTABLE_VANISHING = get("minecraft:enchantable/vanishing");
public static final ItemCategory ENCHANTABLE_WEAPON = get("minecraft:enchantable/weapon");
public static final ItemCategory FENCE_GATES = get("minecraft:fence_gates");
public static final ItemCategory FENCES = get("minecraft:fences");
public static final ItemCategory FISHES = get("minecraft:fishes");
public static final ItemCategory FLOWERS = get("minecraft:flowers");
public static final ItemCategory FOOT_ARMOR = get("minecraft:foot_armor");
public static final ItemCategory FOX_FOOD = get("minecraft:fox_food");
public static final ItemCategory FREEZE_IMMUNE_WEARABLES = get("minecraft:freeze_immune_wearables");
public static final ItemCategory FROG_FOOD = get("minecraft:frog_food");
@Deprecated
public static final ItemCategory FURNACE_MATERIALS = get("minecraft:furnace_materials");
public static final ItemCategory GOAT_FOOD = get("minecraft:goat_food");
public static final ItemCategory GOLD_ORES = get("minecraft:gold_ores");
public static final ItemCategory HANGING_SIGNS = get("minecraft:hanging_signs");
public static final ItemCategory HEAD_ARMOR = get("minecraft:head_armor");
public static final ItemCategory HOES = get("minecraft:hoes");
public static final ItemCategory HOGLIN_FOOD = get("minecraft:hoglin_food");
public static final ItemCategory HORSE_FOOD = get("minecraft:horse_food");
public static final ItemCategory HORSE_TEMPT_ITEMS = get("minecraft:horse_tempt_items");
public static final ItemCategory IGNORED_BY_PIGLIN_BABIES = get("minecraft:ignored_by_piglin_babies");
public static final ItemCategory IRON_ORES = get("minecraft:iron_ores");
public static final ItemCategory JUNGLE_LOGS = get("minecraft:jungle_logs");
public static final ItemCategory LAPIS_ORES = get("minecraft:lapis_ores");
public static final ItemCategory LEAVES = get("minecraft:leaves");
public static final ItemCategory LECTERN_BOOKS = get("minecraft:lectern_books");
public static final ItemCategory LEG_ARMOR = get("minecraft:leg_armor");
public static final ItemCategory LLAMA_FOOD = get("minecraft:llama_food");
public static final ItemCategory LLAMA_TEMPT_ITEMS = get("minecraft:llama_tempt_items");
public static final ItemCategory LOGS = get("minecraft:logs");
public static final ItemCategory LOGS_THAT_BURN = get("minecraft:logs_that_burn");
public static final ItemCategory MANGROVE_LOGS = get("minecraft:mangrove_logs");
public static final ItemCategory MEAT = get("minecraft:meat");
public static final ItemCategory MUSIC_DISCS = get("minecraft:music_discs");
public static final ItemCategory NON_FLAMMABLE_WOOD = get("minecraft:non_flammable_wood");
public static final ItemCategory NOTEBLOCK_TOP_INSTRUMENTS = get("minecraft:noteblock_top_instruments");
public static final ItemCategory OAK_LOGS = get("minecraft:oak_logs");
@Deprecated public static final ItemCategory OCCLUDES_VIBRATION_SIGNALS = get("minecraft:occludes_vibration_signals");
public static final ItemCategory OCELOT_FOOD = get("minecraft:ocelot_food");
@Deprecated public static final ItemCategory OVERWORLD_NATURAL_LOGS = get("minecraft:overworld_natural_logs");
public static final ItemCategory PANDA_FOOD = get("minecraft:panda_food");
public static final ItemCategory PARROT_FOOD = get("minecraft:parrot_food");
public static final ItemCategory PARROT_POISONOUS_FOOD = get("minecraft:parrot_poisonous_food");
public static final ItemCategory PICKAXES = get("minecraft:pickaxes");
public static final ItemCategory PIG_FOOD = get("minecraft:pig_food");
public static final ItemCategory PIGLIN_FOOD = get("minecraft:piglin_food");
public static final ItemCategory PIGLIN_LOVED = get("minecraft:piglin_loved");
public static final ItemCategory PIGLIN_REPELLENTS = get("minecraft:piglin_repellents");
public static final ItemCategory PLANKS = get("minecraft:planks");
public static final ItemCategory RABBIT_FOOD = get("minecraft:rabbit_food");
public static final ItemCategory RAILS = get("minecraft:rails");
public static final ItemCategory REDSTONE_ORES = get("minecraft:redstone_ores");
public static final ItemCategory SAND = get("minecraft:sand");
public static final ItemCategory SAPLINGS = get("minecraft:saplings");
public static final ItemCategory SHEEP_FOOD = get("minecraft:sheep_food");
public static final ItemCategory SHOVELS = get("minecraft:shovels");
public static final ItemCategory SIGNS = get("minecraft:signs");
public static final ItemCategory SKULLS = get("minecraft:skulls");
public static final ItemCategory SLABS = get("minecraft:slabs");
public static final ItemCategory SMALL_FLOWERS = get("minecraft:small_flowers");
public static final ItemCategory SMELTS_TO_GLASS = get("minecraft:smelts_to_glass");
@ -110,18 +156,22 @@ public final class ItemCategories {
public static final ItemCategory STONE_BUTTONS = get("minecraft:stone_buttons");
public static final ItemCategory STONE_CRAFTING_MATERIALS = get("minecraft:stone_crafting_materials");
public static final ItemCategory STONE_TOOL_MATERIALS = get("minecraft:stone_tool_materials");
public static final ItemCategory STRIDER_FOOD = get("minecraft:strider_food");
public static final ItemCategory STRIDER_TEMPT_ITEMS = get("minecraft:strider_tempt_items");
public static final ItemCategory SWORDS = get("minecraft:swords");
public static final ItemCategory TALL_FLOWERS = get("minecraft:tall_flowers");
public static final ItemCategory TERRACOTTA = get("minecraft:terracotta");
public static final ItemCategory TOOLS = get("minecraft:tools");
@Deprecated public static final ItemCategory TOOLS = get("minecraft:tools");
public static final ItemCategory TRAPDOORS = get("minecraft:trapdoors");
public static final ItemCategory TRIM_MATERIALS = get("minecraft:trim_materials");
public static final ItemCategory TRIM_TEMPLATES = get("minecraft:trim_templates");
public static final ItemCategory TRIMMABLE_ARMOR = get("minecraft:trimmable_armor");
public static final ItemCategory TURTLE_FOOD = get("minecraft:turtle_food");
public static final ItemCategory VILLAGER_PLANTABLE_SEEDS = get("minecraft:villager_plantable_seeds");
public static final ItemCategory WALLS = get("minecraft:walls");
public static final ItemCategory WARPED_STEMS = get("minecraft:warped_stems");
public static final ItemCategory WART_BLOCKS = get("minecraft:wart_blocks");
public static final ItemCategory WOLF_FOOD = get("minecraft:wolf_food");
public static final ItemCategory WOODEN_BUTTONS = get("minecraft:wooden_buttons");
public static final ItemCategory WOODEN_DOORS = get("minecraft:wooden_doors");
public static final ItemCategory WOODEN_FENCES = get("minecraft:wooden_fences");

View File

@ -42,7 +42,7 @@ public class ItemType implements RegistryItem, Keyed {
public static final NamespacedRegistry<ItemType> REGISTRY = new NamespacedRegistry<>("item type", true);
private final String id;
@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "this-escape"})
private transient final LazyReference<String> name = LazyReference.from(() -> {
String name = GuavaUtil.firstNonNull(
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
@ -51,10 +51,12 @@ public class ItemType implements RegistryItem, Keyed {
);
return name.isEmpty() ? getId() : name;
});
@SuppressWarnings("this-escape")
private transient final LazyReference<Component> richName = LazyReference.from(() ->
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getItemRegistry().getRichName(this)
);
@SuppressWarnings("this-escape")
private transient final LazyReference<ItemMaterial> itemMaterial = LazyReference.from(() ->
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
.getRegistries().getItemRegistry().getMaterial(this)

View File

@ -105,6 +105,10 @@ public final class ItemTypes {
@Nullable
public static final ItemType ARMOR_STAND = init();
@Nullable
public static final ItemType ARMADILLO_SCUTE = init();
@Nullable
public static final ItemType ARMADILLO_SPAWN_EGG = init();
@Nullable
public static final ItemType ARMS_UP_POTTERY_SHERD = init();
@Nullable
public static final ItemType ARROW = init();
@ -297,6 +301,10 @@ public final class ItemTypes {
@Nullable
public static final ItemType BLUE_WOOL = init();
@Nullable
public static final ItemType BOGGED_SPAWN_EGG = init();
@Nullable
public static final ItemType BOLT_ARMOR_TRIM_SMITHING_TEMPLATE = init();
@Nullable
public static final ItemType BONE = init();
@Nullable
public static final ItemType BONE_BLOCK = init();
@ -319,6 +327,8 @@ public final class ItemTypes {
@Nullable
public static final ItemType BREAD = init();
@Nullable
public static final ItemType BREEZE_ROD = init();
@Nullable
public static final ItemType BREEZE_SPAWN_EGG = init();
@Nullable
public static final ItemType BREWER_POTTERY_SHERD = init();
@ -971,6 +981,12 @@ public final class ItemTypes {
@Nullable
public static final ItemType FLINT_AND_STEEL = init();
@Nullable
public static final ItemType FLOW_ARMOR_TRIM_SMITHING_TEMPLATE = init();
@Nullable
public static final ItemType FLOW_BANNER_PATTERN = init();
@Nullable
public static final ItemType FLOW_POTTERY_SHERD = init();
@Nullable
public static final ItemType FLOWER_BANNER_PATTERN = init();
@Nullable
public static final ItemType FLOWER_POT = init();
@ -1132,6 +1148,10 @@ public final class ItemTypes {
@Nullable
public static final ItemType GUNPOWDER = init();
@Nullable
public static final ItemType GUSTER_BANNER_PATTERN = init();
@Nullable
public static final ItemType GUSTER_POTTERY_SHERD = init();
@Nullable
public static final ItemType HANGING_ROOTS = init();
@Nullable
public static final ItemType HAY_BLOCK = init();
@ -1142,6 +1162,8 @@ public final class ItemTypes {
@Nullable
public static final ItemType HEARTBREAK_POTTERY_SHERD = init();
@Nullable
public static final ItemType HEAVY_CORE = init();
@Nullable
public static final ItemType HEAVY_WEIGHTED_PRESSURE_PLATE = init();
@Nullable
public static final ItemType HOGLIN_SPAWN_EGG = init();
@ -1404,6 +1426,8 @@ public final class ItemTypes {
@Nullable
public static final ItemType LOOM = init();
@Nullable
public static final ItemType MACE = init();
@Nullable
public static final ItemType MAGENTA_BANNER = init();
@Nullable
public static final ItemType MAGENTA_BED = init();
@ -1668,6 +1692,10 @@ public final class ItemTypes {
@Nullable
public static final ItemType OCHRE_FROGLIGHT = init();
@Nullable
public static final ItemType OMINOUS_BOTTLE = init();
@Nullable
public static final ItemType OMINOUS_TRIAL_KEY = init();
@Nullable
public static final ItemType ORANGE_BANNER = init();
@Nullable
public static final ItemType ORANGE_BED = init();
@ -2075,6 +2103,8 @@ public final class ItemTypes {
@Nullable
public static final ItemType SCAFFOLDING = init();
@Nullable
public static final ItemType SCRAPE_POTTERY_SHERD = init();
@Nullable
public static final ItemType SCULK = init();
@Nullable
public static final ItemType SCULK_CATALYST = init();
@ -2085,6 +2115,7 @@ public final class ItemTypes {
@Nullable
public static final ItemType SCULK_VEIN = init();
@Nullable
@Deprecated
public static final ItemType SCUTE = init();
@Nullable
public static final ItemType SEA_LANTERN = init();
@ -2424,10 +2455,14 @@ public final class ItemTypes {
@Nullable
public static final ItemType TURTLE_HELMET = init();
@Nullable
public static final ItemType TURTLE_SCUTE = init();
@Nullable
public static final ItemType TURTLE_SPAWN_EGG = init();
@Nullable
public static final ItemType TWISTING_VINES = init();
@Nullable
public static final ItemType VAULT = init();
@Nullable
public static final ItemType VERDANT_FROGLIGHT = init();
@Nullable
public static final ItemType VEX_ARMOR_TRIM_SMITHING_TEMPLATE = init();
@ -2614,6 +2649,8 @@ public final class ItemTypes {
@Nullable
public static final ItemType WILD_ARMOR_TRIM_SMITHING_TEMPLATE = init();
@Nullable
public static final ItemType WIND_CHARGE = init();
@Nullable
public static final ItemType WITCH_SPAWN_EGG = init();
@Nullable
public static final ItemType WITHER_ROSE = init();
@ -2624,6 +2661,8 @@ public final class ItemTypes {
@Nullable
public static final ItemType WITHER_SPAWN_EGG = init();
@Nullable
public static final ItemType WOLF_ARMOR = init();
@Nullable
public static final ItemType WOLF_SPAWN_EGG = init();
@Nullable
public static final ItemType WOODEN_AXE = init();