Fix worldedit-core warnings

This commit is contained in:
Octavia Togami 2024-03-31 10:36:39 -07:00 committed by Maddy Miller
parent f3f0b981d4
commit 8b3a8a5f81
80 changed files with 163 additions and 623 deletions

View File

@ -22,13 +22,14 @@
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
.configureEach {
val disabledLint = listOf(
"processing", "path", "fallthrough", "serial"
"processing", "path", "fallthrough", "serial", "overloads",
)
options.release.set(javaRelease)
options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
options.isDeprecation = true
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")
options.compilerArgs.add("-Werror")
}
configure<CheckstyleExtension> {

View File

@ -3,7 +3,7 @@
object Versions {
const val TEXT = "3.0.4"
const val TEXT_EXTRAS = "3.0.6"
const val PISTON = "0.5.8"
const val PISTON = "0.5.10"
const val AUTO_VALUE = "1.10.4"
const val JUNIT = "5.10.2"
const val MOCKITO = "5.11.0"

View File

@ -1,377 +1,32 @@
{
"Nothing should be implementing a conflicting method": [
"Removing useless Authorizer classes": [
{
"type": "com.sk89q.worldedit.extent.clipboard.Clipboard",
"member": "Method com.sk89q.worldedit.extent.clipboard.Clipboard.transform(com.sk89q.worldedit.math.transform.Transform)",
"type": "com.sk89q.worldedit.util.auth.Authorizer",
"member": "Class com.sk89q.worldedit.util.auth.Authorizer",
"changes": [
"METHOD_NEW_DEFAULT"
"CLASS_REMOVED"
]
},
{
"type": "com.sk89q.worldedit.function.mask.Mask",
"member": "Method com.sk89q.worldedit.function.mask.Mask.toMask2D()",
"type": "com.sk89q.worldedit.util.auth.Authorizer",
"member": "Method com.sk89q.worldedit.util.auth.Authorizer.testPermission(com.sk89q.minecraft.util.commands.CommandLocals,java.lang.String)",
"changes": [
"METHOD_ABSTRACT_NOW_DEFAULT"
"METHOD_REMOVED"
]
},
{
"type": "com.sk89q.worldedit.util.paste.Paster",
"member": "Method com.sk89q.worldedit.util.paste.Paster.paste(java.lang.String)",
"type": "com.sk89q.worldedit.util.auth.NullAuthorizer",
"member": "Class com.sk89q.worldedit.util.auth.NullAuthorizer",
"changes": [
"METHOD_ABSTRACT_NOW_DEFAULT"
"CLASS_REMOVED"
]
},
{
"type": "com.sk89q.worldedit.world.block.BlockStateHolder",
"member": "Method com.sk89q.worldedit.world.block.BlockStateHolder.toBaseBlock(com.sk89q.jnbt.CompoundTag)",
"changes": [
"METHOD_ABSTRACT_NOW_DEFAULT",
"ANNOTATION_DEPRECATED_ADDED"
]
},
{
"type": "com.sk89q.worldedit.world.block.BlockStateHolder",
"member": "Method com.sk89q.worldedit.world.block.BlockStateHolder.toBaseBlock(com.sk89q.worldedit.util.concurrency.LazyReference)",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.world.block.BlockStateHolder",
"member": "Method com.sk89q.worldedit.world.block.BlockStateHolder.toBaseBlock(com.sk89q.worldedit.util.nbt.CompoundBinaryTag)",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.world.NbtValued",
"member": "Method com.sk89q.worldedit.world.NbtValued.getNbt()",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.world.NbtValued",
"member": "Method com.sk89q.worldedit.world.NbtValued.getNbtData()",
"changes": [
"METHOD_ABSTRACT_NOW_DEFAULT",
"ANNOTATION_DEPRECATED_ADDED"
]
},
{
"type": "com.sk89q.worldedit.world.NbtValued",
"member": "Method com.sk89q.worldedit.world.NbtValued.getNbtReference()",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.world.NbtValued",
"member": "Method com.sk89q.worldedit.world.NbtValued.hasNbtData()",
"changes": [
"METHOD_ABSTRACT_NOW_DEFAULT",
"ANNOTATION_DEPRECATED_ADDED"
]
},
{
"type": "com.sk89q.worldedit.world.NbtValued",
"member": "Method com.sk89q.worldedit.world.NbtValued.setNbt(com.sk89q.worldedit.util.nbt.CompoundBinaryTag)",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.world.NbtValued",
"member": "Method com.sk89q.worldedit.world.NbtValued.setNbtData(com.sk89q.jnbt.CompoundTag)",
"changes": [
"METHOD_ABSTRACT_NOW_DEFAULT",
"ANNOTATION_DEPRECATED_ADDED"
]
},
{
"type": "com.sk89q.worldedit.world.NbtValued",
"member": "Method com.sk89q.worldedit.world.NbtValued.setNbtReference(com.sk89q.worldedit.util.concurrency.LazyReference)",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.extent.clipboard.io.legacycompat.EntityNBTCompatibilityHandler",
"member": "Method com.sk89q.worldedit.extent.clipboard.io.legacycompat.EntityNBTCompatibilityHandler.updateNbt(com.sk89q.worldedit.world.entity.EntityType,org.enginehub.linbus.tree.LinCompoundTag)",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler",
"member": "Method com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler.updateNbt(com.sk89q.worldedit.world.block.BaseBlock)",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.world.block.BlockStateHolder",
"member": "Method com.sk89q.worldedit.world.block.BlockStateHolder.toBaseBlock(org.enginehub.linbus.tree.LinCompoundTag)",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.world.NbtValued",
"member": "Method com.sk89q.worldedit.world.NbtValued.setNbt(org.enginehub.linbus.tree.LinCompoundTag)",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.world.World",
"member": "Method com.sk89q.worldedit.world.World.generateFeature(com.sk89q.worldedit.world.generation.ConfiguredFeatureType,com.sk89q.worldedit.EditSession,com.sk89q.worldedit.math.BlockVector3)",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.world.World",
"member": "Method com.sk89q.worldedit.world.World.generateStructure(com.sk89q.worldedit.world.generation.StructureType,com.sk89q.worldedit.EditSession,com.sk89q.worldedit.math.BlockVector3)",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.registry.Keyed",
"member": "Method com.sk89q.worldedit.registry.Keyed.id()",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.world.registry.ItemMaterial",
"member": "Method com.sk89q.worldedit.world.registry.ItemMaterial.maxDamage()",
"changes": [
"METHOD_NEW_DEFAULT"
]
},
{
"type": "com.sk89q.worldedit.world.registry.ItemMaterial",
"member": "Method com.sk89q.worldedit.world.registry.ItemMaterial.maxStackSize()",
"changes": [
"METHOD_NEW_DEFAULT"
]
}
],
"LazyReference was never publicly extensible": [
{
"type": "com.sk89q.worldedit.util.concurrency.LazyReference",
"member": "Class com.sk89q.worldedit.util.concurrency.LazyReference",
"changes": [
"CLASS_NOW_FINAL"
]
}
],
"Extending Tag never made sense": [
{
"type": "com.sk89q.jnbt.Tag",
"member": "Constructor com.sk89q.jnbt.Tag()",
"type": "com.sk89q.worldedit.util.auth.NullAuthorizer",
"member": "Constructor com.sk89q.worldedit.util.auth.NullAuthorizer()",
"changes": [
"CONSTRUCTOR_REMOVED"
]
}
],
"DataFixer isn't API": [
{
"type": "com.sk89q.worldedit.world.DataFixer$FixTypes",
"member": "Field ENTITY",
"changes": [
"FIELD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.DataFixer$FixTypes",
"member": "Field BIOME",
"changes": [
"FIELD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.DataFixer$FixTypes",
"member": "Field BLOCK_STATE",
"changes": [
"FIELD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.DataFixer$FixTypes",
"member": "Field BLOCK_ENTITY",
"changes": [
"FIELD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.DataFixer$FixTypes",
"member": "Field ITEM_TYPE",
"changes": [
"FIELD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.DataFixer$FixTypes",
"member": "Field CHUNK",
"changes": [
"FIELD_NOW_FINAL"
]
}
],
"This now delegates to the InputStream method if not implemented": [
{
"type": "com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat",
"member": "Method com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat.isFormat(java.io.File)",
"changes": [
"METHOD_ABSTRACT_NOW_DEFAULT"
]
}
],
"New method added with default implementation": [
{
"type": "com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat",
"member": "Method com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat.isFormat(java.io.InputStream)",
"changes": [
"METHOD_NEW_DEFAULT"
]
}
],
"Should not have been extended anyway": [
{
"type": "com.sk89q.worldedit.math.transform.AffineTransform",
"member": "Class com.sk89q.worldedit.math.transform.AffineTransform",
"changes": [
"CLASS_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.history.change.BiomeChange3D",
"member": "Class com.sk89q.worldedit.history.change.BiomeChange3D",
"changes": [
"CLASS_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.history.change.BlockChange",
"member": "Class com.sk89q.worldedit.history.change.BlockChange",
"changes": [
"CLASS_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.biome.BiomeType",
"member": "Class com.sk89q.worldedit.world.biome.BiomeType",
"changes": [
"CLASS_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.biome.BiomeType",
"member": "Method com.sk89q.worldedit.world.biome.BiomeType.equals(java.lang.Object)",
"changes": [
"METHOD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.biome.BiomeType",
"member": "Method com.sk89q.worldedit.world.biome.BiomeType.hashCode()",
"changes": [
"METHOD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.entity.EntityType",
"member": "Class com.sk89q.worldedit.world.entity.EntityType",
"changes": [
"CLASS_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.entity.EntityType",
"member": "Method com.sk89q.worldedit.world.entity.EntityType.equals(java.lang.Object)",
"changes": [
"METHOD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.entity.EntityType",
"member": "Method com.sk89q.worldedit.world.entity.EntityType.hashCode()",
"changes": [
"METHOD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.fluid.FluidType",
"member": "Class com.sk89q.worldedit.world.fluid.FluidType",
"changes": [
"CLASS_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.fluid.FluidType",
"member": "Method com.sk89q.worldedit.world.fluid.FluidType.equals(java.lang.Object)",
"changes": [
"METHOD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.fluid.FluidType",
"member": "Method com.sk89q.worldedit.world.fluid.FluidType.hashCode()",
"changes": [
"METHOD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.gamemode.GameMode",
"member": "Class com.sk89q.worldedit.world.gamemode.GameMode",
"changes": [
"CLASS_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.gamemode.GameMode",
"member": "Method com.sk89q.worldedit.world.gamemode.GameMode.equals(java.lang.Object)",
"changes": [
"METHOD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.gamemode.GameMode",
"member": "Method com.sk89q.worldedit.world.gamemode.GameMode.hashCode()",
"changes": [
"METHOD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.registry.SimpleItemMaterial",
"member": "Class com.sk89q.worldedit.world.registry.SimpleItemMaterial",
"changes": [
"CLASS_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.weather.WeatherType",
"member": "Class com.sk89q.worldedit.world.weather.WeatherType",
"changes": [
"CLASS_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.weather.WeatherType",
"member": "Method com.sk89q.worldedit.world.weather.WeatherType.equals(java.lang.Object)",
"changes": [
"METHOD_NOW_FINAL"
]
},
{
"type": "com.sk89q.worldedit.world.weather.WeatherType",
"member": "Method com.sk89q.worldedit.world.weather.WeatherType.hashCode()",
"changes": [
"METHOD_NOW_FINAL"
]
}
]
}

View File

@ -48,12 +48,8 @@
"implementation"("com.thoughtworks.paranamer:paranamer:2.6")
"implementation"("com.sk89q.lib:jlibnoise:1.0.0")
"api"(platform("org.enginehub.lin-bus:lin-bus-bom:${Versions.LIN_BUS}"))
"api"("org.enginehub.lin-bus:lin-bus-tree") {
exclude(group = "org.jetbrains", module = "annotations")
}
"api"("org.enginehub.lin-bus.format:lin-bus-format-snbt") {
exclude(group = "org.jetbrains", module = "annotations")
}
"api"("org.enginehub.lin-bus:lin-bus-tree")
"api"("org.enginehub.lin-bus.format:lin-bus-format-snbt")
"implementation"("org.apache.logging.log4j:log4j-api:${Versions.LOG4J}") {
because("Mojang provides Log4J")
@ -72,21 +68,25 @@
"compileOnly"("com.google.auto.value:auto-value-annotations:${Versions.AUTO_VALUE}")
"annotationProcessor"("com.google.auto.value:auto-value:${Versions.AUTO_VALUE}")
"compileOnly"("com.google.auto.service:auto-service:1.1.1") {
because("Needed to resolve annotations in Piston")
}
"languageFiles"("${project.group}:worldedit-lang:7.3.1:1309@zip")
"testRuntimeOnly"("org.apache.logging.log4j:log4j-core:${Versions.LOG4J}")
}
tasks.named<Test>("test") {
tasks.test {
maxHeapSize = "1G"
}
tasks.withType<JavaCompile>().configureEach {
tasks.compileJava {
dependsOn(":worldedit-libs:build")
options.compilerArgs.add("-Aarg.name.key.prefix=")
}
tasks.named<AntlrTask>("generateGrammarSource").configure {
tasks.generateGrammarSource {
val pkg = "com.sk89q.worldedit.antlr"
outputDirectory = file("build/generated-src/antlr/main/${pkg.replace('.', '/')}")
arguments = listOf(

View File

@ -38,6 +38,7 @@
* @deprecated WorldEdit does not handle interpreting NBT,
* deprecated for removal without replacement
*/
@SuppressWarnings({"rawtypes", "unchecked"})
@Deprecated
public class MobSpawnerBlock extends LegacyBaseBlockWrapper {
@ -48,7 +49,7 @@ public class MobSpawnerBlock extends LegacyBaseBlockWrapper {
private short spawnCount = 4;
private short spawnRange = 4;
private CompoundTag spawnData;
private ListTag spawnPotentials;
private ListTag<?, ?> spawnPotentials;
private short minSpawnDelay = 200;
private short maxSpawnDelay = 800;
private short maxNearbyEntities = 6;

View File

@ -113,7 +113,7 @@ public void setNbtData(CompoundTag rootTag) {
Map<String, Tag<?, ?>> values = rootTag.getValue();
Tag t;
Tag<?, ?> t;
t = values.get("id");
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals(getNbtId())) {

View File

@ -28,6 +28,7 @@
* Note that the method name can actually be anything.
*/
@Retention(RetentionPolicy.RUNTIME)
@Deprecated
public @interface Command {
/**

View File

@ -29,6 +29,7 @@
*/
@Retention(RetentionPolicy.RUNTIME)
@Deprecated
public @interface CommandAlias {
/**

View File

@ -27,6 +27,7 @@
import java.util.Map;
import java.util.Set;
@Deprecated
public class CommandContext {
protected final String command;

View File

@ -27,6 +27,7 @@
import javax.annotation.Nullable;
@Deprecated
public class CommandException extends Exception {
private final List<String> commandStack = new ArrayList<>();

View File

@ -22,6 +22,7 @@
import java.util.HashMap;
import java.util.Map;
@Deprecated
public class CommandLocals {
private final Map<Object, Object> locals = new HashMap<>();

View File

@ -26,6 +26,7 @@
* Indicates a list of permissions that should be checked.
*/
@Retention(RetentionPolicy.RUNTIME)
@Deprecated
public @interface CommandPermissions {
/**

View File

@ -22,6 +22,7 @@
/**
* Thrown when not enough permissions are satisfied.
*/
@Deprecated
public class CommandPermissionsException extends CommandException {
}

View File

@ -19,6 +19,7 @@
package com.sk89q.minecraft.util.commands;
@Deprecated
public class CommandUsageException extends CommandException {
protected String usage;

View File

@ -26,6 +26,7 @@
* This annotation indicates that a command can be used from the console.
*/
@Retention(RetentionPolicy.RUNTIME)
@Deprecated
public @interface Console {
}

View File

@ -24,6 +24,7 @@
/**
* Constructs new instances.
*/
@Deprecated
public interface Injector {
/**

View File

@ -19,6 +19,7 @@
package com.sk89q.minecraft.util.commands;
@Deprecated
public class MissingNestedCommandException extends CommandUsageException {
public MissingNestedCommandException(String message, String usage) {

View File

@ -31,6 +31,7 @@
* are still required.
*/
@Retention(RetentionPolicy.RUNTIME)
@Deprecated
public @interface NestedCommand {
/**

View File

@ -25,6 +25,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@Deprecated
public class SimpleInjector implements Injector {
private static final Logger LOGGER = LogManagerCompat.getLogger();

View File

@ -19,6 +19,7 @@
package com.sk89q.minecraft.util.commands;
@Deprecated
public class SuggestionContext {
private static final SuggestionContext FOR_LAST = new SuggestionContext(null, true);

View File

@ -19,6 +19,7 @@
package com.sk89q.minecraft.util.commands;
@Deprecated
public class UnhandledCommandException extends CommandException {
}

View File

@ -19,6 +19,7 @@
package com.sk89q.minecraft.util.commands;
@Deprecated
public class WrappedCommandException extends CommandException {
public WrappedCommandException(Throwable t) {

View File

@ -21,5 +21,4 @@
* This package contains the old command system. It is no longer in use. Please switch
* to Piston, Intake, ACF, or similar systems.
*/
@Deprecated
package com.sk89q.minecraft.util.commands;

View File

@ -95,6 +95,7 @@ public abstract class LocalConfiguration {
public String defaultLocaleName = "default";
public Locale defaultLocale = Locale.getDefault();
@SuppressWarnings("deprecation")
protected String[] getDefaultDisallowedBlocks() {
List<BlockType> blockTypes = Lists.newArrayList(
BlockTypes.OAK_SAPLING,
@ -161,7 +162,7 @@ protected String[] getDefaultDisallowedBlocks() {
// ores and stuff
BlockTypes.BEDROCK
);
return blockTypes.stream().filter(Objects::nonNull).map(BlockType::getId).toArray(String[]::new);
return blockTypes.stream().filter(Objects::nonNull).map(BlockType::id).toArray(String[]::new);
}
/**
@ -224,7 +225,7 @@ public String convertLegacyItem(String legacy) {
id = Integer.parseInt(splitter[0]);
data = Byte.parseByte(splitter[1]);
}
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).getId();
item = LegacyMapper.getInstance().getItemFromLegacy(id, data).id();
} catch (Throwable ignored) {
}

View File

@ -789,7 +789,7 @@ public void setTool(ItemType item, @Nullable Tool tool) throws InvalidToolBindEx
}, this.navWandItem, item);
} else if (tool == null) {
// Check if un-setting sel/nav
String id = item.getId();
String id = item.id();
if (id.equals(this.wandItem)) {
this.wandItem = null;
setDirty();
@ -809,7 +809,7 @@ private void setSingleItemTool(Consumer<String> setter, @Nullable String itemId,
this.tools.remove(item);
}
}
setter.accept(newItem.getId());
setter.accept(newItem.id());
setDirty();
}

View File

@ -111,6 +111,6 @@ public String toString() {
nbtString = LinStringIO.writeToString(nbtData.getValue());
}
return getType().getId() + nbtString;
return getType().id() + nbtString;
}
}

View File

@ -91,7 +91,7 @@ public void biomeList(Actor actor,
PaginationBox paginationBox = PaginationBox.fromComponents("Available Biomes", "/biomelist -p %page%",
BiomeType.REGISTRY.values().stream()
.map(biomeType -> TextComponent.builder()
.append(biomeType.getId())
.append(biomeType.id())
.append(" (")
.append(biomeRegistry.getRichName(biomeType))
.append(")")
@ -155,7 +155,7 @@ public void biomeInfo(Actor actor, World world, LocalSession session,
List<Component> components = biomes.stream().map(biome ->
biomeRegistry.getRichName(biome).hoverEvent(
HoverEvent.showText(TextComponent.of(biome.getId()))
HoverEvent.showText(TextComponent.of(biome.id()))
)
).collect(Collectors.toList());
actor.printInfo(TranslatableComponent.of(messageKey, TextUtils.join(components, TextComponent.of(", "))));

View File

@ -381,7 +381,7 @@ public void world(Actor actor, LocalSession session,
if (world == null) {
actor.printInfo(TranslatableComponent.of("worldedit.world.remove"));
} else {
actor.printInfo(TranslatableComponent.of("worldedit.world.set", TextComponent.of(world.getId())));
actor.printInfo(TranslatableComponent.of("worldedit.world.set", TextComponent.of(world.id())));
}
}
@ -532,7 +532,7 @@ public Component call() throws Exception {
if (itemsOnly && searchType.hasBlockType()) {
continue;
}
final String id = searchType.getId();
final String id = searchType.id();
if (id.contains(idMatch)) {
Component name = searchType.getRichName();
results.put(id, TextComponent.builder()

View File

@ -839,7 +839,7 @@ public Component getComponent(int number) {
toolTip = TextComponent.of(state.getAsString(), TextColor.GRAY);
blockName = blockName.append(TextComponent.of("*", TextColor.LIGHT_PURPLE));
} else {
toolTip = TextComponent.of(blockType.getId(), TextColor.GRAY);
toolTip = TextComponent.of(blockType.id(), TextColor.GRAY);
}
blockName = blockName.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, toolTip));
line.append(blockName);

View File

@ -144,8 +144,8 @@ static void setToolNone(Player player, LocalSession session, boolean isBrush)
throws InvalidToolBindException {
ItemType type = player.getItemInHand(HandSide.MAIN_HAND).getType();
boolean set = session.getTool(type) != null
|| type.getId().equals(session.getWandItem())
|| type.getId().equals(session.getNavWandItem());
|| type.id().equals(session.getWandItem())
|| type.id().equals(session.getNavWandItem());
if (set) {
session.setTool(type, null);
player.printInfo(TranslatableComponent.of(isBrush ? "worldedit.brush.none.equip" : "worldedit.tool.none.equip"));

View File

@ -86,7 +86,7 @@ public void version(Actor actor) {
producer.append(
TextComponent.of("* ", TextColor.GRAY)
.append(TextComponent.of(platform.getPlatformName())
.hoverEvent(HoverEvent.showText(TextComponent.of(platform.getId()))))
.hoverEvent(HoverEvent.showText(TextComponent.of(platform.id()))))
.append(TextComponent.of("(" + platform.getPlatformVersion() + ")"))
).newline();
}

View File

@ -63,7 +63,7 @@ private Stream<? extends World> getWorlds() {
@Override
public List<String> getSuggestions(String input, InjectedValueAccess context) {
return getWorlds()
.map(World::getId)
.map(World::id)
.filter(world -> world.startsWith(input))
.collect(Collectors.toList());
}
@ -71,7 +71,7 @@ public List<String> getSuggestions(String input, InjectedValueAccess context) {
@Override
public ConversionResult<World> convert(String s, InjectedValueAccess injectedValueAccess) {
World result = getWorlds()
.filter(world -> world.getId().equals(s))
.filter(world -> world.id().equals(s))
.findAny().orElse(null);
return result == null
? FailedConversion.from(new IllegalArgumentException(

View File

@ -64,7 +64,7 @@ private boolean handleCycle(LocalConfiguration config, Player player, LocalSessi
if (!config.allowedDataCycleBlocks.isEmpty()
&& !player.hasPermission("worldedit.override.data-cycler")
&& !config.allowedDataCycleBlocks.contains(block.getBlockType().getId())) {
&& !config.allowedDataCycleBlocks.contains(block.getBlockType().id())) {
player.printError(TranslatableComponent.of("worldedit.tool.data-cycler.block-not-permitted"));
return true;
}

View File

@ -123,22 +123,22 @@ public BaseBlock parseFromInput(String input, ParserContext context)
@SuppressWarnings("ConstantConditions")
private String woolMapper(String string) {
return switch (string.toLowerCase(Locale.ROOT)) {
case "white" -> BlockTypes.WHITE_WOOL.getId();
case "black" -> BlockTypes.BLACK_WOOL.getId();
case "blue" -> BlockTypes.BLUE_WOOL.getId();
case "brown" -> BlockTypes.BROWN_WOOL.getId();
case "cyan" -> BlockTypes.CYAN_WOOL.getId();
case "gray", "grey" -> BlockTypes.GRAY_WOOL.getId();
case "green" -> BlockTypes.GREEN_WOOL.getId();
case "light_blue", "lightblue" -> BlockTypes.LIGHT_BLUE_WOOL.getId();
case "light_gray", "light_grey", "lightgray", "lightgrey" -> BlockTypes.LIGHT_GRAY_WOOL.getId();
case "lime" -> BlockTypes.LIME_WOOL.getId();
case "magenta" -> BlockTypes.MAGENTA_WOOL.getId();
case "orange" -> BlockTypes.ORANGE_WOOL.getId();
case "pink" -> BlockTypes.PINK_WOOL.getId();
case "purple" -> BlockTypes.PURPLE_WOOL.getId();
case "yellow" -> BlockTypes.YELLOW_WOOL.getId();
case "red" -> BlockTypes.RED_WOOL.getId();
case "white" -> BlockTypes.WHITE_WOOL.id();
case "black" -> BlockTypes.BLACK_WOOL.id();
case "blue" -> BlockTypes.BLUE_WOOL.id();
case "brown" -> BlockTypes.BROWN_WOOL.id();
case "cyan" -> BlockTypes.CYAN_WOOL.id();
case "gray", "grey" -> BlockTypes.GRAY_WOOL.id();
case "green" -> BlockTypes.GREEN_WOOL.id();
case "light_blue", "lightblue" -> BlockTypes.LIGHT_BLUE_WOOL.id();
case "light_gray", "light_grey", "lightgray", "lightgrey" -> BlockTypes.LIGHT_GRAY_WOOL.id();
case "lime" -> BlockTypes.LIME_WOOL.id();
case "magenta" -> BlockTypes.MAGENTA_WOOL.id();
case "orange" -> BlockTypes.ORANGE_WOOL.id();
case "pink" -> BlockTypes.PINK_WOOL.id();
case "purple" -> BlockTypes.PURPLE_WOOL.id();
case "yellow" -> BlockTypes.YELLOW_WOOL.id();
case "red" -> BlockTypes.RED_WOOL.id();
default -> string;
};
}
@ -164,10 +164,10 @@ private static Map<Property<?>, Object> parseProperties(BlockType type, String[]
throw new NoMatchException(TranslatableComponent.of(
"worldedit.error.parser.unknown-property",
TextComponent.of(parts[0]),
TextComponent.of(type.getId())
TextComponent.of(type.id())
));
} else {
WorldEdit.logger.debug("Unknown property " + parts[0] + " for block " + type.getId());
WorldEdit.logger.debug("Unknown property " + parts[0] + " for block " + type.id());
}
return Map.of();
}
@ -423,7 +423,7 @@ private BaseBlock parseLogic(String input, ParserContext context) throws InputPa
if (context.isRestricted()) {
Actor actor = context.requireActor();
if (actor != null && !actor.hasPermission("worldedit.anyblock")
&& worldEdit.getConfiguration().disallowedBlocks.contains(blockType.getId())) {
&& worldEdit.getConfiguration().disallowedBlocks.contains(blockType.id())) {
throw new DisallowedUsageException(TranslatableComponent.of("worldedit.error.disallowed-block", TextComponent.of(input)));
}
}
@ -437,7 +437,7 @@ private BaseBlock parseLogic(String input, ParserContext context) throws InputPa
if (DeprecationUtil.isSign(blockType) && blockAndExtraData.length > 1) {
// Allow special sign text syntax
String[] text = new String[4];
text[0] = blockAndExtraData.length > 1 ? blockAndExtraData[1] : "";
text[0] = blockAndExtraData[1];
text[1] = blockAndExtraData.length > 2 ? blockAndExtraData[2] : "";
text[2] = blockAndExtraData.length > 3 ? blockAndExtraData[3] : "";
text[3] = blockAndExtraData.length > 4 ? blockAndExtraData[4] : "";
@ -453,19 +453,19 @@ private BaseBlock parseLogic(String input, ParserContext context) throws InputPa
if (ent == null) {
throw new NoMatchException(TranslatableComponent.of("worldedit.error.unknown-entity", TextComponent.of(mobName)));
}
mobName = ent.getId();
mobName = ent.id();
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
throw new NoMatchException(TranslatableComponent.of("worldedit.error.unknown-mob", TextComponent.of(mobName)));
}
} else {
mobName = EntityTypes.PIG.getId();
mobName = EntityTypes.PIG.id();
}
@SuppressWarnings("deprecation")
MobSpawnerBlock mobSpawnerBlock = new MobSpawnerBlock(state, mobName);
return mobSpawnerBlock;
} else if ((blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) && (blockAndExtraData.length > 1 || blockNbtData != null)) {
// allow setting type/player/rotation
if (blockAndExtraData.length <= 1) {
if (blockAndExtraData.length == 1) {
@SuppressWarnings("deprecation")
SkullBlock skullBlock = new SkullBlock(state);
return skullBlock;

View File

@ -50,7 +50,7 @@ public DefaultItemParser(WorldEdit worldEdit) {
}
@Override
public Stream<String> getSuggestions(String input) {
public Stream<String> getSuggestions(String input, ParserContext context) {
return SuggestionHelper.getNamespacedRegistrySuggestions(ItemType.REGISTRY, input);
}

View File

@ -45,7 +45,7 @@ public BiomeMaskParser(WorldEdit worldEdit) {
}
@Override
public Stream<String> getSuggestions(String input) {
public Stream<String> getSuggestions(String input, ParserContext context) {
if (input.isEmpty()) {
return Stream.of("$");
}

View File

@ -41,7 +41,7 @@ public BlockCategoryMaskParser(WorldEdit worldEdit) {
}
@Override
public Stream<String> getSuggestions(String input) {
public Stream<String> getSuggestions(String input, ParserContext context) {
return SuggestionHelper.getBlockCategorySuggestions(input, false);
}

View File

@ -38,7 +38,7 @@ public BlockStateMaskParser(WorldEdit worldEdit) {
}
@Override
public Stream<String> getSuggestions(String input) {
public Stream<String> getSuggestions(String input, ParserContext context) {
if (input.isEmpty()) {
return Stream.of("^[", "^=[");
}

View File

@ -42,7 +42,7 @@ public ExpressionMaskParser(WorldEdit worldEdit) {
}
@Override
public Stream<String> getSuggestions(String input) {
public Stream<String> getSuggestions(String input, ParserContext context) {
if (input.isEmpty()) {
return Stream.of("=");
}

View File

@ -35,7 +35,7 @@ public NoiseMaskParser(WorldEdit worldEdit) {
}
@Override
public Stream<String> getSuggestions(String input) {
public Stream<String> getSuggestions(String input, ParserContext context) {
if (input.isEmpty()) {
return Stream.of("%");
}

View File

@ -43,7 +43,7 @@ public BlockCategoryPatternParser(WorldEdit worldEdit) {
}
@Override
public Stream<String> getSuggestions(String input) {
public Stream<String> getSuggestions(String input, ParserContext context) {
return SuggestionHelper.getBlockCategorySuggestions(input, true);
}
@ -67,7 +67,7 @@ public Pattern parseFromInput(String input, ParserContext context) throws InputP
Set<BlockType> blocks = category.getAll();
if (blocks.isEmpty()) {
throw new InputParseException(TranslatableComponent.of("worldedit.error.empty-tag", TextComponent.of(category.getId())));
throw new InputParseException(TranslatableComponent.of("worldedit.error.empty-tag", TextComponent.of(category.id())));
}
if (anyState) {

View File

@ -42,7 +42,7 @@ public ClipboardPatternParser(WorldEdit worldEdit) {
}
@Override
public Stream<String> getSuggestions(String input) {
public Stream<String> getSuggestions(String input, ParserContext context) {
if (input.isEmpty()) {
return Stream.of("#clipboard");
}

View File

@ -203,7 +203,7 @@ default void registerGameHooks() {
*/
@NonAbstractForCompatibility(delegateName = "getPlatformName", delegateParams = {})
@Override
default String getId() {
default String id() {
return "legacy:" + getPlatformName().toLowerCase(Locale.ROOT).replaceAll("[^a-z_.-]", "_");
}

View File

@ -68,7 +68,7 @@ private BlockState convertLegacyBlockType(String id, int data) {
} else {
BlockState plantedWithData = LegacyMapper.getInstance().getBlockFromLegacy(newId, data);
if (plantedWithData != null) {
plantedName = plantedWithData.getBlockType().getId().substring(10); // remove "minecraft:"
plantedName = plantedWithData.getBlockType().id().substring(10); // remove "minecraft:"
}
}
if (plantedName != null) {

View File

@ -27,6 +27,7 @@
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import org.enginehub.linbus.tree.LinCompoundTag;
import org.enginehub.linbus.tree.LinTag;
import java.util.HashMap;
import java.util.Map;
@ -73,7 +74,6 @@ default <B extends BlockStateHolder<B>> BlockStateHolder<?> updateNBT(B block, M
delegateName = "updateNBT",
delegateParams = { BlockStateHolder.class, Map.class }
)
@SuppressWarnings("deprecated")
default BaseBlock updateNbt(BaseBlock block) {
DeprecationUtil.checkDelegatingOverride(getClass());
if (!isAffectedBlock(block)) {
@ -87,8 +87,9 @@ default BaseBlock updateNbt(BaseBlock block) {
BlockStateHolder<?> changedBlock = updateNBT(block, values);
return changedBlock.toBaseBlock(LazyReference.from(() -> {
var builder = LinCompoundTag.builder();
for (var entry : values.entrySet()) {
builder.put(entry.getKey(), entry.getValue().toLinTag());
for (@SuppressWarnings("deprecation") var entry : values.entrySet()) {
LinTag<?> linTag = entry.getValue().toLinTag();
builder.put(entry.getKey(), linTag);
}
return builder.build();
}));

View File

@ -29,7 +29,7 @@ public class Pre13HangingCompatibilityHandler implements EntityNBTCompatibilityH
@Override
public LinCompoundTag updateNbt(EntityType type, LinCompoundTag tag) {
if (!type.getId().startsWith("minecraft:")) {
if (!type.id().startsWith("minecraft:")) {
return tag;
}
Direction newDirection;

View File

@ -104,7 +104,7 @@ private LinCompoundTag write2(Clipboard clipboard) {
worldEditSection.putString("Version", WorldEdit.getVersion());
worldEditSection.putString(
"EditingPlatform",
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getId()
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).id()
);
worldEditSection.putIntArray("Offset", new int[] {
offset.x(), offset.y(), offset.z()
@ -113,7 +113,7 @@ private LinCompoundTag write2(Clipboard clipboard) {
LinCompoundTag.Builder platformsSection = LinCompoundTag.builder();
for (Platform platform : WorldEdit.getInstance().getPlatformManager().getPlatforms()) {
platformsSection.put(
platform.getId(),
platform.id(),
LinCompoundTag.builder()
.putString("Name", platform.getPlatformName())
.putString("Version", platform.getPlatformVersion())

View File

@ -107,7 +107,7 @@ private LinCompoundTag write3(Clipboard clipboard) {
worldEditSection.putString("Version", WorldEdit.getVersion());
worldEditSection.putString(
"EditingPlatform",
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getId()
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).id()
);
worldEditSection.putIntArray("Origin", new int[] {
origin.x(), origin.y(), origin.z()
@ -116,7 +116,7 @@ private LinCompoundTag write3(Clipboard clipboard) {
LinCompoundTag.Builder platformsSection = LinCompoundTag.builder();
for (Platform platform : WorldEdit.getInstance().getPlatformManager().getPlatforms()) {
platformsSection.put(
platform.getId(),
platform.id(),
LinCompoundTag.builder()
.putString("Name", platform.getPlatformName())
.putString("Version", platform.getPlatformVersion())

View File

@ -99,7 +99,9 @@ public static Pattern getTemperatePattern() {
BlockType grass = BlockTypes.SHORT_GRASS;
if (grass == null) {
// Fallback for <1.20.3 compat
grass = BlockTypes.GRASS;
@SuppressWarnings("deprecation")
BlockType deprecatedGrass = BlockTypes.GRASS;
grass = deprecatedGrass;
}
pattern.add(grass.getDefaultState(), 300);
pattern.add(BlockTypes.POPPY.getDefaultState(), 5);

View File

@ -55,7 +55,7 @@ public Mask2D toMask2D() {
}
@Override
public void close() throws Exception {
public void close() {
clear();
}
}

View File

@ -51,7 +51,7 @@ public void clear() {
}
@Override
public void close() throws Exception {
public void close() {
clear();
}
}

View File

@ -54,11 +54,11 @@ public void add(Change change) {
if (isRecordingChanges()) {
if (change instanceof BlockChange blockChange) {
BlockVector3 position = blockChange.getPosition();
BlockVector3 position = blockChange.position();
if (!previous.containsLocation(position)) {
previous.add(position, blockChange.getPrevious());
previous.add(position, blockChange.previous());
}
current.add(position, blockChange.getCurrent());
current.add(position, blockChange.current());
} else {
super.add(change);
}

View File

@ -1,40 +0,0 @@
/*
* 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.internal.command;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.auth.Authorizer;
/**
* Implementation of an authorizer that uses {@link Actor#hasPermission(String)}.
*/
public class ActorAuthorizer implements Authorizer {
@Override
public boolean testPermission(CommandLocals locals, String permission) {
Actor sender = locals.get(Actor.class);
if (sender == null) {
throw new RuntimeException("Uh oh! No 'Actor' specified so that we can check permissions");
} else {
return sender.hasPermission(permission);
}
}
}

View File

@ -162,7 +162,7 @@ public static BaseBlock createStructureBlock(Player player) {
structureTag.putString("mode", "SAVE");
structureTag.putByte("ignoreEntities", (byte) 1);
structureTag.putByte("showboundingbox", (byte) 1);
structureTag.putString("id", BlockTypes.STRUCTURE_BLOCK.getId());
structureTag.putString("id", BlockTypes.STRUCTURE_BLOCK.id());
return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(structureTag.build());
}

View File

@ -47,7 +47,7 @@ protected InputParser(WorldEdit worldEdit) {
* @return a stream of suggestions
* @deprecated Use the version that takes a {@link ParserContext}, {@link #getSuggestions(String, ParserContext)}
*/
@Deprecated
@Deprecated(forRemoval = true)
public Stream<String> getSuggestions(String input) {
return Stream.empty();
}

View File

@ -66,7 +66,7 @@ public String getPrimaryMatcher() {
}
@Override
public Stream<String> getSuggestions(String input) {
public Stream<String> getSuggestions(String input, ParserContext context) {
if (input.isEmpty()) {
return Stream.of(getPrimaryMatcher());
}

View File

@ -23,7 +23,9 @@
import java.util.Set;
import java.util.function.Supplier;
public abstract class Category<T extends Keyed> {
import static com.google.common.base.Preconditions.checkState;
public abstract class Category<T extends Keyed> implements Keyed {
private final Set<T> set = new HashSet<>();
private final Supplier<Set<T>> supplier;
protected final String id;
@ -39,17 +41,14 @@ public Category(final String id, final Supplier<Set<T>> contentSupplier) {
this.supplier = contentSupplier;
}
public final String getId() {
@Override
public final String id() {
return this.id;
}
public final Set<T> getAll() {
if (this.empty) {
if (supplier != null) {
this.set.addAll(this.supplier.get());
} else {
this.set.addAll(this.load());
}
this.set.addAll(this.load());
this.empty = false;
}
return this.set;
@ -63,7 +62,10 @@ public final Set<T> getAll() {
* the platforms via the supplier constructor.
*/
@Deprecated
protected abstract Set<T> load();
protected Set<T> load() {
checkState(this.supplier != null, "load() should be overriden or a supplier should be provided in the constructor.");
return this.supplier.get();
}
/**
* Checks if this category contains {@code object}.
@ -82,6 +84,6 @@ public void invalidateCache() {
@Override
public String toString() {
return getId();
return id();
}
}

View File

@ -107,7 +107,7 @@ public void load() {
registerHelp = getBool("register-help", registerHelp);
wandItem = getString("wand-item", wandItem).toLowerCase(Locale.ROOT);
try {
wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).getId();
wandItem = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(wandItem)).id();
} catch (Throwable ignored) {
}
superPickaxeDrop = getBool("super-pickaxe-drop-items", superPickaxeDrop);
@ -117,7 +117,7 @@ public void load() {
useInventoryCreativeOverride = getBool("use-inventory-creative-override", useInventoryCreativeOverride);
navigationWand = getString("nav-wand-item", navigationWand).toLowerCase(Locale.ROOT);
try {
navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).getId();
navigationWand = LegacyMapper.getInstance().getItemFromLegacy(Integer.parseInt(navigationWand)).id();
} catch (Throwable ignored) {
}
navigationWandMaxDistance = getInt("nav-wand-distance", navigationWandMaxDistance);

View File

@ -1,38 +0,0 @@
/*
* 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.auth;
import com.sk89q.minecraft.util.commands.CommandLocals;
/**
* Tests whether permission is granted.
*/
public interface Authorizer {
/**
* Tests whether permission is granted for the given context.
*
* @param locals locals
* @param permission the permission string
* @return true if permitted
*/
boolean testPermission(CommandLocals locals, String permission);
}

View File

@ -1,35 +0,0 @@
/*
* 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.auth;
import com.sk89q.minecraft.util.commands.CommandLocals;
/**
* An implementation of {@link Authorizer} that always returns false for
* tests of permissions.
*/
public class NullAuthorizer implements Authorizer {
@Override
public boolean testPermission(CommandLocals locals, String permission) {
return false;
}
}

View File

@ -65,7 +65,7 @@ public String getName() {
}
@Override
public String getId() {
public String id() {
return "null";
}

View File

@ -34,16 +34,10 @@ public class BiomeCategory extends Category<BiomeType> implements Keyed {
public static final NamespacedRegistry<BiomeCategory> REGISTRY = new NamespacedRegistry<>("biome tag", true);
public BiomeCategory(final String id) {
super(id);
super(id, Set::of);
}
public BiomeCategory(final String id, final Supplier<Set<BiomeType>> contentSupplier) {
super(id, contentSupplier);
}
@Override
protected Set<BiomeType> load() {
return Set.of();
}
}

View File

@ -25,8 +25,6 @@
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import java.util.Set;
/**
* A category of blocks. This is due to the splitting up of
* blocks such as wool into separate ids.
@ -36,14 +34,9 @@ public class BlockCategory extends Category<BlockType> implements Keyed {
public static final NamespacedRegistry<BlockCategory> REGISTRY = new NamespacedRegistry<>("block tag", true);
public BlockCategory(final String id) {
super(id);
}
@Override
protected Set<BlockType> load() {
return WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries()
.getBlockCategoryRegistry().getAll(this);
super(id, () -> WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries()
.getBlockCategoryRegistry().getCategorisedByName(id));
}
/**

View File

@ -137,7 +137,7 @@ static Map<Map<Property<?>, Object>, BlockState> generateStateMap(BlockType bloc
}
long timeTaken = System.currentTimeMillis() - startTime;
if (timeTaken > 5000) {
WorldEdit.logger.warn("Took more than 5 seconds to generate complete state map for " + blockType.getId() + ". This block is likely improperly using properties. State count: " + stateMap.size() + ". " + timeTaken + "ms elapsed.");
WorldEdit.logger.warn("Took more than 5 seconds to generate complete state map for " + blockType.id() + ". This block is likely improperly using properties. State count: " + stateMap.size() + ". " + timeTaken + "ms elapsed.");
}
return stateMap;

View File

@ -135,14 +135,14 @@ default BaseBlock applyBlock(BlockVector3 position) {
default String getAsString() {
if (getStates().isEmpty()) {
return this.getBlockType().getId();
return this.getBlockType().id();
} else {
String properties = getStates().entrySet().stream()
.map(entry -> entry.getKey().getName()
+ "="
+ entry.getValue().toString().toLowerCase(Locale.ROOT))
.collect(Collectors.joining(","));
return this.getBlockType().getId() + "[" + properties + "]";
return this.getBlockType().id() + "[" + properties + "]";
}
}
}

View File

@ -97,7 +97,7 @@ private Map<Map<Property<?>, Object>, BlockState> getBlockStatesMap() {
* @return The id
*/
@Override
public String getId() {
public String id() {
return this.id;
}
@ -116,7 +116,7 @@ public Component getRichName() {
public String getName() {
String name = this.name.getValue();
if (name == null || name.isEmpty()) {
return getId();
return id();
}
return name;
}
@ -249,7 +249,7 @@ private int computeLegacy(int index) {
@Override
public String toString() {
return getId();
return id();
}
@Override

View File

@ -119,7 +119,7 @@ public AnvilChunk13(LinCompoundTag tag) throws DataException {
try {
blockState = getBlockStateWith(blockState, property, value);
} catch (IllegalArgumentException e) {
throw new InvalidFormatException("Invalid block state for " + blockState.getBlockType().getId() + ", " + property.getName() + ": " + value);
throw new InvalidFormatException("Invalid block state for " + blockState.getBlockType().id() + ", " + property.getName() + ": " + value);
}
}
}

View File

@ -111,7 +111,7 @@ public AnvilChunk18(LinCompoundTag tag) throws DataException {
try {
blockState = getBlockStateWith(blockState, property, value);
} catch (IllegalArgumentException e) {
throw new InvalidFormatException("Invalid block state for " + blockState.getBlockType().getId() + ", " + property.getName() + ": " + value);
throw new InvalidFormatException("Invalid block state for " + blockState.getBlockType().id() + ", " + property.getName() + ": " + value);
}
}
}

View File

@ -37,7 +37,7 @@ private static FluidCategory register(final String id) {
}
public static FluidCategory register(final FluidCategory tag) {
return FluidCategory.REGISTRY.register(tag.getId(), tag);
return FluidCategory.REGISTRY.register(tag.id(), tag);
}
public static @Nullable FluidCategory get(final String id) {

View File

@ -23,7 +23,6 @@
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import java.util.Collections;
import java.util.Set;
/**
@ -35,14 +34,10 @@ public class FluidCategory extends Category<FluidType> implements Keyed {
public static final NamespacedRegistry<FluidCategory> REGISTRY = new NamespacedRegistry<>("fluid tag");
public FluidCategory(final String id) {
super(id);
}
@Override
protected Set<FluidType> load() {
return Collections.emptySet(); // TODO Make this work.
// TODO Make this work.
// return WorldEdit.getInstance().getPlatformManager()
// .queryCapability(Capability.GAME_HOOKS).getRegistries()
// .getBlockCategoryRegistry().getCategorisedByName(this.id);
super(id, Set::of);
}
}

View File

@ -40,7 +40,7 @@ private static FluidType register(final String id) {
}
public static FluidType register(final FluidType fluid) {
return FluidType.REGISTRY.register(fluid.getId(), fluid);
return FluidType.REGISTRY.register(fluid.id(), fluid);
}
public static @Nullable FluidType get(final String id) {

View File

@ -36,7 +36,7 @@ private static GameMode register(final String id) {
}
public static GameMode register(final GameMode gameMode) {
return GameMode.REGISTRY.register(gameMode.getId(), gameMode);
return GameMode.REGISTRY.register(gameMode.id(), gameMode);
}
@Nullable

View File

@ -26,8 +26,6 @@
import com.sk89q.worldedit.registry.Keyed;
import com.sk89q.worldedit.registry.NamespacedRegistry;
import java.util.Set;
/**
* A category of items. This is due to the splitting up of
* items such as wool into separate ids.
@ -37,14 +35,9 @@ public class ItemCategory extends Category<ItemType> implements Keyed {
public static final NamespacedRegistry<ItemCategory> REGISTRY = new NamespacedRegistry<>("item tag");
public ItemCategory(final String id) {
super(id);
}
@Override
protected Set<ItemType> load() {
return WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries()
.getItemCategoryRegistry().getAll(this);
super(id, () -> WorldEdit.getInstance().getPlatformManager()
.queryCapability(Capability.GAME_HOOKS).getRegistries()
.getItemCategoryRegistry().getCategorisedByName(id));
}
/**

View File

@ -44,7 +44,7 @@ public class ItemType implements Keyed {
.getRegistries().getItemRegistry().getName(this),
""
);
return name.isEmpty() ? getId() : name;
return name.isEmpty() ? id() : name;
});
private final LazyReference<Component> richName = LazyReference.from(() ->
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS)
@ -64,7 +64,7 @@ public ItemType(String id) {
}
@Override
public String getId() {
public String id() {
return this.id;
}
@ -114,7 +114,7 @@ public ItemMaterial getMaterial() {
@Override
public String toString() {
return getId();
return id();
}
@Override

View File

@ -40,7 +40,7 @@ public class BundledBlockRegistry implements BlockRegistry {
@Override
public Component getRichName(BlockType blockType) {
BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.getId());
BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.id());
if (blockEntry != null) {
// This is more likely to be "right", but not translated
// Some vanilla MC blocks have overrides so we need this name here
@ -49,7 +49,7 @@ public Component getRichName(BlockType blockType) {
return TextComponent.of(blockEntry.localizedName);
}
return TranslatableComponent.of(
TranslationManager.makeTranslationKey("block", blockType.getId())
TranslationManager.makeTranslationKey("block", blockType.id())
);
}
@ -59,14 +59,14 @@ public Component getRichName(BlockType blockType) {
// dumb_intellij.jpg
@SuppressWarnings("deprecation")
public String getName(BlockType blockType) {
BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.getId());
BundledBlockData.BlockEntry blockEntry = BundledBlockData.getInstance().findById(blockType.id());
return blockEntry != null ? blockEntry.localizedName : null;
}
@Nullable
@Override
public BlockMaterial getMaterial(BlockType blockType) {
return new PassthroughBlockMaterial(BundledBlockData.getInstance().getMaterialById(blockType.getId()));
return new PassthroughBlockMaterial(BundledBlockData.getInstance().getMaterialById(blockType.id()));
}
@Nullable

View File

@ -34,7 +34,7 @@
public class BundledItemRegistry implements ItemRegistry {
private BundledItemData.ItemEntry getEntryById(ItemType itemType) {
return BundledItemData.getInstance().findById(itemType.getId());
return BundledItemData.getInstance().findById(itemType.id());
}
@Override
@ -48,7 +48,7 @@ public Component getRichName(ItemType itemType) {
return TextComponent.of(itemEntry.localizedName);
}
return TranslatableComponent.of(
TranslationManager.makeTranslationKey("item", itemType.getId())
TranslationManager.makeTranslationKey("item", itemType.id())
);
}
@ -62,7 +62,7 @@ public String getName(ItemType itemType) {
if (itemEntry != null) {
String localized = itemEntry.localizedName;
if (localized.equals("Air")) {
String id = itemType.getId();
String id = itemType.id();
int c = id.indexOf(':');
return c < 0 ? id : id.substring(c + 1);
}
@ -74,6 +74,6 @@ public String getName(ItemType itemType) {
@Nullable
@Override
public ItemMaterial getMaterial(ItemType itemType) {
return new PassthroughItemMaterial(BundledItemData.getInstance().getMaterialById(itemType.getId()));
return new PassthroughItemMaterial(BundledItemData.getInstance().getMaterialById(itemType.id()));
}
}

View File

@ -38,6 +38,6 @@ public interface CategoryRegistry<T extends Keyed> {
Set<T> getCategorisedByName(String category);
default Set<T> getAll(final Category<T> category) {
return getCategorisedByName(category.getId());
return getCategorisedByName(category.id());
}
}

View File

@ -41,7 +41,7 @@ public NullBiomeRegistry() {
@Override
public Component getRichName(BiomeType biomeType) {
return TranslatableComponent.of(
TranslationManager.makeTranslationKey("biome", biomeType.getId())
TranslationManager.makeTranslationKey("biome", biomeType.id())
);
}

View File

@ -50,7 +50,7 @@ private NBTConversions() {
* @deprecated Use {@link #toLocation(Extent, LinListTag, LinListTag)} instead.
*/
@Deprecated
public static Location toLocation(Extent extent, ListTag positionTag, ListTag directionTag) {
public static Location toLocation(Extent extent, ListTag<?, ?> positionTag, ListTag<?, ?> directionTag) {
checkNotNull(extent);
checkNotNull(positionTag);
checkNotNull(directionTag);

View File

@ -35,7 +35,7 @@ private static WeatherType register(String id) {
}
public static WeatherType register(WeatherType weather) {
return WeatherType.REGISTRY.register(weather.getId(), weather);
return WeatherType.REGISTRY.register(weather.id(), weather);
}
@Nullable