forked from Grasscutters/Grasscutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c02ce9
commit 027bd28
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/emu/grasscutter/command/commands/CoopCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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."); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/emu/grasscutter/command/commands/TpallCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |