mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-25 10:51:47 +00:00
Run formatter & bump version
This commit is contained in:
parent
543749bc9f
commit
8cac8d13f4
@ -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()
|
||||
|
@ -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,19 +154,21 @@ public final class QuestCommand implements CommandHandler {
|
||||
case "list" -> {
|
||||
var questManager = targetPlayer.getQuestManager();
|
||||
var mainQuests = questManager.getActiveMainQuests();
|
||||
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())
|
||||
.flatMap(Collection::stream)
|
||||
.filter(quest -> quest.getState() == QuestState.QUEST_STATE_UNFINISHED)
|
||||
.map(GameQuest::getSubQuestId)
|
||||
.map(String::valueOf)
|
||||
.toList();
|
||||
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())
|
||||
.flatMap(Collection::stream)
|
||||
.filter(quest -> quest.getState() == QuestState.QUEST_STATE_UNFINISHED)
|
||||
.map(GameQuest::getSubQuestId)
|
||||
.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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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)));
|
||||
|
||||
|
@ -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?
|
||||
|
Loading…
Reference in New Issue
Block a user