mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-25 11:57:35 +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
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
|
||||||
group = 'io.grasscutter'
|
group = 'io.grasscutter'
|
||||||
version = '1.6.2'
|
version = '1.6.3'
|
||||||
|
|
||||||
java {
|
java {
|
||||||
withJavadocJar()
|
withJavadocJar()
|
||||||
|
@ -4,11 +4,9 @@ import static emu.grasscutter.utils.lang.Language.translate;
|
|||||||
|
|
||||||
import at.favre.lib.crypto.bcrypt.BCrypt;
|
import at.favre.lib.crypto.bcrypt.BCrypt;
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.command.Command;
|
import emu.grasscutter.command.*;
|
||||||
import emu.grasscutter.command.CommandHandler;
|
|
||||||
import emu.grasscutter.config.Configuration;
|
import emu.grasscutter.config.Configuration;
|
||||||
import emu.grasscutter.database.DatabaseHelper;
|
import emu.grasscutter.database.*;
|
||||||
import emu.grasscutter.database.DatabaseManager;
|
|
||||||
import emu.grasscutter.game.Account;
|
import emu.grasscutter.game.Account;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -31,17 +29,17 @@ public final class AccountCommand implements CommandHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.size() < 2) {
|
|
||||||
sendUsageMessage(sender);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String action = args.get(0);
|
String action = args.get(0);
|
||||||
String username = args.get(1);
|
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
default -> this.sendUsageMessage(sender);
|
default -> this.sendUsageMessage(sender);
|
||||||
case "create" -> {
|
case "create" -> {
|
||||||
|
if (args.size() < 2) {
|
||||||
|
this.sendUsageMessage(sender);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var username = args.get(1);
|
||||||
|
|
||||||
int uid = 0;
|
int uid = 0;
|
||||||
String password = "";
|
String password = "";
|
||||||
if (Configuration.ACCOUNT.EXPERIMENTAL_RealPassword) {
|
if (Configuration.ACCOUNT.EXPERIMENTAL_RealPassword) {
|
||||||
@ -94,6 +92,12 @@ public final class AccountCommand implements CommandHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "delete" -> {
|
case "delete" -> {
|
||||||
|
if (args.size() < 2) {
|
||||||
|
this.sendUsageMessage(sender);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var username = args.get(1);
|
||||||
|
|
||||||
// Get the account we want to delete.
|
// Get the account we want to delete.
|
||||||
Account toDelete = DatabaseHelper.getAccountByName(username);
|
Account toDelete = DatabaseHelper.getAccountByName(username);
|
||||||
if (toDelete == null) {
|
if (toDelete == null) {
|
||||||
@ -104,6 +108,12 @@ public final class AccountCommand implements CommandHandler {
|
|||||||
CommandHandler.sendMessage(sender, translate(sender, "commands.account.delete"));
|
CommandHandler.sendMessage(sender, translate(sender, "commands.account.delete"));
|
||||||
}
|
}
|
||||||
case "resetpass" -> {
|
case "resetpass" -> {
|
||||||
|
if (args.size() < 2) {
|
||||||
|
this.sendUsageMessage(sender);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var username = args.get(1);
|
||||||
|
|
||||||
if (!Configuration.ACCOUNT.EXPERIMENTAL_RealPassword) {
|
if (!Configuration.ACCOUNT.EXPERIMENTAL_RealPassword) {
|
||||||
CommandHandler.sendMessage(
|
CommandHandler.sendMessage(
|
||||||
sender, "resetpass requires EXPERIMENTAL_RealPassword to be true.");
|
sender, "resetpass requires EXPERIMENTAL_RealPassword to be true.");
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
package emu.grasscutter.command.commands;
|
package emu.grasscutter.command.commands;
|
||||||
|
|
||||||
import static emu.grasscutter.utils.lang.Language.translate;
|
|
||||||
|
|
||||||
import emu.grasscutter.command.*;
|
import emu.grasscutter.command.*;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import emu.grasscutter.game.quest.GameQuest;
|
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 java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static emu.grasscutter.utils.lang.Language.translate;
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
label = "quest",
|
label = "quest",
|
||||||
aliases = {"q"},
|
aliases = {"q"},
|
||||||
@ -15,27 +17,30 @@ import java.util.stream.Collectors;
|
|||||||
permission = "player.quest",
|
permission = "player.quest",
|
||||||
permissionTargeted = "player.quest.others")
|
permissionTargeted = "player.quest.others")
|
||||||
public final class QuestCommand implements CommandHandler {
|
public final class QuestCommand implements CommandHandler {
|
||||||
|
private static final List<String> SINGLE_ARG = List.of("dungeons", "list");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
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);
|
sendUsageMessage(sender);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String cmd = args.get(0).toLowerCase();
|
var cmd = args.get(0).toLowerCase();
|
||||||
int questId;
|
int questId = -1;
|
||||||
|
|
||||||
try {
|
if (!SINGLE_ARG.contains(cmd)) {
|
||||||
questId = Integer.parseInt(args.get(1));
|
try {
|
||||||
} catch (Exception e) {
|
questId = Integer.parseInt(args.get(1));
|
||||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.invalid_id"));
|
} catch (Exception e) {
|
||||||
return;
|
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.invalid_id"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case "add" -> {
|
case "add" -> {
|
||||||
GameQuest quest = targetPlayer.getQuestManager().addQuest(questId);
|
var quest = targetPlayer.getQuestManager().addQuest(questId);
|
||||||
|
|
||||||
if (quest != null) {
|
if (quest != null) {
|
||||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.added", questId));
|
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"));
|
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found"));
|
||||||
}
|
}
|
||||||
case "finish" -> {
|
case "finish" -> {
|
||||||
GameQuest quest = targetPlayer.getQuestManager().getQuestById(questId);
|
var quest = targetPlayer.getQuestManager().getQuestById(questId);
|
||||||
|
|
||||||
if (quest == null) {
|
if (quest == null) {
|
||||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found"));
|
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found"));
|
||||||
@ -112,7 +117,7 @@ public final class QuestCommand implements CommandHandler {
|
|||||||
var shouldAdd = !loggedQuests.contains(questId);
|
var shouldAdd = !loggedQuests.contains(questId);
|
||||||
|
|
||||||
if (shouldAdd) loggedQuests.add(questId);
|
if (shouldAdd) loggedQuests.add(questId);
|
||||||
else loggedQuests.remove(loggedQuests.indexOf(questId));
|
else loggedQuests.remove(questId);
|
||||||
|
|
||||||
CommandHandler.sendMessage(
|
CommandHandler.sendMessage(
|
||||||
sender,
|
sender,
|
||||||
@ -147,6 +152,23 @@ public final class QuestCommand implements CommandHandler {
|
|||||||
.map(entry -> "%s: %s".formatted(entry.getKey(), entry.getValue()))
|
.map(entry -> "%s: %s".formatted(entry.getKey(), entry.getValue()))
|
||||||
.collect(Collectors.joining(", ")));
|
.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);
|
default -> this.sendUsageMessage(sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,10 @@ public final class QuestManager extends BasePlayerManager {
|
|||||||
|
|
||||||
47001, 47002, 47003, 47004,
|
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