Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.83 KB | None | 0 0
  1. public class CitybuildSystem extends JavaPlugin {
  2.  
  3. public static CitybuildSystem instance;
  4. public static CitybuildSystem plugin;
  5. private PlayerhomeManager playerhomeManager;
  6. private Map<UUID, List<UUID>> tpaRequests = new HashMap<>();
  7. public static HashMap<UUID, UUID> LastMessage = new HashMap<>();
  8. public static ArrayList<UUID> messagetoggle = new ArrayList<UUID>();
  9. public static File homeFile = new File("plugins/CitybuildSystem/home/homes.yml");
  10. public static YamlConfiguration homeConfiguration = YamlConfiguration.loadConfiguration(homeFile);
  11. public static PlotAPI plotAPI;
  12.  
  13. @Override
  14. public void onEnable() {
  15. RegisterInitiation();
  16. RegisterListener(Bukkit.getPluginManager());
  17. RegisterCommands();
  18. RegisterMessage();
  19. RegisterConfiguration();
  20. }
  21.  
  22. private void RegisterConfiguration() {
  23. getConfig().options().copyDefaults(true);
  24. saveDefaultConfig();
  25. saveConfig();
  26. reloadConfig();
  27. }
  28.  
  29. private void RegisterMessage() {
  30. Bukkit.getConsoleSender().sendMessage("§a-------------==+==-------------");
  31. Bukkit.getConsoleSender().sendMessage("§7Plugin §7» §eCitybuildSystem");
  32. Bukkit.getConsoleSender().sendMessage("§7Plugin author §7» §eFaceknoxwell");
  33. Bukkit.getConsoleSender().sendMessage("§7Plugin version §7» §e1.0");
  34. Bukkit.getConsoleSender().sendMessage("§7Plugin aktiviert §7» §a§lJa");
  35. Bukkit.getConsoleSender().sendMessage("§7Skype Support §7» §bFaceknoxwell");
  36. Bukkit.getConsoleSender().sendMessage("§a-------------==+==-------------");
  37. }
  38. private void RegisterCommands() {
  39. getCommand("armor").setExecutor(new ArmorCommand());
  40. getCommand("clearchat").setExecutor(new ClearchatCommand());
  41. getCommand("clear").setExecutor(new ClearCommand());
  42. getCommand("coins").setExecutor(new CoinsCommand());
  43. getCommand("commandspy").setExecutor(new CommandspyCommand());
  44. getCommand("day").setExecutor(new DayCommand());
  45. getCommand("deletehome").setExecutor(new DeletehomeCommand());
  46. getCommand("deletewarp").setExecutor(new DeletewarpCommand());
  47. getCommand("enderchest").setExecutor(new EnderchestCommand());
  48. getCommand("fly").setExecutor(new FlyCommand());
  49. getCommand("gamemode").setExecutor(new GamemodeCommand());
  50. getCommand("heal").setExecutor(new HealCommand());
  51. getCommand("home").setExecutor(new HomeCommand());
  52. getCommand("invsee").setExecutor(new InvseeCommand());
  53. getCommand("kill").setExecutor(new KillCommand());
  54. getCommand("message").setExecutor(new MessageCommand());
  55. getCommand("messagetoggle").setExecutor(new MessagetoggleCommand());
  56. getCommand("night").setExecutor(new NightCommand());
  57. getCommand("pay").setExecutor(new PayCommand());
  58. getCommand("rand").setExecutor(new RandCommand());
  59. getCommand("repair").setExecutor(new RepairCommand());
  60. getCommand("reply").setExecutor(new ReplyCommand());
  61. getCommand("sethome").setExecutor(new SethomeCommand());
  62. getCommand("setspawn").setExecutor(new SetspawnCommand());
  63. getCommand("setwarp").setExecutor(new SetwarpCommand());
  64. getCommand("skull").setExecutor(new SkullCommand());
  65. getCommand("spawn").setExecutor(new SpawnCommand());
  66. getCommand("warp").setExecutor(new WarpCommand());
  67. getCommand("warplist").setExecutor(new WarplistCommand());
  68. getCommand("citybuild").setExecutor(new CitybuildCommand());
  69. getCommand("sun").setExecutor(new SunCommand());
  70. getCommand("teleport").setExecutor(new TeleportCommand());
  71. getCommand("teleporthere").setExecutor(new TeleporthereCommand());
  72. getCommand("sudo").setExecutor(new SudoCommand());
  73. getCommand("tpa").setExecutor(new TpaCommand());
  74. getCommand("tpaaccept").setExecutor(new TpaacceptCommand());
  75. getCommand("tpadeny").setExecutor(new TpadenyCommand());
  76. }
  77. private void RegisterInitiation() {
  78. instance = this;
  79. plugin = this;
  80. plotAPI = new PlotAPI();
  81. playerhomeManager = new PlayerhomeManager();
  82.  
  83. MySQL.host = instance.getConfig().getString("MySQL.Host");
  84. MySQL.port = instance.getConfig().getString("MySQL.Port");
  85. MySQL.database = instance.getConfig().getString("MySQL.Database");
  86. MySQL.username = instance.getConfig().getString("MySQL.Username");
  87. MySQL.password = instance.getConfig().getString("MySQL.Password");
  88.  
  89.  
  90. if (CitybuildSystem.plugin.getConfig().getBoolean("Entityremover.MobRemover", true)) {
  91. new EntityRemover().start();
  92. }
  93.  
  94. try {
  95. homeConfiguration.save(homeFile);
  96. } catch (IOException e) {
  97. e.printStackTrace();
  98. }
  99.  
  100. try {
  101.  
  102. MySQL.connect();
  103. Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
  104. public void run() {
  105. UUIDFetcher.clearCache();
  106. }
  107. }, 12000L, 12000L);
  108. MySQL.createTableIfNotExists();
  109. Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
  110. public void run() {
  111. MySQL.createTableIfNotExists();
  112. }
  113. }, 12000L, 12000L);
  114. //
  115. Bukkit.getConsoleSender().sendMessage(Data.Prefix + "§a§lDie Verbindung zur Datenbank wurde erfolgreich hergestellt.");
  116. } catch (Exception e) {
  117. Bukkit.getConsoleSender().sendMessage(Data.Prefix + "§c§lDie Verbindung zur Datenbank konnte nicht hergestellt werden.");
  118. }
  119.  
  120. }
  121.  
  122. private void RegisterListener(final PluginManager pluginManager) {
  123. pluginManager.registerEvents(new PlayerSpawnListener(), this);
  124. pluginManager.registerEvents(new PlayerAchievementsListener(), this);
  125. pluginManager.registerEvents(new PlayerJoinListener(), this);
  126. pluginManager.registerEvents(new PlayerQuitListener(), this);
  127. pluginManager.registerEvents(new PlayerRandListener(), this);
  128. pluginManager.registerEvents(new PlayerRespawnListener(), this);
  129. pluginManager.registerEvents(new PlayerSpyListener(), this);
  130. pluginManager.registerEvents(new PlayerChatListener(), this);
  131. pluginManager.registerEvents(new PlayerOwnerListener(), this);
  132. pluginManager.registerEvents(new PlayerDeathListener(), this);
  133. pluginManager.registerEvents(new PlayerExistListener(), this);
  134. pluginManager.registerEvents(new PlayerAsyncloginListener(), this);
  135. }
  136.  
  137. @Override
  138. public void onDisable() {
  139. Bukkit.getConsoleSender().sendMessage("§a-------------==+==-------------");
  140. Bukkit.getConsoleSender().sendMessage("§7Plugin §7» §eCitybuildSystem");
  141. Bukkit.getConsoleSender().sendMessage("§7Plugin author §7» §eFaceknoxwell");
  142. Bukkit.getConsoleSender().sendMessage("§7Plugin version §7» §e1.0");
  143. Bukkit.getConsoleSender().sendMessage("§7Plugin deaktiviert §7» §c§lJa");
  144. Bukkit.getConsoleSender().sendMessage("§7Skype Support §7» §bFaceknoxwell");
  145. Bukkit.getConsoleSender().sendMessage("§a-------------==+==-------------");
  146.  
  147. MySQL.disconnect();
  148.  
  149. try {
  150. homeConfiguration.save(homeFile);
  151. } catch (IOException e) {
  152. e.printStackTrace();
  153. }
  154. }
  155.  
  156. public static CitybuildSystem getInstance() {
  157. return instance;
  158. }
  159. public static CitybuildSystem getPlugin() {
  160. return plugin;
  161. }
  162. public PlayerhomeManager getPlayerhomeManager() {
  163. return playerhomeManager;
  164. }
  165. public Map<UUID, List<UUID>> getTpaRequests() {
  166. return tpaRequests;
  167. }
  168. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement