-
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.
[skip]feat(commands): add rcon command support
- Loading branch information
Showing
5 changed files
with
49 additions
and
12 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
34 changes: 34 additions & 0 deletions
34
src/main/java/fun/suya/suisuroru/commands/execute/othercommands/sub/Rcon.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,34 @@ | ||
package fun.suya.suisuroru.commands.execute.othercommands.sub; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import static fun.suya.suisuroru.rcon.RconCommandExecute.executeRconCommand; | ||
|
||
public class Rcon implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { | ||
sender.sendMessage("此命令为测试命令,不显示使用方法"); | ||
String address = args[0]; | ||
String[] parts = address.split(":"); | ||
String IP; | ||
int port; | ||
if (parts.length == 2) { | ||
IP = parts[0]; | ||
port = Integer.parseInt(parts[1]); | ||
} else { | ||
sender.sendMessage("请输入正确的IP地址和端口号"); | ||
return true; | ||
} | ||
String psd = args[1]; | ||
StringBuilder CommandBuilder = new StringBuilder(); | ||
for (int i = 2; i < args.length; i++) { | ||
CommandBuilder.append(args[i]).append(" "); | ||
} | ||
String full_command = CommandBuilder.toString().trim(); | ||
sender.sendMessage(executeRconCommand(IP, port, psd, full_command)); | ||
return true; | ||
} | ||
} |
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