Einfaches /roll Modul
This commit is contained in:
89
src/main/java/Simpleroll/language.java
Normal file
89
src/main/java/Simpleroll/language.java
Normal file
@ -0,0 +1,89 @@
|
||||
package Simpleroll;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
public class language {
|
||||
|
||||
public String language = "Deutsch";
|
||||
public String emptyCommand = " der %command% befehl benötigt einen Wert";
|
||||
public String error = " Irgend was dummes ist passiert beim Verstehen von %command%";
|
||||
public String error2 = " Irgend was dummes ist passiert beim Verstehen von %command%";
|
||||
public String noNegativ = " es darf kein Negativen Wurf geben";
|
||||
public String dice = "w";
|
||||
public String resultText = " %numberOfDice%w%diceart% %EdgeDice%:\tErfolge: %hits%\tMisserfolge: %oneHits%";
|
||||
public String basisresultText = " %numberOfDice%w%diceart%:";
|
||||
|
||||
public language() {
|
||||
this.readConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param lang Srache
|
||||
*/
|
||||
public language(String lang) {
|
||||
this.readConfig(lang);
|
||||
}
|
||||
|
||||
public void readConfig() {
|
||||
this.readConfig("de");
|
||||
}
|
||||
public void readConfig(String lang) {
|
||||
FileInputStream input = null;
|
||||
OutputStream output = null;
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
File f = new File("shadowrun.cfg");
|
||||
if (f.isFile() && f.canRead()) {
|
||||
|
||||
input = new FileInputStream("shadowrun.cfg");
|
||||
config.load(input);
|
||||
if(config.containsKey(lang + ".language"))
|
||||
this.language = config.getProperty(lang + ".language");
|
||||
|
||||
if(config.containsKey(lang + ".emptyCommand"))
|
||||
this.emptyCommand = config.getProperty(lang + ".emptyCommand");
|
||||
if(config.containsKey(lang + ".error"))
|
||||
this.error = config.getProperty(lang + ".error");
|
||||
if(config.containsKey(lang + ".error2"))
|
||||
this.error2 = config.getProperty(lang + ".error2");
|
||||
if(config.containsKey(lang + ".noNegativ"))
|
||||
this.noNegativ = config.getProperty(lang + ".noNegativ");
|
||||
if(config.containsKey(lang + ".dice"))
|
||||
this.dice = config.getProperty(lang + ".dice");
|
||||
if(config.containsKey(lang + ".resultText"))
|
||||
this.resultText = config.getProperty(lang + ".resultText");
|
||||
if(config.containsKey(lang + ".basisresultText"))
|
||||
this.resultText = config.getProperty(lang + ".basisresultText");
|
||||
|
||||
}
|
||||
else {
|
||||
output = new FileOutputStream("shadowrun.cfg");
|
||||
config.setProperty(lang + ".language", this.language);
|
||||
config.setProperty(lang + ".emptyCommand", this.emptyCommand);
|
||||
config.setProperty(lang + ".error", this.error);
|
||||
config.setProperty(lang + ".error2", this.error2);
|
||||
config.setProperty(lang + ".noNegativ", this.noNegativ);
|
||||
config.setProperty(lang + ".dice", this.dice);
|
||||
config.setProperty(lang + ".resultText", this.resultText);
|
||||
config.setProperty(lang + ".basisresultText", this.basisresultText);
|
||||
config.store(output, null);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
finally {
|
||||
if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user