nicatronTg

Shank

Feb 3rd, 2011
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.50 KB | None | 0 0
  1.     public void loadConfig(String name){
  2.         File file = new File(getDataFolder(), "config.yml");
  3.         if (!file.exists()){
  4.             InputStream defaultFile = ShankAFK.class.getResourceAsStream("/config/" + name);
  5.             try {
  6.                 FileOutputStream writer = new FileOutputStream(file);
  7.                 byte[] buf = new byte[8192];
  8.                 int length = 0;
  9.                 try {
  10.                     while ((length = defaultFile.read(buf)) > 0){
  11.                         writer.write(buf, 0, length);
  12.                     }
  13.                 } catch (IOException e) {
  14.                     e.printStackTrace();
  15.                 } finally {
  16.                     try {
  17.                         writer.close();
  18.                     } catch (IOException e) {
  19.                         e.printStackTrace();
  20.                     }
  21.                 }
  22.             } catch (FileNotFoundException e) {
  23.                 e.printStackTrace();
  24.             } finally {
  25.                 try {
  26.                     defaultFile.close();
  27.                 } catch (IOException e) {
  28.                     e.printStackTrace();
  29.                 }
  30.                
  31.             }
  32.            
  33.            
  34.         }
  35.         Configuration config = new Configuration(file);
  36.         config.load();
  37.         playerThreshold = config.getInt("player-threshold", 15);
  38.         playerIdleTime = config.getInt("player-idletime", 900);
  39.         kickMsg = config.getString("kick-message");
  40.         announceKick = config.getBoolean("announce", true);
  41.        
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment