version cmd, minor stuff

This commit is contained in:
Jsinco 2024-02-13 20:05:27 -05:00
parent 525c9afd0b
commit 3203ecff10
5 changed files with 53 additions and 1 deletions

View File

@ -25,6 +25,7 @@ permissions:
brewery.cauldron.time: true
brewery.cauldron.insert: true
brewery.cauldron.fill: true
brewery.cmd.version: true
# Mod
brewery.mod:
description: Allow to maintain Wakeup Points and to login even if overdrunken
@ -100,6 +101,8 @@ permissions:
description: View the material name of an item
brewery.cmd.reloadaddons:
description: Reload all Addons
brewery.cmd.version:
description: See misc info about BreweryX
# -- Barrel --
brewery.createbarrel:

View File

@ -3,7 +3,6 @@ package com.dre.brewery.api.addons;
import com.dre.brewery.BreweryPlugin;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandMap;
import org.bukkit.command.SimpleCommandMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

View File

@ -37,6 +37,7 @@ public class CommandManager implements TabExecutor {
subCommands.put("puke", new PukeCommand());
subCommands.put("drink", new DrinkCommand());
subCommands.put("reloadaddons", new ReloadAddonsCommand());
subCommands.put("version", new VersionCommand());
}
@Override

View File

@ -0,0 +1,45 @@
package com.dre.brewery.commands.subcommands;
import com.dre.brewery.BreweryPlugin;
import com.dre.brewery.api.addons.AddonManager;
import com.dre.brewery.api.addons.BreweryAddon;
import com.dre.brewery.commands.SubCommand;
import com.dre.brewery.filedata.UpdateChecker;
import org.bukkit.command.CommandSender;
import java.util.List;
public class VersionCommand implements SubCommand {
@Override
public void execute(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
List<BreweryAddon> addons = new AddonManager(breweryPlugin).getAddons();
StringBuilder addonString = new StringBuilder();
for (BreweryAddon addon : addons) {
addonString.append(addon.getClass().getSimpleName());
if (addons.indexOf(addon) < addons.size() - 1) {
addonString.append("&f, &a");
}
}
breweryPlugin.msg(sender, "&2BreweryX version&7: &av" + breweryPlugin.getDescription().getVersion() + " &7(Latest: v" + UpdateChecker.getLatestVersion() + ")");
breweryPlugin.msg(sender, "&2Original Authors&7: &aGrafe&f, &aTTTheKing&f, &aSn0wStorm");
breweryPlugin.msg(sender, "&2BreweryX Authors/Maintainers&7: &aJsinco");
breweryPlugin.msg(sender, "&2Loaded addons&7: &a" + addonString);
}
@Override
public List<String> tabComplete(BreweryPlugin breweryPlugin, CommandSender sender, String label, String[] args) {
return null;
}
@Override
public String permission() {
return "brewery.cmd.version";
}
@Override
public boolean playerOnly() {
return false;
}
}

View File

@ -52,6 +52,10 @@ public class UpdateChecker {
latestVersion = version;
}
public static String getLatestVersion() {
return latestVersion;
}
public static void setUpdateAvailable(boolean available) {
updateAvailable = available;
}