Skip to content

Commit 8a52ce8

Browse files
authored
Don't create help and permissions files by default
Adding permissions to commands that don't have any yet may be eventually put into a more easily usable config option, or into a separate plugin. Changing help messages seems to have no use whatsoever and offers less than stellar configurability anyway
1 parent 572ef8f commit 8a52ce8

2 files changed

Lines changed: 14 additions & 20 deletions

File tree

paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,19 +1111,18 @@ private void loadIcon() {
11111111
}
11121112
}
11131113

1114-
@SuppressWarnings({ "unchecked", "finally" })
11151114
private void loadCustomPermissions() {
11161115
File file = new File(this.configuration.getString("settings.permissions-file"));
1116+
if (!file.isFile()) {
1117+
return;
1118+
}
1119+
11171120
FileInputStream stream;
11181121

11191122
try {
11201123
stream = new FileInputStream(file);
11211124
} catch (FileNotFoundException ex) {
1122-
try {
1123-
file.createNewFile();
1124-
} finally {
1125-
return;
1126-
}
1125+
return;
11271126
}
11281127

11291128
Map<String, Map<String, Object>> perms;

paper-server/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package org.bukkit.craftbukkit.help;
22

33
import java.io.File;
4-
import java.io.IOException;
54
import java.io.InputStreamReader;
65
import java.nio.charset.StandardCharsets;
76
import java.util.LinkedList;
87
import java.util.List;
9-
import java.util.logging.Level;
108
import org.bukkit.ChatColor;
119
import org.bukkit.Server;
1210
import org.bukkit.configuration.ConfigurationSection;
@@ -27,21 +25,18 @@ public HelpYamlReader(Server server) {
2725

2826
File helpYamlFile = new File("help.yml");
2927
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("configurations/help.yml"), StandardCharsets.UTF_8));
28+
this.helpYaml = defaultConfig;
3029

31-
try {
32-
this.helpYaml = YamlConfiguration.loadConfiguration(helpYamlFile);
33-
this.helpYaml.options().copyDefaults(true);
34-
this.helpYaml.setDefaults(defaultConfig);
35-
this.helpYaml.options().setHeader(defaultConfig.options().getHeader());
36-
30+
if (helpYamlFile.isFile()) {
3731
try {
38-
this.helpYaml.save(helpYamlFile);
39-
} catch (IOException ex) {
40-
server.getLogger().log(Level.SEVERE, "Could not save " + helpYamlFile, ex);
32+
this.helpYaml = YamlConfiguration.loadConfiguration(helpYamlFile);
33+
this.helpYaml.options().copyDefaults(true);
34+
this.helpYaml.setDefaults(defaultConfig);
35+
this.helpYaml.options().setHeader(defaultConfig.options().getHeader());
36+
} catch (Exception ex) {
37+
server.getLogger().severe("Failed to load help.yml. Verify the yaml indentation is correct. Reverting to default help.yml.");
38+
this.helpYaml = defaultConfig;
4139
}
42-
} catch (Exception ex) {
43-
server.getLogger().severe("Failed to load help.yml. Verify the yaml indentation is correct. Reverting to default help.yml.");
44-
this.helpYaml = defaultConfig;
4540
}
4641
}
4742

0 commit comments

Comments
 (0)