mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-25 09:47:28 +00:00
Merge branch 'development' into talking
This commit is contained in:
commit
70e6d7f334
@ -57,7 +57,7 @@ sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
group = 'io.grasscutter'
|
||||
version = '1.6.2'
|
||||
version = '1.6.3'
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
|
@ -4,11 +4,9 @@ import static emu.grasscutter.utils.lang.Language.translate;
|
||||
|
||||
import at.favre.lib.crypto.bcrypt.BCrypt;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.command.*;
|
||||
import emu.grasscutter.config.Configuration;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.database.DatabaseManager;
|
||||
import emu.grasscutter.database.*;
|
||||
import emu.grasscutter.game.Account;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import java.util.List;
|
||||
@ -31,17 +29,17 @@ public final class AccountCommand implements CommandHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.size() < 2) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
String action = args.get(0);
|
||||
String username = args.get(1);
|
||||
|
||||
switch (action) {
|
||||
default -> this.sendUsageMessage(sender);
|
||||
case "create" -> {
|
||||
if (args.size() < 2) {
|
||||
this.sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
var username = args.get(1);
|
||||
|
||||
int uid = 0;
|
||||
String password = "";
|
||||
if (Configuration.ACCOUNT.EXPERIMENTAL_RealPassword) {
|
||||
@ -94,6 +92,12 @@ public final class AccountCommand implements CommandHandler {
|
||||
}
|
||||
}
|
||||
case "delete" -> {
|
||||
if (args.size() < 2) {
|
||||
this.sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
var username = args.get(1);
|
||||
|
||||
// Get the account we want to delete.
|
||||
Account toDelete = DatabaseHelper.getAccountByName(username);
|
||||
if (toDelete == null) {
|
||||
@ -104,6 +108,12 @@ public final class AccountCommand implements CommandHandler {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.account.delete"));
|
||||
}
|
||||
case "resetpass" -> {
|
||||
if (args.size() < 2) {
|
||||
this.sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
var username = args.get(1);
|
||||
|
||||
if (!Configuration.ACCOUNT.EXPERIMENTAL_RealPassword) {
|
||||
CommandHandler.sendMessage(
|
||||
sender, "resetpass requires EXPERIMENTAL_RealPassword to be true.");
|
||||
|
@ -1,13 +1,15 @@
|
||||
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 java.util.List;
|
||||
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"},
|
||||
@ -15,27 +17,30 @@ import java.util.stream.Collectors;
|
||||
permission = "player.quest",
|
||||
permissionTargeted = "player.quest.others")
|
||||
public final class QuestCommand implements CommandHandler {
|
||||
private static final List<String> SINGLE_ARG = List.of("dungeons", "list");
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() != 2 || (args.size() == 1 && !args.get(0).toLowerCase().equals("dungeons"))) {
|
||||
if (args.isEmpty()) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
String cmd = args.get(0).toLowerCase();
|
||||
int questId;
|
||||
var cmd = args.get(0).toLowerCase();
|
||||
int questId = -1;
|
||||
|
||||
try {
|
||||
questId = Integer.parseInt(args.get(1));
|
||||
} catch (Exception e) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.invalid_id"));
|
||||
return;
|
||||
if (!SINGLE_ARG.contains(cmd)) {
|
||||
try {
|
||||
questId = Integer.parseInt(args.get(1));
|
||||
} catch (Exception e) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.invalid_id"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case "add" -> {
|
||||
GameQuest quest = targetPlayer.getQuestManager().addQuest(questId);
|
||||
var quest = targetPlayer.getQuestManager().addQuest(questId);
|
||||
|
||||
if (quest != null) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.added", questId));
|
||||
@ -45,7 +50,7 @@ public final class QuestCommand implements CommandHandler {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found"));
|
||||
}
|
||||
case "finish" -> {
|
||||
GameQuest quest = targetPlayer.getQuestManager().getQuestById(questId);
|
||||
var quest = targetPlayer.getQuestManager().getQuestById(questId);
|
||||
|
||||
if (quest == null) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found"));
|
||||
@ -112,7 +117,7 @@ public final class QuestCommand implements CommandHandler {
|
||||
var shouldAdd = !loggedQuests.contains(questId);
|
||||
|
||||
if (shouldAdd) loggedQuests.add(questId);
|
||||
else loggedQuests.remove(loggedQuests.indexOf(questId));
|
||||
else loggedQuests.remove(questId);
|
||||
|
||||
CommandHandler.sendMessage(
|
||||
sender,
|
||||
@ -147,6 +152,23 @@ public final class QuestCommand implements CommandHandler {
|
||||
.map(entry -> "%s: %s".formatted(entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.joining(", ")));
|
||||
}
|
||||
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();
|
||||
|
||||
CommandHandler.sendMessage(sender, "Quests: " +
|
||||
(allQuestIds.isEmpty() ? "(no active quests)" :
|
||||
String.join(", ", allQuestIds)));
|
||||
}
|
||||
default -> this.sendUsageMessage(sender);
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,10 @@ public final class QuestManager extends BasePlayerManager {
|
||||
|
||||
47001, 47002, 47003, 47004,
|
||||
|
||||
2010103, 2010144 // Prologue Act 2: Chasing Shadows
|
||||
2010103, 2010144, // Prologue Act 2: Chasing Shadows,
|
||||
|
||||
2012 // This is the main quest ID for Chapter 2 Act 1.
|
||||
// Used for debugging giving items.
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user