Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.yogsther.ultrahardcore;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.GameMode;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.entity.EntityDamageByEntityEvent;
  12. import org.bukkit.event.player.PlayerJoinEvent;
  13. import org.bukkit.plugin.PluginManager;
  14. import org.bukkit.plugin.java.JavaPlugin;
  15. import org.bukkit.potion.PotionEffect;
  16. import org.bukkit.potion.PotionEffectType;
  17.  
  18. // TODO LIST
  19. // Add a /start command (Clear inventory, clear XP, clear effects, setDifficlty, setDaylycykle, toggle PVP,and other booleans)
  20. // FIX PREMISSIONS!!!
  21. //
  22. //
  23. //
  24. //
  25. //
  26. //
  27. //
  28. //
  29.  
  30. public class ultrahardcore extends JavaPlugin implements Listener {
  31.  
  32. public boolean isPVP;
  33. public boolean duringSetup;
  34. public boolean setupDone;
  35. public boolean duringGame;
  36.  
  37. @EventHandler
  38. public void onPlayerAttack(EntityDamageByEntityEvent event) {
  39. if ((!isPVP) && event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
  40. event.setCancelled(true);
  41. }
  42. }
  43.  
  44. public void setPVP(boolean pvp) {
  45. isPVP = pvp;
  46. }
  47.  
  48. public boolean getPVP() {
  49. return isPVP;
  50. }
  51.  
  52. public void onEnable() {
  53.  
  54. PluginManager pm = this.getServer().getPluginManager();
  55. pm.registerEvents(this, this);
  56.  
  57. isPVP = true;
  58. duringSetup = false;
  59. setupDone = false;
  60. duringGame = false;
  61.  
  62. }
  63.  
  64. // onPlayerJoin (To fix falldamage and hunger)
  65. @EventHandler
  66. public void onPlayerJoin(PlayerJoinEvent e) {
  67. Player player = e.getPlayer();
  68. if (duringSetup == true) {
  69. player.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 1000000, 1, true));
  70. player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, 255, true));
  71. player.setGameMode(GameMode.ADVENTURE);
  72. player.sendMessage(ChatColor.GOLD
  73. + "Welcome to todays Ultra Hardcore, the game has not started yet. Please just wait.");
  74. } else if (duringGame == false) {
  75.  
  76. player.sendMessage(ChatColor.LIGHT_PURPLE + "Looks like nothing special is going on here..");
  77.  
  78. } else {
  79. player.setGameMode(GameMode.SPECTATOR);
  80. player.sendMessage(ChatColor.RED
  81. + "OBS: A game of Ultra Hardcore is going on right now. If you wanted too join it's too late.");
  82. }
  83. }
  84.  
  85. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  86.  
  87. // All commands
  88.  
  89. // Start command
  90. if (label.equalsIgnoreCase("start") && (sender instanceof Player)) {
  91. if (setupDone == true) {
  92. if (duringGame == false) {
  93. if (duringSetup == true) {
  94.  
  95. Bukkit.dispatchCommand(sender, "gamemode 0 @a");
  96. Bukkit.dispatchCommand(sender, "clear @a");
  97. Bukkit.dispatchCommand(sender, "xp -10000L @a");
  98. Bukkit.dispatchCommand(sender, "difficulty hard");
  99. Bukkit.dispatchCommand(sender, "gamerule doDaylightCycle true");
  100. Bukkit.dispatchCommand(sender, "time set day");
  101. Bukkit.dispatchCommand(sender, "worldborder set 2000");
  102. Bukkit.dispatchCommand(sender, "worldborder set 200 9000");
  103. Bukkit.dispatchCommand(sender, "spreadplayers 0 0 400 999 true @a");
  104. Bukkit.dispatchCommand(sender, "time set day");
  105. Bukkit.dispatchCommand(sender, "effect @a clear");
  106.  
  107. Bukkit.broadcastMessage(ChatColor.GOLD + "Ultra hardcore has started, have fun!");
  108. Bukkit.broadcastMessage(ChatColor.RED
  109. + "OBS: Loading all the chunks and players will take about 10 seconds, you may experience lag. Just wait a few seconds.");
  110.  
  111. isPVP = true;
  112. duringGame = true;
  113. duringSetup = false;
  114. return false;
  115. }
  116. } else {
  117. sender.sendMessage(ChatColor.RED
  118. + "A game is already in progress, please reload the server if you want to end the game!");
  119. return false;
  120. }
  121.  
  122. } else {
  123. sender.sendMessage(ChatColor.RED + "Setup has not been done! Do /setup");
  124. return false;
  125. }
  126.  
  127. }
  128.  
  129. if (label.equalsIgnoreCase("setup") && (sender instanceof Player)) {
  130.  
  131. if (setupDone == false) {
  132.  
  133. Bukkit.broadcastMessage(ChatColor.BLUE + "Ultra Hardcore is setting up. This will take a few seconds.");
  134. long seed = Bukkit.getWorld(Bukkit.getServer().getPlayer(sender.getName()).getWorld().getName())
  135. .getSeed();
  136. sender.sendMessage(ChatColor.LIGHT_PURPLE + "The world seed is: " + seed);
  137.  
  138. // Important setup
  139. Bukkit.dispatchCommand(sender, "gamerule logAdminCommands false");
  140. Bukkit.dispatchCommand(sender, "gamerule doDaylightCycle false");
  141. Bukkit.dispatchCommand(sender, "time set day");
  142. Bukkit.dispatchCommand(sender, "gamemode 2 @a");
  143. Bukkit.dispatchCommand(sender, "effect @a minecraft:jump_boost 1000000 255 true");
  144. Bukkit.dispatchCommand(sender, "effect @a minecraft:saturation 1000000 255 true");
  145. Bukkit.dispatchCommand(sender, "difficulty 0");
  146.  
  147. Bukkit.dispatchCommand(sender, "tp @a 0 100 0");
  148.  
  149. Bukkit.dispatchCommand(sender, "gamerule naturalRegeneration false");
  150. // Turn off PVP
  151. isPVP = false;
  152.  
  153. // Worldborder
  154. Bukkit.dispatchCommand(sender, "worldborder set 20");
  155. Bukkit.dispatchCommand(sender, "worldborder damage amount 0");
  156.  
  157. // Teams
  158. // Setting up teams
  159. Bukkit.dispatchCommand(sender, "scoreboard teams add blue");
  160. Bukkit.dispatchCommand(sender, "scoreboard teams add red");
  161. Bukkit.dispatchCommand(sender, "scoreboard teams add green");
  162. Bukkit.dispatchCommand(sender, "scoreboard teams add purple");
  163. Bukkit.dispatchCommand(sender, "scoreboard teams add yellow");
  164. Bukkit.dispatchCommand(sender, "scoreboard teams add black");
  165. Bukkit.dispatchCommand(sender, "scoreboard teams add green");
  166. Bukkit.dispatchCommand(sender, "scoreboard teams add aqua");
  167. Bukkit.dispatchCommand(sender, "scoreboard teams add white");
  168.  
  169. // Setting up colors
  170. Bukkit.dispatchCommand(sender, "scoreboard teams option blue color blue");
  171. Bukkit.dispatchCommand(sender, "scoreboard teams option red color red");
  172. Bukkit.dispatchCommand(sender, "scoreboard teams option green color green");
  173. Bukkit.dispatchCommand(sender, "scoreboard teams option purple color light_purple");
  174. Bukkit.dispatchCommand(sender, "scoreboard teams option yellow color yellow");
  175. Bukkit.dispatchCommand(sender, "scoreboard teams option black color black");
  176. Bukkit.dispatchCommand(sender, "scoreboard teams option green color green");
  177. Bukkit.dispatchCommand(sender, "scoreboard teams option aqua color aqua");
  178. Bukkit.dispatchCommand(sender, "scoreboard teams option white color white");
  179.  
  180. // Setting up Healthbars
  181.  
  182. Bukkit.dispatchCommand(sender, "scoreboard objectives add Health health");
  183. Bukkit.dispatchCommand(sender, "scoreboard objectives setdisplay list Health");
  184.  
  185. // Setting worldspawn
  186. Bukkit.dispatchCommand(sender, "setworldspawn");
  187. sender.sendMessage(ChatColor.GREEN
  188. + "Setup is done, people can now join and wait here in the lobby. To start the game type /start.");
  189.  
  190. // Add effects to everyone
  191.  
  192. duringSetup = true;
  193. setupDone = true;
  194. return false;
  195. }
  196. sender.sendMessage(ChatColor.RED + "Setup has already been done!");
  197. return false;
  198. } else {
  199.  
  200. sender.sendMessage(ChatColor.RED + "You have to be a player to use this command.");
  201. return false;
  202. }
  203. }
  204.  
  205. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement