9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-27 02:49:08 +00:00

Added reload command

This commit is contained in:
HeroBrineGoat
2021-11-09 22:15:36 -05:00
parent 6a2778693c
commit b2550b20a7
6 changed files with 32 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import io.github.fisher2911.hmccosmetics.gui.ArmorItem;
import io.github.fisher2911.hmccosmetics.gui.CosmeticsMenu;
import io.github.fisher2911.hmccosmetics.gui.DyeSelectorGui;
import io.github.fisher2911.hmccosmetics.message.MessageHandler;
import io.github.fisher2911.hmccosmetics.message.Messages;
import io.github.fisher2911.hmccosmetics.user.User;
import io.github.fisher2911.hmccosmetics.user.UserManager;
import me.mattstudios.mf.annotations.Command;
@@ -12,7 +13,9 @@ import me.mattstudios.mf.annotations.Default;
import me.mattstudios.mf.annotations.Permission;
import me.mattstudios.mf.annotations.SubCommand;
import me.mattstudios.mf.base.CommandBase;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Map;
@@ -39,6 +42,21 @@ public class CosmeticsCommand extends CommandBase {
this.cosmeticsMenu.openDefault(player);
}
@SubCommand("reload")
@Permission(io.github.fisher2911.hmccosmetics.message.Permission.RELOAD_COMMAND)
public void reloadCommand(final CommandSender sender) {
Bukkit.getScheduler().runTaskAsynchronously(
this.plugin,
() -> {
this.cosmeticsMenu.reload();
this.messageHandler.sendMessage(
sender,
Messages.RELOADED
);
}
);
}
@SubCommand("dye")
@Permission(io.github.fisher2911.hmccosmetics.message.Permission.DYE_COMMAND)
public void dyeArmor(final Player player, String typeString) {

View File

@@ -38,7 +38,12 @@ public class CosmeticsMenu {
this.openMenu(MAIN_MENU, humanEntity);
}
public void reload() {
this.load();
}
public void load() {
this.guiMap.clear();
final File file = Path.of(this.plugin.getDataFolder().getPath(),
"menus").toFile();

View File

@@ -14,4 +14,6 @@ public class Messages {
new Message("removed-backpack", "Removed backpack");
public static final Message MUST_BE_PLAYER =
new Message("must-be-player", "You must be a player to do this!");
public static final Message RELOADED =
new Message("reloaded", "Config reloaded");
}

View File

@@ -4,5 +4,6 @@ public class Permission {
public static final String DEFAULT_COMMAND = "hmccosmetics.cmd.default";
public static final String DYE_COMMAND = "hmccosmetics.cmd.dye";
public static final String RELOAD_COMMAND = "hmccosmetics.cmd.reload";
}

View File

@@ -3,4 +3,5 @@ set-hat: "<green>Set Hat!"
removed-hat: "<green>Removed Hat"
set-backpack: "<green>Set Backpack!"
removed-backpack: "<green>Removed Backpack"
must-be-player: "You must be a player to do this!"
must-be-player: "You must be a player to do this!"
reloaded: "<green>Config files reloaded"

View File

@@ -8,4 +8,7 @@ permissions:
description: Permission to execute the default command
hmccosmetics.cmd.dye:
default: op
description: Permission to dye armor
description: Permission to dye armor
hmccosmetics.cmd.reload:
default: op
description: Permission to use the reload command