mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-06 06:41:44 +00:00
added main plugin command
This commit is contained in:
@@ -19,6 +19,7 @@ package lol.hyper.toolstats;
|
|||||||
|
|
||||||
import lol.hyper.githubreleaseapi.GitHubRelease;
|
import lol.hyper.githubreleaseapi.GitHubRelease;
|
||||||
import lol.hyper.githubreleaseapi.GitHubReleaseAPI;
|
import lol.hyper.githubreleaseapi.GitHubReleaseAPI;
|
||||||
|
import lol.hyper.toolstats.commands.CommandToolStats;
|
||||||
import lol.hyper.toolstats.events.*;
|
import lol.hyper.toolstats.events.*;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -61,6 +62,7 @@ public final class ToolStats extends JavaPlugin {
|
|||||||
public EntityDamage mobKill;
|
public EntityDamage mobKill;
|
||||||
public PlayerFish playerFish;
|
public PlayerFish playerFish;
|
||||||
public SheepShear sheepShear;
|
public SheepShear sheepShear;
|
||||||
|
public CommandToolStats commandToolStats;
|
||||||
|
|
||||||
public final Logger logger = this.getLogger();
|
public final Logger logger = this.getLogger();
|
||||||
public final File configFile = new File(this.getDataFolder(), "config.yml");
|
public final File configFile = new File(this.getDataFolder(), "config.yml");
|
||||||
@@ -80,6 +82,7 @@ public final class ToolStats extends JavaPlugin {
|
|||||||
mobKill = new EntityDamage(this);
|
mobKill = new EntityDamage(this);
|
||||||
playerFish = new PlayerFish(this);
|
playerFish = new PlayerFish(this);
|
||||||
sheepShear = new SheepShear(this);
|
sheepShear = new SheepShear(this);
|
||||||
|
commandToolStats = new CommandToolStats(this);
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(blocksMined, this);
|
Bukkit.getServer().getPluginManager().registerEvents(blocksMined, this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(craftItem, 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(playerFish, this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(sheepShear, this);
|
Bukkit.getServer().getPluginManager().registerEvents(sheepShear, this);
|
||||||
|
|
||||||
|
this.getCommand("toolstats").setExecutor(commandToolStats);
|
||||||
|
|
||||||
new Metrics(this, 14110);
|
new Metrics(this, 14110);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(this, this::checkForUpdates);
|
Bukkit.getScheduler().runTaskAsynchronously(this, this::checkForUpdates);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,3 +2,14 @@ name: ToolStats
|
|||||||
version: '${project.version}'
|
version: '${project.version}'
|
||||||
main: lol.hyper.toolstats.ToolStats
|
main: lol.hyper.toolstats.ToolStats
|
||||||
api-version: 1.18
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user