PexTabChat

A Bukkit-Plugin based around the PermissionEx-Api. The core features are a colored tablist and a chatformat.
git clone git://git.oshgnacknak.de/PexTabChat.git
Log | Files | Refs | README | LICENSE

Config.java (2221B)


      1 package de.oshgnacknak.PexTabChat;
      2 
      3 import java.io.File;
      4 import java.io.IOException;
      5 
      6 import org.bukkit.configuration.InvalidConfigurationException;
      7 import org.bukkit.configuration.file.YamlConfiguration;
      8 
      9 //This class is for loading and holding the config.yml in the working memory
     10 
     11 public class Config {
     12 	// SIGLETON
     13 	public static final Config global = new Config();
     14 
     15 	private Config() {
     16 	}
     17 
     18 	public TablistText tablisttext;
     19 	public Format chatformat;
     20 	public boolean tablistnames;
     21 	public Joinquit joinquit;
     22 
     23 	public void load() throws IOException, InvalidConfigurationException {
     24 		File file = new File("plugins/" + Main.getPlugin().getName() + "/config.yml");
     25 		
     26 		file.getParentFile().mkdirs();
     27 		if (!file.exists()) {
     28 			Main.getPlugin().getConfig().options().copyDefaults(true);
     29 			Main.getPlugin().saveConfig();
     30 		}
     31 		
     32 		YamlConfiguration config = new YamlConfiguration();
     33 		config.load(file);
     34 		
     35 		tablisttext = new TablistText(config.getBoolean("tablisttext.enabled"), config.getString("tablisttext.header"),
     36 				config.getString("tablisttext.footer"));
     37 
     38 		chatformat = new Format(config.getBoolean("chatformat.enabled"), config.getString("chatformat.format"));
     39 
     40 		tablistnames = config.getBoolean("tablistnames");
     41 
     42 		joinquit = new Joinquit(config.getBoolean("joinquit.enabled"), config.getString("joinquit.join"),
     43 				config.getString("joinquit.quit"));
     44 	}
     45 
     46 	public class TablistText {
     47 		public final boolean enabled;
     48 		public final String header;
     49 		public final String footer;
     50 
     51 		public TablistText(boolean enabled, String header, String footer) {
     52 			this.enabled = enabled;
     53 			this.header = header;
     54 			this.footer = footer;
     55 		}
     56 	}
     57 
     58 	public class Format { // For chatformat
     59 		public final boolean enabled;
     60 		public final String format;
     61 
     62 		public Format(boolean enabled, String format) {
     63 			this.enabled = enabled;
     64 			this.format = format;
     65 		}
     66 		
     67 		@Override
     68 			public String toString() {
     69 				return "enabled=" + enabled + " format" + format;
     70 			}
     71 	}
     72 
     73 	public class Joinquit {
     74 		public final boolean enabled;
     75 		public final String join;
     76 		public final String quit;
     77 
     78 		public Joinquit(boolean enabled, String join, String quit) {
     79 			this.enabled = enabled;
     80 			this.join = join;
     81 			this.quit = quit;
     82 		}
     83 	}
     84 }