Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mrkirby153.ExtremeHardcore;
- import java.io.File;
- import java.util.List;
- import java.util.Scanner;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin{
- FileConfiguration config = getConfig();
- File playerList = new File("plugins" +File.separator + "ExtremeHardcore" + File.separator + "playerList.txt");
- List<String> hardcorePlayers;
- @Override
- public void onEnable() {
- getLogger().info("[Extreme Hardcore] Extreme hardcore has been Enabled!");
- }
- @Override
- public void onDisable() {
- getLogger().info("[Extreme Hardcore] Saving players...");
- getLogger().info("[Extreme Hardcore] Extreme hardocre has been Disabled!");
- }
- public void loadConfig(){
- this.saveDefaultConfig();
- }
- public void loadPlayerListFromFile(){
- try{
- if(!playerList.exists()){
- getLogger().info("[Extreme Hardcore] Created playerlist file at: " + playerList.getAbsolutePath());
- playerList.mkdir();
- playerList.createNewFile();
- }
- Scanner sc = new Scanner(playerList);
- while (sc.hasNextLine()){
- hardcorePlayers.add(sc.nextLine());
- }
- }catch(Exception e){
- e.printStackTrace();
- getLogger().info("[Extreme Hardcore] There was a problem loading the player file from " + playerList.getAbsolutePath());
- }
- System.out.println(hardcorePlayers.toString());
- }
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if(command.getName().equalsIgnoreCase("eh")){
- if(!(sender instanceof Player)){
- if(args[0].equalsIgnoreCase("reloadFile")){
- loadPlayerListFromFile();
- sender.sendMessage("[Extreme Hardcore] Plugin file succesfully reloaded!");
- }
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment