Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. package me.illuminatiproductions.headtohead;
  2.  
  3. import me.illuminatiproductions.headtohead.commands.DuelCommand;
  4. import me.illuminatiproductions.headtohead.data.Person;
  5. import me.illuminatiproductions.headtohead.listeners.DuelListener;
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.configuration.InvalidConfigurationException;
  8. import org.bukkit.configuration.file.FileConfiguration;
  9. import org.bukkit.configuration.file.YamlConfiguration;
  10. import org.bukkit.configuration.serialization.ConfigurationSerializable;
  11. import org.bukkit.configuration.serialization.ConfigurationSerialization;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.plugin.java.JavaPlugin;
  14.  
  15. import java.io.File;
  16. import java.io.IOException;
  17. import java.util.HashMap;
  18.  
  19. public final class HeadToHead extends JavaPlugin {
  20.  
  21. private File customConfigFile;
  22. private FileConfiguration customConfig;
  23.  
  24. public static HashMap<Player, Player> pending_challenge_requests = new HashMap<>();
  25. public static HashMap<Player, Duel> players_in_a_game = new HashMap<>();
  26.  
  27. @Override
  28. public void onEnable() {
  29. // Plugin startup logic
  30. ConfigurationSerialization.registerClass(Person.class);
  31. setup();
  32. getServer().getPluginManager().registerEvents(new DuelListener(this), this);
  33. getCommand("duel").setExecutor(new DuelCommand());
  34. }
  35.  
  36. @Override
  37. public void onDisable() {
  38. System.out.println("Saving stats");
  39. save();
  40. }
  41.  
  42. public FileConfiguration getCustomConfig() {
  43. return this.customConfig;
  44. }
  45.  
  46. private void setup(){
  47. customConfigFile = new File(Bukkit.getServer().getPluginManager().getPlugin("HeadToHead").getDataFolder(), "stats.yml");
  48.  
  49. if (!customConfigFile.exists()){
  50. try{
  51. customConfigFile.createNewFile();
  52. }catch (IOException e){
  53. //owww
  54. }
  55. }
  56. customConfig = YamlConfiguration.loadConfiguration(customConfigFile);
  57. }
  58.  
  59. public void save(){
  60. try{
  61. customConfig.save(customConfigFile);
  62. }catch (IOException e){
  63. System.out.println("Couldn't save file");
  64. }
  65. }
  66.  
  67. public void reload(){
  68. customConfig = YamlConfiguration.loadConfiguration(customConfigFile);
  69. }
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement