Add a broadcast command for announcements.
This commit is contained in:
parent
7f54ad07d6
commit
771fec3e46
4 changed files with 41 additions and 0 deletions
|
@ -6,6 +6,7 @@ import dev.zontreck.ase.commands.homes.DelHomeCommand;
|
|||
import dev.zontreck.ase.commands.homes.HomeCommand;
|
||||
import dev.zontreck.ase.commands.homes.HomesCommand;
|
||||
import dev.zontreck.ase.commands.homes.SetHomeCommand;
|
||||
import dev.zontreck.ase.commands.misc.BroadcastCommand;
|
||||
import dev.zontreck.ase.commands.misc.CreditsCommand;
|
||||
import dev.zontreck.ase.commands.misc.ShareItemCommand;
|
||||
import dev.zontreck.ase.commands.tpa.TPACancelCommand;
|
||||
|
@ -87,5 +88,13 @@ public class CommandRegistry {
|
|||
cmds.register(Commands.literal("asecredits")
|
||||
.requires(x -> x.getSender().isPermissionSet(CreditsCommand.PERMISSION))
|
||||
.executes(ctx -> CreditsCommand.execute(ctx.getSource())).build());
|
||||
|
||||
cmds.register(Commands.literal("broadcast")
|
||||
.requires(x -> x.getSender().isPermissionSet(BroadcastCommand.PERMISSION)
|
||||
|| x.getSender().isOp())
|
||||
.then(Commands.argument("message", StringArgumentType.greedyString())
|
||||
.executes(ctx -> BroadcastCommand.execute(ctx.getSource(),
|
||||
StringArgumentType.getString(ctx, "message"))))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package dev.zontreck.ase.commands.misc;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import net.kyori.adventure.text.Component;
|
||||
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) {
|
||||
ctx.getSender().getServer().broadcast(Component.text("[", NamedTextColor.YELLOW)
|
||||
.append(Component.text(ctx.getSender().getName(), NamedTextColor.DARK_RED))
|
||||
.append(Component.text("] ", NamedTextColor.YELLOW))
|
||||
.append(Component.text(message, NamedTextColor.DARK_PURPLE)));
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
|
@ -39,6 +39,9 @@ commands:
|
|||
asecredits:
|
||||
description: Displays the plugin's credits
|
||||
usage: "- /asecredits -"
|
||||
broadcast:
|
||||
description: Broadcasts a message
|
||||
usage: "- /broadcast [message] -"
|
||||
permissions:
|
||||
ase.commands.*:
|
||||
description: Allow all commands
|
||||
|
@ -88,3 +91,6 @@ permissions:
|
|||
ase.commands.asecredits:
|
||||
description: Allow /asecredits
|
||||
default: true
|
||||
ase.broadcast:
|
||||
description: Allows broadcasting messages
|
||||
default: false
|
||||
|
|
|
@ -38,6 +38,9 @@ commands:
|
|||
asecredits:
|
||||
description: Displays the plugin's credits
|
||||
usage: "- /asecredits -"
|
||||
broadcast:
|
||||
description: Broadcasts a message
|
||||
usage: "- /broadcast [message] -"
|
||||
permissions:
|
||||
ase.commands.*:
|
||||
description: Allow all commands
|
||||
|
@ -87,3 +90,6 @@ permissions:
|
|||
ase.commands.asecredits:
|
||||
description: Allow /asecredits
|
||||
default: true
|
||||
ase.broadcast:
|
||||
description: Allows broadcasting messages
|
||||
default: false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue