Fix SoundGroup preventing the plugin from loading

This commit is contained in:
libraryaddict 2020-05-24 16:49:13 +12:00
parent 17a53e22e4
commit 84f48b0346
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
7 changed files with 22 additions and 15 deletions

View File

@ -5,7 +5,7 @@
<!-- A good example on why temporary names for project identification shouldn't be used -->
<groupId>LibsDisguises</groupId>
<artifactId>LibsDisguises</artifactId>
<version>10.0.11</version>
<version>10.0.11-SNAPSHOT</version>
<build>
<defaultGoal>exec:java clean install</defaultGoal>

View File

@ -968,9 +968,10 @@ public class DisguiseConfig {
try {
addCustomDisguise(key, toParse);
}
catch (DisguiseParseException e) {
catch (Exception e) {
failedCustomDisguises++;
if (e instanceof DisguiseParseException) {
if (e.getMessage() != null) {
DisguiseUtilities.getLogger().severe(e.getMessage());
}
@ -978,6 +979,9 @@ public class DisguiseConfig {
if (e.getCause() != null) {
e.printStackTrace();
}
} else {
e.printStackTrace();
}
}
}

View File

@ -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);

View File

@ -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()));

View File

@ -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;
}

View File

@ -19,14 +19,14 @@ public class ParamInfoSoundGroup extends ParamInfoEnum {
}
public void recalculate() {
LinkedHashMap<String, Object> possibleSoundGroups = new LinkedHashMap<>();
LinkedHashMap<String, String> possibleSoundGroups = new LinkedHashMap<>();
ArrayList<String> 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();

View File

@ -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();
}