Advertisement
Lisenochek

Untitled

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