Run formatter & bump version

This commit is contained in:
KingRainbow44 2023-08-14 18:53:23 -04:00
parent 543749bc9f
commit 8cac8d13f4
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
9 changed files with 53 additions and 70 deletions

View File

@ -39,6 +39,7 @@ spotless {
target fileTree(rootDir) { target fileTree(rootDir) {
include '**/*.java' include '**/*.java'
exclude '**/generated/**/*.*' exclude '**/generated/**/*.*'
exclude '.idea/**/*.*'
} }
importOrder('io.grasscutter', '', 'java', 'javax', '\\#java', '\\#') // Configure import order. importOrder('io.grasscutter', '', 'java', 'javax', '\\#java', '\\#') // Configure import order.
@ -57,7 +58,7 @@ sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17
group = 'io.grasscutter' group = 'io.grasscutter'
version = '1.6.3' version = '1.7.0'
java { java {
withJavadocJar() withJavadocJar()

View File

@ -1,15 +1,14 @@
package emu.grasscutter.command.commands; package emu.grasscutter.command.commands;
import static emu.grasscutter.utils.lang.Language.translate;
import emu.grasscutter.command.*; import emu.grasscutter.command.*;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.GameQuest; import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.game.quest.enums.*; import emu.grasscutter.game.quest.enums.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static emu.grasscutter.utils.lang.Language.translate;
@Command( @Command(
label = "quest", label = "quest",
aliases = {"q"}, aliases = {"q"},
@ -155,7 +154,8 @@ public final class QuestCommand implements CommandHandler {
case "list" -> { case "list" -> {
var questManager = targetPlayer.getQuestManager(); var questManager = targetPlayer.getQuestManager();
var mainQuests = questManager.getActiveMainQuests(); var mainQuests = questManager.getActiveMainQuests();
var allQuestIds = mainQuests.stream() var allQuestIds =
mainQuests.stream()
.filter(quest -> questManager.getLoggedQuests().contains(quest.getParentQuestId())) .filter(quest -> questManager.getLoggedQuests().contains(quest.getParentQuestId()))
.filter(quest -> quest.getState() != ParentQuestState.PARENT_QUEST_STATE_FINISHED) .filter(quest -> quest.getState() != ParentQuestState.PARENT_QUEST_STATE_FINISHED)
.map(quest -> quest.getChildQuests().values()) .map(quest -> quest.getChildQuests().values())
@ -165,9 +165,10 @@ public final class QuestCommand implements CommandHandler {
.map(String::valueOf) .map(String::valueOf)
.toList(); .toList();
CommandHandler.sendMessage(sender, "Quests: " + CommandHandler.sendMessage(
(allQuestIds.isEmpty() ? "(no active quests)" : sender,
String.join(", ", allQuestIds))); "Quests: "
+ (allQuestIds.isEmpty() ? "(no active quests)" : String.join(", ", allQuestIds)));
} }
default -> this.sendUsageMessage(sender); default -> this.sendUsageMessage(sender);
} }

View File

@ -3,9 +3,8 @@ package emu.grasscutter.data.binout;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.common.DynamicFloat; import emu.grasscutter.data.common.DynamicFloat;
import emu.grasscutter.game.props.ElementType; import emu.grasscutter.game.props.ElementType;
import lombok.ToString;
import java.io.Serializable; import java.io.Serializable;
import lombok.ToString;
public class AbilityModifier implements Serializable { public class AbilityModifier implements Serializable {
private static final long serialVersionUID = -2001232313615923575L; private static final long serialVersionUID = -2001232313615923575L;
@ -342,8 +341,10 @@ public class AbilityModifier implements Serializable {
public int param3; public int param3;
public LuaCallType luaCallType; public LuaCallType luaCallType;
@SerializedName("CallParamList") @SerializedName("CallParamList")
public int[] callParamList; public int[] callParamList;
public String funcName; public String funcName;
public String content; public String content;

View File

@ -10,9 +10,7 @@ import emu.grasscutter.game.entity.GameEntity;
public final class ActionDebugLog extends AbilityActionHandler { public final class ActionDebugLog extends AbilityActionHandler {
@Override @Override
public boolean execute( public boolean execute(
Ability ability, AbilityModifierAction action, Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
ByteString abilityData, GameEntity target
) {
Grasscutter.getLogger().debug("[Ability] DebugLog: {}", action.content); Grasscutter.getLogger().debug("[Ability] DebugLog: {}", action.content);
return true; return true;
} }

View File

@ -5,17 +5,14 @@ import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction; import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
import emu.grasscutter.game.ability.Ability; import emu.grasscutter.game.ability.Ability;
import emu.grasscutter.game.entity.GameEntity; import emu.grasscutter.game.entity.GameEntity;
import org.luaj.vm2.LuaFunction;
import javax.script.Bindings; import javax.script.Bindings;
import org.luaj.vm2.LuaFunction;
@AbilityAction(AbilityModifierAction.Type.ServerLuaCall) @AbilityAction(AbilityModifierAction.Type.ServerLuaCall)
public final class ActionServerLuaCall extends AbilityActionHandler { public final class ActionServerLuaCall extends AbilityActionHandler {
@Override @Override
public boolean execute( public boolean execute(
Ability ability, AbilityModifierAction action, Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
ByteString abilityData, GameEntity target
) {
var scene = target.getScene(); var scene = target.getScene();
var scriptManager = scene.getScriptManager(); var scriptManager = scene.getScriptManager();
var functionName = action.funcName; var functionName = action.funcName;
@ -58,8 +55,7 @@ public final class ActionServerLuaCall extends AbilityActionHandler {
return true; return true;
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger().warn("Unable to invoke {}.", Grasscutter.getLogger().warn("Unable to invoke {}.", functionName, exception);
functionName, exception);
return false; return false;
} }
} }

View File

@ -910,8 +910,7 @@ public final class Scene {
public int loadDynamicGroup(int group_id) { public int loadDynamicGroup(int group_id) {
SceneGroup group = getScriptManager().getGroupById(group_id); SceneGroup group = getScriptManager().getGroupById(group_id);
if (group == null) if (group == null) return -1; // Group not found
return -1; // Group not found
this.onLoadGroup(new ArrayList<>(List.of(group))); this.onLoadGroup(new ArrayList<>(List.of(group)));

View File

@ -1,5 +1,7 @@
package emu.grasscutter.scripts; 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.RTree;
import com.github.davidmoten.rtreemulti.geometry.Geometry; import com.github.davidmoten.rtreemulti.geometry.Geometry;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
@ -19,20 +21,17 @@ import emu.grasscutter.server.packet.send.PacketGroupSuiteNotify;
import emu.grasscutter.utils.*; import emu.grasscutter.utils.*;
import io.netty.util.concurrent.FastThreadLocalThread; import io.netty.util.concurrent.FastThreadLocalThread;
import it.unimi.dsi.fastutil.ints.*; 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.io.*;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.*;
import static emu.grasscutter.scripts.constants.EventType.EVENT_TIMER_EVENT; import kotlin.Pair;
import lombok.val;
import org.luaj.vm2.*;
import org.luaj.vm2.lib.jse.CoerceJavaToLua;
public class SceneScriptManager { public class SceneScriptManager {
private final Scene scene; private final Scene scene;
@ -40,8 +39,7 @@ public class SceneScriptManager {
private SceneMeta meta; private SceneMeta meta;
private boolean isInit; private boolean isInit;
private final Map<String, SceneTimeAxis> timeAxis private final Map<String, SceneTimeAxis> timeAxis = new ConcurrentHashMap<>();
= new ConcurrentHashMap<>();
/** current triggers controlled by RefreshGroup */ /** current triggers controlled by RefreshGroup */
private final Map<Integer, Set<SceneTrigger>> currentTriggers; private final Map<Integer, Set<SceneTrigger>> currentTriggers;
@ -1203,8 +1201,7 @@ public class SceneScriptManager {
} }
/** /**
* Registers a new time axis for this scene. * Registers a new time axis for this scene. Starts the time axis after.
* Starts the time axis after.
* *
* @param timeAxis The time axis. * @param timeAxis The time axis.
*/ */

View File

@ -2,9 +2,8 @@ package emu.grasscutter.scripts;
import emu.grasscutter.scripts.constants.EventType; import emu.grasscutter.scripts.constants.EventType;
import emu.grasscutter.scripts.data.ScriptArgs; import emu.grasscutter.scripts.data.ScriptArgs;
import lombok.*;
import java.util.*; import java.util.*;
import lombok.*;
@Getter @Getter
@RequiredArgsConstructor @RequiredArgsConstructor
@ -18,21 +17,16 @@ public final class SceneTimeAxis {
private final int delay; private final int delay;
private final boolean loop; private final boolean loop;
/** /** Schedules the task to run. */
* Schedules the task to run.
*/
public void start() { public void start() {
if (this.loop) { if (this.loop) {
this.timer.scheduleAtFixedRate( this.timer.scheduleAtFixedRate(new Task(), this.delay, this.delay);
new Task(), this.delay, this.delay);
} else { } else {
this.timer.schedule(new Task(), this.delay); this.timer.schedule(new Task(), this.delay);
} }
} }
/** /** Terminates a repeating task. */
* Terminates a repeating task.
*/
public void stop() { public void stop() {
this.timer.cancel(); this.timer.cancel();
} }
@ -41,10 +35,9 @@ public final class SceneTimeAxis {
@Override @Override
public void run() { public void run() {
// Invoke script event. // Invoke script event.
SceneTimeAxis.this.handle.callEvent(new ScriptArgs( SceneTimeAxis.this.handle.callEvent(
SceneTimeAxis.this.groupId, new ScriptArgs(SceneTimeAxis.this.groupId, EventType.EVENT_TIME_AXIS_PASS)
EventType.EVENT_TIME_AXIS_PASS .setEventSource(SceneTimeAxis.this.identifier));
).setEventSource(SceneTimeAxis.this.identifier));
} }
} }
} }

View File

@ -8,18 +8,17 @@ import emu.grasscutter.scripts.constants.*;
import emu.grasscutter.scripts.data.SceneMeta; import emu.grasscutter.scripts.data.SceneMeta;
import emu.grasscutter.scripts.serializer.*; import emu.grasscutter.scripts.serializer.*;
import emu.grasscutter.utils.FileUtils; 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 lombok.Getter;
import org.luaj.vm2.*; import org.luaj.vm2.*;
import org.luaj.vm2.lib.OneArgFunction; import org.luaj.vm2.lib.OneArgFunction;
import org.luaj.vm2.lib.jse.CoerceJavaToLua; import org.luaj.vm2.lib.jse.CoerceJavaToLua;
import org.luaj.vm2.script.LuajContext; 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 { public class ScriptLoader {
private static ScriptEngineManager sm; private static ScriptEngineManager sm;
@Getter private static ScriptEngine engine; @Getter private static ScriptEngine engine;
@ -110,8 +109,7 @@ public class ScriptLoader {
public LuaValue call(LuaValue arg) { public LuaValue call(LuaValue arg) {
// Resolve the script path. // Resolve the script path.
var scriptName = arg.checkjstring(); var scriptName = arg.checkjstring();
var scriptPath = FileUtils.getScriptPath( var scriptPath = FileUtils.getScriptPath("Common/" + scriptName + ".lua");
"Common/" + scriptName + ".lua");
// Load & compile the script. // Load & compile the script.
var script = ScriptLoader.getScript(scriptPath.toString()); var script = ScriptLoader.getScript(scriptPath.toString());
@ -124,8 +122,7 @@ public class ScriptLoader {
script.eval(); script.eval();
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Loading script {} failed! - {}", .error("Loading script {} failed! - {}", scriptPath, exception.getLocalizedMessage());
scriptPath, exception.getLocalizedMessage());
} }
// TODO: What is the proper return value? // TODO: What is the proper return value?