-
Notifications
You must be signed in to change notification settings - Fork 1
/
Config.java
76 lines (61 loc) · 1.86 KB
/
Config.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.echo28.bukkit.craftdispenser.crafts;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.block.Block;
import org.bukkit.util.config.Configuration;
import com.echo28.bukkit.craftdispenser.CraftDispenser;
import com.echo28.bukkit.craftdispenser.Items;
public class Config extends Craft
{
private List<Configuration> configs = new ArrayList<Configuration>();
public Config(CraftDispenser plugin, Block block)
{
super(plugin, block);
loadCustom();
}
private void loadCustom()
{
for (File file : plugin.getDataFolder().listFiles())
{
if (file.getName().equalsIgnoreCase("config.yml"))
continue;
Configuration config = new Configuration(file);
config.load();
configs.add(config);
}
}
@Override
public boolean make()
{
for (Configuration config : configs)
{
if (checkConfig(config))
{
int[][] items = Items.parseItemList(config.getStringList("craft", null));
CraftDispenser.dispenseItems(block, Items.createItemStacks(items));
int[][] outputItems = Items.parseItemList(config.getStringList("output-items", null));
if (outputItems != null && outputItems.length == 9) {
for (int i = 0; i < 9; i++) {
int[] item = outputItems[i];
if (item[0] != 0 && item[0] != -1) {
inventory.setItem(i, Items.createItemStack(item));
}
}
}
return true;
}
}
return false;
}
private boolean checkConfig(Configuration config)
{
if (config.getProperty("input-items-vertical") != null) {
return checkVerticalItems(Items.parseItemList(config.getStringList("input-items-vertical", null)));
}
if (config.getProperty("input-items") != null) {
return checkCustomItems(Items.parseItemList(config.getStringList("input-items", null)));
}
return false;
}
}