From 446b0e27ba7e1b2fb4e90776ffc4e6df0a9295a0 Mon Sep 17 00:00:00 2001 From: 7man7LMYT <67489949+7man7LMYT@users.noreply.github.com> Date: Sat, 30 Jul 2022 20:42:01 -0700 Subject: [PATCH] Redo most of the plugin (#8) * Main changes * Update README and also update the version checker Due to how the plugin reads the config, it falls back onto the default value if the value is not present. To get around this issue, I made slot #0 the slot that can't be removed. This can reduce issues due to it being a single slot and can simply have it's material set to 'air'. --- .gitignore | 1 + README.md | 11 +- pom.xml | 135 ++++++++++------- .../gamersclub/customstats/CustomStats.java | 57 +++++++ .../gamersclub/customstats/GuiListener.java | 26 ++++ .../gamersclub/customstats/StatsCommand.java | 142 ++++++++++++++++++ .../customstats}/bStats/Metrics.java | 6 +- .../customstats/menus/StatForm.java | 37 +++++ .../customstats/util/PlaceholderManager.java | 37 +++++ .../customstats/util}/UpdateChecker.java | 6 +- .../me/stats/CustomStats/CustomStats.java | 32 ---- .../me/stats/CustomStats/GuiListener.java | 23 --- .../me/stats/CustomStats/StatsCommand.java | 84 ----------- src/main/resources/config.yml | 86 ++++++++--- src/main/resources/plugin.yml | 12 +- 15 files changed, 468 insertions(+), 227 deletions(-) create mode 100644 src/main/java/me/gamersclub/customstats/CustomStats.java create mode 100644 src/main/java/me/gamersclub/customstats/GuiListener.java create mode 100644 src/main/java/me/gamersclub/customstats/StatsCommand.java rename src/main/java/me/{stats/CustomStats => gamersclub/customstats}/bStats/Metrics.java (99%) create mode 100644 src/main/java/me/gamersclub/customstats/menus/StatForm.java create mode 100644 src/main/java/me/gamersclub/customstats/util/PlaceholderManager.java rename src/main/java/me/{stats/CustomStats => gamersclub/customstats/util}/UpdateChecker.java (85%) delete mode 100644 src/main/java/me/stats/CustomStats/CustomStats.java delete mode 100644 src/main/java/me/stats/CustomStats/GuiListener.java delete mode 100644 src/main/java/me/stats/CustomStats/StatsCommand.java diff --git a/.gitignore b/.gitignore index d447412..6e32de0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ .project .classpath /out/ +dependency-reduced-pom.xml diff --git a/README.md b/README.md index cfb32f3..5487ad1 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # CustomStats -[![discord](https://discord.com/api/guilds/339280188926066689/embed.png)](https://discord.gg/Z5MyDwp) [![](https://img.shields.io/badge/contributions-welcome-brightgreen)](https://github.com/7man7LMYT/CustomStats)[![HitCount](http://hits.dwyl.com/7man7LMYT/CustomStats.svg)](http://hits.dwyl.com/7man7LMYT/CustomStats) -bStats: https://bstats.org/plugin/bukkit/CustomStats/10123 +[![Discord Server](https://discord.com/api/guilds/339280188926066689/embed.png)](https://discord.gg/Z5MyDwp) +[![](https://img.shields.io/badge/contributions-welcome-brightgreen)](https://github.com/7man7LMYT/CustomStats) +[![HitCount](http://hits.dwyl.com/7man7LMYT/CustomStats.svg)](http://hits.dwyl.com/7man7LMYT/CustomStats) +[![Spigot Version](https://img.shields.io/spiget/version/88300?label=CustomStats&color=red)](https://www.spigotmc.org/resources/88300/) +[![CustomStats Wiki](https://img.shields.io/badge/CustomStats-wiki-blue)](https://7man7lmyt.github.io/CustomStats/) -Spigot Link: https://www.spigotmc.org/resources/customstats.88300/ +A Minecraft anarchy server oriented plugin that adds /stats. -An anarchy server oriented plugin that adds /stats. +Check out our [bStats page](https://bstats.org/plugin/bukkit/CustomStats/10123)! diff --git a/pom.xml b/pom.xml index 448e4f4..c516ef4 100644 --- a/pom.xml +++ b/pom.xml @@ -2,62 +2,93 @@ - 4.0.0 + 4.0.0 - me.stats - CustomStats - 1.2.1 - jar + me.gamersclub.customstats + CustomStats + 2.0.0 + jar - CustomStats + + 8 + 8 + - An anarchy server oriented plugin that adds /stats. + CustomStats + An anarchy server oriented plugin that adds /stats. - - - - org.apache.maven.plugins - maven-shade-plugin - 3.1.0 - - - package - - shade - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - - - - - - src/main/resources - true - - - + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + + org.bstats + + me.gamersclub.customstats.bStats + + + + + + package + + shade + + + + + + - - - spigotmc-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + placeholderapi + https://repo.extendedclip.com/content/repositories/placeholderapi/ + + + opencollab-snapshot + https://repo.opencollab.dev/maven-snapshots/ + + - - - org.spigotmc - spigot-api - 1.16.2-R0.1-SNAPSHOT - provided - - + + + org.spigotmc + spigot-api + 1.19.1-R0.1-SNAPSHOT + provided + + + org.jetbrains + annotations + 23.0.0 + compile + + + org.geysermc.floodgate + api + 2.2.0-SNAPSHOT + provided + + + me.clip + placeholderapi + 2.11.2 + provided + + + org.bstats + bstats-bukkit + 3.0.0 + compile + + diff --git a/src/main/java/me/gamersclub/customstats/CustomStats.java b/src/main/java/me/gamersclub/customstats/CustomStats.java new file mode 100644 index 0000000..02b4d8c --- /dev/null +++ b/src/main/java/me/gamersclub/customstats/CustomStats.java @@ -0,0 +1,57 @@ +package me.gamersclub.customstats; + +import me.gamersclub.customstats.bStats.Metrics; +import me.gamersclub.customstats.util.UpdateChecker; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.logging.Logger; + +public class CustomStats extends JavaPlugin { + public final Logger log = this.getLogger(); + public boolean floodgateIsInstalled = false; + public boolean placeholderAPIInstalled = false; + @SuppressWarnings("CanBeFinal") + List uuidsWithGuiOpen = new ArrayList<>(); + + public void onEnable() { + log.info("CustomStats v2.0.0"); + + File configFile = new File(getDataFolder(), "config.yml"); + if (!configFile.exists()) { + saveResource("config.yml", false); + } + + floodgateIsInstalled = this.getServer().getPluginManager().isPluginEnabled("floodgate"); + if (floodgateIsInstalled) { + log.info("Floodgate detected!"); + } + + placeholderAPIInstalled = this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI"); + if (placeholderAPIInstalled) { + log.info("PlaceholderAPI detected!"); + } + + log.info("Registering commands/events.."); + Objects.requireNonNull(getCommand("stats")).setExecutor(new StatsCommand(this)); + + this.getServer().getPluginManager().registerEvents(new GuiListener(this), this); + + log.info("Starting Metrics.."); + Metrics metrics = new Metrics(this, 10123); + + log.info("Checking for a newer version.."); + new UpdateChecker(this, 88300).getVersion(version -> { + if (this.getDescription().getVersion().equalsIgnoreCase(version)) { + log.info("You are up to date! (v2.0.0)"); + } else { + log.warning("There is a new update available! \nDownload it at https://www.spigotmc.org/resources/88300/"); + } + }); + + log.info("Successfully started!"); + } +} diff --git a/src/main/java/me/gamersclub/customstats/GuiListener.java b/src/main/java/me/gamersclub/customstats/GuiListener.java new file mode 100644 index 0000000..c218499 --- /dev/null +++ b/src/main/java/me/gamersclub/customstats/GuiListener.java @@ -0,0 +1,26 @@ +package me.gamersclub.customstats; + +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryCloseEvent; +import org.jetbrains.annotations.NotNull; + +public class GuiListener implements Listener { + public GuiListener(CustomStats customStats) { + this.customStats = customStats; + } + final CustomStats customStats; + + @EventHandler + public void onInventoryClick (InventoryClickEvent event){ + if (customStats.uuidsWithGuiOpen.contains(event.getWhoClicked().getUniqueId().toString())) { + event.setCancelled(true); + } + } + + @EventHandler + public void onInventoryClose (@NotNull InventoryCloseEvent event){ + customStats.uuidsWithGuiOpen.remove(event.getPlayer().getUniqueId().toString()); + } +} diff --git a/src/main/java/me/gamersclub/customstats/StatsCommand.java b/src/main/java/me/gamersclub/customstats/StatsCommand.java new file mode 100644 index 0000000..c7be810 --- /dev/null +++ b/src/main/java/me/gamersclub/customstats/StatsCommand.java @@ -0,0 +1,142 @@ +package me.gamersclub.customstats; + +import me.gamersclub.customstats.util.PlaceholderManager; +import me.gamersclub.customstats.menus.StatForm; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.*; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.geysermc.floodgate.api.FloodgateApi; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class StatsCommand implements CommandExecutor, TabExecutor { + private final boolean floodgate; + final CustomStats customStats; + final PlaceholderManager placeholderManager; + @SuppressWarnings("CanBeFinal") + List valid = new ArrayList<>(); + + public StatsCommand(CustomStats customStats) { + this.customStats = customStats; + this.floodgate = customStats.floodgateIsInstalled; + this.placeholderManager = new PlaceholderManager(customStats); + + valid.add(9); + valid.add(18); + valid.add(27); + valid.add(36); + valid.add(45); + valid.add(54); + } + + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String alias, String @NotNull [] args) { + if (args.length == 0) { + if (sender instanceof ConsoleCommandSender) { + List statCommand = customStats.getConfig().getStringList("stats.stat-command"); + + //color code is & + for (String s : statCommand) { + sender.sendMessage(ChatColor.translateAlternateColorCodes(('&'), placeholderManager.placeholderReplacer(null, s))); + } + } else { + List statCommand = customStats.getConfig().getStringList("stats.stat-command"); + + //color code is & + for (String s : statCommand) { + sender.sendMessage(ChatColor.translateAlternateColorCodes(('&'), placeholderManager.placeholderReplacer((Player) sender, s))); + } + } + + } else { + if (args[0].equalsIgnoreCase("reload")) { + if (sender.hasPermission("customstats.reload")) { + customStats.reloadConfig(); + customStats.getConfig(); + sender.sendMessage(ChatColor.GREEN + "Configuration reloaded!"); + } else { + sender.sendMessage(ChatColor.RED + "Usage: /stats (menu)"); + } + } else if (args[0].equalsIgnoreCase("menu")) { + if (sender instanceof Player) { + Player player = (Player) sender; + + if (floodgate) { + if (FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId())) { + StatForm statForm = new StatForm(customStats, placeholderManager, player); + statForm.sendStatForm(player.getUniqueId()); + return true; + } + } + + String title = Objects.requireNonNull(customStats.getConfig().getString("stats.stat-menu.title")); + int size = customStats.getConfig().getInt("stats.stat-menu.menu-size"); + if (!valid.contains(size)) { + customStats.log.warning(size + " is not a valid multiple of 9!"); + sender.sendMessage(ChatColor.RED + "An internal issue occurred while running this command."); + return true; + } + + Inventory inventory = Bukkit.createInventory(player, size, ChatColor.translateAlternateColorCodes('&', title)); + + for (int i = 0; i < size; i++) { + if (customStats.getConfig().contains("stats.stat-menu.items." + i)) { + List statsGui = customStats.getConfig().getStringList("stats.stat-menu.items." + i); + + ItemStack item = new ItemStack(Material.valueOf(statsGui.get(0).toUpperCase()), 1); + + //set item to name if not air + if (item.getType() != Material.AIR) { + ItemMeta itemMeta = item.getItemMeta(); + String name = placeholderManager.placeholderReplacer(player, statsGui.get(1)); + + assert itemMeta != null; + itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); + + if (statsGui.size() > 2) { + List lore = new ArrayList<>(); + for (int l = 2; l < statsGui.size(); l++) { + lore.add(ChatColor.translateAlternateColorCodes('&',placeholderManager.placeholderReplacer(player, statsGui.get(l)))); + } + itemMeta.setLore(lore); + } + + item.setItemMeta(itemMeta); + } + inventory.setItem(i, item); + } else { + inventory.clear(i); + } + } + + player.openInventory(inventory); + customStats.uuidsWithGuiOpen.add(player.getUniqueId().toString()); + } else { + sender.sendMessage(ChatColor.RED + "You must be a player to use this command!"); + } + } else { + sender.sendMessage(ChatColor.RED + "Usage: /stats (menu)"); + } + } + return true; + } + + @Override + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, String[] strings) { + List completions = new ArrayList<>(); + completions.add("menu"); + + if (sender.hasPermission("customstats.reload")) { + completions.add("reload"); + } + return completions; + } +} diff --git a/src/main/java/me/stats/CustomStats/bStats/Metrics.java b/src/main/java/me/gamersclub/customstats/bStats/Metrics.java similarity index 99% rename from src/main/java/me/stats/CustomStats/bStats/Metrics.java rename to src/main/java/me/gamersclub/customstats/bStats/Metrics.java index 99067e9..56916f1 100644 --- a/src/main/java/me/stats/CustomStats/bStats/Metrics.java +++ b/src/main/java/me/gamersclub/customstats/bStats/Metrics.java @@ -1,4 +1,4 @@ -package me.stats.CustomStats.bStats; +package me.gamersclub.customstats.bStats; import com.google.gson.JsonArray; import com.google.gson.JsonObject; @@ -29,7 +29,7 @@ /** * bStats collects some data for plugin authors. *

- * Check out https://bStats.org/ to learn more about bStats! + * Check out https://bStats.org/ to learn more about bStats! */ @SuppressWarnings({"WeakerAccess", "unused"}) public class Metrics { @@ -730,4 +730,4 @@ protected JsonObject getChartData() throws Exception { } } -} \ No newline at end of file +} diff --git a/src/main/java/me/gamersclub/customstats/menus/StatForm.java b/src/main/java/me/gamersclub/customstats/menus/StatForm.java new file mode 100644 index 0000000..04d9ca6 --- /dev/null +++ b/src/main/java/me/gamersclub/customstats/menus/StatForm.java @@ -0,0 +1,37 @@ +package me.gamersclub.customstats.menus; + +import me.gamersclub.customstats.util.PlaceholderManager; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; +import org.geysermc.cumulus.component.LabelComponent; +import org.geysermc.cumulus.form.CustomForm; +import org.geysermc.floodgate.api.FloodgateApi; +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.Objects; +import java.util.UUID; + +public class StatForm { + @SuppressWarnings("CanBeFinal") + private CustomForm.Builder statForm = CustomForm.builder(); + + public StatForm(@NotNull JavaPlugin plugin, @NotNull PlaceholderManager pManager, @NotNull Player player) { + String title = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("stats.stat-form.title"))); + List content = Objects.requireNonNull(plugin.getConfig().getStringList("stats.stat-form.content")); + + statForm.component(LabelComponent.of(title)); + + for (String message : content) { + message = pManager.placeholderReplacer(player, message); + statForm.component(LabelComponent.of(ChatColor.translateAlternateColorCodes('&', message))); + } + + statForm.build(); + } + + public void sendStatForm(@NotNull UUID uuid) { + FloodgateApi.getInstance().getPlayer(uuid).sendForm(statForm); + } +} diff --git a/src/main/java/me/gamersclub/customstats/util/PlaceholderManager.java b/src/main/java/me/gamersclub/customstats/util/PlaceholderManager.java new file mode 100644 index 0000000..bda5367 --- /dev/null +++ b/src/main/java/me/gamersclub/customstats/util/PlaceholderManager.java @@ -0,0 +1,37 @@ +package me.gamersclub.customstats.util; + +import me.clip.placeholderapi.PlaceholderAPI; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +public class PlaceholderManager { + static JavaPlugin plugin; + @SuppressWarnings("CanBeFinal") + boolean papiInstalled; + + public PlaceholderManager(JavaPlugin plugin) { + this.plugin = plugin; + this.papiInstalled = plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI"); + } + + public String placeholderReplacer(Player player, String message) { + //handle our own placeholders first + message = message.replaceAll("%totalplayers%",totalPlayers()+""); + message = message.replaceAll("%onlineplayers",onlinePlayers()+""); + + //handle PlaceholderAPI placeholders after our own + if (papiInstalled) { + message = PlaceholderAPI.setPlaceholders(player, message); + } + + return message; + } + + public int totalPlayers() { + return plugin.getServer().getOfflinePlayers().length; + } + + public int onlinePlayers() { + return plugin.getServer().getOnlinePlayers().size(); + } +} diff --git a/src/main/java/me/stats/CustomStats/UpdateChecker.java b/src/main/java/me/gamersclub/customstats/util/UpdateChecker.java similarity index 85% rename from src/main/java/me/stats/CustomStats/UpdateChecker.java rename to src/main/java/me/gamersclub/customstats/util/UpdateChecker.java index 126c273..08f3a60 100644 --- a/src/main/java/me/stats/CustomStats/UpdateChecker.java +++ b/src/main/java/me/gamersclub/customstats/util/UpdateChecker.java @@ -1,4 +1,4 @@ -package me.stats.CustomStats; +package me.gamersclub.customstats.util; import org.bukkit.plugin.java.JavaPlugin; import java.io.IOException; @@ -23,7 +23,7 @@ public void getVersion(final Consumer consumer) { consumer.accept(scanner.next()); } } catch (IOException exception) { - this.plugin.getLogger().info("Cannot check for updates: " + exception.getMessage()); + this.plugin.getLogger().warning("Cannot check for updates: " + exception.getMessage()); } } -} \ No newline at end of file +} diff --git a/src/main/java/me/stats/CustomStats/CustomStats.java b/src/main/java/me/stats/CustomStats/CustomStats.java deleted file mode 100644 index b098ff2..0000000 --- a/src/main/java/me/stats/CustomStats/CustomStats.java +++ /dev/null @@ -1,32 +0,0 @@ -package me.stats.CustomStats; - -import me.stats.CustomStats.bStats.Metrics; -import org.bukkit.plugin.java.JavaPlugin; - -import java.util.HashMap; -import java.util.Objects; -import java.util.UUID; -import java.util.logging.Logger; - -public class CustomStats extends JavaPlugin { - HashMap opengui = new HashMap<>(); - private Logger console; - public void onEnable() { - Objects.requireNonNull(getCommand("stats")).setExecutor(new StatsCommand(this)); - getServer().getPluginManager().registerEvents(new GuiListener(this), this); - console = getLogger(); - console.info("Loading config."); - saveDefaultConfig(); - console.info("Config loaded!"); - new Metrics(this, 10123); - console.info("Checking for a newer version."); - new UpdateChecker(this, 88300).getVersion(version -> { - if (this.getDescription().getVersion().equalsIgnoreCase(version)) { - console.info("You are up to date! (v1.2.1)"); - } else { - console.info("There is a new update available. Download it at https://www.spigotmc.org/resources/customstats.88300/!"); - } - }); - console.info("Successfully started!"); - } -} diff --git a/src/main/java/me/stats/CustomStats/GuiListener.java b/src/main/java/me/stats/CustomStats/GuiListener.java deleted file mode 100644 index b6f811a..0000000 --- a/src/main/java/me/stats/CustomStats/GuiListener.java +++ /dev/null @@ -1,23 +0,0 @@ -package me.stats.CustomStats; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryCloseEvent; - -public class GuiListener implements Listener { - CustomStats customStats; - public GuiListener(CustomStats customStats) { - this.customStats = customStats; - } - @EventHandler - public void clickevent(InventoryClickEvent e){ - if (customStats.opengui.get(e.getWhoClicked().getUniqueId()).equals(1)){ - e.setCancelled(true); - } - } - @EventHandler - public void onInventoryClose(InventoryCloseEvent e){ - customStats.opengui.put(e.getPlayer().getUniqueId(), 0); - } -} diff --git a/src/main/java/me/stats/CustomStats/StatsCommand.java b/src/main/java/me/stats/CustomStats/StatsCommand.java deleted file mode 100644 index feb2ea7..0000000 --- a/src/main/java/me/stats/CustomStats/StatsCommand.java +++ /dev/null @@ -1,84 +0,0 @@ -package me.stats.CustomStats; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.TabExecutor; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import java.util.ArrayList; -import java.util.List; - -public class StatsCommand implements CommandExecutor, TabExecutor { - CustomStats customStats; - public StatsCommand(CustomStats customStats) { - this.customStats = customStats; - } - @Override - public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) { - if (sender instanceof Player) { - Player p = (Player) sender; - if (args.length == 1){ - if (args[0].equals("reload")){ - // Checks for permission - if (p.hasPermission("customstats.reload")){ - customStats.reloadConfig(); - customStats.saveConfig(); - customStats.getConfig(); - p.sendMessage(ChatColor.GREEN+"Configuration reloaded!"); - } - else { - p.sendMessage(ChatColor.RED+"Usage: /stats"); - } - } - else if (args[0].equals("gui")){ - Inventory gui = Bukkit.createInventory(p, 9, ChatColor.translateAlternateColorCodes('&', customStats.getConfig().getString("statsgui.title"))); - for (int i = 1; i < 10; i++){ - if (customStats.getConfig().contains("statsgui.item"+i)){ - List statsgui = customStats.getConfig().getStringList("statsgui.item"+i); - ItemStack item = new ItemStack(Material.valueOf(statsgui.get(0).toUpperCase()), 1); - if (item.getType() != Material.AIR){ - ItemMeta meta = item.getItemMeta(); - meta.setDisplayName(ChatColor.translateAlternateColorCodes('&',statsgui.get(1))); - item.setItemMeta(meta); - } - gui.setItem(i-1, item); - } - else{ - gui.clear(i-1); - i++; - } - } - p.openInventory(gui); - customStats.opengui.put(p.getUniqueId(), 1); - } - else { - p.sendMessage(ChatColor.RED+"Usage: /stats"); - } - } - if (args.length>1){ - p.sendMessage(ChatColor.RED+"Usage: /stats"); - } - else if (args.length == 0){ - List statcommand = customStats.getConfig().getStringList("statscommand"); - //color code is & - for (int i = 0; i onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) { - return new ArrayList<>(); - } -} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9332c30..b0981f7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,24 +1,62 @@ -# FORMAT FOR GUI ITEMS: -# item(1-9): -# - (Item type) -# - '(display name)' -# Max 9 slots, must be in order. Set item type to air to leave blank. -# -statscommand: - - '&a-----------------------------------------------------' - - '&6This server was created on February 1, 2021.' - - '&6The world is 12.34GB in size.' - - '&6Over 1,234 players have joined since.' - - '&a-----------------------------------------------------' -statsgui: - title: - - '&3Server Stats GUI&0' - item1: - - book - - '&6This server was created on February 1, 2021.' - item2: - - grass_block - - '&6The world is 12.34GB in size.' - item3: - - player_head - - '&6Over 1,234 players have joined since.' +# CustomStats v2.0.0 +# More detailed information on how to edit the configuration can be found on the wiki: +# https://7man7lmyt.github.io/CustomStats/ + + + +# New with v2.0.0: Placeholders + +# The plugin supports PlaceholderAPI placeholders, as well as its own built in ones. +# Note: Placeholders that require a player will not work in the /stats command. +# Built in placeholders: +# %totalplayers% - How many unique players have joined the server +# %onlineplayers% - How many players are currently online. + +stats: + stat-command: + - "&a-----------------------------------------------------" + - "&6This server was created on July 30, 2022." + - "&6The world is 12.34GB in size." + - "&6%totalplayers% unique players have joined since." + - "&a-----------------------------------------------------" + + # Customize the menu sent to Minecraft: Java Edition clients. + stat-menu: + # Format for adding more items to the GUI: + # (0-53): + # - (Item type) + # - "(display name)" + # - "(item lore)" + # - "(more item lore)" + + # Maximum inventory slots are limited by 'menu-size'. + # The items are not required to be in order. + # Either set the item type to air or remove the slot to leave blank. + # Slot #0 is an exception, you have to set it to air if you wish to set nothing in the slot. + + # Must be a multiple of 9. + menu-size: 9 + + title: "&3Server Stats Menu" + items: + 0: + - book + - "&6This server was created on July 30, 2022." + - "&6The world is 12.34GB in size." + - "&6%totalplayers% unique players have joined since." + + # Customize the form sent to Minecraft: Bedrock Edition clients. (Will only work if you have GeyserMC + Floodgate!) + stat-form: + # Format for adding more lines to the form: + # content: + # - "&6This text is gold!" + # - "&lThis text is bold!" + # - "&0R&1a&2i&3n&4b&5o&6w &7C&8o&9l&ao&br&cs&d!&e!&f! + + title: "&3Server Stats Menu" + content: + - "&a--------------------------------" + - "&6This server was created on July 30, 2022." + - "&6The world is 12.34GB in size." + - "&6%totalplayers% unique players have joined since." + - "&a--------------------------------" diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 4272ef8..77a311d 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,10 +1,18 @@ name: CustomStats -version: 1.2.1 -main: me.stats.CustomStats.CustomStats +version: 2.0.0 +main: me.gamersclub.customstats.CustomStats author: 7man7LMYT website: https://discord.gg/Z5MyDwp description: An anarchy server oriented plugin that adds /stats. + +permissions: + customstats.reload: + default: op +softdepend: + - floodgate + - PlaceholderAPI api-version: 1.13 + commands: stats: description: Command to give information about the server.