Minor code cleanup
This commit is contained in:
parent
2cb8d90158
commit
93f807e6c9
@ -144,43 +144,50 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
|
|
||||||
private String read(Reader reader) {
|
private String read(Reader reader) {
|
||||||
String toWrite = "";
|
String toWrite = "";
|
||||||
try {
|
BufferedReader input = null;
|
||||||
BufferedReader input = new BufferedReader(reader);
|
|
||||||
String currentPath = "";
|
|
||||||
try {
|
|
||||||
String line;
|
|
||||||
|
|
||||||
while ((line = input.readLine()) != null) {
|
try {
|
||||||
if (line.replace(" ", "").startsWith("#")) {
|
input = new BufferedReader(reader);
|
||||||
|
String currentPath = "";
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while ((line = input.readLine()) != null) {
|
||||||
|
if (line.replace(" ", "").startsWith("#")) {
|
||||||
|
toWrite += line;
|
||||||
|
} else if (line.contains(":")) {
|
||||||
|
if (line.substring(line.indexOf(":") + 1).equals("")) {
|
||||||
|
currentPath = line.substring(0, line.length() - 1) + ".";
|
||||||
toWrite += line;
|
toWrite += line;
|
||||||
} else if (line.contains(":")) {
|
} else {
|
||||||
if (line.substring(line.indexOf(":") + 1).equals("")) {
|
if (!line.startsWith(" ")) {
|
||||||
currentPath = line.substring(0, line.length() - 1) + ".";
|
currentPath = "";
|
||||||
toWrite += line;
|
|
||||||
} else {
|
|
||||||
if (!line.startsWith(" ")) {
|
|
||||||
currentPath = "";
|
|
||||||
}
|
|
||||||
String obj = line.substring(0, line.indexOf(":")).replace(" ", "");
|
|
||||||
Object value = getConfig().get(currentPath + obj);
|
|
||||||
if (value instanceof String) {
|
|
||||||
value = "'" + value + "'";
|
|
||||||
}
|
|
||||||
toWrite += (currentPath.length() == 0 ? "" : " ") + obj + ": " + value;
|
|
||||||
}
|
}
|
||||||
}
|
String obj = line.substring(0, line.indexOf(":")).replace(" ", "");
|
||||||
if (input.ready()) {
|
Object value = getConfig().get(currentPath + obj);
|
||||||
toWrite += "\n";
|
if (value instanceof String) {
|
||||||
|
value = "'" + value + "'";
|
||||||
|
}
|
||||||
|
toWrite += (currentPath.length() == 0 ? "" : " ") + obj + ": " + value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
if (input.ready()) {
|
||||||
input.close();
|
toWrite += "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
reader.close();
|
if (input != null) {
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (reader != null) {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user