mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-25 15:22:16 +00:00
Add command /coop and /tpall
This commit is contained in:
parent
0c02ce9f63
commit
027bd28afb
@ -108,6 +108,7 @@ There is a dummy user named "Server" in every player's friends list that you can
|
||||
| -------------- | ------------------------------------------------- | ------------------------- | ------------ | ------------------------------------------------------------ | ----------------------------------------------- |
|
||||
| account | account <create\|delete> <username> [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 <message> | server.broadcast | Both side | Sends a message to all the players. | b |
|
||||
| coop | coop <playerId> <target playerId> | server.coop | Both side | Forces someone to join the world of others. | |
|
||||
| changescene | changescene <scene id> | 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 <talentID> <value> | player.settalent | Client only | Sets talent level for your currently selected character | |
|
||||
| teleport | teleport <x> <y> <z> | 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 <weatherID> <climateID> | player.weather | Client only | Changes the weather | w |
|
||||
|
||||
### Bonus
|
||||
|
@ -109,6 +109,7 @@ chmod +x gradlew
|
||||
| -------------- | -------------------------------------------- | ------------------------- | -------- | ------------------------------------------ | ----------------------------------------------- |
|
||||
| account | account <create\|delete> <用户名> [uid] | | 仅服务端 | 通过指定用户名和uid增删账户 | |
|
||||
| broadcast | broadcast <消息内容> | server.broadcast | 均可使用 | 给所有玩家发送公告 | b |
|
||||
| coop | coop <uid> <目标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 <x> <y> <z> | player.teleport | 仅客户端 | 传送玩家到指定坐标 | tp |
|
||||
| tpall | | player.tpall | 仅客户端 | 传送多人世界中所有的玩家到自身地点 | |
|
||||
| weather | weather <天气ID> <气候ID> | player.weather | 仅客户端 | 改变天气 | w |
|
||||
|
||||
### 额外功能
|
||||
|
@ -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<String> args) {
|
||||
if (args.size() < 2) {
|
||||
CommandHandler.sendMessage(sender, "Usage: coop <playerId> <target playerId>");
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
@ -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<String> 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user