mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-25 15:35:11 +01:00
Fixed malformedextensionexception verbosity
This commit is contained in:
parent
0fce11d439
commit
a0d438c2c1
@ -1,6 +1,7 @@
|
|||||||
package com.willfp.ecoenchants.extensions;
|
package com.willfp.ecoenchants.extensions;
|
||||||
|
|
||||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||||
|
import com.willfp.ecoenchants.util.Logger;
|
||||||
import com.willfp.ecoenchants.util.tuplets.Pair;
|
import com.willfp.ecoenchants.util.tuplets.Pair;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -11,8 +12,13 @@ import java.io.InputStreamReader;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class containing method to load extensions
|
* Class containing method to load extensions
|
||||||
@ -64,8 +70,12 @@ public class ExtensionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
YamlConfiguration extensionYml = YamlConfiguration.loadConfiguration(new InputStreamReader(ymlIn));
|
YamlConfiguration extensionYml = YamlConfiguration.loadConfiguration(new InputStreamReader(ymlIn));
|
||||||
if (!extensionYml.getKeys(false).contains("main") || !extensionYml.getKeys(false).contains("name") || !extensionYml.getKeys(false).contains("version")) {
|
|
||||||
throw new MalformedExtensionException("Invalid extension.yml found in " + extensionJar.getName());
|
Set<String> keys = extensionYml.getKeys(false);
|
||||||
|
ArrayList<String> required = new ArrayList<>(Arrays.asList("main", "name", "version"));
|
||||||
|
required.removeAll(keys);
|
||||||
|
if(!required.isEmpty()) {
|
||||||
|
throw new MalformedExtensionException("Invalid extension.yml found in " + extensionJar.getName() + " - Missing: " + String.join(", ", required));
|
||||||
}
|
}
|
||||||
|
|
||||||
String mainClass = extensionYml.getString("main");
|
String mainClass = extensionYml.getString("main");
|
||||||
|
Loading…
Reference in New Issue
Block a user