spenk

Untitled

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