Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.WMisiedjan.Infchests;
- import java.io.File;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Hashtable;
- import java.util.List;
- import org.bukkit.Server;
- import org.bukkit.World;
- import org.bukkit.util.config.Configuration;
- public class InfChestConfiguration {
- private File pluginfolder;
- private File pluginconfig;
- private StackableLogger log = new StackableLogger("InfChests");
- private Hashtable<String, Object> configtable;
- private List<String> allowedWorlds;
- public Configuration ConfY;
- private Server BServer;
- public InfChestConfiguration(Server server) {
- this.pluginfolder = new File("plugins\\InfChests");
- this.pluginconfig = new File("plugins\\InfChests\\config.yml");
- this.configtable = new Hashtable<String, Object>();
- this.allowedWorlds = new ArrayList<String>();
- this.BServer = server;
- }
- public boolean isFirstrun() {
- if (this.getPluginFolder().exists()) {
- return false;
- } else {
- return true;
- }
- }
- public boolean CreatePluginFiles() {
- if (!this.getPluginFolder().mkdir()) {
- log.warning("Error Creating plugin folder.");
- return false;
- } else {
- try {
- if (!this.getConfigFile().createNewFile()) {
- log.warning("Error Creating plugin Configuration.");
- return false;
- } else {
- return true;
- }
- } catch (IOException e) {
- e.printStackTrace();
- return false;
- }
- }
- }
- public boolean CreateConfiguration() {
- //Load Worlds
- ConfY = new Configuration(pluginconfig);
- List<String> worlds = new ArrayList<String>();
- for(World world : BServer.getWorlds())
- {
- worlds.add(world.getName());
- }
- ConfY.setProperty("AllowedWorlds", worlds);
- if (ConfY.save())
- return true;
- else
- return false;
- }
- public boolean LoadConfiguration()
- {
- ConfY = new Configuration(pluginconfig);
- Object list = ConfY.getProperty("AllowedWorlds");
- if(list instanceof List<?>)
- {
- this.allowedWorlds = (List<String>)list;
- }
- else
- {
- return false;
- }
- return true;
- }
- public File getPluginFolder() {
- return pluginfolder;
- }
- public File getConfigFile() {
- return pluginconfig;
- }
- public List<String> getAllowedWorlds()
- {
- return this.allowedWorlds;
- }
- public boolean AddAllowedWorld(String name)
- {
- return this.allowedWorlds.add(name);
- }
- public Hashtable<String, Object> getConfigTable() {
- return configtable;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement