Skip to content

Commit ed3eaab

Browse files
committed
Fixed dependency/imports that come from Bukkit
1 parent c181aec commit ed3eaab

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

API/src/main/java/io/github/thatsmusic99/configurationmaster/api/ConfigFile.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package io.github.thatsmusic99.configurationmaster.api;
22

3-
import com.google.common.collect.Lists;
43
import io.github.thatsmusic99.configurationmaster.impl.CMConfigSection;
5-
import org.bukkit.configuration.file.YamlConstructor;
6-
import org.bukkit.configuration.file.YamlRepresenter;
74
import org.jetbrains.annotations.NotNull;
85
import org.yaml.snakeyaml.DumperOptions;
96
import org.yaml.snakeyaml.LoaderOptions;
107
import org.yaml.snakeyaml.Yaml;
8+
import org.yaml.snakeyaml.constructor.SafeConstructor;
119
import org.yaml.snakeyaml.error.YAMLException;
1210
import org.yaml.snakeyaml.representer.Representer;
1311

@@ -20,7 +18,7 @@ public class ConfigFile extends CMConfigSection {
2018
private final Yaml yaml;
2119
private final DumperOptions yamlOptions = new DumperOptions();
2220
private final LoaderOptions loaderOptions = new LoaderOptions();
23-
private final Representer yamlRepresenter = new YamlRepresenter();
21+
private final Representer yamlRepresenter = new Representer();
2422
private final File file;
2523
private boolean isNew = false;
2624
private CommentWriter writer;
@@ -35,7 +33,7 @@ public class ConfigFile extends CMConfigSection {
3533
* @param file The config file to be loaded.
3634
*/
3735
public ConfigFile(@NotNull File file) {
38-
yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions, loaderOptions);
36+
yaml = new Yaml(new SafeConstructor(), yamlRepresenter, yamlOptions, loaderOptions);
3937
yamlOptions.setIndent(2);
4038
yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
4139
yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
@@ -139,7 +137,7 @@ public String saveToString() {
139137
if (dump.equals("{}")) {
140138
dump = "";
141139
}
142-
writer.writeComments(Lists.newArrayList(dump.split("\n")));
140+
writer.writeComments(new ArrayList<>(Arrays.asList(dump.split("\n"))));
143141
StringBuilder result = new StringBuilder();
144142
for (String line : writer.getLines()) {
145143
result.append(line).append("\n");

API/src/main/java/io/github/thatsmusic99/configurationmaster/impl/CMConfigSection.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
package io.github.thatsmusic99.configurationmaster.impl;
22

3-
import com.google.common.collect.Lists;
43
import io.github.thatsmusic99.configurationmaster.api.ConfigFile;
54
import io.github.thatsmusic99.configurationmaster.api.ConfigSection;
65
import org.jetbrains.annotations.NotNull;
76
import org.jetbrains.annotations.Nullable;
87

9-
import java.util.HashMap;
10-
import java.util.LinkedHashMap;
11-
import java.util.List;
12-
import java.util.Map;
8+
import java.util.*;
139

1410
public class CMConfigSection extends CMMemorySection implements ConfigSection {
1511

@@ -36,7 +32,7 @@ public void addDefault(@NotNull String path, Object defaultOption, @Nullable Str
3632
if (cmSection == null) cmSection = createSectionInternal(path);
3733
String key = path.substring(path.lastIndexOf('.') + 1);
3834
// Move comments to parent option
39-
List<String> comments = Lists.newArrayList(getParent().getPendingComments());
35+
List<String> comments = new ArrayList<>(getParent().getPendingComments());
4036
String parentSection = path.substring(0, path.indexOf('.') == -1 ? path.length() : path.indexOf('.'));
4137
addComments(parentSection, comments.toArray(new String[]{}));
4238
comments.clear();

API/src/test/java/io/github/thatsmusic99/configurationmaster/AdvancedTeleportTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.github.thatsmusic99.configurationmaster;
22

3-
import com.google.common.collect.Lists;
43
import io.github.thatsmusic99.configurationmaster.api.ConfigFile;
54
import org.junit.Assert;
65
import org.junit.Test;
@@ -297,6 +296,6 @@ public void initATConfig() throws IOException {
297296
config.set("cooldown-duration", "60");
298297
Assert.assertEquals("60", config.getString("cooldown-duration"));
299298
Assert.assertEquals(60, config.getInteger("cooldown-duration"));
300-
Assert.assertEquals(Lists.newArrayList(), config.getList("disabled-commands"));
299+
Assert.assertEquals(new ArrayList<>(), config.getList("disabled-commands"));
301300
}
302301
}

0 commit comments

Comments
 (0)