Adds broadcast as

This commit is contained in:
zontreck 2025-04-06 11:59:50 -07:00
parent 771fec3e46
commit 71d6eb6af7
4 changed files with 26 additions and 3 deletions

View file

@ -94,7 +94,18 @@ public class CommandRegistry {
|| x.getSender().isOp())
.then(Commands.argument("message", StringArgumentType.greedyString())
.executes(ctx -> BroadcastCommand.execute(ctx.getSource(),
StringArgumentType.getString(ctx, "message"))))
StringArgumentType.getString(ctx, "message"),
ctx.getSource().getSender().getName())))
.build());
cmds.register(Commands.literal("broadcastas")
.requires(x -> x.getSender().isPermissionSet(BroadcastCommand.PERMISSION)
|| x.getSender().isOp())
.then(Commands.argument("name", StringArgumentType.string()))
.then(Commands.argument("message", StringArgumentType.greedyString())
.executes(ctx -> BroadcastCommand.execute(ctx.getSource(),
StringArgumentType.getString(ctx, "message"),
StringArgumentType.getString(ctx, "name"))))
.build());
}
}

View file

@ -9,9 +9,9 @@ import net.kyori.adventure.text.format.NamedTextColor;
public class BroadcastCommand {
public static final String PERMISSION = "ase.broadcast";
public static int execute(CommandSourceStack ctx, String message) {
public static int execute(CommandSourceStack ctx, String message, String name) {
ctx.getSender().getServer().broadcast(Component.text("[", NamedTextColor.YELLOW)
.append(Component.text(ctx.getSender().getName(), NamedTextColor.DARK_RED))
.append(Component.text(name, NamedTextColor.DARK_RED))
.append(Component.text("] ", NamedTextColor.YELLOW))
.append(Component.text(message, NamedTextColor.DARK_PURPLE)));

View file

@ -42,6 +42,9 @@ commands:
broadcast:
description: Broadcasts a message
usage: "- /broadcast [message] -"
broadcastas:
description: Broadcasts a message with a defined name
usage: "- /broadcastas [name] [message] -"
permissions:
ase.commands.*:
description: Allow all commands
@ -94,3 +97,6 @@ permissions:
ase.broadcast:
description: Allows broadcasting messages
default: false
ase.broadcastas:
description: Allows broadcasting messages with a defined name
default: false

View file

@ -41,6 +41,9 @@ commands:
broadcast:
description: Broadcasts a message
usage: "- /broadcast [message] -"
broadcastas:
description: Broadcasts a message with a defined name
usage: "- /broadcastas [name] [message] -"
permissions:
ase.commands.*:
description: Allow all commands
@ -93,3 +96,6 @@ permissions:
ase.broadcast:
description: Allows broadcasting messages
default: false
ase.broadcastas:
description: Allows broadcasting messages with a defined name
default: false