Format code [skip actions]

This commit is contained in:
github-actions 2023-06-01 02:30:23 +00:00
parent 8840e2b574
commit 9bd833c6e7
13 changed files with 57 additions and 63 deletions

View File

@ -1,5 +1,8 @@
package emu.grasscutter.data; 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.annotations.SerializedName;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
@ -19,10 +22,6 @@ import emu.grasscutter.scripts.*;
import emu.grasscutter.utils.*; import emu.grasscutter.utils.*;
import it.unimi.dsi.fastutil.Pair; import it.unimi.dsi.fastutil.Pair;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import lombok.*;
import org.reflections.Reflections;
import javax.script.*;
import java.io.*; import java.io.*;
import java.nio.file.*; import java.nio.file.*;
import java.util.*; import java.util.*;
@ -30,9 +29,9 @@ import java.util.Map.Entry;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.*; import java.util.stream.*;
import javax.script.*;
import static emu.grasscutter.utils.FileUtils.*; import lombok.*;
import static emu.grasscutter.utils.lang.Language.translate; import org.reflections.Reflections;
public final class ResourceLoader { public final class ResourceLoader {

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;

View File

@ -7,9 +7,8 @@ import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.proto.AbilityStringOuterClass.AbilityString; import emu.grasscutter.net.proto.AbilityStringOuterClass.AbilityString;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import it.unimi.dsi.fastutil.objects.*; import it.unimi.dsi.fastutil.objects.*;
import lombok.Getter;
import java.util.*; import java.util.*;
import lombok.Getter;
public class Ability { public class Ability {
@Getter private AbilityData data; @Getter private AbilityData data;
@ -56,7 +55,7 @@ public class Ability {
@Override @Override
public String toString() { public String toString() {
return "Ability Name: %s; Entity Owner: %s; Player Owner: %s".formatted( return "Ability Name: %s; Entity Owner: %s; Player Owner: %s"
data.abilityName, owner, playerOwner); .formatted(data.abilityName, owner, playerOwner);
} }
} }

View File

@ -17,11 +17,10 @@ import emu.grasscutter.net.proto.AbilityScalarTypeOuterClass.AbilityScalarType;
import emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry; import emu.grasscutter.net.proto.AbilityScalarValueEntryOuterClass.AbilityScalarValueEntry;
import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction; import emu.grasscutter.net.proto.ModifierActionOuterClass.ModifierAction;
import io.netty.util.concurrent.FastThreadLocalThread; import io.netty.util.concurrent.FastThreadLocalThread;
import lombok.Getter;
import org.reflections.Reflections;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.*; import java.util.concurrent.*;
import lombok.Getter;
import org.reflections.Reflections;
public final class AbilityManager extends BasePlayerManager { public final class AbilityManager extends BasePlayerManager {
@ -491,8 +490,9 @@ public final class AbilityManager extends BasePlayerManager {
if (!Float.isNaN(entry.getFloatValue())) if (!Float.isNaN(entry.getFloatValue()))
entity.getGlobalAbilityValues().put(key, entry.getFloatValue()); entity.getGlobalAbilityValues().put(key, entry.getFloatValue());
} }
case AbilityScalarType.ABILITY_SCALAR_TYPE_UINT_VALUE -> case AbilityScalarType.ABILITY_SCALAR_TYPE_UINT_VALUE -> entity
entity.getGlobalAbilityValues().put(key, (float) entry.getUintValue()); .getGlobalAbilityValues()
.put(key, (float) entry.getUintValue());
default -> { default -> {
return; return;
} }

View File

@ -9,9 +9,7 @@ import emu.grasscutter.game.entity.GameEntity;
public final class ActionAvatarSkillStart extends AbilityActionHandler { public final class ActionAvatarSkillStart 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
) {
return false; return false;
} }
} }

View File

@ -8,11 +8,10 @@ import emu.grasscutter.game.player.*;
import emu.grasscutter.game.props.*; import emu.grasscutter.game.props.*;
import emu.grasscutter.net.proto.ActivityInfoOuterClass; import emu.grasscutter.net.proto.ActivityInfoOuterClass;
import emu.grasscutter.server.packet.send.PacketActivityScheduleInfoNotify; import emu.grasscutter.server.packet.send.PacketActivityScheduleInfoNotify;
import lombok.Getter;
import org.reflections.Reflections;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import lombok.Getter;
import org.reflections.Reflections;
@Getter @Getter
public class ActivityManager extends BasePlayerManager { public class ActivityManager extends BasePlayerManager {

View File

@ -401,8 +401,7 @@ public class EntityAvatar extends GameEntity {
var count = this.getGlobalAbilityValues().get("_ABILITY_UziExplode_Count"); var count = this.getGlobalAbilityValues().get("_ABILITY_UziExplode_Count");
if (count == 2f) { if (count == 2f) {
this.getGlobalAbilityValues().remove("_ABILITY_UziExplode_Count"); this.getGlobalAbilityValues().remove("_ABILITY_UziExplode_Count");
this.getPlayer().getQuestManager() this.getPlayer().getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_SKILL, 10006);
.queueEvent(QuestContent.QUEST_CONTENT_SKILL, 10006);
} }
} }
} }

View File

@ -14,9 +14,8 @@ import emu.grasscutter.scripts.data.controller.EntityController;
import emu.grasscutter.server.event.entity.*; import emu.grasscutter.server.event.entity.*;
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import lombok.*;
import java.util.*; import java.util.*;
import lombok.*;
public abstract class GameEntity { public abstract class GameEntity {
@Getter private final Scene scene; @Getter private final Scene scene;
@ -256,9 +255,7 @@ public abstract class GameEntity {
} }
} }
/** /** Invoked when a global ability value is updated. */
* Invoked when a global ability value is updated.
*/
public void onAbilityValueUpdate() { public void onAbilityValueUpdate() {
// Does nothing. // Does nothing.
} }

View File

@ -1,5 +1,8 @@
package emu.grasscutter.game.player; package emu.grasscutter.game.player;
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
import static emu.grasscutter.scripts.constants.EventType.EVENT_UNLOCK_TRANS_POINT;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.binout.ScenePointEntry; import emu.grasscutter.data.binout.ScenePointEntry;
import emu.grasscutter.data.excels.OpenStateData; import emu.grasscutter.data.excels.OpenStateData;
@ -9,13 +12,9 @@ import emu.grasscutter.game.quest.enums.*;
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode; import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
import emu.grasscutter.scripts.data.ScriptArgs; import emu.grasscutter.scripts.data.ScriptArgs;
import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.packet.send.*;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
import static emu.grasscutter.scripts.constants.EventType.EVENT_UNLOCK_TRANS_POINT;
// @Entity // @Entity
public final class PlayerProgressManager extends BasePlayerDataManager { public final class PlayerProgressManager extends BasePlayerDataManager {
/****************************************************************************************************************** /******************************************************************************************************************
@ -30,12 +29,16 @@ public final class PlayerProgressManager extends BasePlayerDataManager {
48 // blacklist OPEN_STATE_LIMIT_REGION_GLOBAL to make Meledy happy. =D Remove this as 48 // blacklist OPEN_STATE_LIMIT_REGION_GLOBAL to make Meledy happy. =D Remove this as
// soon as quest unlocks are fully implemented. // soon as quest unlocks are fully implemented.
); );
public static final Set<Integer> IGNORED_OPEN_STATES = Set.of(
1404, // OPEN_STATE_MENGDE_INFUSEDCRYSTAL, causes quest 'Mine Craft' to be given to the player at the start of the game. public static final Set<Integer> IGNORED_OPEN_STATES =
// This should be removed when city reputation is implemented. Set.of(
57 // OPEN_STATE_PERSONAL_LINE, causes the prompt for showing character hangout quests to be permanently shown. 1404, // OPEN_STATE_MENGDE_INFUSEDCRYSTAL, causes quest 'Mine Craft' to be given to the
// This should be removed when character story quests are implemented. // player at the start of the game.
); // This should be removed when city reputation is implemented.
57 // OPEN_STATE_PERSONAL_LINE, causes the prompt for showing character hangout quests to
// be permanently shown.
// This should be removed when character story quests are implemented.
);
// Set of open states that are set per default for all accounts. Can be overwritten by an entry in // Set of open states that are set per default for all accounts. Can be overwritten by an entry in
// `map`. // `map`.
public static final Set<Integer> DEFAULT_OPEN_STATES = public static final Set<Integer> DEFAULT_OPEN_STATES =
@ -58,10 +61,10 @@ public final class PlayerProgressManager extends BasePlayerDataManager {
// working chat. // working chat.
|| s.getId() == 1) || s.getId() == 1)
.map(OpenStateData::getId) .map(OpenStateData::getId)
.filter(s -> !BLACKLIST_OPEN_STATES.contains(s)) // Filter out states in the blacklist.
.filter( .filter(
s -> s ->
!BLACKLIST_OPEN_STATES.contains(s)) // Filter out states in the blacklist. !IGNORED_OPEN_STATES.contains(s)) // Filter out states in the default ignore list.
.filter(s -> !IGNORED_OPEN_STATES.contains(s)) // Filter out states in the default ignore list.
.collect(Collectors.toSet()); .collect(Collectors.toSet());
public PlayerProgressManager(Player player) { public PlayerProgressManager(Player player) {

View File

@ -16,11 +16,10 @@ import emu.grasscutter.net.proto.ChildQuestOuterClass.ChildQuest;
import emu.grasscutter.net.proto.ParentQuestOuterClass.ParentQuest; import emu.grasscutter.net.proto.ParentQuestOuterClass.ParentQuest;
import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.packet.send.*;
import emu.grasscutter.utils.ConversionUtils; import emu.grasscutter.utils.ConversionUtils;
import lombok.*;
import org.bson.types.ObjectId;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.*;
import org.bson.types.ObjectId;
@Entity(value = "quests", useDiscriminator = false) @Entity(value = "quests", useDiscriminator = false)
public class GameMainQuest { public class GameMainQuest {
@ -495,7 +494,8 @@ public class GameMainQuest {
subQuestWithCond.getFinishProgressList()); subQuestWithCond.getFinishProgressList());
var questManager = this.getQuestManager(); var questManager = this.getQuestManager();
if (questManager != null && questManager.getLoggedQuests().contains(subQuestWithCond.getSubQuestId())) { if (questManager != null
&& questManager.getLoggedQuests().contains(subQuestWithCond.getSubQuestId())) {
Grasscutter.getLogger() Grasscutter.getLogger()
.debug( .debug(
">>> Quest {} will be {} as a result of content trigger {} ({}, {}).", ">>> Quest {} will be {} as a result of content trigger {} ({}, {}).",

View File

@ -15,10 +15,9 @@ import emu.grasscutter.scripts.data.SceneGroup;
import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.packet.send.*;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import it.unimi.dsi.fastutil.ints.IntIntImmutablePair; import it.unimi.dsi.fastutil.ints.IntIntImmutablePair;
import lombok.*;
import javax.script.Bindings;
import java.util.*; import java.util.*;
import javax.script.Bindings;
import lombok.*;
@Entity @Entity
public class GameQuest { public class GameQuest {
@ -326,8 +325,6 @@ public class GameQuest {
@Override @Override
public String toString() { public String toString() {
return "Main Quest: %s; Sub Quest: %s; State: %s" return "Main Quest: %s; Sub Quest: %s; State: %s"
.formatted(this.getMainQuestId(), .formatted(this.getMainQuestId(), this.getSubQuestId(), this.getState());
this.getSubQuestId(),
this.getState());
} }
} }

View File

@ -15,7 +15,6 @@ public final class PluginConfig {
*/ */
@SuppressWarnings("BooleanMethodIsAlwaysInverted") @SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean validate() { public boolean validate() {
return name != null && description != null && return name != null && description != null && mainClass != null && api != null;
mainClass != null && api != null;
} }
} }

View File

@ -1,18 +1,17 @@
package emu.grasscutter.plugin; package emu.grasscutter.plugin;
import static emu.grasscutter.utils.lang.Language.translate;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.server.event.*; import emu.grasscutter.server.event.*;
import emu.grasscutter.utils.*; import emu.grasscutter.utils.*;
import lombok.*;
import javax.annotation.Nullable;
import java.io.*; import java.io.*;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import java.util.jar.*; import java.util.jar.*;
import javax.annotation.Nullable;
import static emu.grasscutter.utils.lang.Language.translate; import lombok.*;
/** Manages the server's plugins and the event system. */ /** Manages the server's plugins and the event system. */
public final class PluginManager { public final class PluginManager {
@ -80,11 +79,17 @@ public final class PluginManager {
PluginConfig pluginConfig = JsonUtils.loadToClass(fileReader, PluginConfig.class); PluginConfig pluginConfig = JsonUtils.loadToClass(fileReader, PluginConfig.class);
// Check the plugin's API version. // Check the plugin's API version.
if (pluginConfig.api == null) { if (pluginConfig.api == null) {
Grasscutter.getLogger().warn(translate("plugin.invalid_api.not_present", plugin.getName())); Grasscutter.getLogger()
.warn(translate("plugin.invalid_api.not_present", plugin.getName()));
return; return;
} else if (pluginConfig.api != API_VERSION) { } else if (pluginConfig.api != API_VERSION) {
Grasscutter.getLogger().warn(translate("plugin.invalid_api.lower", Grasscutter.getLogger()
plugin.getName(), pluginConfig.api, API_VERSION)); .warn(
translate(
"plugin.invalid_api.lower",
plugin.getName(),
pluginConfig.api,
API_VERSION));
return; return;
} }