fix join command and remove command bug and update docs (#904)

* feat:new command "join" and "remove" to force join or remove avatar in your current team

* fix:change MaxAvatarsInTeam from 9 to 4

* feat:update & merge branch.Translate fix

* fix(command):fix remove command a stupid bug.Loop delete element bug.

* fix(command):fix join command. When adding avatars, repeat avatars skip and non repeat avatars join.

* fix(language):fix join command remove command translate

* fix(ReadMe):update README.md join and remove command.
This commit is contained in:
lsCoding666 2022-05-15 14:27:23 +08:00 committed by GitHub
parent 49364f9c05
commit 7a66f22827
7 changed files with 189 additions and 177 deletions

View File

@ -122,12 +122,14 @@ There is a dummy user named "Server" in every player's friends list that you can
| godmode | godmode [uid] | player.godmode | Client only | Prevents you from taking damage. | |
| heal | heal | player.heal | Client only | Heals all characters in your current team. | h |
| help | help [command] | | Both side | Sends the help message or shows information about a specified command. | |
| join | join [avatarIds] | player.join | Client only | Force let avatars to join into your current team. Such as `join 10000020 10000021`. | |
| kick | kick \<player> | server.kick | Both side | Kicks the specified player from the server. (WIP) | k |
| killall | killall [playerUid] [sceneId] | server.killall | Both side | Kills all entities in the current scene or specified scene of the corresponding player. | |
| list | list | | Both side | Lists online players. | |
| permission | permission <add\|remove> \<UID> \<permission> | permission | Both side | Grants or removes a permission for a user. | |
| position | position | | Client only | Sends your current coordinates. | pos |
| reload | reload | server.reload | Both side | Reloads the server config | |
| remove | remove [avatarIndexInYourTeams] | player.remove | Client only | Force remove avatar in your current team. Index start from 1.Such as `remove 1 2`. | |
| resetconst | resetconst [all] | player.resetconstellation | Client only | Resets the constellation level on your currently selected character, will need to relog after using the command to see any changes. | resetconstellation |
| restart | | | Both side | Restarts the current session | |
| say | say \<player> \<message> | server.sendmessage | Both side | Sends a message to a player as the server | `sendservmsg` `sendservermessage` `sendmessage` |

View File

@ -123,11 +123,13 @@ chmod +x gradlew
| godmode | godmode [uid] | player.godmode | 仅客户端 | 保护你不受到任何伤害(依然会被击退) | |
| heal | heal | player.heal | 仅客户端 | 治疗队伍中所有角色 | h |
| help | help [命令] | | 均可使用 | 显示帮助或展示指定命令的帮助 | |
| join | join [多个角色id] | player.join | 仅客户端 | 强制入队角色跟config.json中的avatarLimits有关跟队内角色数量上限有关。用法`join 10000021 10000022` | |
| kick | kick \<uid> | server.kick | 均可使用 | 从服务器中踢出指定玩家 (WIP) | k |
| killall | killall [uid] [场景ID] | server.killall | 均可使用 | 杀死指定玩家世界中所在或指定场景的全部生物 | |
| list | list | | 均可使用 | 列出在线玩家 | |
| permission | permission <add\|remove> <UID> <权限节点> | * | 均可使用 | 添加或移除玩家的权限 | |
| position | position | | 仅客户端 | 获取当前坐标 | pos |
| remove | remove [多个角色在队伍中的序号] | player.remove | 仅客户端 | 强制将某个角色从当前队伍中移除。例如`remove 1 2`表示将1号和2号角色移除 | |
| reload | reload | server.reload | 均可使用 | 重载服务器配置 | |
| resetconst | resetconst [all] | player.resetconstellation | 仅客户端 | 重置当前角色的命座,重新登录即可生效 | resetconstellation |
| restart | restart | | 均可使用 | 重启服务端 | |

View File

@ -33,10 +33,13 @@ public class JoinCommand implements CommandHandler {
for (int i = 0; i < args.size(); i++) {
Avatar avatar = sender.getAvatars().getAvatarById(avatarIds.get(i));
if (avatar == null || sender.getTeamManager().getCurrentTeamInfo().contains(avatar)) {
if (avatar == null) {
CommandHandler.sendMessage(sender, translate("commands.generic.invalid.avatarId"));
return;
}
if (sender.getTeamManager().getCurrentTeamInfo().contains(avatar)){
continue;
}
sender.getTeamManager().getCurrentTeamInfo().addAvatar(avatar);
}

View File

@ -7,6 +7,8 @@ import emu.grasscutter.game.player.Player;
import emu.grasscutter.server.packet.send.PacketChangeMpTeamAvatarRsp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@ -17,11 +19,11 @@ public class RemoveCommand implements CommandHandler {
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
List<Integer> avatarIds = new ArrayList<>();
List<Integer> avatarIndexList = new ArrayList<>();
for (String arg : args) {
try {
int avatarId = Integer.parseInt(arg);
avatarIds.add(avatarId);
int avatarIndex = Integer.parseInt(arg);
avatarIndexList.add(avatarIndex);
} catch (Exception ignored) {
ignored.printStackTrace();
CommandHandler.sendMessage(sender, translate("commands.remove.invalid_index"));
@ -29,12 +31,14 @@ public class RemoveCommand implements CommandHandler {
}
}
for (int i = 0; i < avatarIds.size(); i++) {
if (avatarIds.get(i) > sender.getTeamManager().getCurrentTeamInfo().getAvatars().size() || avatarIds.get(i) <= 0) {
Collections.reverse(avatarIndexList);
for (int i = 0; i < avatarIndexList.size(); i++) {
if (avatarIndexList.get(i) > sender.getTeamManager().getCurrentTeamInfo().getAvatars().size() || avatarIndexList.get(i) <= 0) {
CommandHandler.sendMessage(sender, translate("commands.remove.invalid_index"));
return;
}
sender.getTeamManager().getCurrentTeamInfo().removeAvatar(avatarIds.get(i) - 1);
sender.getTeamManager().getCurrentTeamInfo().removeAvatar(avatarIndexList.get(i) - 1);
}
// Packet

View File

@ -238,9 +238,9 @@
"description": "Reload server config"
},
"remove": {
"usage": "Usage: remove [indexOfYourTeams] index start from 1",
"invalid_index": "index start from 1",
"description": "force remove avatar into your team"
"usage": "Usage: remove [indexOfYourTeam] index start from 1",
"invalid_index": "The index number is illegal. It starts from 1 and the maximum value is the number of roles in the team",
"description": "force remove avatar into your team. Such as `remove 1 2`."
},
"resetConst": {
"reset_all": "Reset all avatars' constellations.",
@ -380,7 +380,8 @@
"title": "Banner Details",
"available_five_stars": "Available 5-star Items",
"available_four_stars": "Available 4-star Items",
"available_three_stars": "Available 3-star Items"
"available_three_stars": "Available 3-star Items",
"template_missing": "data/gacha_details.html is missing."
}
}
}

View File

@ -237,9 +237,9 @@
"description": "重载配置文件和数据"
},
"remove": {
"usage": "用法: remove [indexOfYourTeams] 从1开始",
"invalid_index": "下标从1开始",
"description": "强制移除队内角色"
"usage": "用法: remove [多个角色在队伍中的序号] 序号从1开始",
"invalid_index": "序号不合法从1开始最大值为队内角色数量",
"description": "强制将某个角色从当前队伍中移除。例如`remove 1 2`表示将1号和2号角色从队伍中移除"
},
"resetConst": {
"reset_all": "重置所有角色的命座。",

View File

@ -229,9 +229,9 @@
"description": "重新加載設定檔和數據。"
},
"remove": {
"usage": "用法: remove [indexOfYourTeams] 从1开始",
"invalid_index": "下標從1開始",
"description": "强制移除對内角色"
"usage": "用法: remove [多個角色在隊伍中的序號] 序號从1开始",
"invalid_index": "序號不合法從1開始最大值為隊内角色數量",
"description": "强制移除對内角色,例如`remove 1 2`表示將1號和2號角色從隊伍中移除"
},
"resetConst": {
"reset_all": "重設所有角色的命座。",