Skip to content

Commit

Permalink
Remove PersonalChests
Browse files Browse the repository at this point in the history
  • Loading branch information
MetallicGoat committed May 16, 2024
1 parent 24760e6 commit 603e57c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public void registerEvents() {
manager.registerEvents(new HeightCap(), plugin);
manager.registerEvents(new LockTeamChest(), plugin);
manager.registerEvents(new PermanentEffects(), plugin);
manager.registerEvents(new PersonalChests(), plugin);
manager.registerEvents(new PlaceBlocksOnBed(), plugin);
manager.registerEvents(new PlayerLimitBypass(), plugin);
manager.registerEvents(new RemoveInvisOnDamage(), plugin);
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/me/metallicgoat/tweaksaddon/config/ConfigLoader.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package me.metallicgoat.tweaksaddon.config;

import de.marcely.bedwars.api.arena.Team;
import de.marcely.bedwars.api.configuration.ConfigurationAPI;
import de.marcely.bedwars.api.event.ConfigsLoadEvent;
import de.marcely.bedwars.tools.Helper;
import me.metallicgoat.tweaksaddon.MBedwarsTweaksPlugin;
import me.metallicgoat.tweaksaddon.config.ConfigManager.FileType;
import me.metallicgoat.tweaksaddon.gentiers.GenTierLevel;
import me.metallicgoat.tweaksaddon.gentiers.TierAction;
import me.metallicgoat.tweaksaddon.utils.Console;
import me.metallicgoat.tweaksaddon.utils.Util;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

Expand Down Expand Up @@ -57,6 +60,8 @@ public static void loadTweaksConfigs(MBedwarsTweaksPlugin plugin) {

applyCustomTeamColors();

overrideMBedwarsConfigs();

final long end = System.currentTimeMillis();

Console.printInfo("Configs loaded in " + (end - start) + "ms.");
Expand Down Expand Up @@ -109,4 +114,27 @@ private static void applyCustomTeamColors() {
for (Entry<Team, ChatColor> entry : MainConfig.custom_team_colors.entrySet())
entry.getKey().setBungeeChatColor(entry.getValue());
}

private static void overrideMBedwarsConfigs() {
// APPLY OUR OVERRIDES
if (MainConfig.personal_ender_chests_enabled) {
try {
final boolean teamchestEnabled = (boolean) ConfigurationAPI.get().getValue("teamchest-enabled");
final Material teamchestBlock = (Material) ConfigurationAPI.get().getValue("teamchest-block");

if (teamchestEnabled && teamchestBlock == Helper.get().getMaterialByName("ENDER_CHEST")) {
ConfigurationAPI.get().setValue("teamchest-enabled", false);
Console.printWarn(
"WARNING: You have \"personal-ender-chests-enabled\" enabled. This setting will be removed in the future, as it is already possible in MBedwars." ,
"Open your MBedwars config.yml, and either set \"teamchest-enabled\" to false, or set \"teamchest-block\" to CHEST.",
"Currently, we are using the MBedwars configuration api to override these values for you."
);
}

} catch (Exception e) {
Console.printWarn("Failed to apply personal ender chests. Try updating MBedwars, or disabling \"personal-ender-chests-enabled\"");
e.printStackTrace();
}
}
}
}
17 changes: 9 additions & 8 deletions src/main/java/me/metallicgoat/tweaksaddon/config/MainConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,6 @@ public class MainConfig {
@Config public static double lock_team_chest_range = 8;
@Config public static String lock_team_chest_fail_open = "&cYou cannot open this chest until {team} &chas been eliminated.";

@Config(
description = {
"Personal Ender Chests. Overrides MBedwars Team Ender Chests"
}
)
public static boolean personal_ender_chests_enabled = false;
@Config public static String personal_ender_chests_name = "Ender Chest";

// MISCELLANEOUS
@SectionTitle(title = "MISCELLANEOUS")

Expand Down Expand Up @@ -489,6 +481,15 @@ public class MainConfig {
// ===== UNSUPPORTED
@SectionTitle(title = "UNSUPPORTED")

@Config(
description = {
"THIS WILL BE REMOVED IN THE FUTURE - USE MBedwars ENDER CHESTS",
"Personal Ender Chests. Overrides MBedwars Team Ender Chests",
"This config now simply enables the setting in MBedwars by modifying the config value"
}
)
public static boolean personal_ender_chests_enabled = false;

@Config(
description = {
"Add a height cap for specific MBedwars arenas",
Expand Down

This file was deleted.

0 comments on commit 603e57c

Please sign in to comment.