From 81f6e3e7cf40f463e2de4ab7390acba0f4e4acca Mon Sep 17 00:00:00 2001 From: Octavia Togami Date: Tue, 7 Jul 2020 12:52:03 -0700 Subject: [PATCH] Cleanup some javac warnings --- buildSrc/src/main/kotlin/PlatformConfig.kt | 5 ++- worldedit-bukkit/build.gradle.kts | 1 + .../com/sk89q/wepif/DinnerPermsResolver.java | 4 +++ .../sk89q/wepif/NijiPermissionsResolver.java | 9 ++--- .../wepif/PermissionsResolverManager.java | 2 +- .../java/com/sk89q/wepif/VaultResolver.java | 4 +++ .../com/sk89q/wepif/bPermissionsResolver.java | 3 ++ .../bukkit/BukkitBlockCommandSender.java | 4 +++ .../worldedit/bukkit/BukkitCommandSender.java | 4 +++ .../sk89q/worldedit/bukkit/BukkitPlayer.java | 4 +++ .../worldedit/bukkit/WorldEditPlugin.java | 2 +- .../util/commands/SimpleInjector.java | 2 +- .../worldedit/command/GeneralCommands.java | 2 +- .../platform/AbstractPlayerActor.java | 2 +- .../extension/platform/PlayerProxy.java | 4 +++ .../clipboard/io/MCEditSchematicReader.java | 2 +- .../BannerBlockCompatibilityHandler.java | 23 ++++++------- .../BedBlockCompatibilityHandler.java | 34 +++++++++---------- .../FlowerPotCompatibilityHandler.java | 6 ++-- .../legacycompat/NBTCompatibilityHandler.java | 2 +- .../NoteBlockCompatibilityHandler.java | 4 +-- .../SignCompatibilityHandler.java | 2 +- .../SkullBlockCompatibilityHandler.java | 16 ++++----- .../transform/BlockTransformExtent.java | 5 +-- .../sk89q/worldedit/math/BlockVector3.java | 2 +- .../worldedit/regions/RegionIntersection.java | 7 +--- .../formatting/component/SideEffectBox.java | 8 ++++- .../sk89q/worldedit/fabric/FabricAdapter.java | 1 + .../worldedit/fabric/FabricDataFixer.java | 3 +- .../sk89q/worldedit/fabric/FabricPlayer.java | 4 +++ .../sk89q/worldedit/forge/ForgeDataFixer.java | 2 +- .../sk89q/worldedit/forge/ForgePlayer.java | 4 +++ 32 files changed, 107 insertions(+), 70 deletions(-) diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt index 8954ccbb9..2c283daab 100644 --- a/buildSrc/src/main/kotlin/PlatformConfig.kt +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -37,7 +37,10 @@ } tasks.withType().configureEach { - options.compilerArgs.addAll(listOf("-Xlint:all", "-Xlint:-processing", "-Xlint:-path")) + val disabledLint = listOf( + "processing", "path", "fallthrough", "serial" + ) + options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" }) options.isDeprecation = true options.encoding = "UTF-8" } diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 4a9561efa..f33a88ae7 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -25,6 +25,7 @@ "api"("org.bukkit:bukkit:1.15.2-R0.1-SNAPSHOT") { exclude("junit", "junit") } + "compileOnly"("org.jetbrains:annotations:19.0.0") "compileOnly"("com.destroystokyo.paper:paper-api:1.15.2-R0.1-SNAPSHOT") "implementation"("io.papermc:paperlib:1.0.2") "compileOnly"("com.sk89q:dummypermscompat:1.10") diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/DinnerPermsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/DinnerPermsResolver.java index 8fdc5f4a6..5a5c9b1e9 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/DinnerPermsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/DinnerPermsResolver.java @@ -48,21 +48,25 @@ public void load() { } @Override + @SuppressWarnings("deprecation") public boolean hasPermission(String name, String permission) { return hasPermission(server.getOfflinePlayer(name), permission); } @Override + @SuppressWarnings("deprecation") public boolean hasPermission(String worldName, String name, String permission) { return hasPermission(worldName, server.getOfflinePlayer(name), permission); } @Override + @SuppressWarnings("deprecation") public boolean inGroup(String name, String group) { return inGroup(server.getOfflinePlayer(name), group); } @Override + @SuppressWarnings("deprecation") public String[] getGroups(String name) { return getGroups(server.getOfflinePlayer(name)); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java index 675e8e184..5def5dd52 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/NijiPermissionsResolver.java @@ -72,7 +72,6 @@ public NijiPermissionsResolver(Server server, Permissions plugin) { } @Override - @SuppressWarnings("static-access") public boolean hasPermission(String name, String permission) { try { Player player = server.getPlayerExact(name); @@ -82,7 +81,7 @@ public boolean hasPermission(String name, String permission) { try { return api.getHandler().has(player, permission); } catch (Throwable t) { - return api.Security.permission(player, permission); + return Permissions.Security.permission(player, permission); } } catch (Throwable t) { log.warn("Failed to check permissions", t); @@ -105,7 +104,6 @@ public boolean hasPermission(String worldName, String name, String permission) { } @Override - @SuppressWarnings("static-access") public boolean inGroup(String name, String group) { try { Player player = server.getPlayerExact(name); @@ -115,7 +113,7 @@ public boolean inGroup(String name, String group) { try { return api.getHandler().inGroup(player.getWorld().getName(), name, group); } catch (Throwable t) { - return api.Security.inGroup(name, group); + return Permissions.Security.inGroup(name, group); } } catch (Throwable t) { log.warn("Failed to check groups", t); @@ -124,7 +122,6 @@ public boolean inGroup(String name, String group) { } @Override - @SuppressWarnings("static-access") public String[] getGroups(String name) { try { Player player = server.getPlayerExact(name); @@ -135,7 +132,7 @@ public String[] getGroups(String name) { try { groups = api.getHandler().getGroups(player.getWorld().getName(), player.getName()); } catch (Throwable t) { - String group = api.Security.getGroup(player.getWorld().getName(), player.getName()); + String group = Permissions.Security.getGroup(player.getWorld().getName(), player.getName()); if (group != null) { groups = new String[] { group }; } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java index c3382a9e2..e136f5343 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/PermissionsResolverManager.java @@ -84,7 +84,7 @@ public static PermissionsResolverManager getInstance() { private final Logger logger = LoggerFactory.getLogger(getClass()); private final List> enabledResolvers = new ArrayList<>(); - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "rawtypes" }) protected Class[] availableResolvers = new Class[] { PluginPermissionsResolver.class, PermissionsExResolver.class, diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java index a918d601a..10f6ded3c 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java @@ -62,21 +62,25 @@ public String getDetectionMessage() { } @Override + @SuppressWarnings("deprecation") public boolean hasPermission(String name, String permission) { return hasPermission(server.getOfflinePlayer(name), permission); } @Override + @SuppressWarnings("deprecation") public boolean hasPermission(String worldName, String name, String permission) { return hasPermission(worldName, server.getOfflinePlayer(name), permission); } @Override + @SuppressWarnings("deprecation") public boolean inGroup(String player, String group) { return inGroup(server.getOfflinePlayer(player), group); } @Override + @SuppressWarnings("deprecation") public String[] getGroups(String player) { return getGroups(server.getOfflinePlayer(player)); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/bPermissionsResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/bPermissionsResolver.java index 083b91fe7..9ccab3729 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/bPermissionsResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/bPermissionsResolver.java @@ -54,6 +54,7 @@ public String getDetectionMessage() { } @Override + @SuppressWarnings("deprecation") public boolean hasPermission(String name, String permission) { return hasPermission(server.getOfflinePlayer(name), permission); } @@ -64,11 +65,13 @@ public boolean hasPermission(String worldName, String name, String permission) { } @Override + @SuppressWarnings("deprecation") public boolean inGroup(String player, String group) { return inGroup(server.getOfflinePlayer(player), group); } @Override + @SuppressWarnings("deprecation") public String[] getGroups(String player) { return getGroups(server.getOfflinePlayer(player)); } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java index 3f6e11d79..8a1c7bf16 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java @@ -67,6 +67,7 @@ public String getName() { } @Override + @Deprecated public void printRaw(String msg) { for (String part : msg.split("\n")) { sender.sendMessage(part); @@ -74,6 +75,7 @@ public void printRaw(String msg) { } @Override + @Deprecated public void print(String msg) { for (String part : msg.split("\n")) { print(TextComponent.of(part, TextColor.LIGHT_PURPLE)); @@ -81,6 +83,7 @@ public void print(String msg) { } @Override + @Deprecated public void printDebug(String msg) { for (String part : msg.split("\n")) { print(TextComponent.of(part, TextColor.GRAY)); @@ -88,6 +91,7 @@ public void printDebug(String msg) { } @Override + @Deprecated public void printError(String msg) { for (String part : msg.split("\n")) { print(TextComponent.of(part, TextColor.RED)); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java index 7b2b8c6f9..fbdfa004e 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java @@ -65,6 +65,7 @@ public String getName() { } @Override + @Deprecated public void printRaw(String msg) { for (String part : msg.split("\n")) { sender.sendMessage(part); @@ -72,6 +73,7 @@ public void printRaw(String msg) { } @Override + @Deprecated public void print(String msg) { for (String part : msg.split("\n")) { sender.sendMessage("§d" + part); @@ -79,6 +81,7 @@ public void print(String msg) { } @Override + @Deprecated public void printDebug(String msg) { for (String part : msg.split("\n")) { sender.sendMessage("§7" + part); @@ -86,6 +89,7 @@ public void printDebug(String msg) { } @Override + @Deprecated public void printError(String msg) { for (String part : msg.split("\n")) { sender.sendMessage("§c" + part); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 6cf9d39ca..42a7e364d 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -105,6 +105,7 @@ public void giveItem(BaseItemStack itemStack) { } @Override + @Deprecated public void printRaw(String msg) { for (String part : msg.split("\n")) { player.sendMessage(part); @@ -112,6 +113,7 @@ public void printRaw(String msg) { } @Override + @Deprecated public void print(String msg) { for (String part : msg.split("\n")) { player.sendMessage("§d" + part); @@ -119,6 +121,7 @@ public void print(String msg) { } @Override + @Deprecated public void printDebug(String msg) { for (String part : msg.split("\n")) { player.sendMessage("§7" + part); @@ -126,6 +129,7 @@ public void printDebug(String msg) { } @Override + @Deprecated public void printError(String msg) { for (String part : msg.split("\n")) { player.sendMessage("§c" + part); diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 78f255cd5..e719c063c 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -171,7 +171,7 @@ private void setupWorldData() { WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); } - @SuppressWarnings("deprecation") + @SuppressWarnings({ "deprecation", "unchecked" }) private void initializeRegistries() { // Biome for (Biome biome : Biome.values()) { diff --git a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java index 602da14f5..fb617e789 100644 --- a/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java +++ b/worldedit-core/src/main/java/com/sk89q/minecraft/util/commands/SimpleInjector.java @@ -33,7 +33,7 @@ public class SimpleInjector implements Injector { public SimpleInjector(Object... args) { this.args = args; - argClasses = new Class[args.length]; + argClasses = new Class[args.length]; for (int i = 0; i < args.length; ++i) { argClasses[i] = args[i].getClass(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java index 1680332ec..bf1804cd3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java @@ -200,7 +200,7 @@ public void timeout(Actor actor, LocalSession session, desc = "Toggle fast mode" ) @CommandPermissions("worldedit.fast") - @Deprecated + @SuppressWarnings("deprecation") void fast(Actor actor, LocalSession session, @Arg(desc = "The new fast mode state", def = "") Boolean fastMode) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 56dbc3b42..486f539e8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -329,7 +329,7 @@ public void floatAt(int x, int y, int z, boolean alwaysGlass) { } else { setFlying(true); } - setPosition(Vector3.at(x + 0.5, y, z + 0.5)); + trySetPosition(Vector3.at(x + 0.5, y, z + 0.5)); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java index e845ca576..7d675ad9f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java @@ -115,21 +115,25 @@ public World getWorld() { } @Override + @Deprecated public void printRaw(String msg) { basePlayer.print(TextComponent.of(msg)); } @Override + @Deprecated public void printDebug(String msg) { basePlayer.printDebug(TextComponent.of(msg)); } @Override + @Deprecated public void print(String msg) { basePlayer.printInfo(TextComponent.of(msg)); } @Override + @Deprecated public void printError(String msg) { basePlayer.printError(TextComponent.of(msg)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java index acdc050c6..54d3867d0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java @@ -205,7 +205,7 @@ public Clipboard read() throws IOException { if (newBlock != null) { for (NBTCompatibilityHandler handler : COMPATIBILITY_HANDLERS) { if (handler.isAffectedBlock(newBlock)) { - newBlock = handler.updateNBT(block, values); + newBlock = handler.updateNBT(block, values).toImmutableState(); if (newBlock == null || values.isEmpty()) { break; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/BannerBlockCompatibilityHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/BannerBlockCompatibilityHandler.java index 9899bac9c..c8727cc84 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/BannerBlockCompatibilityHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/BannerBlockCompatibilityHandler.java @@ -24,9 +24,8 @@ import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.ListTag; import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.registry.state.DirectionalProperty; -import com.sk89q.worldedit.registry.state.IntegerProperty; import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; @@ -38,15 +37,15 @@ public class BannerBlockCompatibilityHandler implements NBTCompatibilityHandler { - private static final DirectionalProperty FacingProperty; - private static final IntegerProperty RotationProperty; + private static final Property FacingProperty; + private static final Property RotationProperty; static { - DirectionalProperty tempFacing; - IntegerProperty tempRotation; + Property tempFacing; + Property tempRotation; try { - tempFacing = (DirectionalProperty) (Property) BlockTypes.WHITE_WALL_BANNER.getProperty("facing"); - tempRotation = (IntegerProperty) (Property) BlockTypes.WHITE_BANNER.getProperty("rotation"); + tempFacing = BlockTypes.WHITE_WALL_BANNER.getProperty("facing"); + tempRotation = BlockTypes.WHITE_BANNER.getProperty("rotation"); } catch (NullPointerException | IllegalArgumentException | ClassCastException e) { tempFacing = null; tempRotation = null; @@ -62,7 +61,7 @@ public > boolean isAffectedBlock(B block) { } @Override - public > B updateNBT(B block, Map values) { + public > BlockStateHolder updateNBT(B block, Map values) { Tag typeTag = values.get("Base"); if (typeTag instanceof IntTag) { boolean isWall = block.getBlockType() == BlockTypes.WHITE_WALL_BANNER; @@ -73,10 +72,10 @@ public > B updateNBT(B block, Map val BlockState state = type.getDefaultState(); if (isWall) { - Property facingProp = type.getProperty("facing"); + Property facingProp = type.getProperty("facing"); state = state.with(facingProp, block.getState(FacingProperty)); } else { - Property rotationProp = type.getProperty("rotation"); + Property rotationProp = type.getProperty("rotation"); state = state.with(rotationProp, block.getState(RotationProperty)); } @@ -102,7 +101,7 @@ public > B updateNBT(B block, Map val } values.put("Patterns", new ListTag(((ListTag) patternsTag).getType(), tempList)); } - return (B) state; + return state; } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/BedBlockCompatibilityHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/BedBlockCompatibilityHandler.java index 4711f3287..1d143329b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/BedBlockCompatibilityHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/BedBlockCompatibilityHandler.java @@ -21,9 +21,8 @@ import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.registry.state.DirectionalProperty; -import com.sk89q.worldedit.registry.state.EnumProperty; import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; @@ -31,23 +30,24 @@ import java.util.Map; +@SuppressWarnings("") public class BedBlockCompatibilityHandler implements NBTCompatibilityHandler { - private static final DirectionalProperty FacingProperty; - private static final EnumProperty PartProperty; + private static final Property FACING_PROPERTY; + private static final Property PART_PROPERTY; static { - DirectionalProperty tempFacing; - EnumProperty tempPart; + Property tempFacing; + Property tempPart; try { - tempFacing = (DirectionalProperty) (Property) BlockTypes.RED_BED.getProperty("facing"); - tempPart = (EnumProperty) (Property) BlockTypes.RED_BED.getProperty("part"); + tempFacing = BlockTypes.RED_BED.getProperty("facing"); + tempPart = BlockTypes.RED_BED.getProperty("part"); } catch (NullPointerException | IllegalArgumentException | ClassCastException e) { tempFacing = null; tempPart = null; } - FacingProperty = tempFacing; - PartProperty = tempPart; + FACING_PROPERTY = tempFacing; + PART_PROPERTY = tempPart; } @Override @@ -56,7 +56,7 @@ public > boolean isAffectedBlock(B block) { } @Override - public > B updateNBT(B block, Map values) { + public > BlockStateHolder updateNBT(B block, Map values) { Tag typeTag = values.get("color"); if (typeTag instanceof IntTag) { String bedType = convertBedType(((IntTag) typeTag).getValue()); @@ -65,17 +65,17 @@ public > B updateNBT(B block, Map val if (type != null) { BlockState state = type.getDefaultState(); - Property facingProp = type.getProperty("facing"); - state = state.with(facingProp, block.getState(FacingProperty)); + Property facingProp = type.getProperty("facing"); + state = state.with(facingProp, block.getState(FACING_PROPERTY)); - Property occupiedProp = type.getProperty("occupied"); + Property occupiedProp = type.getProperty("occupied"); state = state.with(occupiedProp, false); - Property partProp = type.getProperty("part"); - state = state.with(partProp, block.getState(PartProperty)); + Property partProp = type.getProperty("part"); + state = state.with(partProp, block.getState(PART_PROPERTY)); values.remove("color"); - return (B) state; + return state; } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/FlowerPotCompatibilityHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/FlowerPotCompatibilityHandler.java index 92e998f75..713005a6e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/FlowerPotCompatibilityHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/FlowerPotCompatibilityHandler.java @@ -37,12 +37,12 @@ public > boolean isAffectedBlock(B block) { } @Override - public > B updateNBT(B block, Map values) { + public > BlockStateHolder updateNBT(B block, Map values) { Tag item = values.get("Item"); if (item instanceof StringTag) { String id = ((StringTag) item).getValue(); if (id.isEmpty()) { - return (B) BlockTypes.FLOWER_POT.getDefaultState(); + return BlockTypes.FLOWER_POT.getDefaultState(); } int data = 0; Tag dataTag = values.get("Data"); @@ -52,7 +52,7 @@ public > B updateNBT(B block, Map val BlockState newState = convertLegacyBlockType(id, data); if (newState != null) { values.clear(); - return (B) newState; // generics pls :\ + return newState; } } return block; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NBTCompatibilityHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NBTCompatibilityHandler.java index 4890885c7..77b4b8761 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NBTCompatibilityHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NBTCompatibilityHandler.java @@ -27,5 +27,5 @@ public interface NBTCompatibilityHandler { > boolean isAffectedBlock(B block); - > B updateNBT(B block, Map values); + > BlockStateHolder updateNBT(B block, Map values); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NoteBlockCompatibilityHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NoteBlockCompatibilityHandler.java index a839efe29..42d702dc7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NoteBlockCompatibilityHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NoteBlockCompatibilityHandler.java @@ -47,7 +47,7 @@ public > boolean isAffectedBlock(B block) { } @Override - public > B updateNBT(B block, Map values) { + public > BlockStateHolder updateNBT(B block, Map values) { // note that instrument was not stored (in state or nbt) previously. // it will be updated to the block below when it gets set into the world for the first time Tag noteTag = values.get("note"); @@ -55,7 +55,7 @@ public > B updateNBT(B block, Map val Byte note = ((ByteTag) noteTag).getValue(); if (note != null) { values.clear(); - return (B) block.with(NoteProperty, (int) note).toImmutableState(); + return block.with(NoteProperty, (int) note).toImmutableState(); } } return block; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SignCompatibilityHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SignCompatibilityHandler.java index 901822912..a394b0b13 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SignCompatibilityHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SignCompatibilityHandler.java @@ -39,7 +39,7 @@ public > boolean isAffectedBlock(B block) { } @Override - public > B updateNBT(B block, Map values) { + public > BlockStateHolder updateNBT(B block, Map values) { for (int i = 0; i < 4; ++i) { String key = "Text" + (i + 1); Tag value = values.get(key); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SkullBlockCompatibilityHandler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SkullBlockCompatibilityHandler.java index f4fe1a3ce..772e7c6a6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SkullBlockCompatibilityHandler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SkullBlockCompatibilityHandler.java @@ -21,8 +21,8 @@ import com.sk89q.jnbt.ByteTag; import com.sk89q.jnbt.Tag; -import com.sk89q.worldedit.registry.state.DirectionalProperty; import com.sk89q.worldedit.registry.state.Property; +import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; @@ -32,12 +32,12 @@ public class SkullBlockCompatibilityHandler implements NBTCompatibilityHandler { - private static final DirectionalProperty FacingProperty; + private static final Property FacingProperty; static { - DirectionalProperty tempFacing; + Property tempFacing; try { - tempFacing = (DirectionalProperty) (Property) BlockTypes.SKELETON_WALL_SKULL.getProperty("facing"); + tempFacing = BlockTypes.SKELETON_WALL_SKULL.getProperty("facing"); } catch (NullPointerException | IllegalArgumentException | ClassCastException e) { tempFacing = null; } @@ -51,7 +51,7 @@ public > boolean isAffectedBlock(B block) { } @Override - public > B updateNBT(B block, Map values) { + public > BlockStateHolder updateNBT(B block, Map values) { boolean isWall = block.getBlockType() == BlockTypes.SKELETON_WALL_SKULL; Tag typeTag = values.get("SkullType"); if (typeTag instanceof ByteTag) { @@ -61,18 +61,18 @@ public > B updateNBT(B block, Map val if (type != null) { BlockState state = type.getDefaultState(); if (isWall) { - Property newProp = type.getProperty("facing"); + Property newProp = type.getProperty("facing"); state = state.with(newProp, block.getState(FacingProperty)); } else { Tag rotTag = values.get("Rot"); if (rotTag instanceof ByteTag) { - Property newProp = type.getProperty("rotation"); + Property newProp = type.getProperty("rotation"); state = state.with(newProp, (int) ((ByteTag) rotTag).getValue()); } } values.remove("SkullType"); values.remove("Rot"); - return (B) state; + return state; } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java index 12c940f4f..ee2a2d8f7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java @@ -260,8 +260,9 @@ public static > B transform(B block, Transform tra directionalProperties.put(closestProp, Boolean.TRUE); } else { if (prop.getValues().contains("none")) { - //noinspection unchecked - result = result.with((Property) prop, "none"); + @SuppressWarnings("unchecked") + Property propAsObj = (Property) prop; + result = result.with(propAsObj, "none"); } directionalProperties.put(closestProp, block.getState(prop)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java index 34528dfc7..d1baf5fd3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java @@ -130,7 +130,7 @@ private BlockVector3(int x, int y, int z) { public long toLongPackedForm() { checkLongPackable(this); - return (x & BITS_26) | ((z & BITS_26) << 26) | (((y & (long) BITS_12) << (26 + 26))); + return (x & BITS_26) | ((z & BITS_26) << 26) | (((y & BITS_12) << (26 + 26))); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java index 5f2a14db2..f49aa81c1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java @@ -132,14 +132,9 @@ public boolean contains(BlockVector3 position) { return false; } - @SuppressWarnings("unchecked") @Override public Iterator iterator() { - Iterator[] iterators = (Iterator[]) new Iterator[regions.size()]; - for (int i = 0; i < regions.size(); i++) { - iterators[i] = regions.get(i).iterator(); - } - return Iterators.concat(iterators); + return Iterators.concat(Iterators.transform(regions.iterator(), r -> r.iterator())); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/SideEffectBox.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/SideEffectBox.java index fcba427db..569d5cf30 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/SideEffectBox.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/formatting/component/SideEffectBox.java @@ -23,6 +23,7 @@ import com.sk89q.worldedit.util.SideEffect; import com.sk89q.worldedit.util.SideEffectSet; import com.sk89q.worldedit.util.concurrency.LazyReference; +import com.sk89q.worldedit.util.formatting.WorldEditText; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; @@ -40,7 +41,12 @@ public class SideEffectBox extends PaginationBox { private static final LazyReference> SIDE_EFFECTS = LazyReference.from(() -> WorldEdit.getInstance().getPlatformManager().getSupportedSideEffects() .stream() - .sorted(Comparator.comparing(Enum::name)) + .sorted(Comparator.comparing(effect -> + WorldEditText.reduceToText( + TranslatableComponent.of(effect.getDisplayName()), + Locale.US + ) + )) .collect(Collectors.toList()) ); diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricAdapter.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricAdapter.java index b74c6c483..b80ee8111 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricAdapter.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricAdapter.java @@ -159,6 +159,7 @@ public static Map, Object> adaptProperties(BlockType block, Map stateContainer, net.minecraft.block.BlockState newState, Map, Object> states) { for (Map.Entry, Object> state : states.entrySet()) { diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricDataFixer.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricDataFixer.java index 066758b98..cd73eee35 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricDataFixer.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricDataFixer.java @@ -86,10 +86,9 @@ * receive the source version in the compound. *

*/ -@SuppressWarnings("UnnecessarilyQualifiedStaticUsage") +@SuppressWarnings({ "UnnecessarilyQualifiedStaticUsage", "unchecked", "rawtypes" }) class FabricDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.world.DataFixer { - @SuppressWarnings("unchecked") @Override public T fixUp(FixType type, T original, int srcVer) { if (type == FixTypes.CHUNK) { diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java index a95483f19..646164c7f 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java @@ -139,6 +139,7 @@ public Locale getLocale() { } @Override + @Deprecated public void printRaw(String msg) { for (String part : msg.split("\n")) { this.player.sendMessage(new LiteralText(part), false); @@ -146,16 +147,19 @@ public void printRaw(String msg) { } @Override + @Deprecated public void printDebug(String msg) { sendColorized(msg, Formatting.GRAY); } @Override + @Deprecated public void print(String msg) { sendColorized(msg, Formatting.LIGHT_PURPLE); } @Override + @Deprecated public void printError(String msg) { sendColorized(msg, Formatting.RED); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeDataFixer.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeDataFixer.java index 398fbd085..6c0fcdf98 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeDataFixer.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeDataFixer.java @@ -87,7 +87,7 @@ * receive the source version in the compound. *

*/ -@SuppressWarnings("UnnecessarilyQualifiedStaticUsage") +@SuppressWarnings({ "UnnecessarilyQualifiedStaticUsage", "unchecked", "rawtypes" }) class ForgeDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.world.DataFixer { @SuppressWarnings("unchecked") diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java index 1ba8205aa..7cb95e3cd 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java @@ -138,6 +138,7 @@ private void sendMessage(ITextComponent textComponent) { } @Override + @Deprecated public void printRaw(String msg) { for (String part : msg.split("\n")) { sendMessage(new StringTextComponent(part)); @@ -145,16 +146,19 @@ public void printRaw(String msg) { } @Override + @Deprecated public void printDebug(String msg) { sendColorized(msg, TextFormatting.GRAY); } @Override + @Deprecated public void print(String msg) { sendColorized(msg, TextFormatting.LIGHT_PURPLE); } @Override + @Deprecated public void printError(String msg) { sendColorized(msg, TextFormatting.RED); }