Advertisement
Lisenochek

Untitled

Oct 2nd, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. package com.realistic.signals;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.Location;
  7. import org.bukkit.Material;
  8. import org.bukkit.block.Block;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.event.EventHandler;
  11. import org.bukkit.event.Listener;
  12. import org.bukkit.event.block.BlockPlaceEvent;
  13.  
  14. import com.realistic.api.MessageManager;
  15. import com.realistic.api.MessageManager.MsgType;
  16. import com.realistic.config.configMessage;
  17. import com.realistic.crate.Crate_list;
  18. import com.realistic.otherAPI.ParticleEffect;
  19.  
  20. public class Handler_Place implements Listener {
  21.  
  22. private static final Random r = new Random();
  23.  
  24. @EventHandler
  25. public static void onPlace(BlockPlaceEvent e) {
  26.  
  27. Player p = e.getPlayer();
  28. Block b = e.getBlockPlaced();
  29.  
  30. if (e.isCancelled()) {
  31. return;
  32. }
  33.  
  34. if (b.getType() == Material.REDSTONE_TORCH_ON) {
  35.  
  36. if (p.getItemInHand().getItemMeta().getDisplayName() != null
  37. && p.getItemInHand().getItemMeta().getDisplayName()
  38. .equalsIgnoreCase(ChatColor.GOLD + ChatColor.BOLD.toString() + "Сигнальная шашка")) {
  39.  
  40. MessageManager.getManager().msg(p, MsgType.SUCCESS,
  41. configMessage.messageConfig.getString("signal_enable"));
  42.  
  43. spawn(b.getLocation(), b, p);
  44. }
  45. }
  46. }
  47.  
  48. public static void spawn(Location loc, Block b, Player p) {
  49.  
  50. new Thread() {
  51.  
  52. @SuppressWarnings("deprecation")
  53. @Override
  54. public void run() {
  55.  
  56. try {
  57. Thread.sleep(1000);
  58. } catch (InterruptedException e) {
  59. return;
  60. }
  61.  
  62. ParticleEffect.SMOKE_LARGE.display(0, 2, 0, 0, 5, b.getLocation().add(0.5, 3, 0.5), 200);
  63.  
  64. if (r.nextInt(5000) <= 100) {
  65.  
  66. b.setType(Material.AIR);
  67. Crate_list.commonCrate(loc, b, p);
  68.  
  69. this.interrupt();
  70. this.stop();
  71. }
  72. }
  73. }.start();
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement