diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java index 99b0b945..68f7655f 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/config/WardrobeSettings.java @@ -6,6 +6,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import com.hibiscusmc.hmccosmetics.util.misc.Utils; import net.kyori.adventure.bossbar.BossBar; import org.apache.commons.lang3.EnumUtils; +import org.bukkit.GameMode; import org.bukkit.Location; import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.serialize.SerializationException; @@ -29,6 +30,9 @@ public class WardrobeSettings { private static final String LEAVE_LOCATION_PATH = "leave-location"; private static final String EQUIP_PUMPKIN_WARDROBE = "equip-pumpkin"; private static final String RETURN_LAST_LOCATION = "return-last-location"; + 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"; private static final String BOSSBAR_PATH = "bossbar"; private static final String BOSSBAR_ENABLE_PATH = "enabled"; private static final String BOSSBAR_TEXT_PATH = "text"; @@ -57,6 +61,8 @@ public class WardrobeSettings { private static boolean equipPumpkin; private static boolean returnLastLocation; private static boolean enabledBossbar; + private static boolean forceExitGamemode; + private static GameMode exitGamemode; private static Location wardrobeLocation; private static Location viewerLocation; private static Location leaveLocation; @@ -85,6 +91,10 @@ public class WardrobeSettings { equipPumpkin = source.node(EQUIP_PUMPKIN_WARDROBE).getBoolean(); returnLastLocation = source.node(RETURN_LAST_LOCATION).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")); + ConfigurationNode bossBarNode = source.node(BOSSBAR_PATH); enabledBossbar = bossBarNode.node(BOSSBAR_ENABLE_PATH).getBoolean(false); bossbarProgress = bossBarNode.node(BOSSBAR_PROGRESS_PATH).getFloat(1.0f); @@ -227,6 +237,14 @@ public class WardrobeSettings { return transitionFadeOut; } + public static boolean isForceExitGamemode() { + return forceExitGamemode; + } + + public static GameMode getExitGamemode() { + return exitGamemode; + } + public static void setWardrobeLocation(Location newLocation) { wardrobeLocation = newLocation; diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java index 56e696f9..31e21e9d 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/user/manager/UserWardrobeManager.java @@ -168,13 +168,20 @@ public class UserWardrobeManager { // Player PacketManager.sendCameraPacket(player.getEntityId(), viewer); - PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success // Armorstand PacketManager.sendEntityDestroyPacket(ARMORSTAND_ID, viewer); // Sucess //PacketManager.sendEntityDestroyPacket(player.getEntityId(), viewer); // Success - player.setGameMode(this.originalGamemode); + if (WardrobeSettings.isForceExitGamemode()) { + MessagesUtil.sendDebugMessages("Force Exit Gamemode " + WardrobeSettings.getExitGamemode()); + player.setGameMode(WardrobeSettings.getExitGamemode()); + PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(WardrobeSettings.getExitGamemode())); // Success + } else { + MessagesUtil.sendDebugMessages("Original Gamemode " + this.originalGamemode); + player.setGameMode(this.originalGamemode); + PacketManager.gamemodeChangePacket(player, ServerUtils.convertGamemode(this.originalGamemode)); // Success + } user.showPlayer(); if (user.hasCosmeticInSlot(CosmeticSlot.BACKPACK)) { diff --git a/common/src/main/resources/config.yml b/common/src/main/resources/config.yml index 7e54110f..ab147156 100644 --- a/common/src/main/resources/config.yml +++ b/common/src/main/resources/config.yml @@ -70,6 +70,11 @@ wardrobe: equip-pumpkin: false # Rather than having a set exit location, this will send the player back to where they entered the wardrobe. Not recommended for WG regions return-last-location: false + + 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 force-exit-gamemode is true, find gamemodes here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/GameMode.html + # Bossbar that shows when a player is in a wardrobe. bossbar: enabled: false