mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-02-13 15:32:54 +08:00
Lint code
This commit is contained in:
parent
bb6569b736
commit
e20c7c151b
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -4,3 +4,4 @@
|
|||||||
*.properties text=lf
|
*.properties text=lf
|
||||||
*.py text=lf
|
*.py text=lf
|
||||||
*.sh text=lf
|
*.sh text=lf
|
||||||
|
* text eol=lf
|
||||||
|
@ -8,11 +8,11 @@ import java.util.List;
|
|||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
label = "cutscene",
|
label = "cutscene",
|
||||||
aliases = {"c"},
|
aliases = {"c"},
|
||||||
usage = {"[<cutsceneId>]"},
|
usage = {"[<cutsceneId>]"},
|
||||||
permission = "player.group",
|
permission = "player.group",
|
||||||
permissionTargeted = "player.group.others")
|
permissionTargeted = "player.group.others")
|
||||||
public final class CutsceneCommand implements CommandHandler {
|
public final class CutsceneCommand implements CommandHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,11 +11,11 @@ import java.util.List;
|
|||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
label = "sound",
|
label = "sound",
|
||||||
aliases = {"s", "audio"},
|
aliases = {"s", "audio"},
|
||||||
usage = {"[<audioname>] [<x><y><z>]"},
|
usage = {"[<audioname>] [<x><y><z>]"},
|
||||||
permission = "player.group",
|
permission = "player.group",
|
||||||
permissionTargeted = "player.group.others")
|
permissionTargeted = "player.group.others")
|
||||||
public final class SoundCommand implements CommandHandler {
|
public final class SoundCommand implements CommandHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -42,7 +42,7 @@ public final class SoundCommand implements CommandHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
targetPlayer
|
targetPlayer
|
||||||
.getScene()
|
.getScene()
|
||||||
.broadcastPacket(new PacketScenePlayerSoundNotify(playPosition, soundName, 1));
|
.broadcastPacket(new PacketScenePlayerSoundNotify(playPosition, soundName, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ public class CompoundData extends GameResource {
|
|||||||
|
|
||||||
@SerializedName("groupID")
|
@SerializedName("groupID")
|
||||||
private int groupId;
|
private int groupId;
|
||||||
|
|
||||||
private int rankLevel;
|
private int rankLevel;
|
||||||
private boolean isDefaultUnlocked;
|
private boolean isDefaultUnlocked;
|
||||||
private int costTime;
|
private int costTime;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package emu.grasscutter.game.entity;
|
package emu.grasscutter.game.entity;
|
||||||
|
|
||||||
|
import static emu.grasscutter.scripts.constants.EventType.EVENT_SPECIFIC_GADGET_HP_CHANGE;
|
||||||
|
|
||||||
import emu.grasscutter.data.binout.config.ConfigEntityGadget;
|
import emu.grasscutter.data.binout.config.ConfigEntityGadget;
|
||||||
import emu.grasscutter.game.props.FightProperty;
|
import emu.grasscutter.game.props.FightProperty;
|
||||||
import emu.grasscutter.game.quest.enums.QuestContent;
|
import emu.grasscutter.game.quest.enums.QuestContent;
|
||||||
@ -9,8 +11,6 @@ import emu.grasscutter.server.event.entity.EntityDamageEvent;
|
|||||||
import emu.grasscutter.utils.Position;
|
import emu.grasscutter.utils.Position;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import static emu.grasscutter.scripts.constants.EventType.EVENT_SPECIFIC_GADGET_HP_CHANGE;
|
|
||||||
|
|
||||||
public abstract class EntityBaseGadget extends GameEntity {
|
public abstract class EntityBaseGadget extends GameEntity {
|
||||||
@Getter(onMethod_ = @Override)
|
@Getter(onMethod_ = @Override)
|
||||||
protected final Position position;
|
protected final Position position;
|
||||||
|
@ -2,11 +2,10 @@ package emu.grasscutter.game.inventory;
|
|||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public enum EquipType {
|
public enum EquipType {
|
||||||
EQUIP_NONE(0),
|
EQUIP_NONE(0),
|
||||||
|
@ -2,11 +2,10 @@ package emu.grasscutter.game.inventory;
|
|||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public enum ItemQuality {
|
public enum ItemQuality {
|
||||||
QUALITY_NONE(0),
|
QUALITY_NONE(0),
|
||||||
|
@ -2,11 +2,10 @@ package emu.grasscutter.game.inventory;
|
|||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public enum ItemType {
|
public enum ItemType {
|
||||||
ITEM_NONE(0),
|
ITEM_NONE(0),
|
||||||
|
@ -2,11 +2,10 @@ package emu.grasscutter.game.inventory;
|
|||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public enum MaterialType {
|
public enum MaterialType {
|
||||||
MATERIAL_NONE(0),
|
MATERIAL_NONE(0),
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package emu.grasscutter.game.player;
|
package emu.grasscutter.game.player;
|
||||||
|
|
||||||
|
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;
|
||||||
@ -15,8 +17,6 @@ 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.scripts.constants.EventType.EVENT_UNLOCK_TRANS_POINT;
|
|
||||||
|
|
||||||
// @Entity
|
// @Entity
|
||||||
public final class PlayerProgressManager extends BasePlayerDataManager {
|
public final class PlayerProgressManager extends BasePlayerDataManager {
|
||||||
/******************************************************************************************************************
|
/******************************************************************************************************************
|
||||||
|
@ -23,12 +23,11 @@ import emu.grasscutter.server.packet.send.PacketFinishedParentQuestUpdateNotify;
|
|||||||
import emu.grasscutter.server.packet.send.PacketQuestProgressUpdateNotify;
|
import emu.grasscutter.server.packet.send.PacketQuestProgressUpdateNotify;
|
||||||
import emu.grasscutter.utils.ConversionUtils;
|
import emu.grasscutter.utils.ConversionUtils;
|
||||||
import emu.grasscutter.utils.Position;
|
import emu.grasscutter.utils.Position;
|
||||||
|
import java.util.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.bson.types.ObjectId;
|
import org.bson.types.ObjectId;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Entity(value = "quests", useDiscriminator = false)
|
@Entity(value = "quests", useDiscriminator = false)
|
||||||
public class GameMainQuest {
|
public class GameMainQuest {
|
||||||
@Id private ObjectId id;
|
@Id private ObjectId id;
|
||||||
@ -39,14 +38,14 @@ public class GameMainQuest {
|
|||||||
@Getter private int parentQuestId;
|
@Getter private int parentQuestId;
|
||||||
@Getter private int[] questVars;
|
@Getter private int[] questVars;
|
||||||
@Getter private long[] timeVar;
|
@Getter private long[] timeVar;
|
||||||
//QuestUpdateQuestVarReq is sent in two stages...
|
// QuestUpdateQuestVarReq is sent in two stages...
|
||||||
private List<Integer> questVarsUpdate;
|
private List<Integer> questVarsUpdate;
|
||||||
@Getter private ParentQuestState state;
|
@Getter private ParentQuestState state;
|
||||||
@Getter private boolean isFinished;
|
@Getter private boolean isFinished;
|
||||||
@Getter List<QuestGroupSuite> questGroupSuites;
|
@Getter List<QuestGroupSuite> questGroupSuites;
|
||||||
|
|
||||||
@Getter int[] suggestTrackMainQuestList;
|
@Getter int[] suggestTrackMainQuestList;
|
||||||
@Getter private Map<Integer,TalkData> talks;
|
@Getter private Map<Integer, TalkData> talks;
|
||||||
|
|
||||||
@Deprecated // Morphia only. Do not use.
|
@Deprecated // Morphia only. Do not use.
|
||||||
public GameMainQuest() {}
|
public GameMainQuest() {}
|
||||||
@ -58,33 +57,37 @@ public class GameMainQuest {
|
|||||||
this.parentQuestId = parentQuestId;
|
this.parentQuestId = parentQuestId;
|
||||||
this.childQuests = new HashMap<>();
|
this.childQuests = new HashMap<>();
|
||||||
this.talks = new HashMap<>();
|
this.talks = new HashMap<>();
|
||||||
//official server always has a list of 5 questVars, with default value 0
|
// official server always has a list of 5 questVars, with default value 0
|
||||||
this.questVars = new int[] {0,0,0,0,0};
|
this.questVars = new int[] {0, 0, 0, 0, 0};
|
||||||
this.timeVar = new long[] {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; // theoretically max is 10 here
|
this.timeVar =
|
||||||
|
new long[] {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; // theoretically max is 10 here
|
||||||
this.state = ParentQuestState.PARENT_QUEST_STATE_NONE;
|
this.state = ParentQuestState.PARENT_QUEST_STATE_NONE;
|
||||||
this.questGroupSuites = new ArrayList<>();
|
this.questGroupSuites = new ArrayList<>();
|
||||||
addAllChildQuests();
|
addAllChildQuests();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getQuestVarsUpdate() {
|
public List<Integer> getQuestVarsUpdate() {
|
||||||
if(questVarsUpdate == null){
|
if (questVarsUpdate == null) {
|
||||||
questVarsUpdate = new ArrayList<>();
|
questVarsUpdate = new ArrayList<>();
|
||||||
}
|
}
|
||||||
return questVarsUpdate;
|
return questVarsUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAllChildQuests() {
|
private void addAllChildQuests() {
|
||||||
List<Integer> subQuestIds = Arrays.stream(GameData.getMainQuestDataMap().get(this.parentQuestId).getSubQuests()).map(SubQuestData::getSubId).toList();
|
List<Integer> subQuestIds =
|
||||||
|
Arrays.stream(GameData.getMainQuestDataMap().get(this.parentQuestId).getSubQuests())
|
||||||
|
.map(SubQuestData::getSubId)
|
||||||
|
.toList();
|
||||||
for (Integer subQuestId : subQuestIds) {
|
for (Integer subQuestId : subQuestIds) {
|
||||||
QuestData questConfig = GameData.getQuestDataMap().get(subQuestId);
|
QuestData questConfig = GameData.getQuestDataMap().get(subQuestId);
|
||||||
this.childQuests.put(subQuestId, new GameQuest(this, questConfig));
|
this.childQuests.put(subQuestId, new GameQuest(this, questConfig));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<GameQuest> getActiveQuests(){
|
public Collection<GameQuest> getActiveQuests() {
|
||||||
return childQuests.values().stream()
|
return childQuests.values().stream()
|
||||||
.filter(q->q.getState().getValue() == QuestState.QUEST_STATE_UNFINISHED.getValue())
|
.filter(q -> q.getState().getValue() == QuestState.QUEST_STATE_UNFINISHED.getValue())
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOwner(Player player) {
|
public void setOwner(Player player) {
|
||||||
@ -95,30 +98,39 @@ public class GameMainQuest {
|
|||||||
public int getQuestVar(int i) {
|
public int getQuestVar(int i) {
|
||||||
return questVars[i];
|
return questVars[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setQuestVar(int i, int value) {
|
public void setQuestVar(int i, int value) {
|
||||||
int previousValue = this.questVars[i];
|
int previousValue = this.questVars[i];
|
||||||
this.questVars[i] = value;
|
this.questVars[i] = value;
|
||||||
Grasscutter.getLogger().debug("questVar {} value changed from {} to {}", i, previousValue, value);
|
Grasscutter.getLogger()
|
||||||
|
.debug("questVar {} value changed from {} to {}", i, previousValue, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incQuestVar(int i, int inc) {
|
public void incQuestVar(int i, int inc) {
|
||||||
int previousValue = this.questVars[i];
|
int previousValue = this.questVars[i];
|
||||||
this.questVars[i] += inc;
|
this.questVars[i] += inc;
|
||||||
Grasscutter.getLogger().debug("questVar {} value incremented from {} to {}", i, previousValue, previousValue + inc);
|
Grasscutter.getLogger()
|
||||||
|
.debug(
|
||||||
|
"questVar {} value incremented from {} to {}", i, previousValue, previousValue + inc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decQuestVar(int i, int dec) {
|
public void decQuestVar(int i, int dec) {
|
||||||
int previousValue = this.questVars[i];
|
int previousValue = this.questVars[i];
|
||||||
this.questVars[i] -= dec;
|
this.questVars[i] -= dec;
|
||||||
Grasscutter.getLogger().debug("questVar {} value decremented from {} to {}", i, previousValue, previousValue - dec);
|
Grasscutter.getLogger()
|
||||||
|
.debug(
|
||||||
|
"questVar {} value decremented from {} to {}", i, previousValue, previousValue - dec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public GameQuest getChildQuestById(int id) {
|
public GameQuest getChildQuestById(int id) {
|
||||||
return this.getChildQuests().get(id);
|
return this.getChildQuests().get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameQuest getChildQuestByOrder(int order) {
|
public GameQuest getChildQuestByOrder(int order) {
|
||||||
return this.getChildQuests().values().stream().filter(p -> p.getQuestData().getOrder() == order).toList().get(0);
|
return this.getChildQuests().values().stream()
|
||||||
|
.filter(p -> p.getQuestData().getOrder() == order)
|
||||||
|
.toList()
|
||||||
|
.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finish() {
|
public void finish() {
|
||||||
@ -132,25 +144,22 @@ public class GameMainQuest {
|
|||||||
this.isFinished = true;
|
this.isFinished = true;
|
||||||
this.state = ParentQuestState.PARENT_QUEST_STATE_FINISHED;
|
this.state = ParentQuestState.PARENT_QUEST_STATE_FINISHED;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
We also need to check for unfinished childQuests in this MainQuest
|
We also need to check for unfinished childQuests in this MainQuest
|
||||||
force them to complete and send a packet about this to the user,
|
force them to complete and send a packet about this to the user,
|
||||||
because at some points there are special "invisible" child quests that control
|
because at some points there are special "invisible" child quests that control
|
||||||
some situations.
|
some situations.
|
||||||
|
|
||||||
For example, subQuest 35312 is responsible for the event of leaving the territory
|
For example, subQuest 35312 is responsible for the event of leaving the territory
|
||||||
of the island with a statue and automatically returns the character back,
|
of the island with a statue and automatically returns the character back,
|
||||||
quest 35311 completes the main quest line 353 and starts 35501 from
|
quest 35311 completes the main quest line 353 and starts 35501 from
|
||||||
new MainQuest 355 but if 35312 is not completed after the completion
|
new MainQuest 355 but if 35312 is not completed after the completion
|
||||||
of the main quest 353 - the character will not be able to leave place
|
of the main quest 353 - the character will not be able to leave place
|
||||||
(return again and again)
|
(return again and again)
|
||||||
*/
|
*/
|
||||||
this
|
this.getChildQuests().values().stream()
|
||||||
.getChildQuests()
|
.filter(p -> p.state != QuestState.QUEST_STATE_FINISHED)
|
||||||
.values()
|
.forEach(GameQuest::finish);
|
||||||
.stream()
|
|
||||||
.filter(p -> p.state != QuestState.QUEST_STATE_FINISHED)
|
|
||||||
.forEach(GameQuest::finish);
|
|
||||||
|
|
||||||
this.getOwner().getSession().send(new PacketFinishedParentQuestUpdateNotify(this));
|
this.getOwner().getSession().send(new PacketFinishedParentQuestUpdateNotify(this));
|
||||||
this.getOwner().getSession().send(new PacketCodexDataUpdateNotify(this));
|
this.getOwner().getSession().send(new PacketCodexDataUpdateNotify(this));
|
||||||
@ -159,7 +168,7 @@ public class GameMainQuest {
|
|||||||
|
|
||||||
// Add rewards
|
// Add rewards
|
||||||
MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(this.getParentQuestId());
|
MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(this.getParentQuestId());
|
||||||
if(mainQuestData.getRewardIdList()!=null) {
|
if (mainQuestData.getRewardIdList() != null) {
|
||||||
for (int rewardId : mainQuestData.getRewardIdList()) {
|
for (int rewardId : mainQuestData.getRewardIdList()) {
|
||||||
RewardData rewardData = GameData.getRewardDataMap().get(rewardId);
|
RewardData rewardData = GameData.getRewardDataMap().get(rewardId);
|
||||||
|
|
||||||
@ -167,7 +176,9 @@ public class GameMainQuest {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
getOwner().getInventory().addItemParamDatas(rewardData.getRewardItemList(), ActionReason.QuestReward);
|
getOwner()
|
||||||
|
.getInventory()
|
||||||
|
.addItemParamDatas(rewardData.getRewardItemList(), ActionReason.QuestReward);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,13 +188,13 @@ public class GameMainQuest {
|
|||||||
// .forEach(getQuestManager()::startMainQuest);
|
// .forEach(getQuestManager()::startMainQuest);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
//TODO
|
// TODO
|
||||||
public void fail() {}
|
public void fail() {}
|
||||||
|
|
||||||
public void cancel() {}
|
public void cancel() {}
|
||||||
|
|
||||||
|
public List<Position> rewindTo(GameQuest targetQuest, boolean notifyDelete) {
|
||||||
public List<Position> rewindTo(GameQuest targetQuest, boolean notifyDelete){
|
if (targetQuest == null || !targetQuest.rewind(notifyDelete)) {
|
||||||
if(targetQuest == null || !targetQuest.rewind(notifyDelete)){
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,13 +203,19 @@ public class GameMainQuest {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
List<Position> posAndRot = new ArrayList<>();
|
List<Position> posAndRot = new ArrayList<>();
|
||||||
if(hasRewindPosition(targetQuest.getSubQuestId(), posAndRot)){
|
if (hasRewindPosition(targetQuest.getSubQuestId(), posAndRot)) {
|
||||||
return posAndRot;
|
return posAndRot;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<GameQuest> rewindQuests = getChildQuests().values().stream()
|
List<GameQuest> rewindQuests =
|
||||||
.filter(p -> (p.getState() == QuestState.QUEST_STATE_UNFINISHED || p.getState() == QuestState.QUEST_STATE_FINISHED) &&
|
getChildQuests().values().stream()
|
||||||
p.getQuestData() != null && p.getQuestData().isRewind()).toList();
|
.filter(
|
||||||
|
p ->
|
||||||
|
(p.getState() == QuestState.QUEST_STATE_UNFINISHED
|
||||||
|
|| p.getState() == QuestState.QUEST_STATE_FINISHED)
|
||||||
|
&& p.getQuestData() != null
|
||||||
|
&& p.getQuestData().isRewind())
|
||||||
|
.toList();
|
||||||
|
|
||||||
for (GameQuest quest : rewindQuests) {
|
for (GameQuest quest : rewindQuests) {
|
||||||
if (hasRewindPosition(quest.getSubQuestId(), posAndRot)) {
|
if (hasRewindPosition(quest.getSubQuestId(), posAndRot)) {
|
||||||
@ -209,41 +226,49 @@ public class GameMainQuest {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rewinds to the last finished/unfinished rewind quest, and returns the avatar rewind position (if it exists)
|
// Rewinds to the last finished/unfinished rewind quest, and returns the avatar rewind position
|
||||||
|
// (if it exists)
|
||||||
public List<Position> rewind() {
|
public List<Position> rewind() {
|
||||||
if (this.questManager == null) {
|
if (this.questManager == null) {
|
||||||
this.questManager = getOwner().getQuestManager();
|
this.questManager = getOwner().getQuestManager();
|
||||||
}
|
}
|
||||||
var activeQuests = getActiveQuests();
|
var activeQuests = getActiveQuests();
|
||||||
var highestActiveQuest = activeQuests.stream()
|
var highestActiveQuest =
|
||||||
.filter(q -> q.getQuestData() != null)
|
activeQuests.stream()
|
||||||
.max(Comparator.comparing(q -> q.getQuestData().getOrder()))
|
.filter(q -> q.getQuestData() != null)
|
||||||
.orElse(null);
|
.max(Comparator.comparing(q -> q.getQuestData().getOrder()))
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
if (highestActiveQuest == null) {
|
if (highestActiveQuest == null) {
|
||||||
var firstUnstarted = getChildQuests().values().stream()
|
var firstUnstarted =
|
||||||
.filter(q -> q.getQuestData() != null && q.getState().getValue() != QuestState.FINISHED.getValue())
|
getChildQuests().values().stream()
|
||||||
.min(Comparator.comparingInt(a -> a.getQuestData().getOrder()));
|
.filter(
|
||||||
if(firstUnstarted.isEmpty()){
|
q ->
|
||||||
// all quests are probably finished, do don't rewind and maybe also set the mainquest to finished?
|
q.getQuestData() != null
|
||||||
|
&& q.getState().getValue() != QuestState.FINISHED.getValue())
|
||||||
|
.min(Comparator.comparingInt(a -> a.getQuestData().getOrder()));
|
||||||
|
if (firstUnstarted.isEmpty()) {
|
||||||
|
// all quests are probably finished, do don't rewind and maybe also set the mainquest to
|
||||||
|
// finished?
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
highestActiveQuest = firstUnstarted.get();
|
highestActiveQuest = firstUnstarted.get();
|
||||||
//todo maybe try to accept quests if there is no active quest and no rewind target?
|
// todo maybe try to accept quests if there is no active quest and no rewind target?
|
||||||
//tryAcceptSubQuests(QuestTrigger.QUEST_COND_NONE, "", 0);
|
// tryAcceptSubQuests(QuestTrigger.QUEST_COND_NONE, "", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
var highestOrder = highestActiveQuest.getQuestData().getOrder();
|
var highestOrder = highestActiveQuest.getQuestData().getOrder();
|
||||||
var rewindTarget = getChildQuests().values().stream()
|
var rewindTarget =
|
||||||
.filter(q -> q.getQuestData() != null)
|
getChildQuests().values().stream()
|
||||||
.filter(q -> q.getQuestData().isRewind() && q.getQuestData().getOrder() <= highestOrder)
|
.filter(q -> q.getQuestData() != null)
|
||||||
.max(Comparator.comparingInt(a -> a.getQuestData().getOrder()))
|
.filter(q -> q.getQuestData().isRewind() && q.getQuestData().getOrder() <= highestOrder)
|
||||||
.orElse(null);
|
.max(Comparator.comparingInt(a -> a.getQuestData().getOrder()))
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
return rewindTo(rewindTarget!=null? rewindTarget : highestActiveQuest, false);
|
return rewindTo(rewindTarget != null ? rewindTarget : highestActiveQuest, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasRewindPosition(int subId, List<Position> posAndRot){
|
public boolean hasRewindPosition(int subId, List<Position> posAndRot) {
|
||||||
RewindData questRewind = GameData.getRewindDataMap().get(subId);
|
RewindData questRewind = GameData.getRewindDataMap().get(subId);
|
||||||
if (questRewind == null) return false;
|
if (questRewind == null) return false;
|
||||||
|
|
||||||
@ -255,10 +280,12 @@ public class GameMainQuest {
|
|||||||
if (guide == null) return false;
|
if (guide == null) return false;
|
||||||
|
|
||||||
int sceneId = guide.getGuideScene();
|
int sceneId = guide.getGuideScene();
|
||||||
ScriptSceneData fullGlobals = GameData.getScriptSceneDataMap().get("flat.luas.scenes.full_globals.lua.json");
|
ScriptSceneData fullGlobals =
|
||||||
|
GameData.getScriptSceneDataMap().get("flat.luas.scenes.full_globals.lua.json");
|
||||||
if (fullGlobals == null) return false;
|
if (fullGlobals == null) return false;
|
||||||
|
|
||||||
ScriptSceneData.ScriptObject dummyPointScript = fullGlobals.getScriptObjectList().get(sceneId + "/scene" + sceneId + "_dummy_points.lua");
|
ScriptSceneData.ScriptObject dummyPointScript =
|
||||||
|
fullGlobals.getScriptObjectList().get(sceneId + "/scene" + sceneId + "_dummy_points.lua");
|
||||||
if (dummyPointScript == null) return false;
|
if (dummyPointScript == null) return false;
|
||||||
|
|
||||||
Map<String, List<Float>> dummyPointMap = dummyPointScript.getDummyPoints();
|
Map<String, List<Float>> dummyPointMap = dummyPointScript.getDummyPoints();
|
||||||
@ -268,25 +295,32 @@ public class GameMainQuest {
|
|||||||
List<Float> avatarPosRot = dummyPointMap.get(avatarPos + ".rot");
|
List<Float> avatarPosRot = dummyPointMap.get(avatarPos + ".rot");
|
||||||
if (avatarPosPos == null) return false;
|
if (avatarPosPos == null) return false;
|
||||||
|
|
||||||
posAndRot.add(0, new Position(avatarPosPos.get(0),avatarPosPos.get(1),avatarPosPos.get(2))); // position
|
posAndRot.add(
|
||||||
posAndRot.add(1, new Position(avatarPosRot.get(0),avatarPosRot.get(1),avatarPosRot.get(2))); //rotation
|
0, new Position(avatarPosPos.get(0), avatarPosPos.get(1), avatarPosPos.get(2))); // position
|
||||||
|
posAndRot.add(
|
||||||
|
1, new Position(avatarPosRot.get(0), avatarPosRot.get(1), avatarPosRot.get(2))); // rotation
|
||||||
Grasscutter.getLogger().info("Succesfully loaded rewind data for subQuest {}", subId);
|
Grasscutter.getLogger().info("Succesfully loaded rewind data for subQuest {}", subId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTeleportPostion(int subId, List<Position> posAndRot){
|
public boolean hasTeleportPostion(int subId, List<Position> posAndRot) {
|
||||||
TeleportData questTransmit = GameData.getTeleportDataMap().get(subId);
|
TeleportData questTransmit = GameData.getTeleportDataMap().get(subId);
|
||||||
if (questTransmit == null) return false;
|
if (questTransmit == null) return false;
|
||||||
|
|
||||||
TeleportData.TransmitPoint transmitPoint = questTransmit.getTransmit_points().size() > 0 ? questTransmit.getTransmit_points().get(0) : null;
|
TeleportData.TransmitPoint transmitPoint =
|
||||||
|
questTransmit.getTransmit_points().size() > 0
|
||||||
|
? questTransmit.getTransmit_points().get(0)
|
||||||
|
: null;
|
||||||
if (transmitPoint == null) return false;
|
if (transmitPoint == null) return false;
|
||||||
|
|
||||||
String transmitPos = transmitPoint.getPos();
|
String transmitPos = transmitPoint.getPos();
|
||||||
int sceneId = transmitPoint.getScene_id();
|
int sceneId = transmitPoint.getScene_id();
|
||||||
ScriptSceneData fullGlobals = GameData.getScriptSceneDataMap().get("flat.luas.scenes.full_globals.lua.json");
|
ScriptSceneData fullGlobals =
|
||||||
|
GameData.getScriptSceneDataMap().get("flat.luas.scenes.full_globals.lua.json");
|
||||||
if (fullGlobals == null) return false;
|
if (fullGlobals == null) return false;
|
||||||
|
|
||||||
ScriptSceneData.ScriptObject dummyPointScript = fullGlobals.getScriptObjectList().get(sceneId + "/scene" + sceneId + "_dummy_points.lua");
|
ScriptSceneData.ScriptObject dummyPointScript =
|
||||||
|
fullGlobals.getScriptObjectList().get(sceneId + "/scene" + sceneId + "_dummy_points.lua");
|
||||||
if (dummyPointScript == null) return false;
|
if (dummyPointScript == null) return false;
|
||||||
|
|
||||||
Map<String, List<Float>> dummyPointMap = dummyPointScript.getDummyPoints();
|
Map<String, List<Float>> dummyPointMap = dummyPointScript.getDummyPoints();
|
||||||
@ -296,15 +330,21 @@ public class GameMainQuest {
|
|||||||
List<Float> transmitPosRot = dummyPointMap.get(transmitPos + ".rot");
|
List<Float> transmitPosRot = dummyPointMap.get(transmitPos + ".rot");
|
||||||
if (transmitPosPos == null) return false;
|
if (transmitPosPos == null) return false;
|
||||||
|
|
||||||
posAndRot.add(0, new Position(transmitPosPos.get(0), transmitPosPos.get(1), transmitPosPos.get(2))); // position
|
posAndRot.add(
|
||||||
posAndRot.add(1, new Position(transmitPosRot.get(0), transmitPosRot.get(1), transmitPosRot.get(2))); // rotation
|
0,
|
||||||
|
new Position(
|
||||||
|
transmitPosPos.get(0), transmitPosPos.get(1), transmitPosPos.get(2))); // position
|
||||||
|
posAndRot.add(
|
||||||
|
1,
|
||||||
|
new Position(
|
||||||
|
transmitPosRot.get(0), transmitPosRot.get(1), transmitPosRot.get(2))); // rotation
|
||||||
Grasscutter.getLogger().info("Succesfully loaded teleport data for subQuest {}", subId);
|
Grasscutter.getLogger().info("Succesfully loaded teleport data for subQuest {}", subId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkProgress(){
|
public void checkProgress() {
|
||||||
for (var quest : getChildQuests().values()){
|
for (var quest : getChildQuests().values()) {
|
||||||
if(quest.getState() == QuestState.QUEST_STATE_UNFINISHED) {
|
if (quest.getState() == QuestState.QUEST_STATE_UNFINISHED) {
|
||||||
questManager.checkQuestAlreadyFullfilled(quest);
|
questManager.checkQuestAlreadyFullfilled(quest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -312,10 +352,19 @@ public class GameMainQuest {
|
|||||||
|
|
||||||
public void tryAcceptSubQuests(QuestCond condType, String paramStr, int... params) {
|
public void tryAcceptSubQuests(QuestCond condType, String paramStr, int... params) {
|
||||||
try {
|
try {
|
||||||
List<GameQuest> subQuestsWithCond = getChildQuests().values().stream()
|
List<GameQuest> subQuestsWithCond =
|
||||||
.filter(p -> p.getState() == QuestState.QUEST_STATE_UNSTARTED || p.getState() == QuestState.UNFINISHED)
|
getChildQuests().values().stream()
|
||||||
.filter(p -> p.getQuestData().getAcceptCond().stream().anyMatch(q -> condType == QuestCond.QUEST_COND_NONE || q.getType() == condType))
|
.filter(
|
||||||
.toList();
|
p ->
|
||||||
|
p.getState() == QuestState.QUEST_STATE_UNSTARTED
|
||||||
|
|| p.getState() == QuestState.UNFINISHED)
|
||||||
|
.filter(
|
||||||
|
p ->
|
||||||
|
p.getQuestData().getAcceptCond().stream()
|
||||||
|
.anyMatch(
|
||||||
|
q ->
|
||||||
|
condType == QuestCond.QUEST_COND_NONE || q.getType() == condType))
|
||||||
|
.toList();
|
||||||
var questSystem = owner.getServer().getQuestSystem();
|
var questSystem = owner.getServer().getQuestSystem();
|
||||||
|
|
||||||
for (GameQuest subQuestWithCond : subQuestsWithCond) {
|
for (GameQuest subQuestWithCond : subQuestsWithCond) {
|
||||||
@ -324,28 +373,33 @@ public class GameMainQuest {
|
|||||||
|
|
||||||
for (int i = 0; i < subQuestWithCond.getQuestData().getAcceptCond().size(); i++) {
|
for (int i = 0; i < subQuestWithCond.getQuestData().getAcceptCond().size(); i++) {
|
||||||
var condition = acceptCond.get(i);
|
var condition = acceptCond.get(i);
|
||||||
boolean result = questSystem.triggerCondition(getOwner(), subQuestWithCond.getQuestData(), condition, paramStr, params);
|
boolean result =
|
||||||
|
questSystem.triggerCondition(
|
||||||
|
getOwner(), subQuestWithCond.getQuestData(), condition, paramStr, params);
|
||||||
accept[i] = result ? 1 : 0;
|
accept[i] = result ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean shouldAccept = LogicType.calculate(subQuestWithCond.getQuestData().getAcceptCondComb(), accept);
|
boolean shouldAccept =
|
||||||
|
LogicType.calculate(subQuestWithCond.getQuestData().getAcceptCondComb(), accept);
|
||||||
|
|
||||||
if (shouldAccept)
|
if (shouldAccept) subQuestWithCond.start();
|
||||||
subQuestWithCond.start();
|
|
||||||
}
|
}
|
||||||
this.save();
|
this.save();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Grasscutter.getLogger().error("An error occurred while trying to accept quest.", e);
|
Grasscutter.getLogger().error("An error occurred while trying to accept quest.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tryFailSubQuests(QuestContent condType, String paramStr, int... params) {
|
public void tryFailSubQuests(QuestContent condType, String paramStr, int... params) {
|
||||||
try {
|
try {
|
||||||
List<GameQuest> subQuestsWithCond = getChildQuests().values().stream()
|
List<GameQuest> subQuestsWithCond =
|
||||||
.filter(p -> p.getState() == QuestState.QUEST_STATE_UNFINISHED)
|
getChildQuests().values().stream()
|
||||||
.filter(p -> p.getQuestData().getFailCond().stream().anyMatch(q -> q.getType() == condType))
|
.filter(p -> p.getState() == QuestState.QUEST_STATE_UNFINISHED)
|
||||||
.toList();
|
.filter(
|
||||||
|
p ->
|
||||||
|
p.getQuestData().getFailCond().stream()
|
||||||
|
.anyMatch(q -> q.getType() == condType))
|
||||||
|
.toList();
|
||||||
|
|
||||||
for (GameQuest subQuestWithCond : subQuestsWithCond) {
|
for (GameQuest subQuestWithCond : subQuestsWithCond) {
|
||||||
val failCond = subQuestWithCond.getQuestData().getFailCond();
|
val failCond = subQuestWithCond.getQuestData().getFailCond();
|
||||||
@ -353,7 +407,11 @@ public class GameMainQuest {
|
|||||||
for (int i = 0; i < subQuestWithCond.getQuestData().getFailCond().size(); i++) {
|
for (int i = 0; i < subQuestWithCond.getQuestData().getFailCond().size(); i++) {
|
||||||
val condition = failCond.get(i);
|
val condition = failCond.get(i);
|
||||||
if (condition.getType() == condType) {
|
if (condition.getType() == condType) {
|
||||||
boolean result = this.getOwner().getServer().getQuestSystem().triggerContent(subQuestWithCond, condition, paramStr, params);
|
boolean result =
|
||||||
|
this.getOwner()
|
||||||
|
.getServer()
|
||||||
|
.getQuestSystem()
|
||||||
|
.triggerContent(subQuestWithCond, condition, paramStr, params);
|
||||||
subQuestWithCond.getFailProgressList()[i] = result ? 1 : 0;
|
subQuestWithCond.getFailProgressList()[i] = result ? 1 : 0;
|
||||||
if (result) {
|
if (result) {
|
||||||
getOwner().getSession().send(new PacketQuestProgressUpdateNotify(subQuestWithCond));
|
getOwner().getSession().send(new PacketQuestProgressUpdateNotify(subQuestWithCond));
|
||||||
@ -361,10 +419,12 @@ public class GameMainQuest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean shouldFail = LogicType.calculate(subQuestWithCond.getQuestData().getFailCondComb(), subQuestWithCond.getFailProgressList());
|
boolean shouldFail =
|
||||||
|
LogicType.calculate(
|
||||||
|
subQuestWithCond.getQuestData().getFailCondComb(),
|
||||||
|
subQuestWithCond.getFailProgressList());
|
||||||
|
|
||||||
if (shouldFail)
|
if (shouldFail) subQuestWithCond.fail();
|
||||||
subQuestWithCond.fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -374,11 +434,18 @@ public class GameMainQuest {
|
|||||||
|
|
||||||
public void tryFinishSubQuests(QuestContent condType, String paramStr, int... params) {
|
public void tryFinishSubQuests(QuestContent condType, String paramStr, int... params) {
|
||||||
try {
|
try {
|
||||||
List<GameQuest> subQuestsWithCond = getChildQuests().values().stream()
|
List<GameQuest> subQuestsWithCond =
|
||||||
//There are subQuests with no acceptCond, but can be finished (example: 35104)
|
getChildQuests().values().stream()
|
||||||
.filter(p -> p.getState() == QuestState.QUEST_STATE_UNFINISHED && p.getQuestData().getAcceptCond() != null)
|
// There are subQuests with no acceptCond, but can be finished (example: 35104)
|
||||||
.filter(p -> p.getQuestData().getFinishCond().stream().anyMatch(q -> q.getType() == condType))
|
.filter(
|
||||||
.toList();
|
p ->
|
||||||
|
p.getState() == QuestState.QUEST_STATE_UNFINISHED
|
||||||
|
&& p.getQuestData().getAcceptCond() != null)
|
||||||
|
.filter(
|
||||||
|
p ->
|
||||||
|
p.getQuestData().getFinishCond().stream()
|
||||||
|
.anyMatch(q -> q.getType() == condType))
|
||||||
|
.toList();
|
||||||
|
|
||||||
for (GameQuest subQuestWithCond : subQuestsWithCond) {
|
for (GameQuest subQuestWithCond : subQuestsWithCond) {
|
||||||
val finishCond = subQuestWithCond.getQuestData().getFinishCond();
|
val finishCond = subQuestWithCond.getQuestData().getFinishCond();
|
||||||
@ -386,7 +453,11 @@ public class GameMainQuest {
|
|||||||
for (int i = 0; i < finishCond.size(); i++) {
|
for (int i = 0; i < finishCond.size(); i++) {
|
||||||
val condition = finishCond.get(i);
|
val condition = finishCond.get(i);
|
||||||
if (condition.getType() == condType) {
|
if (condition.getType() == condType) {
|
||||||
boolean result = this.getOwner().getServer().getQuestSystem().triggerContent(subQuestWithCond, condition, paramStr, params);
|
boolean result =
|
||||||
|
this.getOwner()
|
||||||
|
.getServer()
|
||||||
|
.getQuestSystem()
|
||||||
|
.triggerContent(subQuestWithCond, condition, paramStr, params);
|
||||||
subQuestWithCond.getFinishProgressList()[i] = result ? 1 : 0;
|
subQuestWithCond.getFinishProgressList()[i] = result ? 1 : 0;
|
||||||
if (result) {
|
if (result) {
|
||||||
getOwner().getSession().send(new PacketQuestProgressUpdateNotify(subQuestWithCond));
|
getOwner().getSession().send(new PacketQuestProgressUpdateNotify(subQuestWithCond));
|
||||||
@ -394,10 +465,12 @@ public class GameMainQuest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean shouldFinish = LogicType.calculate(subQuestWithCond.getQuestData().getFinishCondComb(), subQuestWithCond.getFinishProgressList());
|
boolean shouldFinish =
|
||||||
|
LogicType.calculate(
|
||||||
|
subQuestWithCond.getQuestData().getFinishCondComb(),
|
||||||
|
subQuestWithCond.getFinishProgressList());
|
||||||
|
|
||||||
if (shouldFinish)
|
if (shouldFinish) subQuestWithCond.finish();
|
||||||
subQuestWithCond.finish();
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Grasscutter.getLogger().debug("An error occurred while trying to finish quest.", e);
|
Grasscutter.getLogger().debug("An error occurred while trying to finish quest.", e);
|
||||||
@ -413,19 +486,21 @@ public class GameMainQuest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ParentQuest toProto(boolean withChildQuests) {
|
public ParentQuest toProto(boolean withChildQuests) {
|
||||||
var proto = ParentQuest.newBuilder()
|
var proto =
|
||||||
.setParentQuestId(getParentQuestId())
|
ParentQuest.newBuilder()
|
||||||
.setIsFinished(isFinished())
|
.setParentQuestId(getParentQuestId())
|
||||||
.setParentQuestState(getState().getValue())
|
.setIsFinished(isFinished())
|
||||||
.setVideoKey(QuestManager.getQuestKey(parentQuestId));
|
.setParentQuestState(getState().getValue())
|
||||||
|
.setVideoKey(QuestManager.getQuestKey(parentQuestId));
|
||||||
|
|
||||||
if (withChildQuests) {
|
if (withChildQuests) {
|
||||||
for (var quest : this.getChildQuests().values()) {
|
for (var quest : this.getChildQuests().values()) {
|
||||||
if (quest.getState() != QuestState.QUEST_STATE_UNSTARTED) {
|
if (quest.getState() != QuestState.QUEST_STATE_UNSTARTED) {
|
||||||
var childQuest = ChildQuest.newBuilder()
|
var childQuest =
|
||||||
.setQuestId(quest.getSubQuestId())
|
ChildQuest.newBuilder()
|
||||||
.setState(quest.getState().getValue())
|
.setQuestId(quest.getSubQuestId())
|
||||||
.build();
|
.setState(quest.getState().getValue())
|
||||||
|
.build();
|
||||||
|
|
||||||
proto.addChildQuestList(childQuest);
|
proto.addChildQuestList(childQuest);
|
||||||
}
|
}
|
||||||
@ -440,9 +515,11 @@ public class GameMainQuest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TimeVar handling TODO check if ingame or irl time
|
// TimeVar handling TODO check if ingame or irl time
|
||||||
public boolean initTimeVar(int index){
|
public boolean initTimeVar(int index) {
|
||||||
if(index >= this.timeVar.length){
|
if (index >= this.timeVar.length) {
|
||||||
Grasscutter.getLogger().error("Trying to init out of bounds time var {} for quest {}", index, this.parentQuestId);
|
Grasscutter.getLogger()
|
||||||
|
.error(
|
||||||
|
"Trying to init out of bounds time var {} for quest {}", index, this.parentQuestId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.timeVar[index] = owner.getWorld().getTotalGameTimeMinutes();
|
this.timeVar[index] = owner.getWorld().getTotalGameTimeMinutes();
|
||||||
@ -450,44 +527,54 @@ public class GameMainQuest {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean clearTimeVar(int index){
|
public boolean clearTimeVar(int index) {
|
||||||
if(index >= this.timeVar.length){
|
if (index >= this.timeVar.length) {
|
||||||
Grasscutter.getLogger().error("Trying to clear out of bounds time var {} for quest {}", index, this.parentQuestId);
|
Grasscutter.getLogger()
|
||||||
|
.error(
|
||||||
|
"Trying to clear out of bounds time var {} for quest {}", index, this.parentQuestId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.timeVar[index] = -1;
|
this.timeVar[index] = -1;
|
||||||
if(!checkActiveTimers()){
|
if (!checkActiveTimers()) {
|
||||||
owner.getActiveQuestTimers().remove(this.parentQuestId);
|
owner.getActiveQuestTimers().remove(this.parentQuestId);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkActiveTimers(){
|
public boolean checkActiveTimers() {
|
||||||
return Arrays.stream(timeVar).anyMatch(value -> value!=-1);
|
return Arrays.stream(timeVar).anyMatch(value -> value != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getDaysSinceTimeVar(int index){
|
public long getDaysSinceTimeVar(int index) {
|
||||||
if(index >= this.timeVar.length){
|
if (index >= this.timeVar.length) {
|
||||||
Grasscutter.getLogger().error("Trying to get days for out of bounds time var {} for quest {}", index, this.parentQuestId);
|
Grasscutter.getLogger()
|
||||||
|
.error(
|
||||||
|
"Trying to get days for out of bounds time var {} for quest {}",
|
||||||
|
index,
|
||||||
|
this.parentQuestId);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
val varTime = timeVar[index];
|
val varTime = timeVar[index];
|
||||||
|
|
||||||
if(varTime == -1){
|
if (varTime == -1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return owner.getWorld().getTotalGameTimeDays() - ConversionUtils.gameTimeToDays(varTime);
|
return owner.getWorld().getTotalGameTimeDays() - ConversionUtils.gameTimeToDays(varTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getHoursSinceTimeVar(int index){
|
public long getHoursSinceTimeVar(int index) {
|
||||||
if(index >= this.timeVar.length){
|
if (index >= this.timeVar.length) {
|
||||||
Grasscutter.getLogger().error("Trying to get hours for out of bounds time var {} for quest {}", index, this.parentQuestId);
|
Grasscutter.getLogger()
|
||||||
|
.error(
|
||||||
|
"Trying to get hours for out of bounds time var {} for quest {}",
|
||||||
|
index,
|
||||||
|
this.parentQuestId);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
val varTime = timeVar[index];
|
val varTime = timeVar[index];
|
||||||
|
|
||||||
if(varTime == -1){
|
if (varTime == -1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,12 +43,11 @@ import java.util.*;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public final class Scene {
|
public final class Scene {
|
||||||
@Getter private final World world;
|
@Getter private final World world;
|
||||||
@Getter private final SceneData sceneData;
|
@Getter private final SceneData sceneData;
|
||||||
|
@ -15,13 +15,12 @@ import emu.grasscutter.scripts.data.SceneGroup;
|
|||||||
import emu.grasscutter.scripts.data.SceneMonster;
|
import emu.grasscutter.scripts.data.SceneMonster;
|
||||||
import emu.grasscutter.server.game.BaseGameSystem;
|
import emu.grasscutter.server.game.BaseGameSystem;
|
||||||
import emu.grasscutter.server.game.GameServer;
|
import emu.grasscutter.server.game.GameServer;
|
||||||
import org.luaj.vm2.LuaError;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import org.luaj.vm2.LuaError;
|
||||||
|
|
||||||
public class WorldDataSystem extends BaseGameSystem {
|
public class WorldDataSystem extends BaseGameSystem {
|
||||||
private final Map<String, ChestInteractHandler> chestInteractHandlerMap; // chestType-Handler
|
private final Map<String, ChestInteractHandler> chestInteractHandlerMap; // chestType-Handler
|
||||||
|
@ -4,7 +4,6 @@ import com.esotericsoftware.reflectasm.ConstructorAccess;
|
|||||||
import com.esotericsoftware.reflectasm.MethodAccess;
|
import com.esotericsoftware.reflectasm.MethodAccess;
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.scripts.ScriptUtils;
|
import emu.grasscutter.scripts.ScriptUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
@ -238,7 +238,7 @@ public final class GameServer extends KcpServer {
|
|||||||
|
|
||||||
public void deregisterWorld(World world) {
|
public void deregisterWorld(World world) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
world.save(); //Save the player's world
|
world.save(); // Save the player's world
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
@ -14,10 +14,7 @@ public class PacketPlayerEnterDungeonRsp extends BasePacket {
|
|||||||
PlayerEnterDungeonRsp.newBuilder()
|
PlayerEnterDungeonRsp.newBuilder()
|
||||||
.setPointId(pointId)
|
.setPointId(pointId)
|
||||||
.setDungeonId(dungeonId)
|
.setDungeonId(dungeonId)
|
||||||
.setRetcode(
|
.setRetcode(success ? Retcode.RET_SUCC_VALUE : Retcode.RET_FAIL_VALUE)
|
||||||
success
|
|
||||||
? Retcode.RET_SUCC_VALUE
|
|
||||||
: Retcode.RET_FAIL_VALUE)
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(proto);
|
||||||
|
@ -5,7 +5,6 @@ import emu.grasscutter.net.packet.BasePacket;
|
|||||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
import emu.grasscutter.net.proto.PlayerHomeCompInfoNotifyOuterClass;
|
import emu.grasscutter.net.proto.PlayerHomeCompInfoNotifyOuterClass;
|
||||||
import emu.grasscutter.net.proto.PlayerHomeCompInfoOuterClass;
|
import emu.grasscutter.net.proto.PlayerHomeCompInfoOuterClass;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PacketPlayerHomeCompInfoNotify extends BasePacket {
|
public class PacketPlayerHomeCompInfoNotify extends BasePacket {
|
||||||
|
@ -10,7 +10,6 @@ public class PacketPlayerSetPauseRsp extends BasePacket {
|
|||||||
public PacketPlayerSetPauseRsp() {
|
public PacketPlayerSetPauseRsp() {
|
||||||
super(PacketOpcodes.PlayerSetPauseRsp);
|
super(PacketOpcodes.PlayerSetPauseRsp);
|
||||||
|
|
||||||
this.setData(PlayerSetPauseRsp.newBuilder()
|
this.setData(PlayerSetPauseRsp.newBuilder().setRetcode(Retcode.RET_SUCC_VALUE));
|
||||||
.setRetcode(Retcode.RET_SUCC_VALUE));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,7 @@ public class PacketScenePointUnlockNotify extends BasePacket {
|
|||||||
super(PacketOpcodes.ScenePointUnlockNotify);
|
super(PacketOpcodes.ScenePointUnlockNotify);
|
||||||
|
|
||||||
ScenePointUnlockNotify.Builder p =
|
ScenePointUnlockNotify.Builder p =
|
||||||
ScenePointUnlockNotify.newBuilder()
|
ScenePointUnlockNotify.newBuilder().setSceneId(sceneId).addPointList(pointId);
|
||||||
.setSceneId(sceneId)
|
|
||||||
.addPointList(pointId);
|
|
||||||
|
|
||||||
this.setData(p);
|
this.setData(p);
|
||||||
}
|
}
|
||||||
@ -20,9 +18,7 @@ public class PacketScenePointUnlockNotify extends BasePacket {
|
|||||||
super(PacketOpcodes.ScenePointUnlockNotify);
|
super(PacketOpcodes.ScenePointUnlockNotify);
|
||||||
|
|
||||||
ScenePointUnlockNotify.Builder p =
|
ScenePointUnlockNotify.Builder p =
|
||||||
ScenePointUnlockNotify.newBuilder()
|
ScenePointUnlockNotify.newBuilder().setSceneId(sceneId).addAllPointList(pointIds);
|
||||||
.setSceneId(sceneId)
|
|
||||||
.addAllPointList(pointIds);
|
|
||||||
|
|
||||||
this.setData(p);
|
this.setData(p);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import emu.grasscutter.data.ResourceLoader;
|
|||||||
import emu.grasscutter.data.excels.ItemData;
|
import emu.grasscutter.data.excels.ItemData;
|
||||||
import emu.grasscutter.data.excels.achievement.AchievementData;
|
import emu.grasscutter.data.excels.achievement.AchievementData;
|
||||||
import emu.grasscutter.data.excels.avatar.AvatarData;
|
import emu.grasscutter.data.excels.avatar.AvatarData;
|
||||||
import emu.grasscutter.game.inventory.MaterialType;
|
|
||||||
import emu.grasscutter.utils.Language;
|
import emu.grasscutter.utils.Language;
|
||||||
import emu.grasscutter.utils.Language.TextStrings;
|
import emu.grasscutter.utils.Language.TextStrings;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntRBTreeMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntRBTreeMap;
|
||||||
|
Loading…
Reference in New Issue
Block a user