diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 809a5ed7..a5d979de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,6 @@ jobs: uses: gradle/actions/setup-gradle@v4 with: add-job-summary: never - generate-job-summary: false cache-read-only: false - name: Setup Git Config run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b64d94d..8c4d4f26 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,6 @@ jobs: uses: gradle/actions/setup-gradle@v4 with: add-job-summary: never - generate-job-summary: false cache-read-only: false - name: Setup Git Config run: | diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/.editorconfig b/leaves-api/src/main/java/org/leavesmc/leaves/.editorconfig index 6f086600..9e663b78 100644 --- a/leaves-api/src/main/java/org/leavesmc/leaves/.editorconfig +++ b/leaves-api/src/main/java/org/leavesmc/leaves/.editorconfig @@ -1,2 +1,6 @@ [*.java] +ij_java_if_brace_force = always +ij_java_do_while_brace_force = always +ij_java_for_brace_force = always +ij_java_while_brace_force = always ij_java_use_fq_class_names = false \ No newline at end of file diff --git a/leaves-server/minecraft-patches/features/0003-Leaves-Utils.patch b/leaves-server/minecraft-patches/features/0003-Leaves-Utils.patch index fd0b9f74..f37b3b4a 100644 --- a/leaves-server/minecraft-patches/features/0003-Leaves-Utils.patch +++ b/leaves-server/minecraft-patches/features/0003-Leaves-Utils.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Leaves Utils diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 3d2c0a4d3a1f9d3e5cc6cd0cdb988ae1205de821..910bec7cbb2ef140ab16d99f93859326b5475a25 100644 +index 3d2c0a4d3a1f9d3e5cc6cd0cdb988ae1205de821..d0b30657d7f1caf49d2b75802c4cad192a16c71d 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -372,6 +372,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -33,6 +33,15 @@ index 3d2c0a4d3a1f9d3e5cc6cd0cdb988ae1205de821..910bec7cbb2ef140ab16d99f93859326 } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Loading entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being loaded"); +@@ -4423,7 +4427,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + return SlotAccess.NULL; + } + +- @Nullable ++ @org.jetbrains.annotations.NotNull // Leaves - notnull + public MinecraftServer getServer() { + return this.level().getServer(); + } @@ -5365,4 +5369,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return ((ServerLevel) this.level()).isPositionEntityTicking(this.blockPosition()); } @@ -43,6 +52,32 @@ index 3d2c0a4d3a1f9d3e5cc6cd0cdb988ae1205de821..910bec7cbb2ef140ab16d99f93859326 + } + // Leaves end - leaves ex data } +diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java +index c41df4b1fff1f65532256e835dc30fadbb4f8c8b..9383d9f940163f42db8802f0a260925a83119160 100644 +--- a/net/minecraft/world/level/Level.java ++++ b/net/minecraft/world/level/Level.java +@@ -962,7 +962,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl + return this.isClientSide; + } + +- @Nullable ++ @org.jetbrains.annotations.NotNull // Leaves - notnull + @Override + public MinecraftServer getServer() { + return null; +diff --git a/net/minecraft/world/level/LevelAccessor.java b/net/minecraft/world/level/LevelAccessor.java +index 5f28df24876f93866312c3c7d19cb6bcaf5e2f8b..049133cba588612127b45c1489f80d2fe6d6e330 100644 +--- a/net/minecraft/world/level/LevelAccessor.java ++++ b/net/minecraft/world/level/LevelAccessor.java +@@ -46,7 +46,7 @@ public interface LevelAccessor extends CommonLevelAccessor, LevelTimeAccess, Sch + + DifficultyInstance getCurrentDifficultyAt(BlockPos pos); + +- @Nullable ++ @org.jetbrains.annotations.NotNull // Leaves - notnull + MinecraftServer getServer(); + + default Difficulty getDifficulty() { diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java index be6f37f91569c659c609e5e8d38671ca86f8cd95..958914e40fceda5d67a98154817b4c5ce478a62d 100644 --- a/net/minecraft/world/level/block/Block.java diff --git a/leaves-server/minecraft-patches/features/0034-Item-overstack-util.patch b/leaves-server/minecraft-patches/features/0034-Item-overstack-util.patch index 3c65cb9a..c66ecf71 100644 --- a/leaves-server/minecraft-patches/features/0034-Item-overstack-util.patch +++ b/leaves-server/minecraft-patches/features/0034-Item-overstack-util.patch @@ -39,18 +39,10 @@ index adba92a9ebef64561147427d1339f70e2701d93c..fc367026ca84b125bf3ccd261ef43a38 if (count > i) { source.sendFailure(Component.translatable("commands.give.failed.toomanyitems", i, itemStack.getDisplayName())); diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 3bb431da22aaf4ed1965aa9bc89732b25b1e3648..2aeb83563ec9f955ef7d9e5f1d85a2dd2a23d71c 100644 +index 3bb431da22aaf4ed1965aa9bc89732b25b1e3648..1f71c320f5226e475253a5f55d97b608aae5988e 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -197,7 +197,6 @@ import net.minecraft.world.level.block.entity.SignBlockEntity; - import net.minecraft.world.level.block.entity.StructureBlockEntity; - import net.minecraft.world.level.block.entity.TestBlockEntity; - import net.minecraft.world.level.block.entity.TestInstanceBlockEntity; --import net.minecraft.world.level.block.state.BlockBehaviour; - import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.storage.TagValueOutput; - import net.minecraft.world.phys.AABB; -@@ -2984,7 +2983,7 @@ public class ServerGamePacketListenerImpl +@@ -2984,7 +2984,7 @@ public class ServerGamePacketListenerImpl } else if (slot.mayPlace(cursor)) { if (ItemStack.isSameItemSameComponents(clickedItem, cursor)) { int toPlace = packet.buttonNum() == 0 ? cursor.getCount() : 1; @@ -59,7 +51,7 @@ index 3bb431da22aaf4ed1965aa9bc89732b25b1e3648..2aeb83563ec9f955ef7d9e5f1d85a2dd toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount()); if (toPlace == 1) { action = InventoryAction.PLACE_ONE; -@@ -3020,7 +3019,7 @@ public class ServerGamePacketListenerImpl +@@ -3020,7 +3020,7 @@ public class ServerGamePacketListenerImpl } } else if (ItemStack.isSameItemSameComponents(cursor, clickedItem)) { if (clickedItem.getCount() >= 0) { @@ -68,7 +60,7 @@ index 3bb431da22aaf4ed1965aa9bc89732b25b1e3648..2aeb83563ec9f955ef7d9e5f1d85a2dd // As of 1.5, this is result slots only action = InventoryAction.PICKUP_ALL; } -@@ -3279,6 +3278,7 @@ public class ServerGamePacketListenerImpl +@@ -3279,6 +3279,7 @@ public class ServerGamePacketListenerImpl this.player.containerMenu.broadcastFullState(); } else { this.player.containerMenu.broadcastChanges(); @@ -76,7 +68,7 @@ index 3bb431da22aaf4ed1965aa9bc89732b25b1e3648..2aeb83563ec9f955ef7d9e5f1d85a2dd } if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. } -@@ -3389,7 +3389,7 @@ public class ServerGamePacketListenerImpl +@@ -3389,7 +3390,7 @@ public class ServerGamePacketListenerImpl } boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45; @@ -85,7 +77,7 @@ index 3bb431da22aaf4ed1965aa9bc89732b25b1e3648..2aeb83563ec9f955ef7d9e5f1d85a2dd if (flag || (flag1 && !ItemStack.matches(this.player.inventoryMenu.getSlot(packet.slotNum()).getItem(), packet.itemStack()))) { // Insist on valid slot // CraftBukkit start - Call click event org.bukkit.inventory.InventoryView inventory = this.player.inventoryMenu.getBukkitView(); -@@ -3431,6 +3431,7 @@ public class ServerGamePacketListenerImpl +@@ -3431,6 +3432,7 @@ public class ServerGamePacketListenerImpl this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemStack); this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemStack); this.player.inventoryMenu.broadcastChanges(); @@ -154,18 +146,10 @@ index 51804b611f469f2ab53e455e8c633b867b00cc88..df24938d5136948b151d3c1c72ccb2ec ItemStack item1 = itemEntity.getItem(); if (Objects.equals(this.target, itemEntity.target) && areMergable(item, item1)) { diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java -index a6bb436dc80daf6901dc027a6011ead4b3ed27e2..4de4e2ce8344db91a9c6644298dc75c2fc9ae237 100644 +index a6bb436dc80daf6901dc027a6011ead4b3ed27e2..71df58ae26325a2d28b6679733c474c0c59f7654 100644 --- a/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java -@@ -7,7 +7,6 @@ import java.util.function.Predicate; - import net.minecraft.CrashReport; - import net.minecraft.CrashReportCategory; - import net.minecraft.ReportedException; --import net.minecraft.core.Holder; - import net.minecraft.core.NonNullList; - import net.minecraft.core.component.DataComponents; - import net.minecraft.network.chat.Component; -@@ -165,10 +164,12 @@ public class Inventory implements Container, Nameable { +@@ -165,10 +165,12 @@ public class Inventory implements Container, Nameable { } private boolean hasRemainingSpaceForItem(ItemStack destination, ItemStack origin) { @@ -180,7 +164,7 @@ index a6bb436dc80daf6901dc027a6011ead4b3ed27e2..4de4e2ce8344db91a9c6644298dc75c2 } // CraftBukkit start - Watch method above! :D -@@ -181,7 +182,7 @@ public class Inventory implements Container, Nameable { +@@ -181,7 +183,7 @@ public class Inventory implements Container, Nameable { } if (this.hasRemainingSpaceForItem(itemInSlot, itemStack)) { @@ -189,7 +173,7 @@ index a6bb436dc80daf6901dc027a6011ead4b3ed27e2..4de4e2ce8344db91a9c6644298dc75c2 } if (remains <= 0) { return itemStack.getCount(); -@@ -190,7 +191,7 @@ public class Inventory implements Container, Nameable { +@@ -190,7 +192,7 @@ public class Inventory implements Container, Nameable { ItemStack itemInOffhand = this.equipment.get(EquipmentSlot.OFFHAND); if (this.hasRemainingSpaceForItem(itemInOffhand, itemStack)) { @@ -198,7 +182,7 @@ index a6bb436dc80daf6901dc027a6011ead4b3ed27e2..4de4e2ce8344db91a9c6644298dc75c2 } if (remains <= 0) { return itemStack.getCount(); -@@ -314,7 +315,7 @@ public class Inventory implements Container, Nameable { +@@ -314,7 +316,7 @@ public class Inventory implements Container, Nameable { this.setItem(slot, item); } @@ -207,7 +191,7 @@ index a6bb436dc80daf6901dc027a6011ead4b3ed27e2..4de4e2ce8344db91a9c6644298dc75c2 int min = Math.min(count, i); if (min == 0) { return count; -@@ -420,7 +421,7 @@ public class Inventory implements Container, Nameable { +@@ -420,7 +422,7 @@ public class Inventory implements Container, Nameable { break; } diff --git a/leaves-server/minecraft-patches/features/0041-Disable-distance-check-for-UseItemOnPacket.patch b/leaves-server/minecraft-patches/features/0041-Disable-distance-check-for-UseItemOnPacket.patch index aa0613d0..c5758606 100644 --- a/leaves-server/minecraft-patches/features/0041-Disable-distance-check-for-UseItemOnPacket.patch +++ b/leaves-server/minecraft-patches/features/0041-Disable-distance-check-for-UseItemOnPacket.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Disable distance check for UseItemOnPacket diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 2aeb83563ec9f955ef7d9e5f1d85a2dd2a23d71c..2ac6dbec5124bb7cee0b382f5308c098016eb134 100644 +index 1f71c320f5226e475253a5f55d97b608aae5988e..da1cb507ac3690dd7c91ea2ce69f004884b6e745 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2025,7 +2025,7 @@ public class ServerGamePacketListenerImpl +@@ -2026,7 +2026,7 @@ public class ServerGamePacketListenerImpl if (this.player.canInteractWithBlock(blockPos, 1.0)) { Vec3 vec3 = location.subtract(Vec3.atCenterOf(blockPos)); double d = 1.0000001; diff --git a/leaves-server/minecraft-patches/features/0043-Disable-packet-limit.patch b/leaves-server/minecraft-patches/features/0043-Disable-packet-limit.patch index 83cb236b..d1ac6001 100644 --- a/leaves-server/minecraft-patches/features/0043-Disable-packet-limit.patch +++ b/leaves-server/minecraft-patches/features/0043-Disable-packet-limit.patch @@ -20,10 +20,10 @@ index c9840dfa4067973aafed7e7c7305182dfabe0a48..fd1e1bce897163e6a78213e9be6acb0f synchronized (PACKET_LIMIT_LOCK) { if (this.allPacketCounts != null) { diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 2ac6dbec5124bb7cee0b382f5308c098016eb134..1f18636c6f496f6f7a93bc4da42d03dcb1e1513c 100644 +index da1cb507ac3690dd7c91ea2ce69f004884b6e745..a18496f2600e9cebe259849670cccb0076ef6e85 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -808,7 +808,7 @@ public class ServerGamePacketListenerImpl +@@ -809,7 +809,7 @@ public class ServerGamePacketListenerImpl public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) { // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); // Paper - AsyncTabCompleteEvent; run this async // CraftBukkit start @@ -32,7 +32,7 @@ index 2ac6dbec5124bb7cee0b382f5308c098016eb134..1f18636c6f496f6f7a93bc4da42d03dc this.disconnectAsync(Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM); // Paper - Kick event cause // Paper - add proper async disconnect return; } -@@ -1989,6 +1989,7 @@ public class ServerGamePacketListenerImpl +@@ -1990,6 +1990,7 @@ public class ServerGamePacketListenerImpl private static int getSpamThreshold() { return io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.incomingPacketThreshold; } // Paper - Configurable threshold private boolean checkLimit(long timestamp) { @@ -40,7 +40,7 @@ index 2ac6dbec5124bb7cee0b382f5308c098016eb134..1f18636c6f496f6f7a93bc4da42d03dc if (this.lastLimitedPacket != -1 && timestamp - this.lastLimitedPacket < getSpamThreshold() && this.limitedPackets++ >= 8) { // Paper - Configurable threshold; raise packet limit to 8 return false; } -@@ -2523,6 +2524,7 @@ public class ServerGamePacketListenerImpl +@@ -2524,6 +2525,7 @@ public class ServerGamePacketListenerImpl // Spigot start - spam exclusions private void detectRateSpam(String message) { @@ -48,7 +48,7 @@ index 2ac6dbec5124bb7cee0b382f5308c098016eb134..1f18636c6f496f6f7a93bc4da42d03dc // CraftBukkit start - replaced with thread safe throttle if (org.spigotmc.SpigotConfig.enableSpamExclusions) { for (String exclude : org.spigotmc.SpigotConfig.spamExclusions) { -@@ -3289,7 +3291,7 @@ public class ServerGamePacketListenerImpl +@@ -3290,7 +3292,7 @@ public class ServerGamePacketListenerImpl @Override public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { // Paper start - auto recipe limit diff --git a/leaves-server/minecraft-patches/features/0044-Syncmatica-Protocol.patch b/leaves-server/minecraft-patches/features/0044-Syncmatica-Protocol.patch index 0c3e3f1e..f7ceadca 100644 --- a/leaves-server/minecraft-patches/features/0044-Syncmatica-Protocol.patch +++ b/leaves-server/minecraft-patches/features/0044-Syncmatica-Protocol.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Syncmatica Protocol This patch is Powered by Syncmatica(https://github.com/End-Tech/syncmatica) diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 1f18636c6f496f6f7a93bc4da42d03dcb1e1513c..f879fc143868672c9ffdefe864b46acc471b47b0 100644 +index a18496f2600e9cebe259849670cccb0076ef6e85..050649fb2a85c14569f76d63d589e17d09e4e299 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -322,9 +322,12 @@ public class ServerGamePacketListenerImpl +@@ -323,9 +323,12 @@ public class ServerGamePacketListenerImpl this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(player.getUUID(), server::enforceSecureProfile); this.chatMessageChain = new FutureChain(server.chatExecutor); // CraftBukkit - async chat this.tickEndEvent = new io.papermc.paper.event.packet.ClientTickEndEvent(player.getBukkitEntity()); // Paper - add client tick end event diff --git a/leaves-server/minecraft-patches/features/0052-Elytra-aeronautics-no-chunk-load.patch b/leaves-server/minecraft-patches/features/0052-Elytra-aeronautics-no-chunk-load.patch index c0bcb203..083e9cfa 100644 --- a/leaves-server/minecraft-patches/features/0052-Elytra-aeronautics-no-chunk-load.patch +++ b/leaves-server/minecraft-patches/features/0052-Elytra-aeronautics-no-chunk-load.patch @@ -41,10 +41,10 @@ index 31fb5ea1e33672ae71210776a0302f0ef87c6814..e6de7ef46d197c14495d4b55d094af34 this.tickBlockEntities(); } diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index f879fc143868672c9ffdefe864b46acc471b47b0..7e39e6fe78fa2306fdef59c6037d451089a3e4d6 100644 +index 050649fb2a85c14569f76d63d589e17d09e4e299..d940593e55dcd1d71a5810ef0c52ed2862994e1e 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -569,7 +569,7 @@ public class ServerGamePacketListenerImpl +@@ -570,7 +570,7 @@ public class ServerGamePacketListenerImpl speed *= 2f; // TODO: Get the speed of the vehicle instead of the player // Paper start - Prevent moving into unloaded chunks @@ -53,7 +53,7 @@ index f879fc143868672c9ffdefe864b46acc471b47b0..7e39e6fe78fa2306fdef59c6037d4510 !serverLevel.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position()))) || !serverLevel.areChunksLoadedForMove(rootVehicle.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(rootVehicle.position()))) )) { -@@ -1584,6 +1584,7 @@ public class ServerGamePacketListenerImpl +@@ -1585,6 +1585,7 @@ public class ServerGamePacketListenerImpl allowMovement = !this.hasNewCollision(serverLevel, this.player, boundingBox, newBox); } // else: no collision at all detected, why do we care? } @@ -62,7 +62,7 @@ index f879fc143868672c9ffdefe864b46acc471b47b0..7e39e6fe78fa2306fdef59c6037d4510 if (!allowMovement) { io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK, diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index a3bb7ce9abd78ef3c999eeeb7fee39b3a5a6aad4..2e4f85a96a9822268ca19de801fefd45cea6c4e4 100644 +index c0e8275130b59093b8bc943bec65a77bdd256062..4951bd277dbda980e443439d77a06e0921b7a5f5 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -1118,7 +1118,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess diff --git a/leaves-server/minecraft-patches/features/0117-Vanilla-creative-pickup-behavior.patch b/leaves-server/minecraft-patches/features/0117-Vanilla-creative-pickup-behavior.patch index 7dbb3cc5..60818f62 100644 --- a/leaves-server/minecraft-patches/features/0117-Vanilla-creative-pickup-behavior.patch +++ b/leaves-server/minecraft-patches/features/0117-Vanilla-creative-pickup-behavior.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Vanilla creative pickup behavior diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java -index 4de4e2ce8344db91a9c6644298dc75c2fc9ae237..94d7d74b19d1f3180709a50c381c239af3daa7f5 100644 +index 71df58ae26325a2d28b6679733c474c0c59f7654..c73a1289a122dd0525e93fafb522d774566dceac 100644 --- a/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java -@@ -175,6 +175,13 @@ public class Inventory implements Container, Nameable { +@@ -176,6 +176,13 @@ public class Inventory implements Container, Nameable { // CraftBukkit start - Watch method above! :D public int canHold(ItemStack itemStack) { int remains = itemStack.getCount(); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/.editorconfig b/leaves-server/src/main/java/org/leavesmc/leaves/.editorconfig index 99412e03..38a42bbb 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/.editorconfig +++ b/leaves-server/src/main/java/org/leavesmc/leaves/.editorconfig @@ -1,3 +1,7 @@ [*.java] +ij_java_if_brace_force = always +ij_java_do_while_brace_force = always +ij_java_for_brace_force = always +ij_java_while_brace_force = always ij_java_use_fq_class_names = false -ij_java_packages_to_use_import_on_demand = java.awt.*, javax.swing.*, org.leavesmc.leaves.bot.agent.actions.*, org.leavesmc.leaves.bot.agent.configs.*, org.leavesmc.leaves.entity.bot.action.* \ No newline at end of file +ij_java_packages_to_use_import_on_demand = org.leavesmc.leaves.bot.agent.actions.*, org.leavesmc.leaves.bot.agent.configs.*, org.leavesmc.leaves.entity.bot.action.* \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotList.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotList.java index 308fe30c..4d7af942 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotList.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotList.java @@ -274,11 +274,15 @@ public class BotList { } public void loadBotInfo() { - if (!LeavesConfig.modify.fakeplayer.enable || !LeavesConfig.modify.fakeplayer.canResident) return; + if (!LeavesConfig.modify.fakeplayer.enable || !LeavesConfig.modify.fakeplayer.canResident) { + return; + } CompoundTag savedBotList = this.getSavedBotList().copy(); for (String realName : savedBotList.keySet()) { CompoundTag nbt = savedBotList.getCompound(realName).orElseThrow(); - if (!nbt.getBoolean("resume").orElse(false)) continue; + if (!nbt.getBoolean("resume").orElse(false)) { + continue; + } UUID levelUuid = BotUtil.getBotLevel(realName, this.dataStorage); if (levelUuid == null) { LOGGER.warn("Bot {} has no world UUID, skipping loading.", realName); @@ -291,9 +295,13 @@ public class BotList { } public void loadResume(String worldUuid) { - if (!LeavesConfig.modify.fakeplayer.enable || !LeavesConfig.modify.fakeplayer.canResident) return; + if (!LeavesConfig.modify.fakeplayer.enable || !LeavesConfig.modify.fakeplayer.canResident) { + return; + } Set bots = this.botsNameByWorldUuid.get(worldUuid); - if (bots == null) return; + if (bots == null) { + return; + } bots.forEach(this::loadNewBot); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotUtil.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotUtil.java index 266ec737..763dd1fb 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotUtil.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotUtil.java @@ -78,11 +78,15 @@ public class BotUtil { public static UUID getBotLevel(@NotNull String realName, BotDataStorage botDataStorage) { UUID uuid = BotUtil.getBotUUID(realName); Optional tagOptional = botDataStorage.read(uuid.toString()); - if (tagOptional.isEmpty()) return null; + if (tagOptional.isEmpty()) { + return null; + } CompoundTag tag = tagOptional.get(); Optional worldUUIDMost = tag.getLong("WorldUUIDMost"); Optional worldUUIDLeast = tag.getLong("WorldUUIDLeast"); - if (worldUUIDMost.isEmpty() || worldUUIDLeast.isEmpty()) return null; + if (worldUUIDMost.isEmpty() || worldUUIDLeast.isEmpty()) { + return null; + } return new UUID(worldUUIDMost.get(), worldUUIDLeast.get()); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java index 41d7f0a0..60282333 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java @@ -133,7 +133,9 @@ public class ServerBot extends ServerPlayer { if (this.invulnerableTime > 0) { this.invulnerableTime--; } - if (this.spawnInvulnerableTime > 0) --this.spawnInvulnerableTime; // Leaves - spawn invulnerable time + if (this.spawnInvulnerableTime > 0) { + --this.spawnInvulnerableTime; // Leaves - spawn invulnerable time + } // copy ServerPlayer end if (this.getConfigValue(Configs.SPAWN_PHANTOM)) { @@ -141,18 +143,8 @@ public class ServerBot extends ServerPlayer { } if (LeavesConfig.modify.fakeplayer.regenAmount > 0.0 && getServer().getTickCount() % 20 == 0) { - float health = getHealth(); - float maxHealth = getMaxHealth(); float regenAmount = (float) (LeavesConfig.modify.fakeplayer.regenAmount * 20); - float amount; - - if (health < maxHealth - regenAmount) { - amount = health + regenAmount; - } else { - amount = maxHealth; - } - - this.setHealth(amount); + this.setHealth(Math.min(this.getHealth() + regenAmount, this.getMaxHealth())); } if (this.getConfigValue(Configs.TICK_TYPE) == TickType.ENTITY_LIST) { @@ -277,7 +269,7 @@ public class ServerBot extends ServerPlayer { } @Override - public void knockback(double strength, double x, double z, @Nullable Entity attacker, EntityKnockbackEvent.Cause eventCause) { + public void knockback(double strength, double x, double z, @Nullable Entity attacker, EntityKnockbackEvent.@NotNull Cause eventCause) { if (!this.hurtMarked) { return; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSneakAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSneakAction.java index 5c66d912..104cb194 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSneakAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSneakAction.java @@ -14,7 +14,9 @@ public class ServerSneakAction extends ServerStateBotAction { @Override public boolean doTick(@NotNull ServerBot bot) { - if (bot.isShiftKeyDown()) return false; + if (bot.isShiftKeyDown()) { + return false; + } bot.setShiftKeyDown(true); return true; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAction.java index 030a4163..b8838f4d 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAction.java @@ -40,7 +40,7 @@ public class ServerUseItemAction extends ServerTimerBotAction= 0) { boolean result = execute(bot); - if (useTick >=0) { + if (useTick >= 0) { return false; } else { return result; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAutoAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAutoAction.java index 58bdf4cf..a65e6f29 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAutoAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAutoAction.java @@ -41,7 +41,7 @@ public class ServerUseItemAutoAction extends ServerTimerBotAction= 0) { boolean result = execute(bot); - if (useTick >=0) { + if (useTick >= 0) { return false; } else { return result; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOffhandAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOffhandAction.java index 2b9efcc4..52d7fd10 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOffhandAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOffhandAction.java @@ -40,7 +40,7 @@ public class ServerUseItemOffhandAction extends ServerTimerBotAction= 0) { boolean result = execute(bot); - if (useTick >=0) { + if (useTick >= 0) { return false; } else { return result; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnAction.java index 108cff5a..330619a9 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnAction.java @@ -50,7 +50,7 @@ public class ServerUseItemOnAction extends ServerTimerBotAction= 0) { HitResult hitResult = bot.getRayTrace(5, ClipContext.Fluid.NONE); boolean result = execute(bot, hitResult); - if (useTick >=0) { + if (useTick >= 0) { return false; } else { return result; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnOffhandAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnOffhandAction.java index 98dc9698..d160f852 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnOffhandAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnOffhandAction.java @@ -50,7 +50,7 @@ public class ServerUseItemOnOffhandAction extends ServerTimerBotAction= 0) { HitResult hitResult = bot.getRayTrace(5, ClipContext.Fluid.NONE); boolean result = execute(bot, hitResult); - if (useTick >=0) { + if (useTick >= 0) { return false; } else { return result; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToAction.java index f9fda47a..62cf461c 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToAction.java @@ -41,7 +41,7 @@ public class ServerUseItemToAction extends ServerTimerBotAction= 0) { Entity entity = bot.getTargetEntity(3, null); boolean result = execute(bot, entity); - if (useTick >=0) { + if (useTick >= 0) { return false; } else { return result; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToOffhandAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToOffhandAction.java index 4bfb26ee..69424c14 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToOffhandAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToOffhandAction.java @@ -41,7 +41,7 @@ public class ServerUseItemToOffhandAction extends ServerTimerBotAction= 0) { Entity entity = bot.getTargetEntity(3, null); boolean result = execute(bot, entity); - if (useTick >=0) { + if (useTick >= 0) { return false; } else { return result; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/command/subcommands/ReportCommand.java b/leaves-server/src/main/java/org/leavesmc/leaves/command/subcommands/ReportCommand.java index 510474bb..924fa03b 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/command/subcommands/ReportCommand.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/command/subcommands/ReportCommand.java @@ -56,8 +56,11 @@ public class ReportCommand implements LeavesSubcommand { if (provider instanceof SpigotPluginProvider) { spigotPlugins.put(configuration.getDisplayName(), provider); } else if (provider instanceof PaperPluginParent.PaperServerPluginProvider) { - if (provider.getMeta() instanceof LeavesPluginMeta) leavesPlugins.put(configuration.getDisplayName(), provider); - else paperPlugins.put(configuration.getDisplayName(), provider); + if (provider.getMeta() instanceof LeavesPluginMeta) { + leavesPlugins.put(configuration.getDisplayName(), provider); + } else { + paperPlugins.put(configuration.getDisplayName(), provider); + } } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/plugin/provider/configuration/MixinConfiguration.java b/leaves-server/src/main/java/org/leavesmc/leaves/plugin/provider/configuration/MixinConfiguration.java index 16462465..77abb231 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/plugin/provider/configuration/MixinConfiguration.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/plugin/provider/configuration/MixinConfiguration.java @@ -15,7 +15,9 @@ public class MixinConfiguration { @PostProcess public void postProcess() { - if (mixins.isEmpty()) return; + if (mixins.isEmpty()) { + return; + } if (packageName == null) { throw new IllegalStateException("Already define mixins: " + mixins + ", but no mixin package-name provided"); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CustomDisplay.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CustomDisplay.java index c98be664..7c24bb0e 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CustomDisplay.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CustomDisplay.java @@ -32,7 +32,7 @@ public class CustomDisplay extends CraftingDisplay { super(inputs, outputs, location); BitSet row = new BitSet(3); BitSet column = new BitSet(3); - for (int i = 0; i < 9; i++) + for (int i = 0; i < 9; i++) { if (i < inputs.size()) { EntryIngredient stacks = inputs.get(i); if (stacks.stream().anyMatch(stack -> !stack.isEmpty())) { @@ -40,6 +40,7 @@ public class CustomDisplay extends CraftingDisplay { column.set(i % 3); } } + } this.width = column.cardinality(); this.height = row.cardinality(); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/Display.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/Display.java index 3e7b9197..10e31d3b 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/Display.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/Display.java @@ -120,11 +120,13 @@ public abstract class Display { } if (potion.potion().get().unwrapKey().isPresent() && registeredPotions.add(potion.potion().get().unwrapKey().get().location())) { List input = new ArrayList<>(); - for (int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { input.add(arrowIngredient); + } input.add(EntryIngredient.of(itemStack)); - for (int i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { input.add(arrowIngredient); + } ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8); outputStack.set(DataComponents.POTION_CONTENTS, potion); displays.add(new CustomDisplay(input, List.of(EntryIngredient.of(outputStack)), recipeHolder.id().location())); @@ -192,7 +194,9 @@ public abstract class Display { List displays = new ArrayList<>(); for (Holder additionStack : (Iterable>) recipe.additionIngredient().map(Ingredient::items).orElse(Stream.of())::iterator) { Holder trimMaterial = getMaterialFromIngredient(registryAccess, additionStack).orElse(null); - if (trimMaterial == null) continue; + if (trimMaterial == null) { + continue; + } EntryIngredient baseIngredient = EntryIngredient.ofIngredient(recipe.baseIngredient()); displays.add(new SmithingDisplay.Trimming(List.of( @@ -241,7 +245,9 @@ public abstract class Display { } public static List ofSlotDisplays(Collection slots) { - if (slots instanceof Collection collection && collection.isEmpty()) return Collections.emptyList(); + if (slots instanceof Collection collection && collection.isEmpty()) { + return Collections.emptyList(); + } ImmutableList.Builder ingredients = ImmutableList.builder(); for (SlotDisplay slot : slots) { ingredients.add(ofSlotDisplay(slot)); @@ -252,11 +258,17 @@ public abstract class Display { public static EntryIngredient ofItemTag(TagKey tagKey) { HolderGetter getter = MinecraftServer.getServer().registryAccess().lookupOrThrow(tagKey.registry()); HolderSet.Named holders = getter.get(tagKey).orElse(null); - if (holders == null) return EntryIngredient.empty(); + if (holders == null) { + return EntryIngredient.empty(); + } int size = holders.size(); - if (size == 0) return EntryIngredient.empty(); - if (size == 1) return EntryIngredient.of(new ItemStack(holders.get(0).value())); + if (size == 0) { + return EntryIngredient.empty(); + } + if (size == 1) { + return EntryIngredient.of(new ItemStack(holders.get(0).value())); + } List stackList = new ArrayList<>(); for (Holder t : holders) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/placement/SchematicPlacement.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/placement/SchematicPlacement.java index 31835231..61bf0d14 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/placement/SchematicPlacement.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/placement/SchematicPlacement.java @@ -169,7 +169,9 @@ public class SchematicPlacement { public ImmutableMap getSubRegionBoxFor(String regionName, SubRegionPlacement.RequiredEnabled required) { SubRegionPlacement placement = this.relativeSubRegionPlacements.get(regionName); - if (placement == null) return ImmutableMap.of(); + if (placement == null) { + return ImmutableMap.of(); + } ImmutableMap.Builder builder = ImmutableMap.builder(); Map areaSizes = this.schematic.getAreaSizes(); @@ -236,7 +238,9 @@ public class SchematicPlacement { BlockPos tmp; BlockPos boxPos1 = box.pos1(); BlockPos boxPos2 = box.pos2(); - if (boxPos1 == null || boxPos2 == null) continue; + if (boxPos1 == null || boxPos2 == null) { + continue; + } tmp = PositionUtils.getMinCorner(boxPos1, boxPos2); if (pos1 == null) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java index 0f8f34ec..d75bd86b 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java @@ -36,7 +36,9 @@ public class ServerPlacement { private static String removeExtension(final String fileName) { final int pos = fileName.lastIndexOf("."); - if (pos < 0) return fileName; + if (pos < 0) { + return fileName; + } return fileName.substring(0, pos); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/region/linear/LinearRegionFile.java b/leaves-server/src/main/java/org/leavesmc/leaves/region/linear/LinearRegionFile.java index 07982b9c..d7cc1a0b 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/region/linear/LinearRegionFile.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/region/linear/LinearRegionFile.java @@ -205,7 +205,9 @@ public class LinearRegionFile implements IRegionFile { while (true) { byte featureNameLength = buffer.get(); - if (featureNameLength == 0) break; + if (featureNameLength == 0) { + break; + } byte[] featureNameBytes = new byte[featureNameLength]; buffer.get(featureNameBytes); String featureName = new String(featureNameBytes); @@ -227,12 +229,16 @@ public class LinearRegionFile implements IRegionFile { bucketBuffers[i] = new byte[bucketSizes[i]]; buffer.get(bucketBuffers[i]); long rawHash = LongHashFunction.xx().hashBytes(bucketBuffers[i]); - if (rawHash != bucketHashes[i]) throw new IOException("Region file hash incorrect " + this.regionFile); + if (rawHash != bucketHashes[i]) { + throw new IOException("Region file hash incorrect " + this.regionFile); + } } } long footerSuperBlock = buffer.getLong(); - if (footerSuperBlock != SUPERBLOCK) throw new IOException("Footer superblock invalid " + this.regionFile); + if (footerSuperBlock != SUPERBLOCK) { + throw new IOException("Footer superblock invalid " + this.regionFile); + } } private synchronized void markToSave() { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/BlockPatternHelper.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/BlockPatternHelper.java index 567cd33a..e2d0850d 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/BlockPatternHelper.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/BlockPatternHelper.java @@ -17,8 +17,9 @@ public class BlockPatternHelper { for (Direction direction : Direction.values()) { for (Direction direction2 : Direction.values()) { BlockPattern.BlockPatternMatch result; - if (direction2 == direction || direction2 == direction.getOpposite() || (result = pattern.matches(blockPos, direction, direction2, loadingCache)) == null) + if (direction2 == direction || direction2 == direction.getOpposite() || (result = pattern.matches(blockPos, direction, direction2, loadingCache)) == null) { continue; + } return result; } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/ElytraAeronauticsHelper.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/ElytraAeronauticsHelper.java index 003d51b6..bc79a7cf 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/ElytraAeronauticsHelper.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/ElytraAeronauticsHelper.java @@ -90,7 +90,9 @@ public class ElytraAeronauticsHelper { MinecraftServer.LOGGER.error("Attempted Double World add on {}", entity, new Throwable()); return true; } - if (entity.spawnReason == null) entity.spawnReason = CreatureSpawnEvent.SpawnReason.DEFAULT; + if (entity.spawnReason == null) { + entity.spawnReason = CreatureSpawnEvent.SpawnReason.DEFAULT; + } if (entity.isRemoved()) { return false; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java index 83fe0ead..2dac5712 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java @@ -314,9 +314,15 @@ public class HopperCounter { int r = (color >> 16 & 255); int g = (color >> 8 & 255); int b = (color & 255); - if (r < 70) r = 70; - if (g < 70) g = 70; - if (b < 70) b = 70; + if (r < 70) { + r = 70; + } + if (g < 70) { + g = 70; + } + if (b < 70) { + b = 70; + } return (r << 16) + (g << 8) + b; }