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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
package net.minecraft.server;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import joptsimple.OptionSet; // CraftBukkit
public class PropertyManager {
public static Logger a = Logger.getLogger("Minecraft");
private Properties b = new Properties();
private File c;
public PropertyManager(File file1) {
this.c = file1;
if (file1.exists()) {
try {
this.b.load(new FileInputStream(file1));
} catch (Exception exception) {
a.log(Level.WARNING, "Failed to load " + file1, exception);
this.a();
}
} else {
a.log(Level.WARNING, file1 + " does not exist");
this.a();
}
}
// CraftBukkit start
private OptionSet options = null;
public PropertyManager(final OptionSet options) {
this((File) options.valueOf("config"));
this.options = options;
}
private <T> T getOverride(String name, T value) {
if ((options != null) && (options.has(name))) {
return (T) options.valueOf(name);
}
return value;
}
// CraftBukkit end
public void a() {
a.log(Level.INFO, "Generating new properties file");
this.b();
}
public void b() {
try {
this.b.store(new FileOutputStream(this.c), "Minecraft server properties");
} catch (Exception exception) {
a.log(Level.WARNING, "Failed to save " + this.c, exception);
this.a();
}
}
public String a(String s, String s1) {
if (!this.b.containsKey(s)) {
this.b.setProperty(s, getOverride(s, s1)); // CraftBukkit
this.b();
}
return getOverride(s, this.b.getProperty(s, s1)); // CraftBukkit
}
public int a(String s, int i) {
try {
return getOverride(s, Integer.parseInt(this.a(s, "" + i))); // CraftBukkit
} catch (Exception exception) {
i = getOverride(s, i); // CraftBukkit
this.b.setProperty(s, "" + i);
return i;
}
}
public boolean a(String s, boolean flag) {
try {
return getOverride(s, Boolean.parseBoolean(this.a(s, "" + flag))); // CraftBukkit
} catch (Exception exception) {
flag = getOverride(s, flag); // CraftBukkit
this.b.setProperty(s, "" + flag);
return flag;
}
}
public void b(String s, boolean flag) {
flag = getOverride(s, flag); // CraftBukkit
this.b.setProperty(s, "" + flag);
this.b();
}
}
|