Ejemplo n.º 1
0
 @EventHandler
 public void onInteract(PlayerInteractEvent event) {
   if (GameManager.INSTANCE.getSession(event.getPlayer()) == null) return;
   ItemStack item = event.getItem();
   if (item == null
       || (!event.getAction().equals(Action.RIGHT_CLICK_AIR)
           && !event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) return;
   if (item.getType().equals(Material.PAPER) && event.getPlayer().getHealth() != 20) {
     GeneralUtils.subtractItemInHand(event.getPlayer());
     GeneralUtils.addHealthByPaper(event.getPlayer());
   }
   if (event.hasBlock() && !Material.WORKBENCH.equals(event.getClickedBlock().getType()))
     event.setCancelled(true);
 }
Ejemplo n.º 2
0
 @EventHandler
 public void onDamage(EntityDamageByEntityEvent event) {
   if (event.getEntity() instanceof Player == false
       || GameManager.INSTANCE.getSession((Player) event.getEntity()) == null) return;
   if (event.getDamager() instanceof Zombie) {
     event.setDamage(
         (int) (Configs.Config.ZOMBIE_DAMAGE_MULTIPLIER.getGlobalDouble() * event.getDamage()));
   } else if (event.getDamager() instanceof Player) {
     Player p = (Player) event.getDamager();
     if (p.getItemInHand().getType().equals(Material.PAPER)) {
       event.setCancelled(true);
       bandage.put(p.getName(), ((Player) event.getEntity()).getName());
       GeneralUtils.subtractItemInHand(p);
     }
   }
 }
Ejemplo n.º 3
0
 @EventHandler
 public void onEntityInteract(PlayerInteractEntityEvent event) {
   if (event.getRightClicked() instanceof Player == false
       || GameManager.INSTANCE.getSession((Player) event.getRightClicked()) == null) return;
   ItemStack item = event.getPlayer().getItemInHand();
   if (item == null) return;
   Player clicked = (Player) event.getRightClicked();
   if (item.getType().equals(Material.SHEARS)) {
     if (bandage.containsKey(event.getPlayer().getName())
         && bandage
             .get(event.getPlayer().getName())
             .equals(((Player) event.getRightClicked()).getName())) {
       GeneralUtils.addHealthByPaper(clicked);
     } else {
       event.getPlayer().sendMessage("Health: " + clicked.getHealth());
     }
   }
 }