2010-11-17 03:49:08 +01:00
|
|
|
import java.io.*;
|
2010-09-29 18:38:54 +02:00
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
2010-10-09 03:20:41 +02:00
|
|
|
|
2010-09-29 18:38:54 +02:00
|
|
|
public class settings {
|
|
|
|
private final static Object syncLock = new Object();
|
|
|
|
protected static final Logger log = Logger.getLogger("Minecraft");
|
|
|
|
private static volatile settings instance;
|
|
|
|
static boolean toggle = true;
|
|
|
|
private boolean adminChat = false;
|
|
|
|
private boolean greentext = false;
|
|
|
|
private boolean FFF = false;
|
|
|
|
private boolean quakeColors = false;
|
|
|
|
private boolean cmdFabulous = false;
|
|
|
|
private boolean cmdPromote = false;
|
|
|
|
private boolean cmdDemote = false;
|
|
|
|
private boolean cmdWhoIs = false;
|
2010-10-09 06:15:57 +02:00
|
|
|
private boolean cmdRules = false;
|
2010-10-13 01:56:01 +02:00
|
|
|
private boolean cmdMasstp = false;
|
2010-10-09 06:15:57 +02:00
|
|
|
private boolean cmdTp = false;
|
|
|
|
private boolean cmdTphere = false;
|
|
|
|
private boolean globalmessages = false;
|
|
|
|
private boolean cmdSay = false;
|
2010-09-29 18:38:54 +02:00
|
|
|
private PropertiesFile properties;
|
|
|
|
String file = "vminecraft.properties";
|
2010-10-09 03:20:41 +02:00
|
|
|
public String rules[] = null;
|
2010-09-29 18:38:54 +02:00
|
|
|
|
2010-10-13 00:49:56 +02:00
|
|
|
public void loadSettings()
|
2010-10-09 03:20:41 +02:00
|
|
|
{
|
2010-11-17 03:49:08 +01:00
|
|
|
File theDir = new File("vminecraft.properties");
|
|
|
|
if(!theDir.exists())
|
2010-10-13 00:49:56 +02:00
|
|
|
{
|
2010-10-13 08:54:03 +02:00
|
|
|
String location = "vminecraft.properties";
|
2010-10-13 00:49:56 +02:00
|
|
|
properties = new PropertiesFile("vminecraft.properties");
|
2010-10-13 01:56:01 +02:00
|
|
|
FileWriter writer = null;
|
|
|
|
try {
|
|
|
|
writer = new FileWriter(location);
|
|
|
|
writer.write("#This plugin is modular\r\n");
|
|
|
|
writer.write("#Turn any features you don't want to false and they won't be running\r\n");
|
|
|
|
writer.write("#If you edit this file and save it, then use /reload it will reload the settings\r\n");
|
|
|
|
writer.write("greentext=true\r\n");
|
|
|
|
writer.write("quakeColors=true\r\n");
|
|
|
|
writer.write("cmdTphere=true\r\n");
|
|
|
|
writer.write("cmdFabulous=true\r\n");
|
|
|
|
writer.write("cmdWhoIs=true\r\n");
|
|
|
|
writer.write("cmdPromote=true\r\n");
|
|
|
|
writer.write("cmdDemote=true\r\n");
|
|
|
|
writer.write("cmdMasstp=true\r\n");
|
|
|
|
writer.write("cmdSay=true\r\n");
|
|
|
|
writer.write("cmdTp=true\r\n");
|
|
|
|
writer.write("cmdRules=true\r\n");
|
|
|
|
writer.write("globalmessages=true\r\n");
|
|
|
|
writer.write("FFF=true\r\n");
|
|
|
|
writer.write("adminchat=true\r\n");
|
2010-10-13 08:54:03 +02:00
|
|
|
writer.write("rules=Rules@#1: No griefing@#2: No griefing\r\n");
|
2010-10-13 01:56:01 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
log.log(Level.SEVERE, "Exception while creating " + location, e);
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (writer != null) {
|
|
|
|
writer.close();
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
log.log(Level.SEVERE, "Exception while closing writer for " + location, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-13 00:49:56 +02:00
|
|
|
} else {
|
2010-11-17 03:49:08 +01:00
|
|
|
properties = new PropertiesFile("vminecraft.properties");
|
2010-10-13 00:49:56 +02:00
|
|
|
properties.load();
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
adminChat = properties.getBoolean("adminchat",true);
|
|
|
|
greentext = properties.getBoolean("greentext",true);
|
|
|
|
FFF = properties.getBoolean("FFF",true);
|
|
|
|
quakeColors = properties.getBoolean("quakeColors",true);
|
|
|
|
cmdFabulous = properties.getBoolean("cmdFabulous",true);
|
|
|
|
cmdPromote = properties.getBoolean("cmdPromote",true);
|
|
|
|
cmdDemote = properties.getBoolean("cmdDemote",true);
|
|
|
|
cmdWhoIs = properties.getBoolean("cmdWhoIs",true);
|
|
|
|
cmdRules = properties.getBoolean("cmdRules",true);
|
|
|
|
cmdTp = properties.getBoolean("cmdTp",true);
|
2010-10-13 01:56:01 +02:00
|
|
|
cmdMasstp = properties.getBoolean("cmdMasstp",true);
|
2010-10-13 00:49:56 +02:00
|
|
|
cmdTphere = properties.getBoolean("cmdTphere",true);
|
|
|
|
globalmessages = properties.getBoolean("globalmessages",true);
|
|
|
|
cmdSay = properties.getBoolean("cmdSay",true);
|
|
|
|
rules = properties.getString("rules", "").split("@");
|
2010-11-17 03:49:08 +01:00
|
|
|
log.log(Level.INFO, "vminecraft plugin successfully loaded");
|
2010-10-13 00:49:56 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
log.log(Level.SEVERE, "vminecraft Error: ERROR LOADING PROPERTIES FILE");
|
|
|
|
}
|
2010-09-29 18:38:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean adminchat() {return adminChat;}
|
|
|
|
public boolean greentext() {return greentext;}
|
|
|
|
public boolean FFF() {return FFF;}
|
|
|
|
public boolean quakeColors() {return quakeColors;}
|
|
|
|
public boolean cmdFabulous() {return cmdFabulous;}
|
|
|
|
public boolean cmdPromote() {return cmdPromote;}
|
|
|
|
public boolean cmdDemote() {return cmdDemote;}
|
|
|
|
public boolean cmdWhoIs() {return cmdWhoIs;}
|
2010-10-09 06:15:57 +02:00
|
|
|
public boolean cmdTp() {return cmdTp;}
|
|
|
|
public boolean cmdTphere() {return cmdTphere;}
|
|
|
|
public boolean cmdSay() {return cmdSay;}
|
|
|
|
public boolean cmdRules() {return cmdRules;}
|
|
|
|
public boolean globalmessages() {return globalmessages;}
|
2010-10-13 01:56:01 +02:00
|
|
|
public boolean cmdMasstp() {return cmdMasstp;}
|
2010-09-29 18:38:54 +02:00
|
|
|
|
|
|
|
public static settings getInstance() {
|
|
|
|
if (instance == null) {
|
|
|
|
instance = new settings();
|
|
|
|
}
|
|
|
|
|
|
|
|
return instance;
|
|
|
|
}
|
2010-10-09 03:20:41 +02:00
|
|
|
//Will return the rules
|
|
|
|
public String[] getRules() {
|
|
|
|
return rules;
|
|
|
|
}
|
|
|
|
|
2010-09-29 18:38:54 +02:00
|
|
|
}
|