From 36dee424ee1dca1ad3ec70c5bdff082b24a26c87 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 31 May 2023 23:26:53 +0000 Subject: [PATCH] Format code [skip actions] --- .../auth/DefaultAuthenticators.java | 9 +++-- .../grasscutter/data/common/DynamicFloat.java | 3 +- .../game/ability/AbilityManager.java | 5 ++- .../ActionSetGlobalValueToOverrideMap.java | 2 +- .../emu/grasscutter/game/avatar/Avatar.java | 24 +++++++++---- .../grasscutter/game/entity/EntityAvatar.java | 3 +- .../grasscutter/game/entity/EntityWeapon.java | 34 +++++++++---------- .../grasscutter/game/inventory/GameItem.java | 15 ++++---- .../emu/grasscutter/game/world/Scene.java | 4 ++- 9 files changed, 55 insertions(+), 44 deletions(-) diff --git a/src/main/java/emu/grasscutter/auth/DefaultAuthenticators.java b/src/main/java/emu/grasscutter/auth/DefaultAuthenticators.java index 372b0267f..1892d4504 100644 --- a/src/main/java/emu/grasscutter/auth/DefaultAuthenticators.java +++ b/src/main/java/emu/grasscutter/auth/DefaultAuthenticators.java @@ -1,5 +1,8 @@ package emu.grasscutter.auth; +import static emu.grasscutter.config.Configuration.ACCOUNT; +import static emu.grasscutter.utils.lang.Language.translate; + import at.favre.lib.crypto.bcrypt.BCrypt; import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter.ServerRunMode; @@ -10,16 +13,12 @@ import emu.grasscutter.server.dispatch.*; import emu.grasscutter.server.http.objects.*; import emu.grasscutter.utils.*; import io.javalin.http.ContentType; - -import javax.crypto.Cipher; import java.nio.charset.StandardCharsets; import java.security.KeyFactory; import java.security.interfaces.RSAPrivateKey; import java.security.spec.PKCS8EncodedKeySpec; import java.util.concurrent.*; - -import static emu.grasscutter.config.Configuration.ACCOUNT; -import static emu.grasscutter.utils.lang.Language.translate; +import javax.crypto.Cipher; /** A class containing default authenticators. */ public final class DefaultAuthenticators { diff --git a/src/main/java/emu/grasscutter/data/common/DynamicFloat.java b/src/main/java/emu/grasscutter/data/common/DynamicFloat.java index ea29e7074..99dc12433 100644 --- a/src/main/java/emu/grasscutter/data/common/DynamicFloat.java +++ b/src/main/java/emu/grasscutter/data/common/DynamicFloat.java @@ -4,9 +4,8 @@ import emu.grasscutter.data.excels.ProudSkillData; import emu.grasscutter.game.ability.Ability; import it.unimi.dsi.fastutil.floats.FloatArrayList; import it.unimi.dsi.fastutil.objects.*; -import lombok.*; - import java.util.*; +import lombok.*; @Getter public class DynamicFloat { diff --git a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java index 30cd8bedb..f6c914d15 100644 --- a/src/main/java/emu/grasscutter/game/ability/AbilityManager.java +++ b/src/main/java/emu/grasscutter/game/ability/AbilityManager.java @@ -17,11 +17,10 @@ import emu.grasscutter.net.proto.AbilityScalarTypeOuterClass.AbilityScalarType; import emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry; import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction; import io.netty.util.concurrent.FastThreadLocalThread; -import lombok.Getter; -import org.reflections.Reflections; - import java.util.HashMap; import java.util.concurrent.*; +import lombok.Getter; +import org.reflections.Reflections; public final class AbilityManager extends BasePlayerManager { diff --git a/src/main/java/emu/grasscutter/game/ability/actions/ActionSetGlobalValueToOverrideMap.java b/src/main/java/emu/grasscutter/game/ability/actions/ActionSetGlobalValueToOverrideMap.java index 1997a755d..7cdad06e7 100644 --- a/src/main/java/emu/grasscutter/game/ability/actions/ActionSetGlobalValueToOverrideMap.java +++ b/src/main/java/emu/grasscutter/game/ability/actions/ActionSetGlobalValueToOverrideMap.java @@ -32,7 +32,7 @@ public class ActionSetGlobalValueToOverrideMap extends AbilityActionHandler { entity.getGlobalAbilityValues().put(globalValueKey, globalValue); - //TODO: ChangeServerGlobalValueNotify + // TODO: ChangeServerGlobalValueNotify return true; } diff --git a/src/main/java/emu/grasscutter/game/avatar/Avatar.java b/src/main/java/emu/grasscutter/game/avatar/Avatar.java index 211cd37f2..c50586430 100644 --- a/src/main/java/emu/grasscutter/game/avatar/Avatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/Avatar.java @@ -463,11 +463,16 @@ public class Avatar { this.getEquips().put(itemEquipType.getValue(), item); if (itemEquipType == EquipType.EQUIP_WEAPON && getPlayer().getWorld() != null) { - if (!(item.getWeaponEntity() != null && item.getWeaponEntity().getScene() == getPlayer().getScene())) { - item.setWeaponEntity(new EntityWeapon(this.getPlayer().getScene(), item.getItemData().getGadgetId())); - this.getPlayer().getScene().getWeaponEntities().put(item.getWeaponEntity().getId(), item.getWeaponEntity()); + if (!(item.getWeaponEntity() != null + && item.getWeaponEntity().getScene() == getPlayer().getScene())) { + item.setWeaponEntity( + new EntityWeapon(this.getPlayer().getScene(), item.getItemData().getGadgetId())); + this.getPlayer() + .getScene() + .getWeaponEntities() + .put(item.getWeaponEntity().getId(), item.getWeaponEntity()); } - //item.setWeaponEntityId(this.getPlayer().getWorld().getNextEntityId(EntityIdType.WEAPON)); + // item.setWeaponEntityId(this.getPlayer().getWorld().getNextEntityId(EntityIdType.WEAPON)); } item.setEquipCharacter(this.getAvatarId()); @@ -1262,9 +1267,14 @@ public class Avatar { item.setEquipCharacter(this.getAvatarId()); item.setOwner(player); if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) { - if (!(item.getWeaponEntity() != null && item.getWeaponEntity().getScene() == player.getScene())) { - item.setWeaponEntity(new EntityWeapon(player.getScene(), item.getItemData().getGadgetId())); - player.getScene().getWeaponEntities().put(item.getWeaponEntity().getId(), item.getWeaponEntity()); + if (!(item.getWeaponEntity() != null + && item.getWeaponEntity().getScene() == player.getScene())) { + item.setWeaponEntity( + new EntityWeapon(player.getScene(), item.getItemData().getGadgetId())); + player + .getScene() + .getWeaponEntities() + .put(item.getWeaponEntity().getId(), item.getWeaponEntity()); } player.sendPacket(new PacketAvatarEquipChangeNotify(this, item)); diff --git a/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java b/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java index 8f285e7ea..f8844adba 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityAvatar.java @@ -64,7 +64,8 @@ public class EntityAvatar extends GameEntity { var weapon = this.getAvatar().getWeapon(); if (weapon != null) { if (!(weapon.getWeaponEntity() != null && weapon.getWeaponEntity().getScene() == scene)) { - weapon.setWeaponEntity(new EntityWeapon(this.getPlayer().getScene(), weapon.getItemData().getGadgetId())); + weapon.setWeaponEntity( + new EntityWeapon(this.getPlayer().getScene(), weapon.getItemData().getGadgetId())); scene.getWeaponEntities().put(weapon.getWeaponEntity().getId(), weapon.getWeaponEntity()); } } diff --git a/src/main/java/emu/grasscutter/game/entity/EntityWeapon.java b/src/main/java/emu/grasscutter/game/entity/EntityWeapon.java index d9c2f4d90..b473e4af3 100644 --- a/src/main/java/emu/grasscutter/game/entity/EntityWeapon.java +++ b/src/main/java/emu/grasscutter/game/entity/EntityWeapon.java @@ -1,14 +1,11 @@ package emu.grasscutter.game.entity; -import javax.annotation.Nullable; - import emu.grasscutter.Grasscutter; import emu.grasscutter.data.GameData; import emu.grasscutter.data.binout.AbilityData; import emu.grasscutter.data.binout.config.ConfigEntityGadget; import emu.grasscutter.data.binout.config.fields.ConfigAbilityData; import emu.grasscutter.data.excels.GadgetData; -import emu.grasscutter.game.entity.gadget.GadgetContent; import emu.grasscutter.game.props.EntityIdType; import emu.grasscutter.game.world.Scene; import emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo; @@ -16,6 +13,7 @@ import emu.grasscutter.scripts.EntityControllerScriptManager; import emu.grasscutter.utils.Position; import it.unimi.dsi.fastutil.ints.Int2FloatMap; import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap; +import javax.annotation.Nullable; import lombok.Getter; import lombok.Setter; import lombok.ToString; @@ -23,10 +21,12 @@ import lombok.ToString; @ToString(callSuper = true) public class EntityWeapon extends EntityBaseGadget { @Getter private final GadgetData gadgetData; - @Getter(onMethod = @__(@Override)) @Setter + + @Getter(onMethod = @__(@Override)) + @Setter private int gadgetId; - @Nullable @Getter - private ConfigEntityGadget configGadget; + + @Nullable @Getter private ConfigEntityGadget configGadget; @Getter(onMethod = @__(@Override), lazy = true) private final Int2FloatMap fightProperties = new Int2FloatOpenHashMap(); @@ -38,7 +38,7 @@ public class EntityWeapon extends EntityBaseGadget { super(scene); this.gadgetData = GameData.getGadgetDataMap().get(gadgetId); - if (gadgetData!=null && gadgetData.getJsonName()!=null) { + if (gadgetData != null && gadgetData.getJsonName() != null) { this.configGadget = GameData.getGadgetConfigData().get(gadgetData.getJsonName()); } @@ -47,31 +47,31 @@ public class EntityWeapon extends EntityBaseGadget { this.bornPos = this.getPosition().clone(); this.bornRot = this.getRotation().clone(); fillFightProps(configGadget); - if(GameData.getGadgetMappingMap().containsKey(gadgetId)) { + if (GameData.getGadgetMappingMap().containsKey(gadgetId)) { String controllerName = GameData.getGadgetMappingMap().get(gadgetId).getServerController(); setEntityController(EntityControllerScriptManager.getGadgetController(controllerName)); - if(getEntityController() == null) { + if (getEntityController() == null) { Grasscutter.getLogger().warn("Gadget controller {} not found", controllerName); } } this.id = scene.getWorld().getNextEntityId(EntityIdType.WEAPON); - Grasscutter.getLogger().warn("New weapon entity id {} at scene {}", this.id, this.getScene().getId()); + Grasscutter.getLogger() + .warn("New weapon entity id {} at scene {}", this.id, this.getScene().getId()); initAbilities(); } - private void addConfigAbility(ConfigAbilityData abilityData){ - AbilityData data = GameData.getAbilityData(abilityData.getAbilityName()); - if(data != null) - getScene().getWorld().getHost().getAbilityManager().addAbilityToEntity( - this, data); + private void addConfigAbility(ConfigAbilityData abilityData) { + AbilityData data = GameData.getAbilityData(abilityData.getAbilityName()); + if (data != null) + getScene().getWorld().getHost().getAbilityManager().addAbilityToEntity(this, data); } @Override public void initAbilities() { - //TODO: handle predynamic, static and dynamic here - if(this.configGadget != null && this.configGadget.getAbilities() != null) { + // TODO: handle predynamic, static and dynamic here + if (this.configGadget != null && this.configGadget.getAbilities() != null) { for (var ability : this.configGadget.getAbilities()) { addConfigAbility(ability); } diff --git a/src/main/java/emu/grasscutter/game/inventory/GameItem.java b/src/main/java/emu/grasscutter/game/inventory/GameItem.java index 8bf300114..64029c752 100644 --- a/src/main/java/emu/grasscutter/game/inventory/GameItem.java +++ b/src/main/java/emu/grasscutter/game/inventory/GameItem.java @@ -276,13 +276,14 @@ public class GameItem { } public SceneWeaponInfo createSceneWeaponInfo() { - var weaponInfo = SceneWeaponInfo.newBuilder() - .setEntityId(this.getWeaponEntity() != null ? this.getWeaponEntity().getId() : 0) - .setItemId(this.getItemId()) - .setGuid(this.getGuid()) - .setLevel(this.getLevel()) - .setGadgetId(this.getItemData().getGadgetId()) - .setAbilityInfo(AbilitySyncStateInfo.newBuilder().setIsInited(getAffixes().size() > 0)); + var weaponInfo = + SceneWeaponInfo.newBuilder() + .setEntityId(this.getWeaponEntity() != null ? this.getWeaponEntity().getId() : 0) + .setItemId(this.getItemId()) + .setGuid(this.getGuid()) + .setLevel(this.getLevel()) + .setGadgetId(this.getItemData().getGadgetId()) + .setAbilityInfo(AbilitySyncStateInfo.newBuilder().setIsInited(getAffixes().size() > 0)); if (this.getAffixes() != null && this.getAffixes().size() > 0) { for (int affix : this.getAffixes()) { diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index 8d4ddc7c5..08f5d61e0 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -800,7 +800,9 @@ public final class Scene { for (GameEntity entity : this.getEntities().values()) { var spawnEntry = entity.getSpawnEntry(); - if (spawnEntry != null && !(entity instanceof EntityWeapon) && !visible.contains(spawnEntry)) { + if (spawnEntry != null + && !(entity instanceof EntityWeapon) + && !visible.contains(spawnEntry)) { toRemove.add(entity); spawnedEntities.remove(spawnEntry); }