Make the /getjson command description truthful and add the MiniMessage functionality in /getjsonmm

This commit is contained in:
Allink 2023-04-02 04:00:49 +01:00
parent 4bbec866ff
commit 4d2455d45b
No known key found for this signature in database
4 changed files with 73 additions and 50 deletions

View file

@ -4,26 +4,27 @@ Extras is a Bukkit plugin that that adds extra functionality to the Kaboom serve
## Commands
| Command | Aliases | Permission | Description |
|-----------------------|----------------------------------------------|-----------------------------|---------------------------------------------------------------|
| /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 |
| /clearchat | /cc | extras.clearchat | Clears messages from the chat |
| /console | | extras.console | Broadcasts a message as the console |
| /destroyentities | /de | extras.destroyentities | Destroys all entities in every world |
| /enchantall | | extras.enchantall | Adds every enchantment to a held item |
| /getjson | /gj, /gmm | extras.getjson | Gets the JSON of a deserialized MiniMessage/legacy component |
| /jumpscare | /scare | extras.jumpscare | Scares a player |
| /kaboom | | extras.kaboom | I wonder... |
| /ping | /ms, /delay | extras.ping | Gets your ping |
| /prefix | /rank, /tag | extras.prefix | Changes your tag |
| /pumpkin | | extras.pumpkin | Places a pumpkin on a player's head |
| /serverinfo | /specs | extras.serverinfo | Shows detailed server information |
| /skin | | extras.skin | Changes your skin |
| /spawn | | extras.spawn | Teleports you to spawn |
| /spidey | | extras.spidey | Annoying little spider... |
| /username | | extras.username | Changes your username on the server |
| Command | Aliases | Permission | Description |
|-----------------------|---------------------|-----------------------------|---------------------------------------------------------|
| /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 |
| /clearchat | /cc | extras.clearchat | Clears messages from the chat |
| /console | | extras.console | Broadcasts a message as the console |
| /destroyentities | /de | extras.destroyentities | Destroys all entities in every world |
| /enchantall | | extras.enchantall | Adds every enchantment to a held item |
| /getjson | /gj | extras.getjson | Gets the JSON of a deserialized legacy component |
| /getjsonmm | /gmm | extras.getjsonmm | Gets the JSON of a deserialized MiniMessage component |
| /jumpscare | /scare | extras.jumpscare | Scares a player |
| /kaboom | | extras.kaboom | I wonder... |
| /ping | /ms, /delay | extras.ping | Gets your ping |
| /prefix | /rank, /tag | extras.prefix | Changes your tag |
| /pumpkin | | extras.pumpkin | Places a pumpkin on a player's head |
| /serverinfo | /specs | extras.serverinfo | Shows detailed server information |
| /skin | | extras.skin | Changes your skin |
| /spawn | | extras.spawn | Teleports you to spawn |
| /spidey | | extras.spidey | Annoying little spider... |
| /username | | extras.username | Changes your username on the server |
## Compiling

View file

@ -1,50 +1,27 @@
package pw.kaboom.extras;
import java.io.File;
import java.util.Collections;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.block.BlockFace;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import pw.kaboom.extras.commands.CommandBroadcastMM;
import pw.kaboom.extras.commands.CommandBroadcastVanilla;
import pw.kaboom.extras.commands.CommandClearChat;
import pw.kaboom.extras.commands.CommandConsole;
import pw.kaboom.extras.commands.CommandDestroyEntities;
import pw.kaboom.extras.commands.CommandEnchantAll;
import pw.kaboom.extras.commands.CommandGetJSON;
import pw.kaboom.extras.commands.CommandJumpscare;
import pw.kaboom.extras.commands.CommandKaboom;
import pw.kaboom.extras.commands.CommandPing;
import pw.kaboom.extras.commands.CommandPrefix;
import pw.kaboom.extras.commands.CommandPumpkin;
import pw.kaboom.extras.commands.CommandServerInfo;
import pw.kaboom.extras.commands.CommandSkin;
import pw.kaboom.extras.commands.CommandSpawn;
import pw.kaboom.extras.commands.CommandSpidey;
import pw.kaboom.extras.commands.CommandTellraw;
import pw.kaboom.extras.commands.CommandUsername;
import pw.kaboom.extras.commands.*;
import pw.kaboom.extras.modules.block.BlockCheck;
import pw.kaboom.extras.modules.block.BlockPhysics;
import pw.kaboom.extras.modules.entity.EntityExplosion;
import pw.kaboom.extras.modules.entity.EntityKnockback;
import pw.kaboom.extras.modules.entity.EntitySpawn;
import pw.kaboom.extras.modules.entity.EntityTeleport;
import pw.kaboom.extras.modules.player.PlayerChat;
import pw.kaboom.extras.modules.player.PlayerCommand;
import pw.kaboom.extras.modules.player.PlayerConnection;
import pw.kaboom.extras.modules.player.PlayerDamage;
import pw.kaboom.extras.modules.player.PlayerInteract;
import pw.kaboom.extras.modules.player.PlayerPrefix;
import pw.kaboom.extras.modules.player.PlayerRecipe;
import pw.kaboom.extras.modules.player.PlayerTeleport;
import pw.kaboom.extras.modules.player.*;
import pw.kaboom.extras.modules.server.ServerCommand;
import pw.kaboom.extras.modules.server.ServerGameRule;
import pw.kaboom.extras.modules.server.ServerTabComplete;
import pw.kaboom.extras.modules.server.ServerTick;
import java.io.File;
import java.util.Collections;
public final class Main extends JavaPlugin {
private File prefixConfigFile;
private FileConfiguration prefixConfig;
@ -80,6 +57,7 @@ public final class Main extends JavaPlugin {
this.getCommand("destroyentities").setExecutor(new CommandDestroyEntities());
this.getCommand("enchantall").setExecutor(new CommandEnchantAll());
this.getCommand("getjson").setExecutor(new CommandGetJSON());
this.getCommand("getjsonmm").setExecutor(new CommandGetJSONMM());
this.getCommand("jumpscare").setExecutor(new CommandJumpscare());
this.getCommand("kaboom").setExecutor(new CommandKaboom());
this.getCommand("ping").setExecutor(new CommandPing());

View file

@ -0,0 +1,40 @@
package pw.kaboom.extras.commands;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import javax.annotation.Nonnull;
public final class CommandGetJSONMM implements CommandExecutor {
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 message = String.join(" ", args);
Component createdComponent = MiniMessage.miniMessage()
.deserialize(message);
String asJson = GsonComponentSerializer.gson()
.serialize(createdComponent);
Component feedback = Component.empty()
.append(Component.text("Your component as JSON (click to copy): "))
.append(Component.text(asJson, NamedTextColor.GREEN))
.clickEvent(ClickEvent.copyToClipboard(asJson));
sender.sendMessage(feedback);
return true;
}
}

View file

@ -32,9 +32,13 @@ commands:
description: Adds every enchantment to a held item
permission: extras.enchantall
getjson:
aliases: [ gj, gmm ]
description: Gets the JSON of a deserialized MiniMessage/legacy component
aliases: [ gj ]
description: Gets the JSON of a deserialized legacy component
permission: extras.getjson
getjsonmm:
aliases: [ gmm ]
description: Gets the JSON of a deserialized MiniMessage component
permission: extras.getjsonmm
jumpscare:
aliases: scare
description: Scares a player