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) {
include '**/*.java'
exclude '**/generated/**/*.*'
exclude '.idea/**/*.*'
}
importOrder('io.grasscutter', '', 'java', 'javax', '\\#java', '\\#') // Configure import order.
@ -57,7 +58,7 @@ sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
group = 'io.grasscutter'
version = '1.6.3'
version = '1.7.0'
java {
withJavadocJar()

View File

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

View File

@ -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;
@ -342,8 +341,10 @@ public class AbilityModifier implements Serializable {
public int param3;
public LuaCallType luaCallType;
@SerializedName("CallParamList")
public int[] callParamList;
public String funcName;
public String content;

View File

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

View File

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

View File

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

View File

@ -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;
@ -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.
*/

View File

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

View File

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