From 494cd3b28c335eb43c87002d54229a7450777fbb Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 3 Jun 2023 19:37:54 +0000 Subject: [PATCH] Format code [skip actions] --- .../java/emu/grasscutter/data/GameData.java | 14 ++++-- .../emu/grasscutter/data/ResourceLoader.java | 27 ++++++++--- .../data/binout/AbilityModifier.java | 3 +- .../game/ability/AbilityLocalIdGenerator.java | 11 +++-- .../grasscutter/game/entity/GameEntity.java | 47 ++++++++++--------- .../emu/grasscutter/game/world/World.java | 7 ++- 6 files changed, 67 insertions(+), 42 deletions(-) diff --git a/src/main/java/emu/grasscutter/data/GameData.java b/src/main/java/emu/grasscutter/data/GameData.java index fd91b091c..3b99f1f26 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -454,9 +454,17 @@ public final class GameData { private static final Int2ObjectMap gadgetMappingMap = new Int2ObjectOpenHashMap<>(); - @Getter private static final Int2ObjectMap subfieldMappingMap = new Int2ObjectOpenHashMap<>(); - @Getter private static final Int2ObjectMap dropSubfieldMappingMap = new Int2ObjectOpenHashMap<>(); - @Getter private static final Int2ObjectMap dropTableExcelConfigDataMap = new Int2ObjectOpenHashMap<>(); + @Getter + private static final Int2ObjectMap subfieldMappingMap = + new Int2ObjectOpenHashMap<>(); + + @Getter + private static final Int2ObjectMap dropSubfieldMappingMap = + new Int2ObjectOpenHashMap<>(); + + @Getter + private static final Int2ObjectMap dropTableExcelConfigDataMap = + new Int2ObjectOpenHashMap<>(); @Getter private static final Int2ObjectMap monsterMappingMap = diff --git a/src/main/java/emu/grasscutter/data/ResourceLoader.java b/src/main/java/emu/grasscutter/data/ResourceLoader.java index 9caa7a613..2e763d405 100644 --- a/src/main/java/emu/grasscutter/data/ResourceLoader.java +++ b/src/main/java/emu/grasscutter/data/ResourceLoader.java @@ -810,8 +810,11 @@ public final class ResourceLoader { try { val subfieldMap = GameData.getSubfieldMappingMap(); try { - JsonUtils.loadToList(getResourcePath("Server/SubfieldMapping.json"), SubfieldMapping.class).forEach(entry -> subfieldMap.put(entry.getEntityId(), entry));; - } catch (IOException | NullPointerException ignored) {} + JsonUtils.loadToList(getResourcePath("Server/SubfieldMapping.json"), SubfieldMapping.class) + .forEach(entry -> subfieldMap.put(entry.getEntityId(), entry)); + ; + } catch (IOException | NullPointerException ignored) { + } Grasscutter.getLogger().debug("Loaded {} subfield mappings.", subfieldMap.size()); } catch (Exception e) { Grasscutter.getLogger().error("Unable to load subfield mappings.", e); @@ -820,8 +823,12 @@ public final class ResourceLoader { try { val dropSubfieldMap = GameData.getDropSubfieldMappingMap(); try { - JsonUtils.loadToList(getResourcePath("Server/DropSubfieldMapping.json"), DropSubfieldMapping.class).forEach(entry -> dropSubfieldMap.put(entry.getDropId(), entry));; - } catch (IOException | NullPointerException ignored) {} + JsonUtils.loadToList( + getResourcePath("Server/DropSubfieldMapping.json"), DropSubfieldMapping.class) + .forEach(entry -> dropSubfieldMap.put(entry.getDropId(), entry)); + ; + } catch (IOException | NullPointerException ignored) { + } Grasscutter.getLogger().debug("Loaded {} drop subfield mappings.", dropSubfieldMap.size()); } catch (Exception e) { Grasscutter.getLogger().error("Unable to load drop subfield mappings.", e); @@ -830,9 +837,15 @@ public final class ResourceLoader { try { val dropTableExcelConfigDataMap = GameData.getDropTableExcelConfigDataMap(); try { - JsonUtils.loadToList(getResourcePath("Server/DropTableExcelConfigData.json"), DropTableExcelConfigData.class).forEach(entry -> dropTableExcelConfigDataMap.put(entry.getId(), entry));; - } catch (IOException | NullPointerException ignored) {} - Grasscutter.getLogger().debug("Loaded {} drop table configs.", dropTableExcelConfigDataMap.size()); + JsonUtils.loadToList( + getResourcePath("Server/DropTableExcelConfigData.json"), + DropTableExcelConfigData.class) + .forEach(entry -> dropTableExcelConfigDataMap.put(entry.getId(), entry)); + ; + } catch (IOException | NullPointerException ignored) { + } + Grasscutter.getLogger() + .debug("Loaded {} drop table configs.", dropTableExcelConfigDataMap.size()); } catch (Exception e) { Grasscutter.getLogger().error("Unable to load drop table config data.", e); } diff --git a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java index 8f7b592fa..69e89fbe5 100644 --- a/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java +++ b/src/main/java/emu/grasscutter/data/binout/AbilityModifier.java @@ -3,9 +3,8 @@ package emu.grasscutter.data.binout; import com.google.gson.annotations.SerializedName; import emu.grasscutter.data.common.DynamicFloat; import emu.grasscutter.game.props.ElementType; -import lombok.ToString; - import java.io.Serializable; +import lombok.ToString; public class AbilityModifier implements Serializable { private static final long serialVersionUID = -2001232313615923575L; diff --git a/src/main/java/emu/grasscutter/game/ability/AbilityLocalIdGenerator.java b/src/main/java/emu/grasscutter/game/ability/AbilityLocalIdGenerator.java index 93218c8a8..9dc377dff 100644 --- a/src/main/java/emu/grasscutter/game/ability/AbilityLocalIdGenerator.java +++ b/src/main/java/emu/grasscutter/game/ability/AbilityLocalIdGenerator.java @@ -3,9 +3,8 @@ package emu.grasscutter.game.ability; import emu.grasscutter.Grasscutter; import emu.grasscutter.data.binout.AbilityMixinData; import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction; -import lombok.AllArgsConstructor; - import java.util.Map; +import lombok.AllArgsConstructor; @SuppressWarnings("ALL") public class AbilityLocalIdGenerator { @@ -38,12 +37,14 @@ public class AbilityLocalIdGenerator { this.actionIndex++; var id = GetLocalId(); - localIdToAction.put((int)id, actions[i]); + localIdToAction.put((int) id, actions[i]); - if(actions[i].actions != null) this.initializeActionLocalIds(actions[i].actions, localIdToAction); + if (actions[i].actions != null) + this.initializeActionLocalIds(actions[i].actions, localIdToAction); else { if (actions[i].successActions != null) - this.initializeActionLocalIds(actions[i].successActions, localIdToAction); //Need to check this specific order + this.initializeActionLocalIds( + actions[i].successActions, localIdToAction); // Need to check this specific order if (actions[i].failActions != null) this.initializeActionLocalIds(actions[i].failActions, localIdToAction); } diff --git a/src/main/java/emu/grasscutter/game/entity/GameEntity.java b/src/main/java/emu/grasscutter/game/entity/GameEntity.java index 476b87312..3ec77618d 100644 --- a/src/main/java/emu/grasscutter/game/entity/GameEntity.java +++ b/src/main/java/emu/grasscutter/game/entity/GameEntity.java @@ -15,9 +15,8 @@ import emu.grasscutter.scripts.data.controller.EntityController; import emu.grasscutter.server.event.entity.*; import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; import it.unimi.dsi.fastutil.ints.*; -import lombok.*; - import java.util.*; +import lombok.*; public abstract class GameEntity { @Getter private final Scene scene; @@ -230,40 +229,45 @@ public abstract class GameEntity { private int[] parseCountRange(String range) { var split = range.split(";"); - if(split.length == 1) return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[0])}; + if (split.length == 1) + return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[0])}; return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[1])}; } public boolean dropSubfieldItem(int dropId) { var drop = GameData.getDropSubfieldMappingMap().get(dropId); - if(drop == null) return false; + if (drop == null) return false; var dropTableEntry = GameData.getDropTableExcelConfigDataMap().get(drop.getItemId()); - if(dropTableEntry == null) return false; + if (dropTableEntry == null) return false; Int2ObjectMap itemsToDrop = new Int2ObjectOpenHashMap<>(); switch (dropTableEntry.getRandomType()) { - case 0: //select one + case 0: // select one { int weightCount = 0; - for(var entry : dropTableEntry.getDropVec()) weightCount += entry.getWeight(); + for (var entry : dropTableEntry.getDropVec()) weightCount += entry.getWeight(); int randomValue = new Random().nextInt(weightCount); weightCount = 0; - for(var entry : dropTableEntry.getDropVec()) { - if(randomValue >= weightCount && randomValue < (weightCount + entry.getWeight())) { + for (var entry : dropTableEntry.getDropVec()) { + if (randomValue >= weightCount && randomValue < (weightCount + entry.getWeight())) { var countRange = parseCountRange(entry.getCountRange()); - itemsToDrop.put(entry.getItemId(), Integer.valueOf((new Random().nextBoolean() ? countRange[0] : countRange[1]))); + itemsToDrop.put( + entry.getItemId(), + Integer.valueOf((new Random().nextBoolean() ? countRange[0] : countRange[1]))); } } } break; - case 1: //Select various + case 1: // Select various { - for(var entry : dropTableEntry.getDropVec()) { - if(entry.getWeight() < new Random().nextInt(10000)) { + for (var entry : dropTableEntry.getDropVec()) { + if (entry.getWeight() < new Random().nextInt(10000)) { var countRange = parseCountRange(entry.getCountRange()); - itemsToDrop.put(entry.getItemId(), Integer.valueOf((new Random().nextBoolean() ? countRange[0] : countRange[1]))); + itemsToDrop.put( + entry.getItemId(), + Integer.valueOf((new Random().nextBoolean() ? countRange[0] : countRange[1]))); } } } @@ -271,13 +275,14 @@ public abstract class GameEntity { } for (var entry : itemsToDrop.int2ObjectEntrySet()) { - var item = new EntityItem( - scene, - null, - GameData.getItemDataMap().get(entry.getIntKey()), - getPosition().nearby2d(1f).addY(0.5f), - entry.getValue(), - true); + var item = + new EntityItem( + scene, + null, + GameData.getItemDataMap().get(entry.getIntKey()), + getPosition().nearby2d(1f).addY(0.5f), + entry.getValue(), + true); scene.addEntity(item); } diff --git a/src/main/java/emu/grasscutter/game/world/World.java b/src/main/java/emu/grasscutter/game/world/World.java index 2040d9788..766cd1ad2 100644 --- a/src/main/java/emu/grasscutter/game/world/World.java +++ b/src/main/java/emu/grasscutter/game/world/World.java @@ -1,5 +1,7 @@ package emu.grasscutter.game.world; +import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT; + import emu.grasscutter.data.GameData; import emu.grasscutter.data.excels.dungeon.DungeonData; import emu.grasscutter.game.entity.*; @@ -18,13 +20,10 @@ import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.ConversionUtils; import it.unimi.dsi.fastutil.ints.*; +import java.util.*; import lombok.*; import org.jetbrains.annotations.NotNull; -import java.util.*; - -import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT; - public class World implements Iterable { @Getter private final GameServer server; @Getter private final Player host;