mirror of
https://github.com/filoghost/ChestCommands.git
synced 2025-02-20 21:41:49 +01:00
Much cleaner method.
This commit is contained in:
parent
0d764dc66c
commit
a71584b0b9
@ -38,6 +38,7 @@ import com.gmail.filoghost.chestcommands.task.ErrorLoggerTask;
|
|||||||
import com.gmail.filoghost.chestcommands.util.CaseInsensitiveMap;
|
import com.gmail.filoghost.chestcommands.util.CaseInsensitiveMap;
|
||||||
import com.gmail.filoghost.chestcommands.util.ErrorLogger;
|
import com.gmail.filoghost.chestcommands.util.ErrorLogger;
|
||||||
import com.gmail.filoghost.chestcommands.util.Utils;
|
import com.gmail.filoghost.chestcommands.util.Utils;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
public class ChestCommands extends JavaPlugin {
|
public class ChestCommands extends JavaPlugin {
|
||||||
@ -180,7 +181,6 @@ public class ChestCommands extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the menus.
|
// Load the menus.
|
||||||
List<PluginConfig> menusList = new ArrayList<PluginConfig>();
|
|
||||||
File menusFolder = new File(getDataFolder(), "menu");
|
File menusFolder = new File(getDataFolder(), "menu");
|
||||||
|
|
||||||
if (!menusFolder.isDirectory()) {
|
if (!menusFolder.isDirectory()) {
|
||||||
@ -189,7 +189,7 @@ public class ChestCommands extends JavaPlugin {
|
|||||||
Utils.saveResourceSafe(this, "menu" + File.separator + "example.yml");
|
Utils.saveResourceSafe(this, "menu" + File.separator + "example.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMenus(menusList, menusFolder);
|
List<PluginConfig> menusList = loadMenus(menusFolder);
|
||||||
for (PluginConfig menuConfig : menusList) {
|
for (PluginConfig menuConfig : menusList) {
|
||||||
try {
|
try {
|
||||||
menuConfig.load();
|
menuConfig.load();
|
||||||
@ -241,16 +241,18 @@ public class ChestCommands extends JavaPlugin {
|
|||||||
/**
|
/**
|
||||||
* Loads all the configuration files recursively into a list.
|
* Loads all the configuration files recursively into a list.
|
||||||
*/
|
*/
|
||||||
private void loadMenus(List<PluginConfig> list, File file) {
|
private List<PluginConfig> loadMenus(File file) {
|
||||||
|
List<PluginConfig> list = Lists.newArrayList();
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
for (File subFile : file.listFiles()) {
|
for (File subFile : file.listFiles()) {
|
||||||
loadMenus(list, subFile);
|
list.addAll(loadMenus(subFile));
|
||||||
}
|
}
|
||||||
} else if (file.isFile()) {
|
} else if (file.isFile()) {
|
||||||
if (file.getName().endsWith(".yml")) {
|
if (file.getName().endsWith(".yml")) {
|
||||||
list.add(new PluginConfig(this, file));
|
list.add(new PluginConfig(this, file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChestCommands getInstance() {
|
public static ChestCommands getInstance() {
|
||||||
|
Loading…
Reference in New Issue
Block a user