Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. package pink.zakshearman.lobby;
  2.  
  3. import org.bukkit.configuration.InvalidConfigurationException;
  4. import org.bukkit.configuration.file.FileConfiguration;
  5. import org.bukkit.configuration.file.YamlConfiguration;
  6. import org.bukkit.plugin.java.JavaPlugin;
  7. import pink.zakshearman.lobby.commands.BroadcastCommand;
  8. import pink.zakshearman.lobby.commands.HelpCommand;
  9. import pink.zakshearman.lobby.commands.SpawnCommand;
  10. import pink.zakshearman.lobby.modules.*;
  11. import pink.zakshearman.lobby.modules.maxplayers.MaxLoginEvent;
  12. import pink.zakshearman.lobby.modules.maxplayers.MaxServerPing;
  13. import pink.zakshearman.lobby.modules.maxplayers.MaxSlotsCommand;
  14.  
  15. import java.io.File;
  16. import java.io.IOException;
  17. import java.util.Arrays;
  18.  
  19. public final class Lobby extends JavaPlugin {
  20.  
  21. private File languageConfigFile;
  22.  
  23. public FileConfiguration languageFile;
  24. public FileConfiguration config;
  25.  
  26. @Override
  27. public void onEnable() {
  28. createLanguageFile();
  29. this.saveDefaultConfig();
  30.  
  31. Arrays.stream(Config.values()).forEach(value -> value.cache(config));
  32. Arrays.stream(Language.values()).forEach(value -> value.cache(languageFile));
  33. config = this.getConfig();
  34. getServer().getPluginManager().registerEvents(new BlockBreak(), this);
  35. getServer().getPluginManager().registerEvents(new BlockChat(), this);
  36. getServer().getPluginManager().registerEvents(new BlockCommands(), this);
  37. getServer().getPluginManager().registerEvents(new BlockPlace(), this);
  38. getServer().getPluginManager().registerEvents(new DisableHunger(), this);
  39. getServer().getPluginManager().registerEvents(new JoinMessages(this), this);
  40. getServer().getPluginManager().registerEvents(new BlockDamage(), this);
  41.  
  42.  
  43.  
  44. getCommand("help").setExecutor(new HelpCommand());
  45. getCommand("spawn").setExecutor(new SpawnCommand());
  46. getCommand("broadcast").setExecutor(new BroadcastCommand());
  47.  
  48. //MaxPlayers
  49. getServer().getPluginManager().registerEvents(new MaxLoginEvent(), this);
  50. getServer().getPluginManager().registerEvents(new MaxServerPing(), this);
  51. getCommand("slots").setExecutor(new MaxSlotsCommand());
  52. VoidFall vf = new VoidFall(this);
  53. vf.runCheck();
  54. }
  55.  
  56. @Override
  57. public void onDisable() {
  58.  
  59. Arrays.stream(Config.values()).forEach(value -> this.config.set(value.getSection(), value.getValue()));
  60. this.saveConfig();
  61. }
  62.  
  63. private void createLanguageFile() {
  64. languageConfigFile = new File(getDataFolder(), "language.yml");
  65. if(!languageConfigFile.exists()) {
  66. //noinspection ResultOfMethodCallIgnored
  67. languageConfigFile.getParentFile().mkdirs();
  68. saveResource("language.yml", false);
  69. }
  70. languageFile = new YamlConfiguration();
  71. try {
  72. languageFile.load(languageConfigFile);
  73. } catch (IOException | InvalidConfigurationException e) {
  74. e.printStackTrace();
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement