diff --git a/README.md b/README.md index f327996fc..909aa6cc5 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ There is a dummy user named "Server" in every player's friends list that you can | -------------- | ------------------------------------------------- | ------------------------- | ------------ | ------------------------------------------------------------ | ----------------------------------------------- | | account | account [UID] | | Server only | Creates an account with the specified username and the in-game UID for that account. The UID will be auto generated if not set. | | | broadcast | broadcast | server.broadcast | Both side | Sends a message to all the players. | b | +| coop | coop | server.coop | Both side | Forces someone to join the world of others. | | | changescene | changescene | player.changescene | Client only | Switch scenes by scene ID. | scene | | clearartifacts | clearartifacts | player.clearartifacts | Client only | Deletes all unequipped and unlocked level 0 artifacts, including 5-star rarity ones from your inventory. | clearart | | clearweapons | clearweapons | player.clearweapons | Client only | Deletes all unequipped and unlocked weapons, including 5-star rarity ones from your inventory. | clearwpns | @@ -134,6 +135,7 @@ There is a dummy user named "Server" in every player's friends list that you can | stop | stop | server.stop | Both side | Stops the server | | | talent | talent | player.settalent | Client only | Sets talent level for your currently selected character | | | teleport | teleport | player.teleport | Client only | Change the player's position. | tp | +| tpall | | player.tpall | Client only | Teleports all players in your world to your position | | | weather | weather | player.weather | Client only | Changes the weather | w | ### Bonus diff --git a/README_zh-CN.md b/README_zh-CN.md index c1e90c27d..97f332f3a 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -109,6 +109,7 @@ chmod +x gradlew | -------------- | -------------------------------------------- | ------------------------- | -------- | ------------------------------------------ | ----------------------------------------------- | | account | account <用户名> [uid] | | 仅服务端 | 通过指定用户名和uid增删账户 | | | broadcast | broadcast <消息内容> | server.broadcast | 均可使用 | 给所有玩家发送公告 | b | +| coop | coop <目标uid> | server.coop | 均可使用 | 强制某位玩家进入指定玩家的多人世界 | | | changescene | changescene <场景ID> | player.changescene | 仅客户端 | 切换到指定场景 | scene | | clearartifacts | clearartifacts | player.clearartifacts | 仅客户端 | 删除所有未装备及未解锁的圣遗物,包括五星 | clearart | | clearweapons | clearweapons | player.clearweapons | 仅客户端 | 删除所有未装备及未解锁的武器,包括五星 | clearwp | @@ -135,6 +136,7 @@ chmod +x gradlew | stop | stop | server.stop | 均可使用 | 停止服务器 | | | talent | talent <天赋ID> <等级> | player.settalent | 仅客户端 | 设置当前角色的天赋等级 | | | teleport | teleport | player.teleport | 仅客户端 | 传送玩家到指定坐标 | tp | +| tpall | | player.tpall | 仅客户端 | 传送多人世界中所有的玩家到自身地点 | | | weather | weather <天气ID> <气候ID> | player.weather | 仅客户端 | 改变天气 | w | ### 额外功能 diff --git a/src/main/java/emu/grasscutter/command/commands/CoopCommand.java b/src/main/java/emu/grasscutter/command/commands/CoopCommand.java new file mode 100644 index 000000000..0dec6839e --- /dev/null +++ b/src/main/java/emu/grasscutter/command/commands/CoopCommand.java @@ -0,0 +1,36 @@ +package emu.grasscutter.command.commands; + +import emu.grasscutter.command.Command; +import emu.grasscutter.command.CommandHandler; +import emu.grasscutter.game.player.Player; + +import java.util.List; + +@Command(label = "coop", usage = "coop", + description = "Forces someone to join the world of others", permission = "server.coop") +public class CoopCommand implements CommandHandler { + @Override + public void execute(Player sender, List args) { + if (args.size() < 2) { + CommandHandler.sendMessage(sender, "Usage: coop "); + return; + } + try { + int tid = Integer.parseInt(args.get(0)); + int hostId = Integer.parseInt(args.get(1)); + Player host = sender.getServer().getPlayerByUid(hostId); + Player want = sender.getServer().getPlayerByUid(tid); + if (host == null || want == null) { + CommandHandler.sendMessage(sender, "Player is offline."); + return; + } + if (want.isInMultiplayer()) { + sender.getServer().getMultiplayerManager().leaveCoop(want); + } + sender.getServer().getMultiplayerManager().applyEnterMp(want, hostId); + sender.getServer().getMultiplayerManager().applyEnterMpReply(host, tid, true); + } catch (Exception e) { + CommandHandler.sendMessage(sender, "Player id is not valid."); + } + } +} diff --git a/src/main/java/emu/grasscutter/command/commands/TpallCommand.java b/src/main/java/emu/grasscutter/command/commands/TpallCommand.java new file mode 100644 index 000000000..20236c729 --- /dev/null +++ b/src/main/java/emu/grasscutter/command/commands/TpallCommand.java @@ -0,0 +1,31 @@ +package emu.grasscutter.command.commands; + +import emu.grasscutter.command.Command; +import emu.grasscutter.command.CommandHandler; +import emu.grasscutter.game.player.Player; +import emu.grasscutter.utils.Position; + +import java.util.List; + +@Command(label = "tpall", usage = "tpall", + description = "Teleports all players in your world to your position", permission = "player.tpall") +public class TpallCommand implements CommandHandler { + @Override + public void execute(Player sender, List args) { + if (sender == null) { + CommandHandler.sendMessage(null, "Run this command in-game."); + return; + } + if (!sender.getWorld().isMultiplayer()) { + CommandHandler.sendMessage(sender, "You only can use this command in MP mode."); + return; + } + for (Player gp : sender.getWorld().getPlayers()) { + if (gp.equals(sender)) + continue; + Position pos = sender.getPos(); + + gp.getWorld().transferPlayerToScene(gp, sender.getSceneId(), pos); + } + } +}