mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-02-04 09:15:07 +01:00
Format code [skip actions]
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
package emu.grasscutter.auth;
|
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 at.favre.lib.crypto.bcrypt.BCrypt;
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.Grasscutter.ServerRunMode;
|
import emu.grasscutter.Grasscutter.ServerRunMode;
|
||||||
@@ -10,16 +13,12 @@ import emu.grasscutter.server.dispatch.*;
|
|||||||
import emu.grasscutter.server.http.objects.*;
|
import emu.grasscutter.server.http.objects.*;
|
||||||
import emu.grasscutter.utils.*;
|
import emu.grasscutter.utils.*;
|
||||||
import io.javalin.http.ContentType;
|
import io.javalin.http.ContentType;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.KeyFactory;
|
import java.security.KeyFactory;
|
||||||
import java.security.interfaces.RSAPrivateKey;
|
import java.security.interfaces.RSAPrivateKey;
|
||||||
import java.security.spec.PKCS8EncodedKeySpec;
|
import java.security.spec.PKCS8EncodedKeySpec;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
import javax.crypto.Cipher;
|
||||||
import static emu.grasscutter.config.Configuration.ACCOUNT;
|
|
||||||
import static emu.grasscutter.utils.lang.Language.translate;
|
|
||||||
|
|
||||||
/** A class containing default authenticators. */
|
/** A class containing default authenticators. */
|
||||||
public final class DefaultAuthenticators {
|
public final class DefaultAuthenticators {
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ import emu.grasscutter.data.excels.ProudSkillData;
|
|||||||
import emu.grasscutter.game.ability.Ability;
|
import emu.grasscutter.game.ability.Ability;
|
||||||
import it.unimi.dsi.fastutil.floats.FloatArrayList;
|
import it.unimi.dsi.fastutil.floats.FloatArrayList;
|
||||||
import it.unimi.dsi.fastutil.objects.*;
|
import it.unimi.dsi.fastutil.objects.*;
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class DynamicFloat {
|
public class DynamicFloat {
|
||||||
|
|||||||
@@ -17,11 +17,10 @@ import emu.grasscutter.net.proto.AbilityScalarTypeOuterClass.AbilityScalarType;
|
|||||||
import emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry;
|
import emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry;
|
||||||
import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction;
|
import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction;
|
||||||
import io.netty.util.concurrent.FastThreadLocalThread;
|
import io.netty.util.concurrent.FastThreadLocalThread;
|
||||||
import lombok.Getter;
|
|
||||||
import org.reflections.Reflections;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.reflections.Reflections;
|
||||||
|
|
||||||
public final class AbilityManager extends BasePlayerManager {
|
public final class AbilityManager extends BasePlayerManager {
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class ActionSetGlobalValueToOverrideMap extends AbilityActionHandler {
|
|||||||
|
|
||||||
entity.getGlobalAbilityValues().put(globalValueKey, globalValue);
|
entity.getGlobalAbilityValues().put(globalValueKey, globalValue);
|
||||||
|
|
||||||
//TODO: ChangeServerGlobalValueNotify
|
// TODO: ChangeServerGlobalValueNotify
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -463,11 +463,16 @@ public class Avatar {
|
|||||||
this.getEquips().put(itemEquipType.getValue(), item);
|
this.getEquips().put(itemEquipType.getValue(), item);
|
||||||
|
|
||||||
if (itemEquipType == EquipType.EQUIP_WEAPON && getPlayer().getWorld() != null) {
|
if (itemEquipType == EquipType.EQUIP_WEAPON && getPlayer().getWorld() != null) {
|
||||||
if (!(item.getWeaponEntity() != null && item.getWeaponEntity().getScene() == getPlayer().getScene())) {
|
if (!(item.getWeaponEntity() != null
|
||||||
item.setWeaponEntity(new EntityWeapon(this.getPlayer().getScene(), item.getItemData().getGadgetId()));
|
&& item.getWeaponEntity().getScene() == getPlayer().getScene())) {
|
||||||
this.getPlayer().getScene().getWeaponEntities().put(item.getWeaponEntity().getId(), item.getWeaponEntity());
|
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());
|
item.setEquipCharacter(this.getAvatarId());
|
||||||
@@ -1262,9 +1267,14 @@ public class Avatar {
|
|||||||
item.setEquipCharacter(this.getAvatarId());
|
item.setEquipCharacter(this.getAvatarId());
|
||||||
item.setOwner(player);
|
item.setOwner(player);
|
||||||
if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) {
|
if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) {
|
||||||
if (!(item.getWeaponEntity() != null && item.getWeaponEntity().getScene() == player.getScene())) {
|
if (!(item.getWeaponEntity() != null
|
||||||
item.setWeaponEntity(new EntityWeapon(player.getScene(), item.getItemData().getGadgetId()));
|
&& item.getWeaponEntity().getScene() == player.getScene())) {
|
||||||
player.getScene().getWeaponEntities().put(item.getWeaponEntity().getId(), item.getWeaponEntity());
|
item.setWeaponEntity(
|
||||||
|
new EntityWeapon(player.getScene(), item.getItemData().getGadgetId()));
|
||||||
|
player
|
||||||
|
.getScene()
|
||||||
|
.getWeaponEntities()
|
||||||
|
.put(item.getWeaponEntity().getId(), item.getWeaponEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendPacket(new PacketAvatarEquipChangeNotify(this, item));
|
player.sendPacket(new PacketAvatarEquipChangeNotify(this, item));
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ public class EntityAvatar extends GameEntity {
|
|||||||
var weapon = this.getAvatar().getWeapon();
|
var weapon = this.getAvatar().getWeapon();
|
||||||
if (weapon != null) {
|
if (weapon != null) {
|
||||||
if (!(weapon.getWeaponEntity() != null && weapon.getWeaponEntity().getScene() == scene)) {
|
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());
|
scene.getWeaponEntities().put(weapon.getWeaponEntity().getId(), weapon.getWeaponEntity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
package emu.grasscutter.game.entity;
|
package emu.grasscutter.game.entity;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
import emu.grasscutter.data.binout.AbilityData;
|
import emu.grasscutter.data.binout.AbilityData;
|
||||||
import emu.grasscutter.data.binout.config.ConfigEntityGadget;
|
import emu.grasscutter.data.binout.config.ConfigEntityGadget;
|
||||||
import emu.grasscutter.data.binout.config.fields.ConfigAbilityData;
|
import emu.grasscutter.data.binout.config.fields.ConfigAbilityData;
|
||||||
import emu.grasscutter.data.excels.GadgetData;
|
import emu.grasscutter.data.excels.GadgetData;
|
||||||
import emu.grasscutter.game.entity.gadget.GadgetContent;
|
|
||||||
import emu.grasscutter.game.props.EntityIdType;
|
import emu.grasscutter.game.props.EntityIdType;
|
||||||
import emu.grasscutter.game.world.Scene;
|
import emu.grasscutter.game.world.Scene;
|
||||||
import emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo;
|
import emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo;
|
||||||
@@ -16,6 +13,7 @@ import emu.grasscutter.scripts.EntityControllerScriptManager;
|
|||||||
import emu.grasscutter.utils.Position;
|
import emu.grasscutter.utils.Position;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2FloatMap;
|
import it.unimi.dsi.fastutil.ints.Int2FloatMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
@@ -23,10 +21,12 @@ import lombok.ToString;
|
|||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class EntityWeapon extends EntityBaseGadget {
|
public class EntityWeapon extends EntityBaseGadget {
|
||||||
@Getter private final GadgetData gadgetData;
|
@Getter private final GadgetData gadgetData;
|
||||||
@Getter(onMethod = @__(@Override)) @Setter
|
|
||||||
|
@Getter(onMethod = @__(@Override))
|
||||||
|
@Setter
|
||||||
private int gadgetId;
|
private int gadgetId;
|
||||||
@Nullable @Getter
|
|
||||||
private ConfigEntityGadget configGadget;
|
@Nullable @Getter private ConfigEntityGadget configGadget;
|
||||||
|
|
||||||
@Getter(onMethod = @__(@Override), lazy = true)
|
@Getter(onMethod = @__(@Override), lazy = true)
|
||||||
private final Int2FloatMap fightProperties = new Int2FloatOpenHashMap();
|
private final Int2FloatMap fightProperties = new Int2FloatOpenHashMap();
|
||||||
@@ -38,7 +38,7 @@ public class EntityWeapon extends EntityBaseGadget {
|
|||||||
super(scene);
|
super(scene);
|
||||||
|
|
||||||
this.gadgetData = GameData.getGadgetDataMap().get(gadgetId);
|
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());
|
this.configGadget = GameData.getGadgetConfigData().get(gadgetData.getJsonName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,31 +47,31 @@ public class EntityWeapon extends EntityBaseGadget {
|
|||||||
this.bornPos = this.getPosition().clone();
|
this.bornPos = this.getPosition().clone();
|
||||||
this.bornRot = this.getRotation().clone();
|
this.bornRot = this.getRotation().clone();
|
||||||
fillFightProps(configGadget);
|
fillFightProps(configGadget);
|
||||||
if(GameData.getGadgetMappingMap().containsKey(gadgetId)) {
|
if (GameData.getGadgetMappingMap().containsKey(gadgetId)) {
|
||||||
String controllerName = GameData.getGadgetMappingMap().get(gadgetId).getServerController();
|
String controllerName = GameData.getGadgetMappingMap().get(gadgetId).getServerController();
|
||||||
setEntityController(EntityControllerScriptManager.getGadgetController(controllerName));
|
setEntityController(EntityControllerScriptManager.getGadgetController(controllerName));
|
||||||
if(getEntityController() == null) {
|
if (getEntityController() == null) {
|
||||||
Grasscutter.getLogger().warn("Gadget controller {} not found", controllerName);
|
Grasscutter.getLogger().warn("Gadget controller {} not found", controllerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.id = scene.getWorld().getNextEntityId(EntityIdType.WEAPON);
|
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();
|
initAbilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addConfigAbility(ConfigAbilityData abilityData){
|
private void addConfigAbility(ConfigAbilityData abilityData) {
|
||||||
AbilityData data = GameData.getAbilityData(abilityData.getAbilityName());
|
AbilityData data = GameData.getAbilityData(abilityData.getAbilityName());
|
||||||
if(data != null)
|
if (data != null)
|
||||||
getScene().getWorld().getHost().getAbilityManager().addAbilityToEntity(
|
getScene().getWorld().getHost().getAbilityManager().addAbilityToEntity(this, data);
|
||||||
this, data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initAbilities() {
|
public void initAbilities() {
|
||||||
//TODO: handle predynamic, static and dynamic here
|
// TODO: handle predynamic, static and dynamic here
|
||||||
if(this.configGadget != null && this.configGadget.getAbilities() != null) {
|
if (this.configGadget != null && this.configGadget.getAbilities() != null) {
|
||||||
for (var ability : this.configGadget.getAbilities()) {
|
for (var ability : this.configGadget.getAbilities()) {
|
||||||
addConfigAbility(ability);
|
addConfigAbility(ability);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,13 +276,14 @@ public class GameItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SceneWeaponInfo createSceneWeaponInfo() {
|
public SceneWeaponInfo createSceneWeaponInfo() {
|
||||||
var weaponInfo = SceneWeaponInfo.newBuilder()
|
var weaponInfo =
|
||||||
.setEntityId(this.getWeaponEntity() != null ? this.getWeaponEntity().getId() : 0)
|
SceneWeaponInfo.newBuilder()
|
||||||
.setItemId(this.getItemId())
|
.setEntityId(this.getWeaponEntity() != null ? this.getWeaponEntity().getId() : 0)
|
||||||
.setGuid(this.getGuid())
|
.setItemId(this.getItemId())
|
||||||
.setLevel(this.getLevel())
|
.setGuid(this.getGuid())
|
||||||
.setGadgetId(this.getItemData().getGadgetId())
|
.setLevel(this.getLevel())
|
||||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder().setIsInited(getAffixes().size() > 0));
|
.setGadgetId(this.getItemData().getGadgetId())
|
||||||
|
.setAbilityInfo(AbilitySyncStateInfo.newBuilder().setIsInited(getAffixes().size() > 0));
|
||||||
|
|
||||||
if (this.getAffixes() != null && this.getAffixes().size() > 0) {
|
if (this.getAffixes() != null && this.getAffixes().size() > 0) {
|
||||||
for (int affix : this.getAffixes()) {
|
for (int affix : this.getAffixes()) {
|
||||||
|
|||||||
@@ -800,7 +800,9 @@ public final class Scene {
|
|||||||
|
|
||||||
for (GameEntity entity : this.getEntities().values()) {
|
for (GameEntity entity : this.getEntities().values()) {
|
||||||
var spawnEntry = entity.getSpawnEntry();
|
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);
|
toRemove.add(entity);
|
||||||
spawnedEntities.remove(spawnEntry);
|
spawnedEntities.remove(spawnEntry);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user