added main plugin command

This commit is contained in:
hyperdefined
2022-01-29 14:39:20 -05:00
parent 46fe889c96
commit 49d864833b
3 changed files with 69 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ package lol.hyper.toolstats;
import lol.hyper.githubreleaseapi.GitHubRelease;
import lol.hyper.githubreleaseapi.GitHubReleaseAPI;
import lol.hyper.toolstats.commands.CommandToolStats;
import lol.hyper.toolstats.events.*;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
@@ -61,6 +62,7 @@ public final class ToolStats extends JavaPlugin {
public EntityDamage mobKill;
public PlayerFish playerFish;
public SheepShear sheepShear;
public CommandToolStats commandToolStats;
public final Logger logger = this.getLogger();
public final File configFile = new File(this.getDataFolder(), "config.yml");
@@ -80,6 +82,7 @@ public final class ToolStats extends JavaPlugin {
mobKill = new EntityDamage(this);
playerFish = new PlayerFish(this);
sheepShear = new SheepShear(this);
commandToolStats = new CommandToolStats(this);
Bukkit.getServer().getPluginManager().registerEvents(blocksMined, this);
Bukkit.getServer().getPluginManager().registerEvents(craftItem, this);
@@ -88,6 +91,8 @@ public final class ToolStats extends JavaPlugin {
Bukkit.getServer().getPluginManager().registerEvents(playerFish, this);
Bukkit.getServer().getPluginManager().registerEvents(sheepShear, this);
this.getCommand("toolstats").setExecutor(commandToolStats);
new Metrics(this, 14110);
Bukkit.getScheduler().runTaskAsynchronously(this, this::checkForUpdates);

View File

@@ -0,0 +1,53 @@
/*
* This file is part of ToolStats.
*
* ToolStats is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ToolStats is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ToolStats. If not, see <https://www.gnu.org/licenses/>.
*/
package lol.hyper.toolstats.commands;
import lol.hyper.toolstats.ToolStats;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
public class CommandToolStats implements CommandExecutor {
private final ToolStats toolStats;
public CommandToolStats(ToolStats toolStats) {
this.toolStats = toolStats;
}
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (args.length == 0) {
sender.sendMessage(ChatColor.GREEN + "ToolStats version " + toolStats.getDescription().getVersion() + ". Created by hyperdefined.");
} else if (args.length == 1) {
if (args[0].equalsIgnoreCase("reload")) {
if (sender.isOp() || sender.hasPermission("toolstats.reload")) {
toolStats.loadConfig();
sender.sendMessage(ChatColor.GREEN + "Configuration reloaded!");
} else {
sender.sendMessage(ChatColor.RED + "You do not have permission for this command.");
}
} else {
sender.sendMessage(ChatColor.RED + "Invalid sub-command.");
}
}
return true;
}
}

View File

@@ -2,3 +2,14 @@ name: ToolStats
version: '${project.version}'
main: lol.hyper.toolstats.ToolStats
api-version: 1.18
author: hyperdefined
description: Track various tool stats!
commands:
toolstats:
usage: /toolstats
description: Main command.
permission: randomenchant.reload
permissions:
randomenchant.reload:
description: Allows the usage of /randomenchant reload
default: op