mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-08 08:42:53 +08:00
Run formatter on code
This commit is contained in:
parent
40887b17fe
commit
154ace3d7e
@ -9,10 +9,10 @@ public final class DebugConstants {
|
||||
public static boolean LOG_MISSING_ABILITY_HANDLERS = true;
|
||||
|
||||
/**
|
||||
* WARNING: THIS IS A DANGEROUS SETTING. DO NOT ENABLE UNLESS YOU KNOW WHAT YOU ARE DOING.
|
||||
* This allows the *client* to send *ANY* token and UID pair to the server.
|
||||
* The server will then accept the token and UID pair as valid, and set the account's token to the client specified one.
|
||||
* This can allow for IMPERSONATION and HIJACKING of accounts/servers.
|
||||
* WARNING: THIS IS A DANGEROUS SETTING. DO NOT ENABLE UNLESS YOU KNOW WHAT YOU ARE DOING. This
|
||||
* allows the *client* to send *ANY* token and UID pair to the server. The server will then accept
|
||||
* the token and UID pair as valid, and set the account's token to the client specified one. This
|
||||
* can allow for IMPERSONATION and HIJACKING of accounts/servers.
|
||||
*/
|
||||
public static final boolean ACCEPT_CLIENT_TOKEN = false;
|
||||
|
||||
|
@ -3,7 +3,6 @@ package emu.grasscutter.command.commands;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.command.*;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Command(
|
||||
@ -33,9 +32,10 @@ public final class DebugCommand implements CommandHandler {
|
||||
|
||||
var scene = sender.getScene();
|
||||
var entityId = Integer.parseInt(args.get(0));
|
||||
var entity = args.size() > 1 && args.get(1).equals("config") ?
|
||||
scene.getEntityByConfigId(entityId) :
|
||||
scene.getEntityById(entityId);
|
||||
var entity =
|
||||
args.size() > 1 && args.get(1).equals("config")
|
||||
? scene.getEntityByConfigId(entityId)
|
||||
: scene.getEntityById(entityId);
|
||||
if (entity == null) {
|
||||
sender.dropMessage("Entity not found.");
|
||||
return;
|
||||
@ -46,8 +46,12 @@ public final class DebugCommand implements CommandHandler {
|
||||
for (var i = 0; i < abilities.size(); i++) {
|
||||
try {
|
||||
var ability = abilities.get(i);
|
||||
Grasscutter.getLogger().debug("Ability #{}: {}; Modifiers: {}",
|
||||
i, ability.toString(), ability.getModifiers().keySet());
|
||||
Grasscutter.getLogger()
|
||||
.debug(
|
||||
"Ability #{}: {}; Modifiers: {}",
|
||||
i,
|
||||
ability.toString(),
|
||||
ability.getModifiers().keySet());
|
||||
} catch (Exception exception) {
|
||||
Grasscutter.getLogger().warn("Failed to print ability #{}.", i, exception);
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package emu.grasscutter.data;
|
||||
|
||||
import static emu.grasscutter.utils.FileUtils.*;
|
||||
import static emu.grasscutter.utils.lang.Language.translate;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
@ -20,10 +23,6 @@ import emu.grasscutter.scripts.*;
|
||||
import emu.grasscutter.utils.*;
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import lombok.*;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import javax.script.*;
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
@ -31,9 +30,9 @@ import java.util.Map.Entry;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.*;
|
||||
|
||||
import static emu.grasscutter.utils.FileUtils.*;
|
||||
import static emu.grasscutter.utils.lang.Language.translate;
|
||||
import javax.script.*;
|
||||
import lombok.*;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
public final class ResourceLoader {
|
||||
|
||||
|
@ -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;
|
||||
|
@ -19,11 +19,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 {
|
||||
private static final HashMap<AbilityModifierAction.Type, AbilityActionHandler> actionHandlers =
|
||||
@ -103,7 +102,7 @@ public final class AbilityManager extends BasePlayerManager {
|
||||
() -> {
|
||||
if (!handler.execute(ability, action, abilityData, target)) {
|
||||
Grasscutter.getLogger()
|
||||
.debug("Ability execute action failed for {} at {}.", action.type, ability);
|
||||
.debug("Ability execute action failed for {} at {}.", action.type, ability);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -182,8 +181,8 @@ public final class AbilityManager extends BasePlayerManager {
|
||||
case ABILITY_INVOKE_ARGUMENT_META_SET_KILLED_SETATE -> this.handleKillState(invoke);
|
||||
default -> {
|
||||
if (DebugConstants.LOG_MISSING_ABILITIES) {
|
||||
Grasscutter.getLogger().trace("Missing invoke handler for ability {}.",
|
||||
invoke.getArgumentType().name());
|
||||
Grasscutter.getLogger()
|
||||
.trace("Missing invoke handler for ability {}.", invoke.getArgumentType().name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,10 @@ public final class ActionCopyGlobalValue extends AbilityActionHandler {
|
||||
destination.onAbilityValueUpdate();
|
||||
|
||||
// Send a value update packet.
|
||||
entity.getScene().getHost().sendPacket(
|
||||
new PacketServerGlobalValueChangeNotify(entity, action.dstKey, value));
|
||||
entity
|
||||
.getScene()
|
||||
.getHost()
|
||||
.sendPacket(new PacketServerGlobalValueChangeNotify(entity, action.dstKey, value));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -6,9 +6,8 @@ import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
||||
import emu.grasscutter.game.ability.Ability;
|
||||
import emu.grasscutter.game.entity.GameEntity;
|
||||
import emu.grasscutter.scripts.ScriptLoader;
|
||||
import org.luaj.vm2.LuaFunction;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import org.luaj.vm2.LuaFunction;
|
||||
|
||||
@AbilityAction(AbilityModifierAction.Type.ServerLuaCall)
|
||||
public final class ActionServerLuaCall extends AbilityActionHandler {
|
||||
|
@ -10,7 +10,7 @@ import emu.grasscutter.server.packet.send.PacketServerGlobalValueChangeNotify;
|
||||
public final class ActionSetGlobalValue extends AbilityActionHandler {
|
||||
@Override
|
||||
public boolean execute(
|
||||
Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
|
||||
Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
|
||||
// Get the key & value.
|
||||
var valueKey = action.key;
|
||||
var value = action.ratio;
|
||||
@ -21,8 +21,10 @@ public final class ActionSetGlobalValue extends AbilityActionHandler {
|
||||
target.onAbilityValueUpdate();
|
||||
|
||||
// Send a value update packet.
|
||||
target.getScene().getHost().sendPacket(
|
||||
new PacketServerGlobalValueChangeNotify(target, valueKey, value.get(ability)));
|
||||
target
|
||||
.getScene()
|
||||
.getHost()
|
||||
.sendPacket(new PacketServerGlobalValueChangeNotify(target, valueKey, value.get(ability)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -40,8 +40,10 @@ public final class ActionSetGlobalValueToOverrideMap extends AbilityActionHandle
|
||||
entity.onAbilityValueUpdate();
|
||||
|
||||
// Send a value update packet.
|
||||
entity.getScene().getHost().sendPacket(
|
||||
new PacketServerGlobalValueChangeNotify(entity, globalValueKey, globalValue));
|
||||
entity
|
||||
.getScene()
|
||||
.getHost()
|
||||
.sendPacket(new PacketServerGlobalValueChangeNotify(entity, globalValueKey, globalValue));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -15,11 +15,7 @@ public class Achievement {
|
||||
@Setter private int finishTimestampSec;
|
||||
|
||||
public Achievement(
|
||||
Status status,
|
||||
int id,
|
||||
int totalProgress,
|
||||
int curProgress,
|
||||
int finishTimestampSec) {
|
||||
Status status, int id, int totalProgress, int curProgress, int finishTimestampSec) {
|
||||
this.status = status;
|
||||
this.id = id;
|
||||
this.totalProgress = totalProgress;
|
||||
|
@ -10,6 +10,7 @@ import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.ActionReason;
|
||||
import emu.grasscutter.net.proto.AchievementOuterClass.Achievement.Status;
|
||||
import emu.grasscutter.server.event.player.PlayerCompleteAchievementEvent;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import lombok.*;
|
||||
import org.bson.types.ObjectId;
|
||||
@ -25,8 +26,7 @@ import java.util.function.IntSupplier;
|
||||
public class Achievements {
|
||||
private static final IntSupplier currentTimeSecs =
|
||||
() -> (int) (System.currentTimeMillis() / 1000L);
|
||||
private static final Achievement INVALID =
|
||||
new Achievement(Status.STATUS_INVALID, -1, 0, 0, 0);
|
||||
private static final Achievement INVALID = new Achievement(Status.STATUS_INVALID, -1, 0, 0, 0);
|
||||
@Id private ObjectId id;
|
||||
private int uid;
|
||||
@Transient private Player player;
|
||||
@ -65,8 +65,7 @@ public class Achievements {
|
||||
a -> {
|
||||
map.put(
|
||||
a.getId(),
|
||||
new Achievement(
|
||||
Status.STATUS_UNFINISHED, a.getId(), a.getProgress(), 0, 0));
|
||||
new Achievement(Status.STATUS_UNFINISHED, a.getId(), a.getProgress(), 0, 0));
|
||||
});
|
||||
return map;
|
||||
}
|
||||
@ -126,10 +125,13 @@ public class Achievements {
|
||||
}
|
||||
|
||||
private boolean update(Achievement a) {
|
||||
if (a.getStatus() == Status.STATUS_UNFINISHED
|
||||
&& a.getCurProgress() >= a.getTotalProgress()) {
|
||||
if (a.getStatus() == Status.STATUS_UNFINISHED && a.getCurProgress() >= a.getTotalProgress()) {
|
||||
a.setStatus(Status.STATUS_FINISHED);
|
||||
a.setFinishTimestampSec(currentTimeSecs.getAsInt());
|
||||
|
||||
// Call PlayerCompleteAchievementEvent.
|
||||
new PlayerCompleteAchievementEvent(this.player, a).call();
|
||||
|
||||
return true;
|
||||
} else if (this.isFinished(a.getId()) && a.getCurProgress() < a.getTotalProgress()) {
|
||||
a.setStatus(Status.STATUS_UNFINISHED);
|
||||
@ -197,8 +199,7 @@ public class Achievements {
|
||||
|
||||
public boolean isFinished(int achievementId) {
|
||||
var status = this.getStatus(achievementId);
|
||||
return status == Status.STATUS_FINISHED
|
||||
|| status == Status.STATUS_REWARD_TAKEN;
|
||||
return status == Status.STATUS_FINISHED || status == Status.STATUS_REWARD_TAKEN;
|
||||
}
|
||||
|
||||
public void takeReward(List<Integer> ids) {
|
||||
|
@ -9,10 +9,9 @@ import emu.grasscutter.game.world.Scene;
|
||||
import emu.grasscutter.scripts.constants.EventType;
|
||||
import emu.grasscutter.scripts.data.*;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -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;
|
||||
|
@ -69,12 +69,12 @@ public abstract class BaseRoute {
|
||||
val pitch = Math.toRadians(startRot.getY());
|
||||
val yaw = Math.toRadians(startRot.getZ());
|
||||
|
||||
val cr = (float)Math.cos(roll * 0.5);
|
||||
val sr = (float)Math.sin(roll * 0.5);
|
||||
val cp = (float)Math.cos(pitch * 0.5);
|
||||
val sp = (float)Math.sin(pitch * 0.5);
|
||||
val cy = (float)Math.cos(yaw * 0.5);
|
||||
val sy = (float)Math.sin(yaw * 0.5);
|
||||
val cr = (float) Math.cos(roll * 0.5);
|
||||
val sr = (float) Math.sin(roll * 0.5);
|
||||
val cp = (float) Math.cos(pitch * 0.5);
|
||||
val sp = (float) Math.sin(pitch * 0.5);
|
||||
val cy = (float) Math.cos(yaw * 0.5);
|
||||
val sy = (float) Math.sin(yaw * 0.5);
|
||||
|
||||
result.setW(cr * cp * cy + sr * sp * sy);
|
||||
result.setX(sr * cp * cy - cr * sp * sy);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package emu.grasscutter.game.player;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
|
||||
|
||||
import dev.morphia.annotations.*;
|
||||
import emu.grasscutter.*;
|
||||
import emu.grasscutter.data.GameData;
|
||||
@ -21,28 +23,19 @@ import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
|
||||
import lombok.*;
|
||||
|
||||
@Entity
|
||||
public final class TeamManager extends BasePlayerDataManager {
|
||||
@Transient private final List<EntityAvatar> avatars;
|
||||
@Transient @Getter private final Set<EntityBaseGadget> gadgets;
|
||||
@Transient @Getter private final IntSet teamResonances;
|
||||
@Transient
|
||||
@Getter
|
||||
private final IntSet teamResonancesConfig;
|
||||
@Transient
|
||||
@Getter
|
||||
@Setter
|
||||
private Set<String> teamAbilityEmbryos;
|
||||
@Transient @Getter private final IntSet teamResonancesConfig;
|
||||
@Transient @Getter @Setter private Set<String> teamAbilityEmbryos;
|
||||
// This needs to be a LinkedHashMap to guarantee insertion order.
|
||||
@Getter
|
||||
private LinkedHashMap<Integer, TeamInfo> teams;
|
||||
@Getter private LinkedHashMap<Integer, TeamInfo> teams;
|
||||
private int currentTeamIndex;
|
||||
@Getter @Setter private int currentCharacterIndex;
|
||||
@Transient @Getter @Setter private TeamInfo mpTeam;
|
||||
@ -82,20 +75,24 @@ public final class TeamManager extends BasePlayerDataManager {
|
||||
|
||||
// Add team ability embryos, NOT to be confused with avatarAbilties.
|
||||
// These should include the ones in LevelEntity (according to levelEntityConfig field in sceneId)
|
||||
// rn only apply to big world defaults, but will fix scaramouch domain circles (BinOutput/LevelEntity/Level_Monster_Nada_setting)
|
||||
// rn only apply to big world defaults, but will fix scaramouch domain circles
|
||||
// (BinOutput/LevelEntity/Level_Monster_Nada_setting)
|
||||
public AbilityControlBlockOuterClass.AbilityControlBlock getAbilityControlBlock() {
|
||||
AbilityControlBlockOuterClass.AbilityControlBlock.Builder abilityControlBlock = AbilityControlBlockOuterClass.AbilityControlBlock.newBuilder();
|
||||
AbilityControlBlockOuterClass.AbilityControlBlock.Builder abilityControlBlock =
|
||||
AbilityControlBlockOuterClass.AbilityControlBlock.newBuilder();
|
||||
int embryoId = 0;
|
||||
|
||||
// add from default
|
||||
if (Arrays.stream(GameConstants.DEFAULT_TEAM_ABILITY_STRINGS).count() > 0) {
|
||||
List<String> teamAbilties = Arrays.stream(GameConstants.DEFAULT_TEAM_ABILITY_STRINGS).toList();
|
||||
List<String> teamAbilties =
|
||||
Arrays.stream(GameConstants.DEFAULT_TEAM_ABILITY_STRINGS).toList();
|
||||
for (String skill : teamAbilties) {
|
||||
AbilityEmbryoOuterClass.AbilityEmbryo emb = AbilityEmbryoOuterClass.AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(Utils.abilityHash(skill))
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
AbilityEmbryoOuterClass.AbilityEmbryo emb =
|
||||
AbilityEmbryoOuterClass.AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(Utils.abilityHash(skill))
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
@ -103,11 +100,12 @@ public final class TeamManager extends BasePlayerDataManager {
|
||||
// same as avatar ability hash (add frm levelEntityConfig data)
|
||||
if (this.getTeamAbilityEmbryos().size() > 0) {
|
||||
for (String skill : this.getTeamAbilityEmbryos()) {
|
||||
AbilityEmbryoOuterClass.AbilityEmbryo emb = AbilityEmbryoOuterClass.AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(Utils.abilityHash(skill))
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
AbilityEmbryoOuterClass.AbilityEmbryo emb =
|
||||
AbilityEmbryoOuterClass.AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(Utils.abilityHash(skill))
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
package emu.grasscutter.game.props;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import lombok.Getter;
|
||||
|
||||
public enum PlayerProperty {
|
||||
PROP_NONE(0),
|
||||
@ -62,8 +61,10 @@ public enum PlayerProperty {
|
||||
PROP_PLAYER_WAIT_SUB_GCG_COIN(10046), // New; unknown/un-used.
|
||||
PROP_PLAYER_ONLINE_TIME(10047), // New; unknown/un-used.
|
||||
PROP_PLAYER_CAN_DIVE(10048, 0, 1), // Can the player dive? [0, 1]
|
||||
PROP_DIVE_MAX_STAMINA(10049, 0, 10000), // The maximum stamina of the player when diving. [0, 10000]
|
||||
PROP_DIVE_CUR_STAMINA(10050, 0, 10000); // The current stamina of the player when diving. [0, 10000]
|
||||
PROP_DIVE_MAX_STAMINA(
|
||||
10049, 0, 10000), // The maximum stamina of the player when diving. [0, 10000]
|
||||
PROP_DIVE_CUR_STAMINA(
|
||||
10050, 0, 10000); // The current stamina of the player when diving. [0, 10000]
|
||||
|
||||
private static final int inf = Integer.MAX_VALUE; // Maybe this should be something else?
|
||||
private static final Int2ObjectMap<PlayerProperty> map = new Int2ObjectOpenHashMap<>();
|
||||
|
@ -23,8 +23,8 @@ import emu.grasscutter.game.props.*;
|
||||
import emu.grasscutter.game.quest.QuestGroupSuite;
|
||||
import emu.grasscutter.game.world.data.TeleportProperties;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult;
|
||||
import emu.grasscutter.net.proto.*;
|
||||
import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult;
|
||||
import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType;
|
||||
import emu.grasscutter.scripts.*;
|
||||
import emu.grasscutter.scripts.constants.EventType;
|
||||
@ -35,12 +35,11 @@ import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.server.scheduler.ServerTaskScheduler;
|
||||
import emu.grasscutter.utils.objects.KahnsSort;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import lombok.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.*;
|
||||
|
||||
public final class Scene {
|
||||
@Getter private final World world;
|
||||
|
@ -1,15 +1,14 @@
|
||||
package emu.grasscutter.scripts;
|
||||
|
||||
import static emu.grasscutter.utils.FileUtils.getScriptPath;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.scripts.data.controller.EntityController;
|
||||
import lombok.val;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static emu.grasscutter.utils.FileUtils.getScriptPath;
|
||||
import lombok.val;
|
||||
|
||||
public class EntityControllerScriptManager {
|
||||
private static final Map<String, EntityController> gadgetController = new ConcurrentHashMap<>();
|
||||
|
@ -8,18 +8,17 @@ import emu.grasscutter.scripts.constants.*;
|
||||
import emu.grasscutter.scripts.data.SceneMeta;
|
||||
import emu.grasscutter.scripts.serializer.*;
|
||||
import emu.grasscutter.utils.FileUtils;
|
||||
import lombok.Getter;
|
||||
import org.luaj.vm2.*;
|
||||
import org.luaj.vm2.lib.OneArgFunction;
|
||||
import org.luaj.vm2.lib.jse.CoerceJavaToLua;
|
||||
import org.luaj.vm2.script.LuajContext;
|
||||
|
||||
import javax.script.*;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import javax.script.*;
|
||||
import lombok.Getter;
|
||||
import org.luaj.vm2.*;
|
||||
import org.luaj.vm2.lib.OneArgFunction;
|
||||
import org.luaj.vm2.lib.jse.CoerceJavaToLua;
|
||||
import org.luaj.vm2.script.LuajContext;
|
||||
|
||||
public class ScriptLoader {
|
||||
private static ScriptEngineManager sm;
|
||||
@ -34,8 +33,7 @@ public class ScriptLoader {
|
||||
/** sceneId - SceneMeta */
|
||||
private static Map<Integer, SoftReference<SceneMeta>> sceneMetaCache = new ConcurrentHashMap<>();
|
||||
|
||||
private static final AtomicReference<Bindings> currentBindings
|
||||
= new AtomicReference<>(null);
|
||||
private static final AtomicReference<Bindings> currentBindings = new AtomicReference<>(null);
|
||||
|
||||
public static synchronized void init() throws Exception {
|
||||
if (sm != null) {
|
||||
@ -110,17 +108,13 @@ public class ScriptLoader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a smart evaluation.
|
||||
* This allows for 'require' to work.
|
||||
* Performs a smart evaluation. This allows for 'require' to work.
|
||||
*
|
||||
* @param script The script to evaluate.
|
||||
* @param bindings The bindings to use.
|
||||
* @return The result of the evaluation.
|
||||
*/
|
||||
public static Object eval(
|
||||
CompiledScript script,
|
||||
Bindings bindings)
|
||||
throws ScriptException {
|
||||
public static Object eval(CompiledScript script, Bindings bindings) throws ScriptException {
|
||||
// Set the current bindings.
|
||||
currentBindings.set(bindings);
|
||||
// Evaluate the script.
|
||||
|
@ -5,11 +5,10 @@ import com.github.davidmoten.rtreemulti.geometry.*;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.game.world.Position;
|
||||
import emu.grasscutter.scripts.*;
|
||||
import lombok.*;
|
||||
|
||||
import javax.script.*;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.script.*;
|
||||
import lombok.*;
|
||||
|
||||
@ToString
|
||||
@Setter
|
||||
|
@ -3,12 +3,11 @@ package emu.grasscutter.scripts.data;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.game.world.Position;
|
||||
import emu.grasscutter.scripts.ScriptLoader;
|
||||
import lombok.*;
|
||||
import org.luaj.vm2.*;
|
||||
|
||||
import javax.script.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.script.*;
|
||||
import lombok.*;
|
||||
import org.luaj.vm2.*;
|
||||
|
||||
@ToString
|
||||
@Setter
|
||||
|
@ -4,11 +4,10 @@ import com.github.davidmoten.rtreemulti.RTree;
|
||||
import com.github.davidmoten.rtreemulti.geometry.Geometry;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.scripts.*;
|
||||
import lombok.*;
|
||||
|
||||
import javax.script.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.script.*;
|
||||
import lombok.*;
|
||||
|
||||
@ToString
|
||||
@Setter
|
||||
|
@ -1,5 +1,7 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.ACCOUNT;
|
||||
|
||||
import emu.grasscutter.*;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
@ -11,12 +13,9 @@ import emu.grasscutter.server.game.GameSession.SessionState;
|
||||
import emu.grasscutter.server.packet.send.PacketGetPlayerTokenRsp;
|
||||
import emu.grasscutter.utils.*;
|
||||
import emu.grasscutter.utils.helpers.ByteHelper;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.Signature;
|
||||
|
||||
import static emu.grasscutter.config.Configuration.ACCOUNT;
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
@Opcodes(PacketOpcodes.GetPlayerTokenReq)
|
||||
public class HandlerGetPlayerTokenReq extends PacketHandler {
|
||||
|
@ -1,5 +1,8 @@
|
||||
package emu.grasscutter.tools;
|
||||
|
||||
import static emu.grasscutter.utils.FileUtils.getResourcePath;
|
||||
import static emu.grasscutter.utils.lang.Language.getTextMapKey;
|
||||
|
||||
import emu.grasscutter.*;
|
||||
import emu.grasscutter.command.*;
|
||||
import emu.grasscutter.data.*;
|
||||
@ -11,8 +14,6 @@ import emu.grasscutter.utils.*;
|
||||
import emu.grasscutter.utils.lang.Language;
|
||||
import emu.grasscutter.utils.lang.Language.TextStrings;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
@ -21,9 +22,7 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.*;
|
||||
|
||||
import static emu.grasscutter.utils.FileUtils.getResourcePath;
|
||||
import static emu.grasscutter.utils.lang.Language.getTextMapKey;
|
||||
import lombok.*;
|
||||
|
||||
public final class Tools {
|
||||
/**
|
||||
@ -422,8 +421,7 @@ public final class Tools {
|
||||
case "ver" -> resourceInfo.version(value);
|
||||
case "patches" -> resourceInfo.patches(value);
|
||||
case "scripts" -> resourceInfo.scripts(ScriptsType.valueOf(value.toUpperCase()));
|
||||
case "hasnolocals" -> resourceInfo.hasNoLocals(
|
||||
Boolean.parseBoolean(value));
|
||||
case "hasnolocals" -> resourceInfo.hasNoLocals(Boolean.parseBoolean(value));
|
||||
case "hasserverres" -> resourceInfo.hasServerResources(
|
||||
Boolean.parseBoolean(value));
|
||||
case "hasscenescriptdata" -> resourceInfo.hasSceneScriptData(
|
||||
|
Loading…
Reference in New Issue
Block a user