Advertisement
DSHunterMC

Untitled

Nov 26th, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. package Events;
  2.  
  3.  
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.GameMode;
  7. import org.bukkit.Material;
  8. import org.bukkit.Sound;
  9. import org.bukkit.WeatherType;
  10. import org.bukkit.World;
  11. import org.bukkit.block.Block;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.event.EventHandler;
  14. import org.bukkit.event.Listener;
  15. import org.bukkit.event.block.Action;
  16. import org.bukkit.event.block.BlockPlaceEvent;
  17. import org.bukkit.event.inventory.InventoryClickEvent;
  18. import org.bukkit.event.player.PlayerInteractEvent;
  19. import org.bukkit.event.player.PlayerJoinEvent;
  20. import org.bukkit.inventory.Inventory;
  21. import org.bukkit.potion.PotionEffect;
  22. import org.bukkit.potion.PotionEffectType;
  23.  
  24. public class EventsClass implements Listener {
  25.  
  26. @EventHandler
  27. public void onJoin (PlayerJoinEvent e) {
  28. Player p = e.getPlayer();
  29.  
  30. if(p.hasPlayedBefore()) {
  31. e.setJoinMessage(ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "Hexigon" +
  32. ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "HF" + ChatColor.AQUA + ">>" +
  33. ChatColor.GRAY + "" + ChatColor.BOLD + " Welcome back " + ChatColor.LIGHT_PURPLE + ChatColor.BOLD +
  34. e.getPlayer().getName() + ChatColor.GRAY + "" + ChatColor.BOLD + " to" + ChatColor.DARK_PURPLE + ChatColor.BOLD + " Hexigon" + ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "HF!");
  35. }else {
  36. e.setJoinMessage(ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "Hexigon" +
  37. ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "HF" + ChatColor.AQUA + ">>" +
  38. ChatColor.GREEN + "" + ChatColor.BOLD + " Welcome " + ChatColor.DARK_GREEN +
  39. "" + ChatColor.BOLD + e.getPlayer().getName() + ChatColor.GREEN + "" + ChatColor.BOLD + " to" +ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + " Hexigon" + ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "HF");
  40.  
  41. }
  42. }
  43.  
  44. @EventHandler
  45. public void onInteract(PlayerInteractEvent e) {
  46. Action a = e.getAction();
  47. Player p = (Player) e.getPlayer();
  48. Block b = e.getClickedBlock();
  49.  
  50. if(a.equals(Action.LEFT_CLICK_BLOCK)) {
  51. if(b.getType().equals(Material.BEACON)) {
  52. if(p.hasPermission("hhf.block.day")) {
  53. if(p.getGameMode().equals(GameMode.SURVIVAL)) {
  54. p.setPlayerTime(1000, false);
  55. p.sendMessage(ChatColor.GREEN + "Your time has been set to" + ChatColor.DARK_GREEN + "" + ChatColor.BOLD + " Day!");
  56.  
  57. }
  58. }
  59. }
  60. }
  61.  
  62. if(a.equals(Action.RIGHT_CLICK_BLOCK)) {
  63. if(b.getType().equals(Material.REDSTONE_BLOCK)) {
  64. if(p.hasPermission("hhf.block.health-deduct")) {
  65. if(p.getGameMode().equals(GameMode.SURVIVAL)) {
  66. if(p.getHealth() != 0) {
  67. p.sendMessage(ChatColor.RED + "Your health has been" + ChatColor.RED + "" + ChatColor.BOLD + " Deducted!");
  68. p.setHealth(p.getHealth() - 1);
  69. p.playSound(p.getLocation(), Sound.BLOCK_CHORUS_FLOWER_DEATH, 1.0f, 1.0f);
  70. }
  71. }
  72. }
  73. }
  74.  
  75. if(a.equals(Action.RIGHT_CLICK_BLOCK)) {
  76. if(b.getType().equals(Material.PURPUR_BLOCK)) {
  77. if(p.hasPermission("hhf.block.weather-clear")) {
  78. if(p.getGameMode().equals(GameMode.SURVIVAL)) {
  79. p.sendMessage(ChatColor.GREEN + "Your weather has been" + ChatColor.DARK_GREEN + "" + ChatColor.BOLD + " Cleared!");
  80. p.setPlayerWeather(WeatherType.CLEAR);
  81. p.playSound(p.getLocation(), Sound.ENTITY_ELDER_GUARDIAN_DEATH, 1.0f, 1.0f);
  82. }
  83. }
  84. }
  85. }
  86.  
  87. if(a.equals(Action.RIGHT_CLICK_BLOCK)) {
  88. if(b.getType().equals(Material.OBSIDIAN)) {
  89. if(p.hasPermission("hhf.block.night")) {
  90. if(p.getGameMode().equals(GameMode.SURVIVAL)) {
  91. p.setPlayerTime(13000, false);
  92. p.sendMessage(ChatColor.DARK_GRAY + "Your time has been set to" + ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + " Night!");
  93.  
  94. }
  95. }
  96. }
  97. }
  98.  
  99. if(a.equals(Action.RIGHT_CLICK_BLOCK)) {
  100. if(b.getType().equals(Material.EMERALD_BLOCK)) {
  101. if(p.hasPermission("hhf.block.regen")) {
  102. if(p.getGameMode().equals(GameMode.SURVIVAL)) {
  103. if(p.getHealth() != 20);
  104. p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 200, 0));
  105. p.sendMessage(ChatColor.GREEN + "You have been given" + ChatColor.DARK_GREEN + "" + ChatColor.BOLD + " Regeneration!");
  106. p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.0f);
  107.  
  108. }
  109. }
  110. }
  111. }
  112. }
  113. }
  114.  
  115. @EventHandler
  116. public void onPlace(BlockPlaceEvent e) {
  117. Block b = e.getBlock();
  118. Player p = e.getPlayer();
  119. World w = b.getWorld();
  120. if(b.getType().equals(Material.TNT)) {
  121. if(!p.isOp()) {
  122. if(p.hasPermission("hhf.tnt.stop")) {
  123. if(w.getName().equalsIgnoreCase("world")) {
  124. e.getBlockPlaced().setType(Material.BLAZE_POWDER);
  125. p.sendMessage(ChatColor.DARK_RED + "" + ChatColor.BOLD + "HHF" + ChatColor.RED + " - Griefing is not allowed in this world!");
  126. }
  127. }
  128. }
  129. }
  130. }
  131.  
  132. @EventHandler
  133. public void AGUI(PlayerInteractEvent e) {
  134. Player p = e.getPlayer();
  135.  
  136. agui = Bukkit.createInventory(null, 54, ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "Admin" +
  137. ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "GUI");
  138.  
  139. agui.setItem(45, ReloadButton);
  140.  
  141.  
  142. if(p.hasPermission("hhf.agui.open")) {
  143. if(p.getInventory().getItemInMainHand().getType() == Material.END_CRYSTAL) {
  144. if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
  145. p.openInventory(agui);
  146.  
  147. }
  148. }
  149. }
  150. }
  151.  
  152.  
  153. @EventHandler
  154. public void AGUI2(InventoryClickEvent e) {
  155. Player p = (Player) e.getWhoClicked();
  156.  
  157. if(e.getInventory().getName().equals(agui.getName())) {
  158. e.setCancelled(true);
  159. }
  160.  
  161. if(e.getCurrentItem() == null) {
  162. return;
  163. }
  164.  
  165. if(e.getSlot() == 45) {
  166. p.performCommand("plugins");
  167. }
  168.  
  169. }
  170.  
  171.  
  172. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement