mirror of
https://github.com/Anime-Game-Servers/Grasscutter-Quests.git
synced 2024-11-27 06:20:37 +00:00
added en translation keys for entity command
This commit is contained in:
parent
6085472262
commit
320699d241
@ -6,9 +6,10 @@ import emu.grasscutter.game.entity.*;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
import emu.grasscutter.game.world.Scene;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
@ -19,9 +20,9 @@ import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(
|
||||
label = "entity",
|
||||
aliases = {"gadget"},
|
||||
usage = {
|
||||
"<configId> [state]"},
|
||||
"<configId gadget> [state<state>] [maxhp<maxhp>] [hp<hp>(0 for infinite)] [atk<atk>] [def<def>]",
|
||||
"<configId monster> [ai<aiId>] [maxhp<maxhp>] [hp<hp>(0 for infinite)] [atk<atk>] [def<def>]"},
|
||||
permission = "server.entity")
|
||||
public final class EntityCommand implements CommandHandler {
|
||||
private static final Map<Pattern, BiConsumer<EntityParameters, Integer>> intCommandHandlers = Map.ofEntries(
|
||||
@ -48,48 +49,69 @@ public final class EntityCommand implements CommandHandler {
|
||||
try {
|
||||
param.configId = Integer.parseInt(args.get(0));
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.generic.invalid.entityId"));
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.generic.invalid.cfgId"));
|
||||
}
|
||||
|
||||
param.scene = targetPlayer.getScene();
|
||||
var entity = param.scene.getEntityByConfigId(param.configId);
|
||||
|
||||
if(entity == null){
|
||||
CommandHandler.sendMessage(sender, "failure");
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.entity.not_found_error"));
|
||||
return;
|
||||
}
|
||||
applyCommonParameters(entity, param);
|
||||
if(param.state != -1 && entity instanceof EntityGadget){
|
||||
applyFightProps(entity, param);
|
||||
applyGadgetParams(entity, param);
|
||||
applyMonsterParams(entity, param);
|
||||
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.status.success"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void applyGadgetParams(GameEntity entity, EntityParameters param) {
|
||||
if(!(entity instanceof EntityGadget)){
|
||||
return;
|
||||
}
|
||||
if(param.state != -1 ){
|
||||
((EntityGadget) entity).updateState(param.state);
|
||||
}
|
||||
|
||||
CommandHandler.sendMessage(sender, "command success");
|
||||
}
|
||||
private void applyMonsterParams(GameEntity entity, EntityParameters param) {
|
||||
if(!(entity instanceof EntityMonster)){
|
||||
return;
|
||||
}
|
||||
|
||||
if(param.ai != -1 ){
|
||||
((EntityMonster) entity).setAiId(param.ai);
|
||||
//TODO notify
|
||||
}
|
||||
}
|
||||
|
||||
private void applyCommonParameters(GameEntity entity, EntityParameters param) {
|
||||
private void applyFightProps(GameEntity entity, EntityParameters param) {
|
||||
var changedFields = new ArrayList<FightProperty>();
|
||||
if (param.maxHP != -1) {
|
||||
entity.setFightProperty(FightProperty.FIGHT_PROP_MAX_HP, param.maxHP);
|
||||
setFightProperty(entity, FightProperty.FIGHT_PROP_MAX_HP, param.maxHP, changedFields);
|
||||
}
|
||||
if (param.hp != -1) {
|
||||
entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, param.hp == 0 ? Float.MAX_VALUE : param.hp);
|
||||
setFightProperty(entity, FightProperty.FIGHT_PROP_CUR_HP, param.hp == 0 ? Float.MAX_VALUE : param.hp, changedFields);
|
||||
}
|
||||
if (param.atk != -1) {
|
||||
entity.setFightProperty(FightProperty.FIGHT_PROP_ATTACK, param.atk);
|
||||
entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_ATTACK, param.atk);
|
||||
setFightProperty(entity, FightProperty.FIGHT_PROP_ATTACK, param.atk, changedFields);
|
||||
setFightProperty(entity, FightProperty.FIGHT_PROP_CUR_ATTACK, param.atk, changedFields);
|
||||
}
|
||||
if (param.def != -1) {
|
||||
entity.setFightProperty(FightProperty.FIGHT_PROP_DEFENSE, param.def);
|
||||
entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_DEFENSE, param.def);
|
||||
setFightProperty(entity, FightProperty.FIGHT_PROP_DEFENSE, param.def, changedFields);
|
||||
setFightProperty(entity, FightProperty.FIGHT_PROP_CUR_DEFENSE, param.def, changedFields);
|
||||
}
|
||||
if(!changedFields.isEmpty()) {
|
||||
entity.getScene().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, changedFields));
|
||||
}
|
||||
//TODO update entity
|
||||
}
|
||||
|
||||
private Position GetRandomPositionInCircle(Position origin, double radius) {
|
||||
Position target = origin.clone();
|
||||
double angle = Math.random() * 360;
|
||||
double r = Math.sqrt(Math.random() * radius * radius);
|
||||
target.addX((float) (r * Math.cos(angle))).addZ((float) (r * Math.sin(angle)));
|
||||
return target;
|
||||
private void setFightProperty(GameEntity entity, FightProperty property, float value, List<FightProperty> modifiedProps){
|
||||
entity.setFightProperty(property, value);
|
||||
modifiedProps.add(property);
|
||||
}
|
||||
|
||||
private static class EntityParameters {
|
||||
|
@ -6,16 +6,28 @@ import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.EntityFightPropUpdateNotifyOuterClass.EntityFightPropUpdateNotify;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class PacketEntityFightPropUpdateNotify extends BasePacket {
|
||||
|
||||
|
||||
public PacketEntityFightPropUpdateNotify(GameEntity entity, FightProperty prop) {
|
||||
super(PacketOpcodes.EntityFightPropUpdateNotify);
|
||||
|
||||
|
||||
EntityFightPropUpdateNotify proto = EntityFightPropUpdateNotify.newBuilder()
|
||||
.setEntityId(entity.getId())
|
||||
.putFightPropMap(prop.getId(), entity.getFightProperty(prop))
|
||||
.build();
|
||||
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
|
||||
public PacketEntityFightPropUpdateNotify(GameEntity entity, Collection<FightProperty> props) {
|
||||
super(PacketOpcodes.EntityFightPropUpdateNotify);
|
||||
|
||||
var protoBuilder = EntityFightPropUpdateNotify.newBuilder()
|
||||
.setEntityId(entity.getId());
|
||||
props.forEach(p -> protoBuilder.putFightPropMap(p.getId(), entity.getFightProperty(p)));
|
||||
|
||||
this.setData(protoBuilder);
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,7 @@
|
||||
"artifactId": "Invalid artifact ID.",
|
||||
"avatarId": "Invalid avatar ID.",
|
||||
"avatarLevel": "Invalid avatarLevel.",
|
||||
"cfgId": "Invalid cfg ID.",
|
||||
"entityId": "Invalid entity ID.",
|
||||
"itemId": "Invalid item ID.",
|
||||
"itemLevel": "Invalid itemLevel.",
|
||||
@ -151,6 +152,10 @@
|
||||
"in_dungeon_error": "You are already in that dungeon.",
|
||||
"description": "Enter a dungeon"
|
||||
},
|
||||
"entity": {
|
||||
"description": "Modify an existing entity's properties",
|
||||
"not_found_error": "Entity does not exist"
|
||||
},
|
||||
"give": {
|
||||
"usage_relic": "Usage: give <artifactID> [mainPropID] [<appendPropID>[,<times>]]... [lv<level 0-20>]",
|
||||
"illegal_relic": "This artifactID belongs to a blacklisted range, it may not be the one you wanted.",
|
||||
|
@ -84,6 +84,7 @@
|
||||
"artifactId": "ID de artefacto no válido.",
|
||||
"avatarId": "ID de avatar no válido.",
|
||||
"avatarLevel": "avatarLevel inválido.",
|
||||
"cfgId": "🇺🇸Invalid cfg ID.",
|
||||
"entityId": "ID de entidad inválido.",
|
||||
"itemId": "ID de objeto inválido.",
|
||||
"itemLevel": "itemLevel inválido.",
|
||||
@ -151,6 +152,10 @@
|
||||
"in_dungeon_error": "Ya estás en esa mazmorra.",
|
||||
"description": "Te introduce en una mazmorra"
|
||||
},
|
||||
"entity": {
|
||||
"description": "🇺🇸Modify an existing entity's properties",
|
||||
"not_found_error": "🇺🇸Entity does not exist"
|
||||
},
|
||||
"give": {
|
||||
"usage_relic": "Uso: give <artifactID> [mainPropID] [<appendPropID>[,<veces>]]... [lv<nivel 0-20>]",
|
||||
"illegal_relic": "Este artifactID pertenece a un rango de la lista negra, puede que no sea el que buscas.",
|
||||
|
@ -84,6 +84,7 @@
|
||||
"artifactId": "ID de l'artéfact invalide.",
|
||||
"avatarId": "ID de l'avatar invalide.",
|
||||
"avatarLevel": "avatarLevel invalide.",
|
||||
"cfgId": "🇺🇸Invalid cfg ID.",
|
||||
"entityId": "ID de l'entité invalide.",
|
||||
"itemId": "ID de l'objet invalide.",
|
||||
"itemLevel": "Niveau de l'objet invalide.",
|
||||
@ -151,6 +152,10 @@
|
||||
"in_dungeon_error": "Vous êtes déjà dans ce donjon.",
|
||||
"description": "Entrer dans un donjon"
|
||||
},
|
||||
"entity": {
|
||||
"description": "🇺🇸Modify an existing entity's properties",
|
||||
"not_found_error": "🇺🇸Entity does not exist"
|
||||
},
|
||||
"give": {
|
||||
"usage_relic": "Utilisation: give <artifactID> [mainPropID] [<appendPropID>[,<times>]]... [lv<level 0-20>]",
|
||||
"illegal_relic": "L'ID de cet artéfact appartient a une liste blacklistée, ce n'est peut-être pas celui que vous désirez.",
|
||||
|
@ -85,6 +85,7 @@
|
||||
"avatarId": "キャラIDが無効な値です。",
|
||||
"avatarLevel": "キャラレベルが無効な値です。",
|
||||
"entityId": "エンティティIDが無効な値です。",
|
||||
"cfgId": "🇺🇸Invalid cfg ID.",
|
||||
"itemId": "アイテムIDが無効な値です。",
|
||||
"itemLevel": "アイテムレベルが無効な値です。",
|
||||
"itemRefinement": "アイテムの精錬ランクが無効な値です。",
|
||||
@ -151,6 +152,10 @@
|
||||
"in_dungeon_error": "あなたはすでにその秘境にいます。",
|
||||
"description": "秘境に入る。"
|
||||
},
|
||||
"entity": {
|
||||
"description": "🇺🇸Modify an existing entity's properties",
|
||||
"not_found_error": "🇺🇸Entity does not exist"
|
||||
},
|
||||
"give": {
|
||||
"usage_relic": "使用方法: give <聖遺物ID> [メインステータスID] [<サブステータスID>[,<強化回数>]]... [lv<レベル 0-20>]",
|
||||
"illegal_relic": "この聖遺物IDはブラックリストに登録された範囲に属しています。必要な範囲ではない可能性があります。",
|
||||
|
@ -84,6 +84,7 @@
|
||||
"artifactId": "성유물ID가 잘못되었습니다.",
|
||||
"avatarId": "캐릭터ID가 잘못되었습니다.",
|
||||
"avatarLevel": "캐릭터 레벨이 잘못되었습니다.",
|
||||
"cfgId": "🇺🇸Invalid cfg ID.",
|
||||
"entityId": "엔티티ID가 잘못되었습니다.",
|
||||
"itemId": "아이템ID가 잘못되었습니다.",
|
||||
"itemLevel": "아이템 레벨이 잘못되었습니다.",
|
||||
@ -151,6 +152,10 @@
|
||||
"in_dungeon_error": "이미 당신은 그 던전에 있습니다.",
|
||||
"description": "던전에 진입합니다."
|
||||
},
|
||||
"entity": {
|
||||
"description": "🇺🇸Modify an existing entity's properties",
|
||||
"not_found_error": "🇺🇸Entity does not exist"
|
||||
},
|
||||
"give": {
|
||||
"usage_relic": "사용법: give <성유물ID> [mainPropID] [<appendPropID>[,<times>]]... [lv<레벨 0-20>]",
|
||||
"illegal_relic": "이 성유물ID는 블랙리스트 범위에 있습니다. 원하는 ID가 아닐 수 있습니다.",
|
||||
|
@ -84,6 +84,7 @@
|
||||
"artifactId": "Błędne ID artefaktu.",
|
||||
"avatarId": "Błędne ID postaci.",
|
||||
"avatarLevel": "Błędny poziom postaci.",
|
||||
"cfgId": "🇺🇸Invalid cfg ID.",
|
||||
"entityId": "Błędne ID obiektu.",
|
||||
"itemId": "Błędne ID przedmiotu.",
|
||||
"itemLevel": "Błędny poziom przedmiotu.",
|
||||
@ -151,6 +152,10 @@
|
||||
"in_dungeon_error": "Wskazany gracz już jest w tym lochu.",
|
||||
"description": "Zmień loch, w którym ma się znajdować wskazany gracz."
|
||||
},
|
||||
"entity": {
|
||||
"description": "🇺🇸Modify an existing entity's properties",
|
||||
"not_found_error": "🇺🇸Entity does not exist"
|
||||
},
|
||||
"give": {
|
||||
"usage_relic": "give <ID reliktu> [ID pierwszego przedmiotu] [<ID drugiego przedmiotu>[, <ile razy je połączyć>]]... [lv<poziom od 0 do 20>]",
|
||||
"illegal_relic": "Ten ID reliktu znajduje się na czarnej liście i może być nie tym, czego szukasz.",
|
||||
|
@ -84,6 +84,7 @@
|
||||
"artifactId": "ID de artefact invalid.",
|
||||
"avatarId": "ID de avatar invalid.",
|
||||
"avatarLevel": "avatarLevel invalid.",
|
||||
"cfgId": "🇺🇸Invalid cfg ID.",
|
||||
"entityId": "ID de entitate invalid.",
|
||||
"itemId": "ID-ul articolului invalid.",
|
||||
"itemLevel": "itemLevel invalid.",
|
||||
@ -151,6 +152,10 @@
|
||||
"in_dungeon_error": "Ești deja în acea temniță.",
|
||||
"description": "Intră într-o temniță."
|
||||
},
|
||||
"entity": {
|
||||
"description": "🇺🇸Modify an existing entity's properties",
|
||||
"not_found_error": "🇺🇸Entity does not exist"
|
||||
},
|
||||
"give": {
|
||||
"usage_relic": "Utilizare: give <artifactID> [mainPropID] [<appendPropID>[,<t>]]... [lv<nivel 0-20>]",
|
||||
"illegal_relic": "Acest ID de artefact aparține unui interval de pe lista neagră, este posibil să nu fie cel pe care l-ați dorit.",
|
||||
|
@ -84,6 +84,7 @@
|
||||
"artifactId": "Некорректный ID артефакта.",
|
||||
"avatarId": "Некорректный ID персонажа.",
|
||||
"avatarLevel": "Некорректный уровень персонажа (avatarLevel).",
|
||||
"cfgId": "🇺🇸Invalid cfg ID.",
|
||||
"entityId": "Некорректный ID сущности.",
|
||||
"itemId": "Некорректный ID предмета.",
|
||||
"itemLevel": "Некорректный уровень предмета (itemLevel).",
|
||||
@ -151,6 +152,10 @@
|
||||
"in_dungeon_error": "Вы уже в этом подземелье.",
|
||||
"description": "Позволяет войти в подземелье"
|
||||
},
|
||||
"entity": {
|
||||
"description": "🇺🇸Modify an existing entity's properties",
|
||||
"not_found_error": "🇺🇸Entity does not exist"
|
||||
},
|
||||
"give": {
|
||||
"usage_relic": "Применение: give <ID_артефакта> [ID_глав_хар-ки] [<ID доп_хар-ки>[,<раз>]]... [lv<уровень 0-20>]",
|
||||
"illegal_relic": "Данный ID_артефакта находится в черном списке. Возможно, это не то, что вы хотите получить.",
|
||||
|
@ -84,6 +84,7 @@
|
||||
"artifactId": "无效的圣遗物ID。",
|
||||
"avatarId": "无效的角色ID。",
|
||||
"avatarLevel": "无效的角色等级。",
|
||||
"cfgId": "🇺🇸Invalid cfg ID.",
|
||||
"entityId": "无效的实体ID。",
|
||||
"itemId": "无效的物品ID。",
|
||||
"itemLevel": "无效的物品等级。",
|
||||
@ -151,6 +152,10 @@
|
||||
"in_dungeon_error": "你已经在这个秘境中了。",
|
||||
"description": "进入指定秘境"
|
||||
},
|
||||
"entity": {
|
||||
"description": "🇺🇸Modify an existing entity's properties",
|
||||
"not_found_error": "🇺🇸Entity does not exist"
|
||||
},
|
||||
"give": {
|
||||
"usage_relic": "用法:give <圣遗物ID> [主词条ID] [<副词条ID>[,<强化次数>]]... [lv<等级 0-20>]",
|
||||
"illegal_relic": "此圣遗物ID属于黑名单范围,也许不是你想要的。",
|
||||
|
@ -84,6 +84,7 @@
|
||||
"artifactId": "無效的聖遺物ID。",
|
||||
"avatarId": "無效的角色ID。",
|
||||
"avatarLevel": "無效的角色等級。",
|
||||
"cfgId": "🇺🇸Invalid cfg ID.",
|
||||
"entityId": "無效的實體ID。",
|
||||
"itemId": "無效的物品ID。",
|
||||
"itemLevel": "無效的物品等級。",
|
||||
@ -151,6 +152,10 @@
|
||||
"in_dungeon_error": "你已經在祕境中了。",
|
||||
"description": "進入指定祕境。"
|
||||
},
|
||||
"entity": {
|
||||
"description": "🇺🇸Modify an existing entity's properties",
|
||||
"not_found_error": "🇺🇸Entity does not exist"
|
||||
},
|
||||
"give": {
|
||||
"usage_relic": "用法: give <artifactID> [mainPropID] [<appendPropID>[,<times>]]... [lv<level 0-20>]",
|
||||
"illegal_relic": "你不可以取得這個聖遺物,因為該聖遺物ID在黑名單列表內。",
|
||||
|
Loading…
Reference in New Issue
Block a user