mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-23 07:57:58 -05:00
/rainbow command (#347)
This commit is contained in:
parent
c052c8c79c
commit
91371ba990
4 changed files with 40 additions and 2 deletions
|
@ -6,6 +6,7 @@ Extras is a Bukkit plugin that that adds extra functionality to the Kaboom serve
|
|||
|
||||
| Command | Aliases | Permission | Description |
|
||||
|-----------------------|---------------------|-----------------------------|---------------------------------------------------------|
|
||||
| /broadcastrainbow | /bcr | extras.broadcastrainbow | Broadcasts a rainbow message |
|
||||
| /broadcastminimessage | /broadcastmm, /bcmm | extras.broadcastminimessage | Broadcasts a deserialized MiniMessage component |
|
||||
| /broadcastraw | /bcraw, /tellraw | extras.broadcastraw | Broadcasts raw text to the server |
|
||||
| /broadcastvanilla | /bcv | extras.broadcastvanilla | Broadcasts text in vanilla style |
|
||||
|
|
|
@ -50,6 +50,7 @@ public final class Main extends JavaPlugin {
|
|||
prefixConfig = YamlConfiguration.loadConfiguration(prefixConfigFile);
|
||||
|
||||
/* Commands */
|
||||
this.getCommand("broadcastrainbow").setExecutor(new CommandBroadcastRainbow());
|
||||
this.getCommand("broadcastminimessage").setExecutor(new CommandBroadcastMM());
|
||||
this.getCommand("broadcastvanilla").setExecutor(new CommandBroadcastVanilla());
|
||||
this.getCommand("clearchat").setExecutor(new CommandClearChat());
|
||||
|
@ -69,7 +70,7 @@ public final class Main extends JavaPlugin {
|
|||
this.getCommand("spidey").setExecutor(new CommandSpidey());
|
||||
this.getCommand("tellraw").setExecutor(new CommandTellraw());
|
||||
this.getCommand("username").setExecutor(new CommandUsername());
|
||||
|
||||
|
||||
/* Block-related modules */
|
||||
BlockPhysics.init(this);
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package pw.kaboom.extras.commands;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class CommandBroadcastRainbow implements CommandExecutor {
|
||||
private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage();
|
||||
|
||||
public boolean onCommand(final @Nonnull CommandSender sender,
|
||||
final @Nonnull Command command,
|
||||
final @Nonnull String label,
|
||||
final String[] args) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(Component
|
||||
.text("Usage: /" + label + " <message ..>",
|
||||
NamedTextColor.RED));
|
||||
return true;
|
||||
}
|
||||
final String strippedTags = MINI_MESSAGE.stripTags(String.join(" ", args));
|
||||
final Component component = MINI_MESSAGE.deserialize("<rainbow>" + strippedTags);
|
||||
Bukkit.getServer().broadcast(component);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,10 @@ commands:
|
|||
aliases: [ broadcastmm, bcmm ]
|
||||
description: Broadcasts a deserialized MiniMessage component
|
||||
permission: extras.broadcastminimessage
|
||||
broadcastrainbow:
|
||||
aliases: [ bcr ]
|
||||
description: Broadcasts a rainbow message
|
||||
permission: extras.broadcastrainbow
|
||||
broadcastraw:
|
||||
aliases: [ bcraw, tellraw ]
|
||||
description: Broadcasts raw text to the server
|
||||
|
@ -72,4 +76,4 @@ commands:
|
|||
permission: extras.spidey
|
||||
username:
|
||||
description: Changes your username on the server
|
||||
permission: extras.username
|
||||
permission: extras.username
|
||||
|
|
Loading…
Reference in a new issue