Format code [skip actions]

This commit is contained in:
github-actions 2023-05-31 23:26:53 +00:00
parent 815ba3e3e3
commit 36dee424ee
9 changed files with 55 additions and 44 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -32,7 +32,7 @@ public class ActionSetGlobalValueToOverrideMap extends AbilityActionHandler {
entity.getGlobalAbilityValues().put(globalValueKey, globalValue);
//TODO: ChangeServerGlobalValueNotify
// TODO: ChangeServerGlobalValueNotify
return true;
}

View File

@ -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));

View File

@ -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());
}
}

View File

@ -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);
}

View File

@ -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()) {

View File

@ -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);
}