Skip to content

Commit

Permalink
chore(deps): bump CM, again
Browse files Browse the repository at this point in the history
  • Loading branch information
Thatsmusic99 committed Jun 17, 2023
1 parent 162fdcf commit 6219216
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 71 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -222,7 +222,7 @@
<dependency>
<groupId>com.github.thatsmusic99</groupId>
<artifactId>ConfigurationMaster-API</artifactId>
<version>v2.0.0-BETA-7</version>
<version>v2.0.0-BETA-8</version>
</dependency>
</dependencies>

Expand Down
Expand Up @@ -286,7 +286,13 @@ private void registerCommand(String command, CommandExecutor executor, String...
private void createInstances() {
configFiles = new ArrayList<>();
MainConfig config = addConfig(MainConfig.class, "config.yml");
if (config != null) config.load();
if (config != null) {
try {
config.load();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
addConfig(ConfigChallenges.class, "challenges.yml");
if (new File(getDataFolder(), "customheads.yml").exists()) addConfig(ConfigCustomHeads.class, "customheads.yml");
addConfig(ConfigCrafting.class, "crafting.yml");
Expand Down
Expand Up @@ -4,7 +4,6 @@
import io.github.thatsmusic99.configurationmaster.api.ConfigSection;
import io.github.thatsmusic99.headsplus.config.defaults.CraftingDefaults;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand All @@ -13,7 +12,7 @@ public class ConfigCrafting extends FeatureConfig {

private static ConfigCrafting instance;

public ConfigCrafting() throws IOException, IllegalAccessException {
public ConfigCrafting() throws Exception {
super("crafting.yml");
instance = this;
}
Expand All @@ -23,7 +22,7 @@ public static ConfigCrafting get() {
}

@Override
public void loadDefaults() {
public void addDefaults() {
addDefault("defaults.price", 0.0);
addExample("defaults.lore", Lists.newArrayList("&7Price &8» &c{price}"));
addDefault("defaults.sellable", false);
Expand Down
Expand Up @@ -7,19 +7,17 @@
import io.github.thatsmusic99.headsplus.managers.HeadManager;
import org.bukkit.ChatColor;

import java.io.IOException;

public class ConfigHeads extends HPConfig {

private static ConfigHeads instance;

public ConfigHeads() throws IOException, IllegalAccessException {
public ConfigHeads() throws Exception {
super("heads.yml");
instance = this;
}

@Override
public void loadDefaults() {
public void addDefaults() {
addComment("This is the config where entirely custom heads can be made, with custom metadata, actions, etc.\n" +
"To reference a custom head, use HP#head_id.\n" +
"If you're looking for mobs.yml instead to change mob drops, please go there :)");
Expand All @@ -32,8 +30,8 @@ public void loadDefaults() {
if (ConfigCustomHeads.get() != null) return;
for (HeadsXEnums head : HeadsXEnums.values()) {
if (isNew() || head.version > getDouble("version")) {
addDefault("heads." + head.name().toLowerCase() + ".display-name", head.displayName);
addDefault("heads." + head.name().toLowerCase() + ".texture", head.texture);
forceExample("heads." + head.name().toLowerCase() + ".display-name", head.displayName);
forceExample("heads." + head.name().toLowerCase() + ".texture", head.texture);
}
}
}
Expand Down
Expand Up @@ -12,7 +12,6 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;

Expand All @@ -23,7 +22,7 @@ public class ConfigHeadsSelector extends FeatureConfig {
private final HashMap<String, BuyableHeadInfo> buyableHeads = new LinkedHashMap<>();
private int totalHeads = 0;

public ConfigHeadsSelector() throws IOException, IllegalAccessException {
public ConfigHeadsSelector() throws Exception {
super("heads-selector.yml");
instance = this;
}
Expand All @@ -38,7 +37,7 @@ public static ConfigHeadsSelector get() {
}

@Override
public void loadDefaults() {
public void addDefaults() {
double version = getDouble("version", -1.0);
if (isNew()) version = -1.0;
addComment("This is where you can configure where the heads selector (/heads)");
Expand Down
Expand Up @@ -9,7 +9,6 @@
import org.bukkit.block.Skull;
import org.bukkit.entity.Player;

import java.io.IOException;
import java.lang.reflect.Field;
import java.util.*;
import java.util.regex.Matcher;
Expand All @@ -20,7 +19,7 @@ public class ConfigInteractions extends HPConfig {
private static ConfigInteractions instance;
private final Gson gson;

public ConfigInteractions() throws IOException, IllegalAccessException {
public ConfigInteractions() throws Exception {
super("interactions.yml");
instance = this;
gson = new Gson();
Expand All @@ -34,7 +33,7 @@ public ConfigInteractions() throws IOException, IllegalAccessException {
Location-specified messages
*/
@Override
public void loadDefaults() {
public void addDefaults() {
double version = getDouble("version");
if (version < 0.1) {
// Default values
Expand Down
Expand Up @@ -6,7 +6,6 @@
import io.github.thatsmusic99.headsplus.inventories.InventoryManager;
import io.github.thatsmusic99.headsplus.inventories.list.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand All @@ -15,7 +14,7 @@ public class ConfigInventories extends HPConfig {

private static ConfigInventories instance;

public ConfigInventories() throws IOException, IllegalAccessException {
public ConfigInventories() throws Exception {
super("inventories.yml");
instance = this;
}
Expand All @@ -25,7 +24,7 @@ public static ConfigInventories get() {
}

@Override
public void loadDefaults() {
public void addDefaults() {
for (InventoryManager.IconType i : InventoryManager.IconType.values()) {
addDefault("icons." + i.getId() + ".material", i.getMaterial());
addDefault("icons." + i.getId() + ".display-name", i.getDisplayName());
Expand Down
Expand Up @@ -4,7 +4,6 @@
import io.github.thatsmusic99.headsplus.api.BaseLevel;
import io.github.thatsmusic99.headsplus.config.challenges.HPChallengeRewardTypes;

import java.io.IOException;
import java.util.HashMap;

public class ConfigLevels extends FeatureConfig {
Expand All @@ -17,7 +16,7 @@ public HashMap<Integer, BaseLevel> getDefLevels() {

private static ConfigLevels instance;

public ConfigLevels() throws IOException, IllegalAccessException {
public ConfigLevels() throws Exception {
super("levels.yml");
instance = this;
addDefLevels();
Expand All @@ -28,7 +27,7 @@ public static ConfigLevels get() {
}

@Override
public void loadDefaults() {
public void addDefaults() {
double version = 0.3;
double current = getDouble("version");
makeSectionLenient("levels");
Expand Down
Expand Up @@ -3,20 +3,19 @@
import com.google.common.collect.Lists;
import io.github.thatsmusic99.headsplus.managers.MaskManager;

import java.io.IOException;
import java.util.Collections;

public class ConfigMasks extends FeatureConfig {

private static ConfigMasks instance;

public ConfigMasks() throws IOException, IllegalAccessException {
public ConfigMasks() throws Exception {
super("masks.yml");
instance = this;
}

@Override
public void loadDefaults() {
public void addDefaults() {
makeSectionLenient("masks");
addExample("masks.chicken.when-wearing", new String[0]);
addExample("masks.chicken.effects", Collections.singletonList("SLOW_FALLING"));
Expand Down
Expand Up @@ -18,7 +18,7 @@ public class ConfigMobs extends FeatureConfig {

private static ConfigMobs instance;

public ConfigMobs() throws IOException, IllegalAccessException {
public ConfigMobs() throws Exception {
super("mobs.yml");
instance = this;
}
Expand All @@ -28,7 +28,7 @@ public static ConfigMobs get() {
}

@Override
public void loadDefaults() {
public void addDefaults() {
addComment("This configuration file has become more complex compared to previous versions.\n" +
"If you have trouble understanding how it works, please use the /hp config mobs command instead.");
addDefault("defaults.lore", new ArrayList<>(Arrays.asList("&7Price &8» &c{price}", "&7Type &8» &c{type}")));
Expand Down
Expand Up @@ -6,7 +6,7 @@ public class ConfigSounds extends HPConfig {

private static ConfigSounds instance;

public ConfigSounds() throws IOException, IllegalAccessException {
public ConfigSounds() throws Exception {
super("sounds.yml");
instance = this;
}
Expand All @@ -16,7 +16,7 @@ public static ConfigSounds get() {
}

@Override
public void loadDefaults() {
public void addDefaults() {
for (Defaults d : Defaults.values()) {
addDefault("sounds." + d.name + ".sound", "ENTITY_EXPERIENCE_ORB_PICKUP");
addDefault("sounds." + d.name + ".volume", 1.0f);
Expand Down
Expand Up @@ -18,7 +18,6 @@
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand All @@ -29,15 +28,15 @@ public class ConfigTextMenus extends HPConfig {

private static ConfigTextMenus instance;

public ConfigTextMenus() throws IOException, IllegalAccessException {
public ConfigTextMenus() throws Exception {
super("textmenus.yml");
instance = this;
}

// TODO - make an interface that all translators override?

@Override
public void loadDefaults() {
public void addDefaults() {
addDefault("default-header", "&c・.&7━━━━━━━━━━━━ &8❰ &c&lHeadsPlus &8❱ &7━━━━━━━━━━━━&c.・");
addDefault("default-header-paged", "&c・.&7━━━━━━━━━━━━ &8❰ &c&lHeadsPlus &7{page}/{pages} &8❱ " +
"&7━━━━━━━━━━━━&c.・");
Expand Down
Expand Up @@ -2,13 +2,11 @@

import org.jetbrains.annotations.NotNull;

import java.io.IOException;

public abstract class FeatureConfig extends HPConfig {

private boolean loaded = false;

public FeatureConfig(@NotNull String name) throws IOException, IllegalAccessException {
public FeatureConfig(@NotNull String name) throws Exception {
super(name);
}

Expand Down
Expand Up @@ -9,35 +9,12 @@

public abstract class HPConfig extends ConfigFile {

public HPConfig(@NotNull String name) throws IOException {
public HPConfig(@NotNull String name) throws Exception {
super(getOrCreateFile(name));
}

public void load() {
loadDefaults();
moveToNew();
try {
save();
} catch (Exception e) {
e.printStackTrace();
return;
}
postSave();
if (this instanceof FeatureConfig) {
((FeatureConfig) this).setLoaded(true);
}
}

public abstract void loadDefaults();

public void moveToNew() {
}

public void postSave() {
}

@Override
public void reload() throws IOException {
public void reload() throws Exception {
super.reload();
moveToNew();
save();
Expand Down
Expand Up @@ -8,7 +8,6 @@
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;

import java.io.IOException;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.ArrayList;
Expand All @@ -35,13 +34,13 @@ public class MainConfig extends HPConfig {

private static MainConfig instance;

public MainConfig() throws IOException, IllegalAccessException {
public MainConfig() throws Exception {
super("config.yml");
instance = this;
}

@Override
public void loadDefaults() {
public void addDefaults() {
setTitle(new Title().withWidth(100)
.addSolidLine()
.addLine("HeadsPlus v7", Title.Pos.CENTER)
Expand Down
Expand Up @@ -5,21 +5,20 @@
import io.github.thatsmusic99.headsplus.config.MainConfig;
import io.github.thatsmusic99.headsplus.managers.EntityDataManager;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;

public class ConfigChallenges extends FeatureConfig {

private static ConfigChallenges instance;

public ConfigChallenges() throws IOException, IllegalAccessException {
public ConfigChallenges() throws Exception {
super("challenges.yml");
instance = this;
}

@Override
public void loadDefaults() {
public void addDefaults() {
addDefault("options.current-version", 1.3);
addDefault("options.prepare-icons", true);
addDefault("options.prepare-rewards", true);
Expand Down

0 comments on commit 6219216

Please sign in to comment.