mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-25 11:57:35 +00:00
Set Constellation Command (#1565)
Original commits: * create `SetConstCommand` class and translations * (partially) functional `setconst` command * fixed punctuation * added success message * implemented `SetConstCommand` * added translation keys * update keys * refactor + automatic reload * Nitpick (Co-authored-by: AnimeGitB <AnimeGitB@bigblueball.in>)
This commit is contained in:
parent
63fd4dfe3a
commit
59a412cc83
@ -0,0 +1,85 @@
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.AvatarTalentData;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.entity.EntityAvatar;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.world.Scene;
|
||||
import emu.grasscutter.game.world.World;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Command(
|
||||
label = "setConst",
|
||||
aliases = {"setconstellation"},
|
||||
usage = {"<constellation level>"},
|
||||
permission = "player.setconstellation",
|
||||
permissionTargeted = "player.setconstellation.others")
|
||||
public final class SetConstCommand implements CommandHandler {
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() < 1) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
int constLevel = Integer.parseInt(args.get(0));
|
||||
if (constLevel < 0 || constLevel > 6) {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.setConst.range_error");
|
||||
return;
|
||||
}
|
||||
|
||||
EntityAvatar entity = targetPlayer.getTeamManager().getCurrentAvatarEntity();
|
||||
if (entity == null) return;
|
||||
Avatar avatar = entity.getAvatar();
|
||||
|
||||
this.setConstellation(targetPlayer, avatar, constLevel);
|
||||
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.setConst.success", avatar.getAvatarData().getName(), constLevel);
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.setConst.level_error");
|
||||
}
|
||||
}
|
||||
|
||||
private void setConstellation(Player player, Avatar avatar, int constLevel) {
|
||||
int currentConstLevel = avatar.getCoreProudSkillLevel();
|
||||
IntArrayList talentIds = new IntArrayList(avatar.getSkillDepot().getTalents());
|
||||
Set<Integer> talentIdList = avatar.getTalentIdList();
|
||||
|
||||
talentIdList.clear();
|
||||
avatar.setCoreProudSkillLevel(0);
|
||||
|
||||
for(int talent = 0; talent < constLevel; talent++) {
|
||||
AvatarTalentData talentData = GameData.getAvatarTalentDataMap().get(talentIds.getInt(talent));
|
||||
int mainCostItemId = talentData.getMainCostItemId();
|
||||
|
||||
player.getInventory().addItem(mainCostItemId);
|
||||
Grasscutter.getGameServer().getInventorySystem().unlockAvatarConstellation(player, avatar.getGuid());
|
||||
}
|
||||
|
||||
// force player to reload scene when necessary
|
||||
if (constLevel < currentConstLevel) {
|
||||
World world = player.getWorld();
|
||||
Scene scene = player.getScene();
|
||||
Position pos = player.getPosition();
|
||||
|
||||
world.transferPlayerToScene(player, 1, pos);
|
||||
world.transferPlayerToScene(player, scene.getId(), pos);
|
||||
scene.broadcastPacket(new PacketSceneEntityAppearNotify(player));
|
||||
}
|
||||
|
||||
// ensure that all changes are visible to the player
|
||||
avatar.recalcConstellations();
|
||||
avatar.recalcStats(true);
|
||||
avatar.save();
|
||||
}
|
||||
}
|
@ -256,6 +256,14 @@
|
||||
"success": "Message sent.",
|
||||
"description": "Sends a message to a player as the server. If used with no target, sends to all players on the server."
|
||||
},
|
||||
"setConst": {
|
||||
"range_error": "Constellation level must be between 0 and 6.",
|
||||
"level_error": "Invalid constellation level.",
|
||||
"fail": "Failed to set constellation.",
|
||||
"failed_success": "Constellations for %s have been set to %s. Please reload scene to see changes.",
|
||||
"success": "Constellations for %s have been set to %s.",
|
||||
"description": "Sets constellation level for your current active character"
|
||||
},
|
||||
"setFetterLevel": {
|
||||
"range_error": "Fetter level must be between 0 and 10.",
|
||||
"success": "Fetter level set to %s.",
|
||||
|
@ -256,6 +256,14 @@
|
||||
"success": "Mensaje enviado.",
|
||||
"description": "Envía un mensaje a un jugador como servidor. Si se usa sin un objetivo fijado, lo envía a todos los jugadores del servidor."
|
||||
},
|
||||
"setConst": {
|
||||
"range_error": "Constellation level must be between 0 and 6.",
|
||||
"level_error": "Invalid constellation level.",
|
||||
"fail": "Failed to set constellation.",
|
||||
"failed_success": "Constellations for %s have been set to %s. Please reload scene to see changes.",
|
||||
"success": "Constellations for %s have been set to %s.",
|
||||
"description": "Sets constellation level for your current active character"
|
||||
},
|
||||
"setFetterLevel": {
|
||||
"range_error": "El nivel de amistad debe estar entre 0 y 10.",
|
||||
"success": "Nivel de amistad establecido a %s.",
|
||||
|
@ -256,6 +256,14 @@
|
||||
"success": "Message envoyé.",
|
||||
"description": "Envoie un message au joueur spécifié en tant que Serveur"
|
||||
},
|
||||
"setConst": {
|
||||
"range_error": "Constellation level must be between 0 and 6.",
|
||||
"level_error": "Invalid constellation level.",
|
||||
"fail": "Failed to set constellation.",
|
||||
"failed_success": "Constellations for %s have been set to %s. Please reload scene to see changes.",
|
||||
"success": "Constellations for %s have been set to %s.",
|
||||
"description": "Sets constellation level for your current active character"
|
||||
},
|
||||
"setFetterLevel": {
|
||||
"range_error": "Le niveau d'affinité doit être compris entre 0 et 10.",
|
||||
"success": "Niveau d'affinité défini à %s.",
|
||||
|
@ -256,6 +256,14 @@
|
||||
"success": "Wiadomość wysłana.",
|
||||
"description": "Wyślij wiadomość do gracza jako serwer. Jeśli nie określono celu, wysyła do wszystkich graczy na serwerze."
|
||||
},
|
||||
"setConst": {
|
||||
"range_error": "Constellation level must be between 0 and 6.",
|
||||
"level_error": "Invalid constellation level.",
|
||||
"fail": "Failed to set constellation.",
|
||||
"failed_success": "Constellations for %s have been set to %s. Please reload scene to see changes.",
|
||||
"success": "Constellations for %s have been set to %s.",
|
||||
"description": "Sets constellation level for your current active character"
|
||||
},
|
||||
"setFetterLevel": {
|
||||
"range_error": "Poziom przyjaźni musi być pomiędzy 0 a 10.",
|
||||
"success": "Poziom przyjaźni został pomyślnie ustawiony na %s.",
|
||||
|
@ -256,6 +256,14 @@
|
||||
"success": "Mesaj trimis.",
|
||||
"description": "Trimite un mesaj unui jucător în calitate de server. Dacă este utilizat fără țintă, trimite mesajul către toți jucătorii de pe server."
|
||||
},
|
||||
"setConst": {
|
||||
"range_error": "Constellation level must be between 0 and 6.",
|
||||
"level_error": "Invalid constellation level.",
|
||||
"fail": "Failed to set constellation.",
|
||||
"failed_success": "Constellations for %s have been set to %s. Please reload scene to see changes.",
|
||||
"success": "Constellations for %s have been set to %s.",
|
||||
"description": "Sets constellation level for your current active character"
|
||||
},
|
||||
"setFetterLevel": {
|
||||
"range_error": "Nivelul Fetter trebuie să fie între 0 și 10.",
|
||||
"success": "Nivelul Fetter setat ca %s.",
|
||||
|
@ -256,6 +256,14 @@
|
||||
"success": "Сообщение было отправлено.",
|
||||
"description": "Отправляет сообщение выбранному игроку от имени сервера. При отсутствии конкретной цели, отправляет сообщение всем игрокам на сервере."
|
||||
},
|
||||
"setConst": {
|
||||
"range_error": "Constellation level must be between 0 and 6.",
|
||||
"level_error": "Invalid constellation level.",
|
||||
"fail": "Failed to set constellation.",
|
||||
"failed_success": "Constellations for %s have been set to %s. Please reload scene to see changes.",
|
||||
"success": "Constellations for %s have been set to %s.",
|
||||
"description": "Sets constellation level for your current active character"
|
||||
},
|
||||
"setFetterLevel": {
|
||||
"range_error": "Значение уровня дружбы должно быть между 0 и 10.",
|
||||
"success": "Уровень дружбы стал равен %s.",
|
||||
|
@ -256,6 +256,14 @@
|
||||
"success": "消息已发送。",
|
||||
"description": "向玩家以服务器的身份发送消息。如果没有指定目标,则向服务器的全部玩家发送"
|
||||
},
|
||||
"setConst": {
|
||||
"range_error": "Constellation level must be between 0 and 6.",
|
||||
"level_error": "Invalid constellation level.",
|
||||
"fail": "Failed to set constellation.",
|
||||
"failed_success": "Constellations for %s have been set to %s. Please reload scene to see changes.",
|
||||
"success": "Constellations for %s have been set to %s.",
|
||||
"description": "Sets constellation level for your current active character"
|
||||
},
|
||||
"setFetterLevel": {
|
||||
"range_error": "好感度等级必须在 0-10 之间。",
|
||||
"success": "好感度已设为 %s 级。",
|
||||
|
@ -256,6 +256,14 @@
|
||||
"success": "訊息已發送。",
|
||||
"description": "向指定玩家發送訊息。"
|
||||
},
|
||||
"setConst": {
|
||||
"range_error": "Constellation level must be between 0 and 6.",
|
||||
"level_error": "Invalid constellation level.",
|
||||
"fail": "Failed to set constellation.",
|
||||
"failed_success": "Constellations for %s have been set to %s. Please reload scene to see changes.",
|
||||
"success": "Constellations for %s have been set to %s.",
|
||||
"description": "Sets constellation level for your current active character"
|
||||
},
|
||||
"setFetterLevel": {
|
||||
"range_error": "好感度必須在 0 到 10 之間。",
|
||||
"success": "好感等級已設定為 %s",
|
||||
|
Loading…
Reference in New Issue
Block a user