mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-17 17:34:39 +01:00
Run formatter & bump version
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package emu.grasscutter.scripts;
|
||||
|
||||
import static emu.grasscutter.scripts.constants.EventType.EVENT_TIMER_EVENT;
|
||||
|
||||
import com.github.davidmoten.rtreemulti.RTree;
|
||||
import com.github.davidmoten.rtreemulti.geometry.Geometry;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
@@ -19,20 +21,17 @@ import emu.grasscutter.server.packet.send.PacketGroupSuiteNotify;
|
||||
import emu.grasscutter.utils.*;
|
||||
import io.netty.util.concurrent.FastThreadLocalThread;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import kotlin.Pair;
|
||||
import lombok.val;
|
||||
import org.luaj.vm2.*;
|
||||
import org.luaj.vm2.lib.jse.CoerceJavaToLua;
|
||||
|
||||
import javax.annotation.*;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static emu.grasscutter.scripts.constants.EventType.EVENT_TIMER_EVENT;
|
||||
import javax.annotation.*;
|
||||
import kotlin.Pair;
|
||||
import lombok.val;
|
||||
import org.luaj.vm2.*;
|
||||
import org.luaj.vm2.lib.jse.CoerceJavaToLua;
|
||||
|
||||
public class SceneScriptManager {
|
||||
private final Scene scene;
|
||||
@@ -40,8 +39,7 @@ public class SceneScriptManager {
|
||||
private SceneMeta meta;
|
||||
private boolean isInit;
|
||||
|
||||
private final Map<String, SceneTimeAxis> timeAxis
|
||||
= new ConcurrentHashMap<>();
|
||||
private final Map<String, SceneTimeAxis> timeAxis = new ConcurrentHashMap<>();
|
||||
|
||||
/** current triggers controlled by RefreshGroup */
|
||||
private final Map<Integer, Set<SceneTrigger>> currentTriggers;
|
||||
@@ -399,7 +397,7 @@ public class SceneScriptManager {
|
||||
var instance = cachedSceneGroupsInstances.getOrDefault(groupId, null);
|
||||
if (instance == null) {
|
||||
instance = DatabaseHelper.loadGroupInstance(groupId, scene.getWorld().getHost());
|
||||
if (instance != null){
|
||||
if (instance != null) {
|
||||
cachedSceneGroupsInstances.put(groupId, instance);
|
||||
this.cachedSceneGroupsInstances.get(groupId).setCached(false);
|
||||
this.cachedSceneGroupsInstances.get(groupId).setLuaGroup(getGroupById(groupId));
|
||||
@@ -833,9 +831,9 @@ public class SceneScriptManager {
|
||||
.filter(
|
||||
t ->
|
||||
(t.getName().length() <= 12
|
||||
|| t.getName().substring(13).equals(String.valueOf(params.param1)))
|
||||
&& (t.getSource().isEmpty()
|
||||
|| t.getSource().equals(params.getEventSource())))
|
||||
|| t.getName().substring(13).equals(String.valueOf(params.param1)))
|
||||
&& (t.getSource().isEmpty()
|
||||
|| t.getSource().equals(params.getEventSource())))
|
||||
.collect(Collectors.toSet());
|
||||
default -> this.getTriggersByEvent(eventType).stream()
|
||||
.filter(
|
||||
@@ -1203,8 +1201,7 @@ public class SceneScriptManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new time axis for this scene.
|
||||
* Starts the time axis after.
|
||||
* Registers a new time axis for this scene. Starts the time axis after.
|
||||
*
|
||||
* @param timeAxis The time axis.
|
||||
*/
|
||||
|
||||
@@ -2,9 +2,8 @@ package emu.grasscutter.scripts;
|
||||
|
||||
import emu.grasscutter.scripts.constants.EventType;
|
||||
import emu.grasscutter.scripts.data.ScriptArgs;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
@@ -18,21 +17,16 @@ public final class SceneTimeAxis {
|
||||
private final int delay;
|
||||
private final boolean loop;
|
||||
|
||||
/**
|
||||
* Schedules the task to run.
|
||||
*/
|
||||
/** Schedules the task to run. */
|
||||
public void start() {
|
||||
if (this.loop) {
|
||||
this.timer.scheduleAtFixedRate(
|
||||
new Task(), this.delay, this.delay);
|
||||
this.timer.scheduleAtFixedRate(new Task(), this.delay, this.delay);
|
||||
} else {
|
||||
this.timer.schedule(new Task(), this.delay);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Terminates a repeating task.
|
||||
*/
|
||||
/** Terminates a repeating task. */
|
||||
public void stop() {
|
||||
this.timer.cancel();
|
||||
}
|
||||
@@ -41,10 +35,9 @@ public final class SceneTimeAxis {
|
||||
@Override
|
||||
public void run() {
|
||||
// Invoke script event.
|
||||
SceneTimeAxis.this.handle.callEvent(new ScriptArgs(
|
||||
SceneTimeAxis.this.groupId,
|
||||
EventType.EVENT_TIME_AXIS_PASS
|
||||
).setEventSource(SceneTimeAxis.this.identifier));
|
||||
SceneTimeAxis.this.handle.callEvent(
|
||||
new ScriptArgs(SceneTimeAxis.this.groupId, EventType.EVENT_TIME_AXIS_PASS)
|
||||
.setEventSource(SceneTimeAxis.this.identifier));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 java.lang.ref.SoftReference;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
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;
|
||||
|
||||
import javax.script.*;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ScriptLoader {
|
||||
private static ScriptEngineManager sm;
|
||||
@Getter private static ScriptEngine engine;
|
||||
@@ -110,8 +109,7 @@ public class ScriptLoader {
|
||||
public LuaValue call(LuaValue arg) {
|
||||
// Resolve the script path.
|
||||
var scriptName = arg.checkjstring();
|
||||
var scriptPath = FileUtils.getScriptPath(
|
||||
"Common/" + scriptName + ".lua");
|
||||
var scriptPath = FileUtils.getScriptPath("Common/" + scriptName + ".lua");
|
||||
|
||||
// Load & compile the script.
|
||||
var script = ScriptLoader.getScript(scriptPath.toString());
|
||||
@@ -124,8 +122,7 @@ public class ScriptLoader {
|
||||
script.eval();
|
||||
} catch (Exception exception) {
|
||||
Grasscutter.getLogger()
|
||||
.error("Loading script {} failed! - {}",
|
||||
scriptPath, exception.getLocalizedMessage());
|
||||
.error("Loading script {} failed! - {}", scriptPath, exception.getLocalizedMessage());
|
||||
}
|
||||
|
||||
// TODO: What is the proper return value?
|
||||
|
||||
Reference in New Issue
Block a user