mrkirby153

Untitled

May 1st, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.83 KB | None | 0 0
  1. package com.mrkirby153.ExtremeHardcore;
  2.  
  3. import java.io.File;
  4. import java.util.List;
  5. import java.util.Scanner;
  6.  
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.configuration.file.FileConfiguration;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12.  
  13. public class Main extends JavaPlugin{
  14.     FileConfiguration config = getConfig();
  15.     File playerList = new File("plugins" +File.separator + "ExtremeHardcore" + File.separator + "playerList.txt");
  16.     List<String> hardcorePlayers;
  17.     @Override
  18.     public void onEnable() {
  19.         getLogger().info("[Extreme Hardcore] Extreme hardcore has been Enabled!");
  20.     }
  21.  
  22.     @Override
  23.     public void onDisable() {
  24.         getLogger().info("[Extreme Hardcore] Saving players...");
  25.         getLogger().info("[Extreme Hardcore] Extreme hardocre has been Disabled!");
  26.     }
  27.  
  28.     public void loadConfig(){
  29.         this.saveDefaultConfig();
  30.  
  31.     }
  32.     public void loadPlayerListFromFile(){
  33.         try{
  34.             if(!playerList.exists()){
  35.                 getLogger().info("[Extreme Hardcore] Created playerlist file at: " + playerList.getAbsolutePath());
  36.                 playerList.mkdir();
  37.                 playerList.createNewFile();
  38.  
  39.             }
  40.             Scanner sc = new Scanner(playerList);
  41.             while (sc.hasNextLine()){
  42.                 hardcorePlayers.add(sc.nextLine());
  43.             }
  44.         }catch(Exception e){
  45.             e.printStackTrace();
  46.             getLogger().info("[Extreme Hardcore] There was a problem loading the player file from " + playerList.getAbsolutePath());
  47.         }
  48.         System.out.println(hardcorePlayers.toString());
  49.     }
  50.    
  51.     @Override
  52.     public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  53.         if(command.getName().equalsIgnoreCase("eh")){
  54.             if(!(sender instanceof Player)){
  55.                 if(args[0].equalsIgnoreCase("reloadFile")){
  56.                     loadPlayerListFromFile();
  57.                     sender.sendMessage("[Extreme Hardcore] Plugin file succesfully reloaded!");
  58.                 }
  59.             }
  60.         }
  61.         return false;
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment