mirror of
https://github.com/JonasunderscoreJones/McWebserver.git
synced 2025-10-22 19:09:19 +02:00
Fixed mcweb command
- Fixed permission level - Fixed copy to clipboard issue - Cleaned up list code
This commit is contained in:
parent
1998000cf7
commit
dcf11d87fe
1 changed files with 3 additions and 8 deletions
|
@ -21,7 +21,7 @@ import static net.minecraft.server.command.CommandManager.*;
|
||||||
|
|
||||||
public class McWebCommand {
|
public class McWebCommand {
|
||||||
public static void registerCommands() {
|
public static void registerCommands() {
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(literal("mcweb")
|
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(literal("mcweb").requires(serverCommandSource -> serverCommandSource.hasPermissionLevel(2))
|
||||||
.then(literal("token")
|
.then(literal("token")
|
||||||
.then(literal("new")
|
.then(literal("new")
|
||||||
.then(CommandManager.argument("Name", StringArgumentType.word())
|
.then(CommandManager.argument("Name", StringArgumentType.word())
|
||||||
|
@ -44,7 +44,7 @@ public class McWebCommand {
|
||||||
if (context.getSource().isExecutedByPlayer()) {
|
if (context.getSource().isExecutedByPlayer()) {
|
||||||
// get the player name
|
// get the player name
|
||||||
String playerName = Objects.requireNonNull(context.getSource().getPlayer()).getName().getString();
|
String playerName = Objects.requireNonNull(context.getSource().getPlayer()).getName().getString();
|
||||||
MC_SERVER.getCommandManager().executeWithPrefix(MC_SERVER.getCommandSource(), "tellraw " + playerName + " [\"\",\"Token (will only show once): \",\"\\n\",\"[\",{\"text\":\"" + result + "\",\"color\":\"green\",\"clickEvent\":{\"action\":\"copy_to_clipboard\",\"value\":\"\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to Copy to Clipboard\"]}},\"]\"]");
|
MC_SERVER.getCommandManager().executeWithPrefix(MC_SERVER.getCommandSource(), "tellraw " + playerName + " [\"\",\"Token: [\",{\"text\":\"" + result + "\",\"color\":\"green\",\"clickEvent\":{\"action\":\"copy_to_clipboard\",\"value\":\"" + result + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"contents\":[\"Click to Copy to Clipboard\"]}},\"]\"]");
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -58,12 +58,7 @@ public class McWebCommand {
|
||||||
}))))
|
}))))
|
||||||
.then(literal("list")
|
.then(literal("list")
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
try {
|
context.getSource().sendFeedback(() -> Text.of(listTokens()), false);
|
||||||
context.getSource().sendFeedback(() -> Text.of(listTokens()), false);
|
|
||||||
return 1;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}))
|
}))
|
||||||
.then(literal("delete")
|
.then(literal("delete")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue