spenk

Jail

Mar 15th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.62 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.logging.Logger;
  3.  
  4.  
  5. public class Jail extends Plugin
  6. {
  7.       String name = "jail";
  8.       String version = "1.0";
  9.       String author = " Spenk";
  10.       static Logger log = Logger.getLogger("Minecraft");
  11.         JailSet js = new JailSet();
  12.         JailDel jd = new JailDel();
  13.         JailWand jw = new JailWand();
  14.         JailListener jl = new JailListener();
  15.         JailProps props = new JailProps();
  16.      
  17.      
  18. public void initialize(){
  19. log.info(this.name +" version "+ this.version + " by " +this.author+(" is initialized!"));
  20. etc.getLoader().addListener(PluginLoader.Hook.COMMAND, js, this, PluginListener.Priority.MEDIUM);
  21. etc.getLoader().addListener(PluginLoader.Hook.COMMAND, jd, this, PluginListener.Priority.MEDIUM);
  22. etc.getLoader().addListener(PluginLoader.Hook.COMMAND, jw, this, PluginListener.Priority.MEDIUM);
  23. etc.getLoader().addListener(PluginLoader.Hook.COMMAND, jl, this, PluginListener.Priority.MEDIUM);
  24. etc.getLoader().addListener(PluginLoader.Hook.BLOCK_RIGHTCLICKED, jw, this, PluginListener.Priority.MEDIUM);
  25. File f = new File("plugins/config");
  26. f.mkdir();
  27. File f1 = new File("plugins/config/Jail");
  28. f1.mkdir();
  29. File f2 = new File("plugins/config/Jail/Jailes");
  30. f2.mkdir();
  31. props.load();
  32. if (!new File("plugins/config/Jail/Jails.properties").exists()) {
  33.     new PropertiesFile("plugins/config/Jail/Jails.properties");
  34. }
  35. Writer writer = null;
  36. File filename;
  37. try {
  38. filename = new File("config/groups.txt");
  39. writer = new BufferedWriter(new FileWriter(filename, true));
  40. if (!isInList(props.group)){
  41.     writer.write("\n"+props.group);
  42. }else{
  43.     return;
  44. }
  45. } catch (FileNotFoundException e) {
  46.     log.info("[ERROR] Groups File not found.");
  47.     return;
  48. } catch (IOException e) {
  49.         log.info("[ERROR] File IOException Found o.O");
  50.         return;
  51. } finally {
  52.     try {
  53.         if (writer != null) {
  54.             writer.close();
  55.         }
  56.     } catch (IOException e) {
  57.         log.info("[ERROR] File IOException Found o.O");
  58.         return;
  59.     }
  60. }
  61. }
  62. public void enable(){
  63.     log.info(this.name + " version " + this.version + " by " + this.author + " is enabled!");
  64. }
  65.  
  66. public void disable(){
  67.     log.info(this.name + " version " + this.version + " is disabled!");
  68. }
  69.  
  70. public boolean isInList(String playername) {
  71.     try {
  72.       BufferedReader in = new BufferedReader(new FileReader("config/groups.txt"));
  73.       String line = in.readLine();
  74.       while (line != null) {
  75.         if (line.equalsIgnoreCase(props.group)) {
  76.           in.close();
  77.           return true;
  78.         }
  79.         line = in.readLine();
  80.       }
  81.       in.close();
  82.     } catch (IOException localIOException) {
  83.     }
  84.     return false; }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment