Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Commit 9bfa057

Browse files
committed
add acl
1 parent 4205444 commit 9bfa057

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/main/java/cat/nyaa/nyaautils/Acl.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import java.util.*;
1010

1111
public class Acl extends FileConfigure {
12-
12+
public boolean default_enchant = true;
13+
public boolean default_repair = true;
1314
public static class list implements ISerializable {
1415
@Serializable
1516
boolean enchant = true;
@@ -41,6 +42,12 @@ protected JavaPlugin getPlugin() {
4142
public void deserialize(ConfigurationSection config) {
4243
aclMap.clear();
4344
for (String key : config.getKeys(false)) {
45+
if (key.equals("default")) {
46+
ConfigurationSection Default = config.getConfigurationSection(key);
47+
this.default_enchant = Default.getBoolean("enchant", this.default_enchant);
48+
this.default_repair = Default.getBoolean("repair", this.default_repair);
49+
continue;
50+
}
4451
if (!config.isConfigurationSection(key)) continue;
4552
list list = new list();
4653
list.deserialize(config.getConfigurationSection(key));
@@ -54,6 +61,9 @@ public void serialize(ConfigurationSection config) {
5461
for (String key : tmp) { // clear section
5562
config.set(key, null);
5663
}
64+
ConfigurationSection Default = config.createSection("default");
65+
Default.set("enchant", this.default_enchant);
66+
Default.set("repair", this.default_repair);
5767

5868
for (Map.Entry<String, list> pair : aclMap.entrySet()) {
5969
ConfigurationSection section = config.createSection(pair.getKey());
@@ -64,23 +74,23 @@ public void serialize(ConfigurationSection config) {
6474
public boolean canEnchant(List<String> lore) {
6575
for (String s : lore) {
6676
if (aclMap.containsKey(ChatColor.stripColor(s))) {
67-
if (aclMap.get(ChatColor.stripColor(s)).enchant != plugin.cfg.acl_default_enchant) {
77+
if (aclMap.get(ChatColor.stripColor(s)).enchant != this.default_enchant) {
6878
return aclMap.get(ChatColor.stripColor(s)).enchant;
6979
}
7080
}
7181
}
72-
return plugin.cfg.acl_default_enchant;
82+
return this.default_enchant;
7383

7484
}
7585

7686
public boolean canRepair(List<String> lore) {
7787
for (String s : lore) {
7888
if (aclMap.containsKey(ChatColor.stripColor(s))) {
79-
if (aclMap.get(ChatColor.stripColor(s)).repair != plugin.cfg.acl_default_repair) {
89+
if (aclMap.get(ChatColor.stripColor(s)).repair != this.default_repair) {
8090
return aclMap.get(ChatColor.stripColor(s)).repair;
8191
}
8292
}
8393
}
84-
return plugin.cfg.acl_default_repair;
94+
return this.default_repair;
8595
}
8696
}

src/main/java/cat/nyaa/nyaautils/Configuration.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ public class Configuration implements ISerializable {
8686
public int mailCooldown = 20;
8787
@Serializable(name = "mail.timeoutTicks")
8888
public int mailTimeout = 200;
89-
@Serializable
90-
public boolean acl_default_enchant = true;
91-
@Serializable
92-
public boolean acl_default_repair = true;
9389

9490
public List<BasicItemMatcher> enchantSrc = new ArrayList<>();
9591
public HashMap<Enchantment, Integer> enchantMaxLevel = new HashMap<>();

0 commit comments

Comments
 (0)