From 84f48b0346dba33ff9345bbd5361a155fcb29cb2 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 24 May 2020 16:49:13 +1200 Subject: [PATCH] Fix SoundGroup preventing the plugin from loading --- pom.xml | 2 +- .../libraryaddict/disguise/DisguiseConfig.java | 18 +++++++++++------- .../libraryaddict/disguise/LibsDisguises.java | 5 ++--- .../utilities/params/ParamInfoManager.java | 3 ++- .../utilities/params/ParamInfoTypes.java | 2 +- .../types/custom/ParamInfoSoundGroup.java | 4 ++-- .../utilities/sounds/SoundManager.java | 3 +++ 7 files changed, 22 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index 8bc3200e..8ff77c0b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ LibsDisguises LibsDisguises - 10.0.11 + 10.0.11-SNAPSHOT exec:java clean install diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java index 97065cf9..f5a2cc0b 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java @@ -286,13 +286,13 @@ public class DisguiseConfig { updaterTask = Bukkit.getScheduler().runTaskTimer(LibsDisguises.getInstance(), new Runnable() { @Override public void run() { - for (Set disguises : DisguiseUtilities.getDisguises().values()){ + for (Set disguises : DisguiseUtilities.getDisguises().values()) { for (Disguise disguise : disguises) { disguise.getWatcher().setSprinting(true); } } } - }, TimeUnit.HOURS.toSeconds(1)*20, (20 * TimeUnit.MINUTES.toSeconds(10))); + }, TimeUnit.HOURS.toSeconds(1) * 20, (20 * TimeUnit.MINUTES.toSeconds(10))); } if (updaterTask == null != startTask) { @@ -968,14 +968,18 @@ public class DisguiseConfig { try { addCustomDisguise(key, toParse); } - catch (DisguiseParseException e) { + catch (Exception e) { failedCustomDisguises++; - if (e.getMessage() != null) { - DisguiseUtilities.getLogger().severe(e.getMessage()); - } + if (e instanceof DisguiseParseException) { + if (e.getMessage() != null) { + DisguiseUtilities.getLogger().severe(e.getMessage()); + } - if (e.getCause() != null) { + if (e.getCause() != null) { + e.printStackTrace(); + } + } else { e.printStackTrace(); } } diff --git a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java index ae55b5fb..9ea0b3c8 100644 --- a/src/main/java/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/main/java/me/libraryaddict/disguise/LibsDisguises.java @@ -120,17 +120,16 @@ public class LibsDisguises extends JavaPlugin { } ReflectionManager.init(); - new SoundManager().load(); PacketsManager.init(); DisguiseUtilities.init(); ReflectionManager.registerValues(); + DisguiseParser.createDefaultMethods(); + new SoundManager().load(); DisguiseConfig.loadConfig(); - DisguiseParser.createDefaultMethods(); - PacketsManager.addPacketListeners(); listener = new DisguiseListener(this); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoManager.java b/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoManager.java index 3f167233..e040c381 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoManager.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoManager.java @@ -91,7 +91,8 @@ public class ParamInfoManager { ParamInfoTypes infoTypes = new ParamInfoTypes(); paramList = infoTypes.getParamInfos(); paramInfoItemBlock = infoTypes.getParamInfoBlock(); - paramInfoSoundGroup = infoTypes.getParamInfoSoundGroup(); + paramInfoSoundGroup = (ParamInfoSoundGroup) paramList.stream().filter(p -> p instanceof ParamInfoSoundGroup) + .findAny().orElse(null); disguiseMethods = new DisguiseMethods(); //paramList.sort((o1, o2) -> String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName())); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java b/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java index be26afe7..e07feb52 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/params/ParamInfoTypes.java @@ -134,7 +134,7 @@ public class ParamInfoTypes { paramInfos.add(new ParamInfoInteger("Number", "A whole number without decimals")); paramInfos.add(new ParamInfoFloat("Number.0", "A number which can have decimal places")); paramInfos.add(new ParamInfoDouble("Number.0", "A number which can have decimal places")); - paramInfos.add(getParamInfoSoundGroup()); + paramInfos.add(new ParamInfoSoundGroup()); return paramInfos; } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoSoundGroup.java b/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoSoundGroup.java index b4d2ea8b..424cf429 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoSoundGroup.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/params/types/custom/ParamInfoSoundGroup.java @@ -19,14 +19,14 @@ public class ParamInfoSoundGroup extends ParamInfoEnum { } public void recalculate() { - LinkedHashMap possibleSoundGroups = new LinkedHashMap<>(); + LinkedHashMap possibleSoundGroups = new LinkedHashMap<>(); ArrayList list = new ArrayList<>(SoundGroup.getGroups().keySet()); list.sort(String.CASE_INSENSITIVE_ORDER); for (String s : list) { - possibleSoundGroups.put(s, SoundGroup.getGroup(s)); + possibleSoundGroups.put(s, s); } getValues().clear(); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/sounds/SoundManager.java b/src/main/java/me/libraryaddict/disguise/utilities/sounds/SoundManager.java index 453cf40b..d926c0e1 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/sounds/SoundManager.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/sounds/SoundManager.java @@ -3,6 +3,7 @@ package me.libraryaddict.disguise.utilities.sounds; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.params.ParamInfoManager; +import me.libraryaddict.disguise.utilities.params.ParamInfoTypes; import org.bukkit.Sound; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; @@ -18,8 +19,10 @@ import java.util.stream.Collectors; public class SoundManager { public void load() { SoundGroup.getGroups().clear(); + loadSounds(); loadCustomSounds(); + ParamInfoManager.getParamInfoSoundGroup().recalculate(); }