mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-06 06:41:44 +00:00
use minimessage for various messages
This commit is contained in:
15
pom.xml
15
pom.xml
@@ -101,7 +101,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.18.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -120,6 +120,19 @@
|
||||
<groupId>lol.hyper</groupId>
|
||||
<artifactId>github-release-api</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.10.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
<version>4.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -21,6 +21,8 @@ import lol.hyper.githubreleaseapi.GitHubRelease;
|
||||
import lol.hyper.githubreleaseapi.GitHubReleaseAPI;
|
||||
import lol.hyper.toolstats.commands.CommandToolStats;
|
||||
import lol.hyper.toolstats.events.*;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -82,8 +84,12 @@ public final class ToolStats extends JavaPlugin {
|
||||
public FileConfiguration config;
|
||||
public final int CONFIG_VERSION = 3;
|
||||
|
||||
private BukkitAudiences adventure;
|
||||
public MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.adventure = BukkitAudiences.create(this);
|
||||
if (!configFile.exists()) {
|
||||
this.saveResource("config.yml", true);
|
||||
logger.info("Copying default config!");
|
||||
@@ -254,4 +260,11 @@ public final class ToolStats extends JavaPlugin {
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
|
||||
public BukkitAudiences getAdventure() {
|
||||
if(this.adventure == null) {
|
||||
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
|
||||
}
|
||||
return this.adventure;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ package lol.hyper.toolstats.commands;
|
||||
|
||||
import lol.hyper.toolstats.ToolStats;
|
||||
import lol.hyper.toolstats.UUIDDataType;
|
||||
import org.bukkit.*;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
@@ -36,28 +39,30 @@ import java.util.*;
|
||||
public class CommandToolStats implements TabExecutor {
|
||||
|
||||
private final ToolStats toolStats;
|
||||
private final BukkitAudiences audiences;
|
||||
|
||||
public CommandToolStats(ToolStats toolStats) {
|
||||
this.toolStats = toolStats;
|
||||
this.audiences = toolStats.getAdventure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!sender.hasPermission("toolstats.use")) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission for this command.");
|
||||
audiences.sender(sender).sendMessage(Component.text("You do not have permission for this command.").color(NamedTextColor.RED));
|
||||
return true;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.GREEN + "ToolStats version " + toolStats.getDescription().getVersion() + ". Created by hyperdefined.");
|
||||
audiences.sender(sender).sendMessage(Component.text("ToolStats version " + toolStats.getDescription().getVersion() + ". Created by hyperdefined.").color(NamedTextColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
switch (args[0]) {
|
||||
case "reload": {
|
||||
if (sender.isOp() || sender.hasPermission("toolstats.reload")) {
|
||||
toolStats.loadConfig();
|
||||
sender.sendMessage(ChatColor.GREEN + "Configuration reloaded!");
|
||||
audiences.sender(sender).sendMessage(Component.text("Configuration reloaded!").color(NamedTextColor.GREEN));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission for this command.");
|
||||
audiences.sender(sender).sendMessage(Component.text("You do not have permission for this command.").color(NamedTextColor.RED));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -66,21 +71,21 @@ public class CommandToolStats implements TabExecutor {
|
||||
Player player = (Player) sender;
|
||||
ItemStack heldItem = player.getInventory().getItemInMainHand();
|
||||
if (heldItem.getType() == Material.AIR) {
|
||||
sender.sendMessage(ChatColor.RED + "You must hold an item!");
|
||||
audiences.sender(sender).sendMessage(Component.text("You must hold an item!").color(NamedTextColor.RED));
|
||||
return true;
|
||||
}
|
||||
fixItemLore(heldItem, player);
|
||||
sender.sendMessage(ChatColor.GREEN + "The lore was reset!");
|
||||
audiences.sender(sender).sendMessage(Component.text("The lore was reset!").color(NamedTextColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + "This will remove ALL current lore from the held item and replace it with the correct lore.");
|
||||
sender.sendMessage(ChatColor.GREEN + "The item owner will be who ever is currently running this command.");
|
||||
sender.sendMessage(ChatColor.GREEN + "Only use this if the tags on the tool are incorrect.");
|
||||
sender.sendMessage(ChatColor.GREEN + "Type /toolstats reset confirm to confirm this.");
|
||||
audiences.sender(sender).sendMessage(Component.text("This will remove ALL current lore from the held item and replace it with the correct lore.").color(NamedTextColor.GREEN));
|
||||
audiences.sender(sender).sendMessage(Component.text("The item owner will be who ever is currently running this command.").color(NamedTextColor.GREEN));
|
||||
audiences.sender(sender).sendMessage(Component.text("Only use this if the tags on the tool are incorrect.").color(NamedTextColor.GREEN));
|
||||
audiences.sender(sender).sendMessage(Component.text("Type /toolstats reset confirm to confirm this.").color(NamedTextColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid sub-command.");
|
||||
audiences.sender(sender).sendMessage(Component.text("Invalid sub-command.").color(NamedTextColor.RED));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -15,4 +15,8 @@ permissions:
|
||||
default: true
|
||||
toolstats.reload:
|
||||
description: Allows the usage of /toolstats reload
|
||||
default: op
|
||||
default: op
|
||||
libraries:
|
||||
- lol.hyper:github-release-api:1.0.1
|
||||
- net.kyori:adventure-text-minimessage:4.10.1
|
||||
- net.kyori:adventure-platform-bukkit:4.1.0
|
||||
Reference in New Issue
Block a user