@Override public Entity getEntity(UUID uuid) { for (Entity entity : getEntities()) { if (entity.getUniqueId().equals(uuid)) { return entity; } } return null; }
@Override protected String disambiguate(Entity subject, String metadataKey) { return UuidUtils.toString(subject.getUniqueId()) + ":" + metadataKey; } }
@Override public Entity getEntity(UUID uuid) { for (World world : getWorlds()) { for (Entity entity : world.getEntities()) { if (entity.getUniqueId().equals(uuid)) { return entity; } } } return null; }
ProjectileSource source = entity.getSource(); if (source instanceof Entity) { UUID uuid = ((Entity) source).getUniqueId(); tag.putLong(OWNER_UUID_LEAST, uuid.getLeastSignificantBits()); tag.putLong(OWNER_UUID_MOST, uuid.getMostSignificantBits());
orb.setSourceEntityId(this.getUniqueId()); if (getLastDamager() != null) { orb.setTriggerEntityId(getLastDamager().getUniqueId());
@Nonnull @Override public Optional<MetadataMap> get(@Nonnull Entity entity) { Objects.requireNonNull(entity, "entity"); return get(entity.getUniqueId()); }
/** * Get the disguise of a entity * * @param disguised * @return */ public static Disguise getDisguise(Entity disguised) { if (disguised == null) { return null; } return DisguiseUtilities.getMainDisguise(disguised.getUniqueId()); }
@Nonnull @Override public MetadataMap provide(@Nonnull Entity entity) { Objects.requireNonNull(entity, "entity"); return provide(entity.getUniqueId()); }
@Nonnull @Override public Optional<MetadataMap> get(@Nonnull Entity entity) { Objects.requireNonNull(entity, "entity"); return get(entity.getUniqueId()); }
@Nonnull @Override public MetadataMap provide(@Nonnull Entity entity) { Objects.requireNonNull(entity, "entity"); return provide(entity.getUniqueId()); }
@Override public void remove(Entity entity) { entity.removeMetadata("MagicBlockList", plugin); if (entities != null) { entities.remove(entity); } UUID entityId = entity.getUniqueId(); if (modifiedEntities != null) { modifiedEntities.remove(entityId); } modifiedTime = System.currentTimeMillis(); }
/** * Called when an entity might die from damage (called before Sentinel detects that an NPC might have killed an entity). */ @EventHandler(priority = EventPriority.HIGHEST) public void whenSomethingMightDie(EntityDamageByEntityEvent event) { needsDropsClear.remove(event.getEntity().getUniqueId()); }
@EventHandler void onEntityTeleport(EntityTeleportEvent e) { try { if (stucked.get(e.getEntity().getUniqueId(), () -> Long.MIN_VALUE) >= (System.currentTimeMillis() - duration * 50)) { e.setCancelled(true); } } catch (ExecutionException ex) { ex.printStackTrace(); } }
@EventHandler public void onArrowHit(EntityDamageEvent e) { if (e.getEntity() instanceof Player && e.getCause() == DamageCause.FALL) { if (Variables.damage.containsKey(e.getEntity().getUniqueId())) { e.setCancelled(true); Variables.damage.remove(e.getEntity().getUniqueId()); } } }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { Entity damager = event.getDamager(); if (damager != null && fireworksLaunchedByPlugin.contains(damager.getUniqueId())) { event.setCancelled(true); } }
@EventHandler(priority = EventPriority.MONITOR) public void onDamage(EntityDamageEvent evt) { if (evt.getEntity() instanceof Player) { UUID uuid = evt.getEntity().getUniqueId(); if (evt.getCause() == EntityDamageEvent.DamageCause.VOID) { causedVoid.add(uuid); } else { causedVoid.remove(uuid); } } }
@EventHandler public void onArrowSuccessfulHit(EntityDamageByEntityEvent e) { if (e.getDamager() instanceof Arrow) { if (Variables.arrows.containsKey(e.getDamager().getUniqueId()) && e.getEntity() instanceof LivingEntity) { for (ItemHandler handler: SlimefunItem.getHandlers("BowShootHandler")) { if (((BowShootHandler) handler).onHit(e, (LivingEntity) e.getEntity())) break; } Variables.arrows.remove(e.getDamager().getUniqueId()); } handleGrapplingHook((Arrow) e.getDamager()); } }
@EventHandler public void onBowUse(EntityShootBowEvent e) { if (!(e.getEntity() instanceof Player) || !(e.getProjectile() instanceof Arrow)) return; if (SlimefunItem.getByItem(e.getBow()) != null) Variables.arrows.put(e.getProjectile().getUniqueId(), e.getBow()); }
@EventHandler public void onChunkUnload(ChunkUnloadEvent event) { if (!DisguiseConfig.isSaveEntityDisguises()) return; for (Entity entity : event.getChunk().getEntities()) { Disguise[] disguises = DisguiseAPI.getDisguises(entity); if (disguises.length <= 0) continue; DisguiseUtilities.saveDisguises(entity.getUniqueId(), disguises); } }
@Override public boolean onHit(EntityDamageByEntityEvent e, LivingEntity n) { if (SlimefunManager.isItemSimiliar(Variables.arrows.get(e.getDamager().getUniqueId()), SlimefunItems.ICY_BOW, true)) { n.getWorld().playEffect(n.getLocation(), Effect.STEP_SOUND, Material.ICE); n.getWorld().playEffect(n.getEyeLocation(), Effect.STEP_SOUND, Material.ICE); n.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20 * 2, 10)); n.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 20 * 2, -10)); return true; } else return false; } });