Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.24 KB | None | 0 0
  1. package com.gaah.moonmanutencao;
  2.  
  3. import com.gaah.JSON.JSONChatClickEventType;
  4. import com.gaah.JSON.JSONChatExtra;
  5. import com.gaah.JSON.JSONChatHoverEventType;
  6. import com.gaah.JSON.JSONChatMessage;
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandExecutor;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.plugin.java.JavaPlugin;
  13.  
  14. public class MoonManutencao extends JavaPlugin {
  15. public void onEnable() {
  16. this.getCommand("utilidades").setExecutor((CommandExecutor) this);
  17. }
  18.  
  19. public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
  20. Player p = (Player) sender;
  21. JSONChatMessage line1 = new JSONChatMessage(" ", null, null);
  22. JSONChatExtra manutencao = new JSONChatExtra("§e✳§c Manutenção");
  23. manutencao.setHoverEvent(JSONChatHoverEventType.SHOW_TEXT, "Clique aqui para iniciar o contador para a Manutenção");
  24. manutencao.setClickEvent(JSONChatClickEventType.SUGGEST_COMMAND, "/utilidades manutencao start");
  25. line1.addExtra(manutencao);
  26. JSONChatMessage line2 = new JSONChatMessage(" ", null, null);
  27. JSONChatExtra kickall = new JSONChatExtra("§e✳§c Kickall");
  28. kickall.setHoverEvent(JSONChatHoverEventType.SHOW_TEXT, "Clique aqui para Kickar todos os jogadores");
  29. kickall.setClickEvent(JSONChatClickEventType.SUGGEST_COMMAND, "/utilidades kickall");
  30. line2.addExtra(kickall);
  31. JSONChatMessage line3 = new JSONChatMessage(" ", null, null);
  32. JSONChatExtra kickallmaiswithelist = new JSONChatExtra("§e✳§c Kickall + Whitelist on");
  33. kickallmaiswithelist.setHoverEvent(JSONChatHoverEventType.SHOW_TEXT, "Clique aqui para Kickar todos os jogadores e ligar a Whitelist");
  34. kickallmaiswithelist.setClickEvent(JSONChatClickEventType.SUGGEST_COMMAND, "/utilidades kickall whitelist");
  35. line3.addExtra(kickallmaiswithelist);
  36. JSONChatMessage line4 = new JSONChatMessage(" ", null, null);
  37. JSONChatExtra stop = new JSONChatExtra("§e✳§c STOP");
  38. stop.setHoverEvent(JSONChatHoverEventType.SHOW_TEXT, "Clique aqui dar STOP no servidor (abre com a whitelist ativada)");
  39. stop.setClickEvent(JSONChatClickEventType.SUGGEST_COMMAND, "/utilidades stop");
  40. line4.addExtra(stop);
  41. if (args.length == 0) {
  42. if (sender.hasPermission("moon.utilidades")) {
  43. sender.sendMessage(" §f Todos os comandos admin:");
  44. sender.sendMessage("");
  45. line1.sendToPlayer(p);
  46. line2.sendToPlayer(p);
  47. line3.sendToPlayer(p);
  48. sender.sendMessage("");
  49. line4.sendToPlayer(p);
  50. sender.sendMessage("");
  51. } else {
  52. sender.sendMessage("§cVocê não tem permissão");
  53. }
  54. }
  55. if (p.hasPermission("moon.manutencao")) {
  56. if (args.length >= 3) {
  57. sender.sendMessage("§cErrado. Correto: /manu start");
  58. return true;
  59. }
  60. } else {
  61. p.sendMessage("§cVocê não tem permissão para isso");
  62. }
  63. if (sender.hasPermission("moon.kickallandwhitelist")) {
  64. if (args.length > 0 && args[0].equalsIgnoreCase("kickall") && args[1].equalsIgnoreCase("whitelist")) {
  65. Bukkit.getOnlinePlayers().forEach(player -> p.kickPlayer("§c§lMOONMC \n §cTodos os jogadores foram kikados!"));
  66. Bukkit.setWhitelist(true);
  67. Bukkit.getWorld("plotworld").save();
  68. Bukkit.getWorld("world").save();
  69. }
  70. }
  71. if (sender.hasPermission("moon.kickall")) {
  72. if (args.length > 0 && args[0].equalsIgnoreCase("kickall")) {
  73. Bukkit.getOnlinePlayers().forEach(player -> p.kickPlayer("§c§lMOONMC \n §cTodos os jogadores foram kikados!"));
  74. Bukkit.getWorld("plotworld").save();
  75. Bukkit.getWorld("world").save();
  76. }
  77. }
  78. if (sender.hasPermission("moon.stop")) {
  79. if (args.length > 0 && args[0].equalsIgnoreCase("stop")) {
  80. Bukkit.getOnlinePlayers().forEach(player -> p.kickPlayer("§c§lMOONMC \n §cO servidor foi fechado temporariamente!"));
  81. Bukkit.getWorld("plotworld").save();
  82. Bukkit.getWorld("world").save();
  83. Bukkit.setWhitelist(true);
  84. Bukkit.shutdown();
  85. }
  86. }
  87. if (sender.hasPermission("moon.manutencao.start")) {
  88. if (args.length > 0 && args[0].equalsIgnoreCase("manutencao") && args[1].equalsIgnoreCase("start")) {
  89. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "lc muteall");
  90. for (int i = 0; i < 1000; ++i) {
  91. sender.sendMessage("");
  92. }
  93. for (Player players : Bukkit.getOnlinePlayers()) {
  94. players.sendMessage("");
  95. players.sendMessage("§cServidor entrando em manutenção em 1 minuto!");
  96. players.sendMessage("");
  97.  
  98. }
  99. Bukkit.setWhitelist(true);
  100. Bukkit.getWorld("plotworld").save();
  101. Bukkit.getWorld("world").save();
  102. Bukkit.getScheduler().scheduleSyncDelayedTask(JavaPlugin.getPlugin(MoonManutencao.class), () -> {
  103. for (Player players : Bukkit.getOnlinePlayers()) {
  104. players.sendMessage("");
  105. players.sendMessage("§cServidor entrando em manutenção em 30 minuto!");
  106. players.sendMessage("");
  107. }
  108. }, 30 * 20);
  109. Bukkit.getScheduler().scheduleSyncDelayedTask(JavaPlugin.getPlugin(MoonManutencao.class), () -> {
  110. Bukkit.getOnlinePlayers().forEach(player -> p.kickPlayer("§c§lMOONMC \n §c Todos os jogadores foram kikados!"));
  111. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "lc unmuteall");
  112. Bukkit.shutdown();
  113. }, 60 * 20);
  114. }
  115. }
  116. return true;
  117. }
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement