开源软件名称(OpenSource Name):MrGraversen/minecraft-rcon开源软件地址(OpenSource Url):https://github.com/MrGraversen/minecraft-rcon开源编程语言(OpenSource Language):Java 100.0%开源软件介绍(OpenSource Introduction):minecraft-rconA MineCraft RCON client in Java. AboutThe client is made to eventually automate some administrative actions of a MineCraft server. Every MineCraft command is exposed over RCON, and made available using this client. Some of the RCON commands are fairly complex in structure; this client will provide convenience methods and builders to help developers construct the correct commands to get the job done. The entire RCON command libarary is not implemeneted, but will be updated along the way. Feel free to PR and contribute with implementations of missing commands. This project will also provide some convenience code for working with the MineCraft target selectors (e.g. Using the convenience methods will synchronously access the RCON stack, but it is also possible to send raw, asynchronous RCON messages. Warning: There's a long-standing issue with MineCraft RCON which, for some reason, causes RCON commands to execute from a not-thread-safe queue (whereas the normal MineCraft action queue execute from a thread-safe queue) (https://bugs.mojang.com/browse/MC-72390). Sometimes when executing many commands rapidly, e.g. giving a player many items, the game server will throw a What is RCON?Originally invented by Valve for the Source Engine, it's a TCP/IP protocol for remote administration of game servers. The MineCraft RCON protocol is more-or-less an implementation of the Source Engine RCON protocol. It was introduced in beta update 1.9. InstallYou may use JitPack to install this from the GitHub releases.
Minecraft ConfigurationTo configure Minecraft RCON, you need to add/modify the following properties in your Minecraft server's
Once done, RCON is available using this client. Example 1The example is also available in the // Define a simple MinecraftRconService
// Assuming Minecraft server is running on localhost and password set to "test"
// If no port is specified, the default Minecraft RCON port will be used
final MinecraftRconService minecraftRconService = new MinecraftRconService(
RconDetails.localhost("test"),
ConnectOptions.defaults()
);
// Let's go!
minecraftRconService.connectBlocking(Duration.ofSeconds(3));
// After connecting, we can (crudely) fetch the underlying Minecraft RCON provider
final MinecraftRcon minecraftRcon = minecraftRconService.minecraftRcon().orElseThrow(IllegalStateException::new);
// Build a TellRaw command - first half of the desired message
final TellRawCommand tellRawCommand1 = new TellRawCommandBuilder()
.targeting(Selectors.ALL_PLAYERS)
.withText("It's dangerous to go alone - ")
.withColor(Colors.GRAY)
.italic()
.build();
// Build another TellRaw command - other half of the message
final TellRawCommand tellRawCommand2 = new TellRawCommandBuilder()
.targeting(Selectors.ALL_PLAYERS)
.withText("Take this!")
.withColor(Colors.DARK_AQUA)
.italic()
.build();
// We are able to transparently stitch together multiple 'tellraw' commands,
// combining their styles and texts into a composite viewing
final TellRawCompositeCommand tellRawCompositeCommand = new TellRawCompositeCommand(List.of(tellRawCommand1, tellRawCommand2));
// Let's also add a nice title to the players' screens
final TitleCommand titleCommand = new TitleCommandBuilder()
.targeting(Selectors.ALL_PLAYERS)
.atPosition(TitlePositions.TITLE)
.withColor(Colors.GREEN)
.withText("Welcome!")
.build();
// We'll give everyone a diamond sword - it's dangerous without
final GiveCommand giveCommand = new GiveCommand(
Selectors.ALL_PLAYERS.getSelectorString(), new MinecraftItem("diamond_sword"), 1
);
// Fire away!
minecraftRcon.sendAsync(tellRawCompositeCommand, titleCommand, giveCommand);
// Just for fun, let's also change some other things
// Set time of day to noon and clear weather - nice and sunny
final TimeCommand timeCommand = new TimeCommand(TimeLabels.NOON);
final WeatherCommand weatherCommand = new WeatherCommand(Weathers.CLEAR, Duration.ofHours(1).toSeconds());
minecraftRcon.sendAsync(timeCommand, weatherCommand);
// The players hate it when their creations are blown up by Creepers, lets' help them
final ICommand disableMobGriefing = GameRulesCommands.setGameRule(GameRules.MOB_GRIEFING, false);
minecraftRcon.sendAsync(disableMobGriefing); In-game result: Sample console output:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论