From 8d565b93f7342abdd77daf8c9d09627143d5fa36 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 29 Dec 2021 16:39:44 +0000 Subject: [PATCH] Compress switch statements a bit using enhanced --- .../bukkit/adapter/NMSAdapter.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/NMSAdapter.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/NMSAdapter.java index 65d93b5b0..bb86a8bc4 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/NMSAdapter.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/adapter/NMSAdapter.java @@ -50,9 +50,7 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl { switch (ordinal) { case BlockTypesCache.ReservedIDs.__RESERVED__: ordinal = BlockTypesCache.ReservedIDs.AIR; - case BlockTypesCache.ReservedIDs.AIR: - case BlockTypesCache.ReservedIDs.CAVE_AIR: - case BlockTypesCache.ReservedIDs.VOID_AIR: + case BlockTypesCache.ReservedIDs.AIR, BlockTypesCache.ReservedIDs.CAVE_AIR, BlockTypesCache.ReservedIDs.VOID_AIR: air++; break; default: @@ -130,15 +128,12 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl { if (getArr == null) { getArr = get.apply(layer); } - ordinal = getArr[i]; - switch (ordinal) { + set[i] = switch (ordinal = getArr[i]) { case BlockTypesCache.ReservedIDs.__RESERVED__: ordinal = BlockTypesCache.ReservedIDs.AIR; - case BlockTypesCache.ReservedIDs.AIR: - case BlockTypesCache.ReservedIDs.CAVE_AIR: - case BlockTypesCache.ReservedIDs.VOID_AIR: + case BlockTypesCache.ReservedIDs.AIR, BlockTypesCache.ReservedIDs.CAVE_AIR, BlockTypesCache.ReservedIDs.VOID_AIR: air++; - break; + yield ordinal; default: if (!fastmode && !tick_placed && tick_existing) { boolean ticking; @@ -160,8 +155,8 @@ public class NMSAdapter implements FAWEPlatformAdapterImpl { ); } } - } - set[i] = ordinal; + yield ordinal; + }; } case BlockTypesCache.ReservedIDs.AIR, BlockTypesCache.ReservedIDs.CAVE_AIR, BlockTypesCache.ReservedIDs.VOID_AIR -> air++; }