Advertisement
Lisenochek

Untitled

Sep 28th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 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. if (r.nextInt(5000) <= 100) {
  44.  
  45. Crate_list.commonCrate(b.getLocation(), b, p);
  46. }
  47.  
  48. new Thread() {
  49.  
  50. @SuppressWarnings("deprecation")
  51. @Override
  52. public void run() {
  53.  
  54. try {
  55. Thread.sleep(1000);
  56. } catch (InterruptedException e) {
  57. return;
  58. }
  59. while (c != i) {
  60.  
  61. ParticleEffect.SMOKE_NORMAL.display(0, 0, 0, 5, 5, b.getLocation(), 10);
  62. }
  63. c++;
  64. if (c >= i) {
  65. this.interrupt();
  66. this.stop();
  67. }
  68. }
  69. }.start();
  70. }
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement