Extend talent command "all" (#1850)

* Extend talent command "all":
Added talent option to set all talents (n, e, q) at once
Modified error message to cover edge cases when player entered talent level lower than 1

* Update src/main/java/emu/grasscutter/command/commands/TalentCommand.java

some suggested changes

Co-authored-by: Luke H-W <Birdulon@users.noreply.github.com>
This commit is contained in:
natsu 2022-10-13 09:16:59 +07:00 committed by GitHub
parent ec3cdc040f
commit 953272489d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 33 additions and 12 deletions

View File

@ -12,7 +12,7 @@ import java.util.List;
@Command(
label = "talent",
usage = {"set <talentId> <level>", "(n|e|q) <level>", "getid"},
usage = {"set <talentId> <level>", "(n|e|q|all) <level>", "getid"},
permission = "player.settalent",
permissionTargeted = "player.settalent.others")
public final class TalentCommand implements CommandHandler {
@ -22,7 +22,7 @@ public final class TalentCommand implements CommandHandler {
var name = Language.getTextMapKey(nameHash);
CommandHandler.sendTranslatedMessage(sender, "commands.talent.set_id", skillId, name, newLevel);
} else {
CommandHandler.sendTranslatedMessage(sender, "commands.talent.lower_16");
CommandHandler.sendTranslatedMessage(sender, "commands.talent.out_of_range");
}
}
@ -87,6 +87,27 @@ public final class TalentCommand implements CommandHandler {
};
setTalentLevel(sender, avatar, skillId, newLevel);
}
case "all" -> {
if (args.size() < 2) {
sendUsageMessage(sender);
return;
}
try {
newLevel = Integer.parseInt(args.get(1));
} catch (NumberFormatException ignored) {
CommandHandler.sendTranslatedMessage(sender, "commands.talent.invalid_level");
return;
}
// This stops setTalentLevel from outputting 3 "levels out of range" messages
if (newLevel < 1 || newLevel > 15) {
CommandHandler.sendTranslatedMessage(sender, "commands.talent.out_of_range");
return;
}
// This is small so array is not needed imo
setTalentLevel(sender, avatar, skillDepot.getSkills().get(0), newLevel);
setTalentLevel(sender, avatar, skillDepot.getSkills().get(1), newLevel);
setTalentLevel(sender, avatar, skillDepot.getEnergySkill(), newLevel);
}
case "getid" -> {
var map = GameData.getAvatarSkillDataMap();
skillDepot.getSkillsAndEnergySkill().forEach(id -> {

View File

@ -292,7 +292,7 @@
"description": "Stops the server"
},
"talent": {
"lower_16": "Invalid talent level. Level should be lower than 16.",
"out_of_range": "Invalid talent level. Level should be in range of 1-15.",
"set_id": "Set talent %s - \"%s\" to %s.",
"id_desc": "Talent %s - \"%s\" - \"%s\"",
"invalid_skill_id": "Invalid skill ID.",

View File

@ -292,7 +292,7 @@
"description": "Detiene el servidor"
},
"talent": {
"lower_16": "Nivel de talento inválido. El nivel debe ser menor que 16.",
"out_of_range": "🇺🇸Invalid talent level. Level should be in range of 1-15.",
"set_id": "🇺🇸Set talent %s - \"%s\" to %s.",
"id_desc": "🇺🇸Talent %s - \"%s\" - \"%s\"",
"invalid_skill_id": "ID de habilidad inválido.",

View File

@ -292,7 +292,7 @@
"description": "Arrête le serveur"
},
"talent": {
"lower_16": "Niveau de talent invalide. Le niveau doit être inférieur a 16.",
"out_of_range": "🇺🇸Invalid talent level. Level should be in range of 1-15.",
"set_id": "🇺🇸Set talent %s - \"%s\" to %s.",
"id_desc": "🇺🇸Talent %s - \"%s\" - \"%s\"",
"invalid_skill_id": "ID de talent invalide.",

View File

@ -292,7 +292,7 @@
"description": "サーバーを停止中"
},
"talent": {
"lower_16": "天賦レベルが無効です。 レベルは16未満である必要があります。",
"out_of_range": "🇺🇸Invalid talent level. Level should be in range of 1-15.",
"set_id": "%s - の天賦\"%s\" を %s に設定しました",
"id_desc": "天賦 %s - \"%s\" - \"%s\"",
"invalid_skill_id": "スキル ID が無効です。",

View File

@ -292,7 +292,7 @@
"description": "서버를 중지합니다"
},
"talent": {
"lower_16": "불분명한 특성 레벨. 특성의 레벨은 16 미만이여야합니다.",
"out_of_range": "🇺🇸Invalid talent level. Level should be in range of 1-15.",
"set_id": "🇺🇸Set talent %s - \"%s\" to %s.",
"id_desc": "🇺🇸Talent %s - \"%s\" - \"%s\"",
"invalid_skill_id": "잘못된 스킬ID.",

View File

@ -292,7 +292,7 @@
"description": "Zatrzymaj serwer."
},
"talent": {
"lower_16": "Błędny poziom talentu. Poziom ten powinien być mniejszy niż 16.",
"out_of_range": "🇺🇸Invalid talent level. Level should be in range of 1-15.",
"set_id": "🇺🇸Set talent %s - \"%s\" to %s.",
"id_desc": "🇺🇸Talent %s - \"%s\" - \"%s\"",
"invalid_skill_id": "Błędne ID umiejętności.",

View File

@ -292,7 +292,7 @@
"description": "Oprește serverul"
},
"talent": {
"lower_16": "Nivel de talent nevalabil. Nivelul trebuie să fie mai mic ca 16.",
"out_of_range": "🇺🇸Invalid talent level. Level should be in range of 1-15.",
"set_id": "🇺🇸Set talent %s - \"%s\" to %s.",
"id_desc": "🇺🇸Talent %s - \"%s\" - \"%s\"",
"invalid_skill_id": "Skill ID nevalabil.",

View File

@ -292,7 +292,7 @@
"description": "Останавливает работу сервера"
},
"talent": {
"lower_16": "Некорректный уровень таланта. Уровень должен быть ниже 16.",
"out_of_range": "🇺🇸Invalid talent level. Level should be in range of 1-15.",
"set_id": "Уровень таланта %s - \"%s\" установлен на %s.",
"id_desc": "Талант %s - \"%s\" - \"%s\"",
"invalid_skill_id": "Некорректный ID способности.",

View File

@ -292,7 +292,7 @@
"description": "停止服务器"
},
"talent": {
"lower_16": "无效的天赋等级,天赋等级应在 1-15 之间。",
"out_of_range": "🇺🇸Invalid talent level. Level should be in range of 1-15.",
"set_id": "修改技能 %s - \"%s\" 至 %s。",
"id_desc": "技能 %s - \"%s\" - \"%s\"",
"invalid_skill_id": "无效的技能ID。",

View File

@ -292,7 +292,7 @@
"description": "以正常的方式關閉伺服器。"
},
"talent": {
"lower_16": "無效的天賦等級,技能等級應低於 16。",
"out_of_range": "🇺🇸Invalid talent level. Level should be in range of 1-15.",
"set_id": "🇺🇸Set talent %s - \"%s\" to %s.",
"id_desc": "🇺🇸Talent %s - \"%s\" - \"%s\"",
"invalid_skill_id": "無效的技能ID。",