Facebook
From Social Cassowary, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 206
  1. {
  2. @EventHandler
  3. public void onEntityExplode(EntityExplodeEvent e)
  4. {
  5.   Calendar c = Calendar.getInstance();
  6.   int hr = c.get(11);
  7.   if (((hr >= 24) || (hr < 12)) && (e.getEntity().getType().equals(EntityType.PRIMED_TNT))) {
  8.     e.setCancelled(true);
  9.   }
  10. }
  11.  
  12. @EventHandler(priority=EventPriority.HIGHEST)
  13. public void onBlock(BlockPlaceEvent e)
  14. {
  15.   Player p = e.getPlayer();
  16.   Material m = e.getBlock().getType();
  17.   Location l = e.getBlock().getLocation();
  18.   int y = l.getBlockY();
  19.   if (m == Material.TNT) {
  20.     if (y > 50) {
  21.       e.setCancelled(true);
  22.       p.sendMessage(ChatUtil.fixColor("§4Blad: §cTnT mozna stawiac od 50 kratki"));
  23.     }
  24.   }
  25. }
  26. @EventHandler
  27. public void onPlayerClick(PlayerInteractEvent e)
  28. {
  29.   Player p = e.getPlayer();
  30.   if ((e.getAction() == Action.RIGHT_CLICK_BLOCK) &&
  31.     (p.getItemInHand().getType().equals(Material.EXPLOSIVE_MINECART)) &&
  32.     (p.getLocation().getY() > 50.0D))
  33.   {
  34.           p.sendMessage(ChatUtil.fixColor( "&4Blad: &cMinecart z TNT mozna stawiac tylko od 50 poziomu w dol."));
  35.     e.setCancelled(true);
  36.     return;
  37.   }
  38. }
  39. @EventHandler
  40. public void onTNTPlace(BlockPlaceEvent e)
  41. {
  42.   Material m = e.getBlockPlaced().getType();
  43.   Player p = e.getPlayer();
  44.  
  45.   Calendar c = Calendar.getInstance();
  46.   int hr = c.get(11);
  47.   if ((m == Material.TNT) && ((hr >= 24) || (hr < 12)))
  48.   {
  49.     e.setCancelled(true);
  50.     p.sendMessage(ChatUtil.fixColor("§4TNT §7dziala w godzinach §c10:00 §7- §c22:00"));
  51.   }
  52. }
  53. }