Advertisement
Guest User

Untitled

a guest
May 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.17 KB | None | 0 0
  1. package a.b;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Location;
  8. import org.bukkit.Material;
  9. import org.bukkit.Server;
  10. import org.bukkit.Sound;
  11. import org.bukkit.World;
  12. import org.bukkit.block.Block;
  13. import org.bukkit.configuration.file.FileConfiguration;
  14. import org.bukkit.configuration.file.FileConfigurationOptions;
  15. import org.bukkit.entity.Entity;
  16. import org.bukkit.entity.Player;
  17. import org.bukkit.entity.TNTPrimed;
  18. import org.bukkit.event.EventHandler;
  19. import org.bukkit.event.Listener;
  20. import org.bukkit.event.block.Action;
  21. import org.bukkit.event.block.BlockPlaceEvent;
  22. import org.bukkit.event.player.PlayerInteractEvent;
  23. import org.bukkit.event.player.PlayerJoinEvent;
  24. import org.bukkit.inventory.ItemStack;
  25. import org.bukkit.inventory.PlayerInventory;
  26. import org.bukkit.inventory.meta.ItemMeta;
  27. import org.bukkit.plugin.PluginManager;
  28. import org.bukkit.plugin.java.JavaPlugin;
  29. import org.bukkit.scheduler.BukkitScheduler;
  30. import org.bukkit.util.Vector;
  31.  
  32. public class C
  33. extends JavaPlugin
  34. implements Listener
  35. {
  36. public void onEnable()
  37. {
  38. Bukkit.getPluginManager().registerEvents(this, this);
  39. getConfig().options().copyDefaults(true);
  40. saveConfig();
  41. for (String c : getConfig().getStringList("P-S")) {
  42. this.s.add(c);
  43. }
  44. for (String d : getConfig().getStringList("P-F")) {
  45. this.f.add(d);
  46. }
  47. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable()
  48. {
  49. public void run()
  50. {
  51. for (Player d : Bukkit.getServer().getOnlinePlayers()) {
  52. if ((C.this.cooldown.containsKey(d.getName())) && (((Double)C.this.cooldown.get(d.getName())).doubleValue() < System.currentTimeMillis())) {
  53. if (C.this.msg.contains(d.getName()))
  54. {
  55. C.this.msg.remove(d.getName());
  56. d.sendMessage(C.this.color("&cInstantTNT: &eYour ability is now refreshed and ready to use!"));
  57. }
  58. else
  59. {
  60. return;
  61. }
  62. }
  63. }
  64. }
  65. }, 1L, 0L);
  66. }
  67.  
  68. public HashMap<String, Double> cooldown = new HashMap();
  69. public ArrayList<String> s = new ArrayList();
  70. public ArrayList<String> msg = new ArrayList();
  71. public ArrayList<String> f = new ArrayList();
  72. public ArrayList<String> place = new ArrayList();
  73.  
  74. @EventHandler
  75. public void aaa(PlayerJoinEvent e)
  76. {
  77. Player p = e.getPlayer();
  78. if ((!this.s.contains(p.getName())) &&
  79. (!this.f.contains(p.getName()))) {
  80. this.s.add(p.getName());
  81. }
  82. }
  83.  
  84. @EventHandler
  85. public void sss(BlockPlaceEvent e)
  86. {
  87. final Player p = e.getPlayer();
  88. Block b = e.getBlock();
  89. if (b.getType() == Material.TNT)
  90. {
  91. ItemStack item = p.getInventory().getItemInHand();
  92. if ((item.hasItemMeta()) &&
  93. (item.getItemMeta().getDisplayName().equals(color("&4Instant TnT"))))
  94. {
  95. b.setType(Material.AIR);
  96. Entity tnt = e.getPlayer().getWorld().spawn(b.getLocation().add(0.5D, 0.0D, 0.5D), TNTPrimed.class);
  97. ((TNTPrimed)tnt).setFuseTicks(50);
  98.  
  99. p.playSound(p.getLocation(), Sound.FIRE_IGNITE, 2.0F, 1.0F);
  100. if (!this.place.contains(p.getName()))
  101. {
  102. e.getPlayer().sendMessage(color("&cInstantTNT: &3You have placed tnt!"));
  103. this.place.add(p.getName());
  104. BukkitScheduler scheduler = getServer().getScheduler();
  105. scheduler.scheduleSyncDelayedTask(this, new Runnable()
  106. {
  107. public void run()
  108. {
  109. C.this.place.remove(p.getName());
  110. }
  111. }, 100L);
  112. }
  113. else {}
  114. }
  115. }
  116. }
  117.  
  118. @EventHandler
  119. public void leftClickAir(PlayerInteractEvent e)
  120. {
  121. Player p = e.getPlayer();
  122. if ((e.getAction() == Action.LEFT_CLICK_AIR) || (e.getAction() == Action.LEFT_CLICK_BLOCK))
  123. {
  124. ItemStack item = p.getInventory().getItemInHand();
  125. if ((item.hasItemMeta()) &&
  126. (item.getItemMeta().getDisplayName().equals(color("&4Instant TnT")))) {
  127. if (p.getItemInHand().getType() == Material.TNT)
  128. {
  129. if (p.isSneaking())
  130. {
  131. if (this.s.contains(p.getName()))
  132. {
  133. this.s.remove(p.getName());
  134. this.f.add(p.getName());
  135. getConfig().set("P-S", this.s);
  136. getConfig().set("P-F", this.f);
  137. saveConfig();
  138. p.sendMessage(color("&cInstantTNT: &5You are now shooting &9far"));
  139. return;
  140. }
  141. if (this.f.contains(p.getName()))
  142. {
  143. this.f.remove(p.getName());
  144. this.s.add(p.getName());
  145. p.sendMessage(color("&cInstantTNT: &5You are now shooting &7short"));
  146. getConfig().set("P-S", this.s);
  147. getConfig().set("P-F", this.f);
  148. saveConfig();
  149. return;
  150. }
  151. return;
  152. }
  153. if ((this.cooldown.containsKey(p.getName())) &&
  154. (((Double)this.cooldown.get(p.getName())).doubleValue() > System.currentTimeMillis()))
  155. {
  156. double remainingTime = ((Double)this.cooldown.get(p.getName())).doubleValue() - System.currentTimeMillis();
  157. p.sendMessage(color("&cInstantTNT: &7Your ability is on cooldown for &5" +
  158. remainingTime / 1000.0D + " &7seconds!"));
  159. }
  160. else
  161. {
  162. if (item.getAmount() == 1) {
  163. p.getInventory().remove(item);
  164. } else {
  165. item.setAmount(item.getAmount() - 1);
  166. }
  167. Entity tnt = e.getPlayer().getWorld().spawn(e.getPlayer().getLocation(), TNTPrimed.class);
  168. ((TNTPrimed)tnt).setFuseTicks(70);
  169. if (this.s.contains(p.getName()))
  170. {
  171. tnt.setVelocity(e.getPlayer().getLocation().getDirection().multiply(0.65D));
  172. p.sendMessage(color("&cInstantTNT: &3You have used your ability!"));
  173. this.cooldown.put(p.getName(), Double.valueOf(System.currentTimeMillis() + 1000L));
  174. if (this.msg.contains(p.getName())) {
  175. return;
  176. }
  177. this.msg.add(p.getName());
  178. }
  179. else if (this.f.contains(p.getName()))
  180. {
  181. tnt.setVelocity(e.getPlayer().getLocation().getDirection().multiply(1.1D));
  182. p.sendMessage(color("&cInstantTNT: &3You have used your ability!"));
  183. this.cooldown.put(p.getName(), Double.valueOf(System.currentTimeMillis() + 10000L));
  184. if (this.msg.contains(p.getName())) {
  185. return;
  186. }
  187. this.msg.add(p.getName());
  188. }
  189. else if ((!this.f.contains(p.getName())) &&
  190. (!this.s.contains(p.getName())))
  191. {
  192. this.s.add(p.getName());
  193. getConfig().set("P-S", this.s);
  194. saveConfig();
  195. }
  196. }
  197. }
  198. }
  199. }
  200. }
  201.  
  202. public String color(String string)
  203. {
  204. return ChatColor.translateAlternateColorCodes('&', string);
  205. }
  206. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement