Skip to content

Commit

Permalink
feat: Option to open menu on wardrobe enter
Browse files Browse the repository at this point in the history
  • Loading branch information
LoJoSho committed Jun 27, 2023
1 parent 78f4870 commit 71a080a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public class WardrobeSettings {
private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin";
private static final String TRY_COSMETICS_WARDROBE = "unchecked-wardrobe-cosmetics";
private static final String RETURN_LAST_LOCATION = "return-last-location";

private static final String WARDROBE_MENU_OPTIONS = "menu-options";
private static final String WARDROBE_ENTER_OPEN_MENU_PATH = "enter-open-menu";

private static final String GAMEMODE_OPTIONS_PATH = "gamemode-options";
private static final String FORCE_EXIT_GAMEMODE_PATH = "exit-gamemode-enabled";
private static final String EXIT_GAMEMODE_PATH = "exit-gamemode";
Expand Down Expand Up @@ -68,6 +72,7 @@ public class WardrobeSettings {
private static boolean equipPumpkin;
private static boolean returnLastLocation;
private static boolean enabledBossbar;
private static boolean enterOpenMenu;
private static boolean forceExitGamemode;
private static GameMode exitGamemode;
private static HashMap<String, Wardrobe> wardrobes;
Expand Down Expand Up @@ -97,6 +102,9 @@ public static void load(ConfigurationNode source) {
returnLastLocation = source.node(RETURN_LAST_LOCATION).getBoolean(false);
tryCosmeticsInWardrobe = source.node(TRY_COSMETICS_WARDROBE).getBoolean(false);

ConfigurationNode menuOptionsNode = source.node(WARDROBE_MENU_OPTIONS);
enterOpenMenu = menuOptionsNode.node(WARDROBE_ENTER_OPEN_MENU_PATH).getBoolean(false);

ConfigurationNode gamemodeNode = source.node(GAMEMODE_OPTIONS_PATH);
forceExitGamemode = gamemodeNode.node(FORCE_EXIT_GAMEMODE_PATH).getBoolean(false);
exitGamemode = GameMode.valueOf(gamemodeNode.node(EXIT_GAMEMODE_PATH).getString("SURVIVAL"));
Expand Down Expand Up @@ -274,6 +282,10 @@ public static int getTransitionFadeOut() {
return transitionFadeOut;
}

public static boolean isEnterOpenMenu() {
return enterOpenMenu;
}

public static boolean isForceExitGamemode() {
return forceExitGamemode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.hibiscusmc.hmccosmetics.config.WardrobeSettings;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.gui.Menu;
import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
Expand Down Expand Up @@ -135,6 +137,11 @@ public void start() {
target.showBossBar(bossBar);
}

if (WardrobeSettings.isEnterOpenMenu()) {
Menu menu = Menus.getDefaultMenu();
if (menu != null) menu.openMenu(user);
}

this.active = true;
update();
setWardrobeStatus(WardrobeStatus.RUNNING);
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ wardrobe:
# If players in wardrobes should be able to equip any cosmetic, regardless of permission (Cosmetics they do not have access to will be removed when they leave the wardrobe)
unchecked-wardrobe-cosmetics: false

menu-options:
enter-open-menu: false # If the menu should open when a player enters a wardrobe

gamemode-options:
exit-gamemode-enabled: false # Setting this to false will set the gamemode the player came in as. True sets to exit-gamemode gamemode
exit-gamemode: "SURVIVAL" # Only activates if exit-gamemode-enabled is true, find gamemodes here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/GameMode.html
Expand Down

0 comments on commit 71a080a

Please sign in to comment.