From ff124095bbfa47aaba04142963cf7baa67d5a876 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 13 May 2023 03:20:49 +0000 Subject: [PATCH] Format code [skip actions] --- .../emu/grasscutter/game/world/Scene.java | 9 ++- .../emu/grasscutter/plugin/PluginManager.java | 11 ++-- .../http/documentation/HandbookHandler.java | 11 ++-- .../java/emu/grasscutter/tools/Tools.java | 58 +++++++++---------- 4 files changed, 42 insertions(+), 47 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 710960fe0..cff8e5e2b 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -41,15 +41,14 @@ import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.KahnsSort; import emu.grasscutter.utils.Position; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import lombok.Getter; -import lombok.Setter; -import lombok.val; - -import javax.annotation.Nullable; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Collectors; +import javax.annotation.Nullable; +import lombok.Getter; +import lombok.Setter; +import lombok.val; public final class Scene { @Getter private final World world; diff --git a/src/main/java/emu/grasscutter/plugin/PluginManager.java b/src/main/java/emu/grasscutter/plugin/PluginManager.java index 9d3de3d6a..615bea574 100644 --- a/src/main/java/emu/grasscutter/plugin/PluginManager.java +++ b/src/main/java/emu/grasscutter/plugin/PluginManager.java @@ -1,15 +1,13 @@ package emu.grasscutter.plugin; +import static emu.grasscutter.utils.Language.translate; + import emu.grasscutter.Grasscutter; import emu.grasscutter.server.event.Event; import emu.grasscutter.server.event.EventHandler; import emu.grasscutter.server.event.HandlerPriority; import emu.grasscutter.utils.FileUtils; import emu.grasscutter.utils.JsonUtils; -import lombok.AllArgsConstructor; -import lombok.Getter; - -import javax.annotation.Nullable; import java.io.File; import java.io.FileNotFoundException; import java.io.InputStreamReader; @@ -20,8 +18,9 @@ import java.net.URLClassLoader; import java.util.*; import java.util.jar.JarEntry; import java.util.jar.JarFile; - -import static emu.grasscutter.utils.Language.translate; +import javax.annotation.Nullable; +import lombok.AllArgsConstructor; +import lombok.Getter; /** Manages the server's plugins and the event system. */ public final class PluginManager { diff --git a/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java b/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java index 9028562d7..a8d405c11 100644 --- a/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java +++ b/src/main/java/emu/grasscutter/server/http/documentation/HandbookHandler.java @@ -1,5 +1,7 @@ package emu.grasscutter.server.http.documentation; +import static emu.grasscutter.config.Configuration.HANDBOOK; + import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter.ServerRunMode; import emu.grasscutter.data.GameData; @@ -11,11 +13,8 @@ import emu.grasscutter.utils.FileUtils; import emu.grasscutter.utils.objects.HandbookBody; import io.javalin.Javalin; import io.javalin.http.Context; - import java.util.Objects; -import static emu.grasscutter.config.Configuration.HANDBOOK; - /** Handles requests for the new GM Handbook. */ public final class HandbookHandler implements Router { private final byte[] handbook; @@ -103,8 +102,7 @@ public final class HandbookHandler implements Router { var avatar = new Avatar(avatarData); avatar.setLevel(request.getLevel()); avatar.setPromoteLevel(Avatar.getMinPromoteLevel(avatar.getLevel())); - Objects.requireNonNull(avatar - .getSkillDepot()) + Objects.requireNonNull(avatar.getSkillDepot()) .getSkillsAndEnergySkill() .forEach(id -> avatar.setSkillLevel(id, request.getTalentLevels())); avatar.forceConstellationLevel(request.getConstellations()); @@ -215,8 +213,7 @@ public final class HandbookHandler implements Router { var position = scene.getDefaultLocation(player); var rotation = scene.getDefaultRotation(player); // Teleport the player. - scene.getWorld().transferPlayerToScene( - player, scene.getId(), position); + scene.getWorld().transferPlayerToScene(player, scene.getId(), position); player.getRotation().set(rotation); ctx.json(HandbookBody.Response.builder().status(200).message("Player teleported.").build()); diff --git a/src/main/java/emu/grasscutter/tools/Tools.java b/src/main/java/emu/grasscutter/tools/Tools.java index ffe4f7bb9..3d57e7850 100644 --- a/src/main/java/emu/grasscutter/tools/Tools.java +++ b/src/main/java/emu/grasscutter/tools/Tools.java @@ -1,5 +1,8 @@ package emu.grasscutter.tools; +import static emu.grasscutter.utils.FileUtils.getResourcePath; +import static emu.grasscutter.utils.Language.getTextMapKey; + import emu.grasscutter.GameConstants; import emu.grasscutter.Grasscutter; import emu.grasscutter.command.CommandHandler; @@ -17,10 +20,6 @@ import emu.grasscutter.utils.Language; import emu.grasscutter.utils.Language.TextStrings; import it.unimi.dsi.fastutil.ints.Int2IntRBTreeMap; import it.unimi.dsi.fastutil.ints.Int2ObjectRBTreeMap; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.val; - import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -32,9 +31,9 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.LongStream; - -import static emu.grasscutter.utils.FileUtils.getResourcePath; -import static emu.grasscutter.utils.Language.getTextMapKey; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.val; public final class Tools { /** @@ -413,36 +412,37 @@ public final class Tools { var file = FileUtils.getResourcePath("resources.info"); try (var reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) { var resourceInfo = ResourceInfo.builder(); - reader.lines().forEach(line -> { - var split = line.split(":"); - if (split.length != 2) return; + reader + .lines() + .forEach( + line -> { + var split = line.split(":"); + if (split.length != 2) return; - var key = split[0].trim(); - var value = split[1].trim(); + var key = split[0].trim(); + var value = split[1].trim(); - // Apply the value to the correct field. - switch (key) { - case "repo" -> resourceInfo.repository(value); - case "ver" -> resourceInfo.version(value); - case "patches" -> resourceInfo.patches(value); - case "scripts" -> resourceInfo.scripts( - ScriptsType.valueOf(value.toUpperCase())); - case "hasserverres" -> resourceInfo.hasServerResources( - Boolean.parseBoolean(value)); - case "hasscenescriptdata" -> resourceInfo.hasSceneScriptData( - Boolean.parseBoolean(value)); - } - }); + // Apply the value to the correct field. + switch (key) { + case "repo" -> resourceInfo.repository(value); + case "ver" -> resourceInfo.version(value); + case "patches" -> resourceInfo.patches(value); + case "scripts" -> resourceInfo.scripts(ScriptsType.valueOf(value.toUpperCase())); + case "hasserverres" -> resourceInfo.hasServerResources( + Boolean.parseBoolean(value)); + case "hasscenescriptdata" -> resourceInfo.hasSceneScriptData( + Boolean.parseBoolean(value)); + } + }); return resourceInfo.build(); } catch (Exception ignored) { - return new ResourceInfo( - null, null, null, - ScriptsType.UNKNOWN, false, false); + return new ResourceInfo(null, null, null, ScriptsType.UNKNOWN, false, false); } } - @AllArgsConstructor @Builder + @AllArgsConstructor + @Builder public static class ResourceInfo { private final String repository; private final String version;