本文整理了Java中org.bukkit.entity.Entity.getUniqueId()
方法的一些代码示例,展示了Entity.getUniqueId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getUniqueId()
方法的具体详情如下:
包路径:org.bukkit.entity.Entity
类名称:Entity
方法名:getUniqueId
[英]Returns a unique and persistent id for this entity
[中]返回此实体的唯一持久id
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public Entity getEntity(UUID uuid) {
for (Entity entity : getEntities()) {
if (entity.getUniqueId().equals(uuid)) {
return entity;
}
}
return null;
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
protected String disambiguate(Entity subject, String metadataKey) {
return UuidUtils.toString(subject.getUniqueId()) + ":" + metadataKey;
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public Entity getEntity(UUID uuid) {
for (World world : getWorlds()) {
for (Entity entity : world.getEntities()) {
if (entity.getUniqueId().equals(uuid)) {
return entity;
}
}
}
return null;
}
代码示例来源:origin: GlowstoneMC/Glowstone
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());
代码示例来源:origin: GlowstoneMC/Glowstone
orb.setSourceEntityId(this.getUniqueId());
if (getLastDamager() != null) {
orb.setTriggerEntityId(getLastDamager().getUniqueId());
代码示例来源:origin: me.lucko/helper
@Nonnull
@Override
public Optional<MetadataMap> get(@Nonnull Entity entity) {
Objects.requireNonNull(entity, "entity");
return get(entity.getUniqueId());
}
代码示例来源:origin: libraryaddict/LibsDisguises
/**
* 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());
}
代码示例来源:origin: me.lucko/helper
@Nonnull
@Override
public MetadataMap provide(@Nonnull Entity entity) {
Objects.requireNonNull(entity, "entity");
return provide(entity.getUniqueId());
}
代码示例来源:origin: lucko/helper
@Nonnull
@Override
public Optional<MetadataMap> get(@Nonnull Entity entity) {
Objects.requireNonNull(entity, "entity");
return get(entity.getUniqueId());
}
代码示例来源:origin: lucko/helper
@Nonnull
@Override
public MetadataMap provide(@Nonnull Entity entity) {
Objects.requireNonNull(entity, "entity");
return provide(entity.getUniqueId());
}
代码示例来源:origin: elBukkit/MagicPlugin
@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();
}
代码示例来源:origin: mcmonkeyprojects/Sentinel
/**
* 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());
}
代码示例来源:origin: NyaaCat/RPGItems-reloaded
@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();
}
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
@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());
}
}
}
代码示例来源:origin: PyvesB/AdvancedAchievements
@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);
}
}
代码示例来源:origin: SkyWars/SkyWars
@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);
}
}
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
@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());
}
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
@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());
}
代码示例来源:origin: libraryaddict/LibsDisguises
@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);
}
}
代码示例来源:origin: TheBusyBiscuit/Slimefun4
@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;
}
});
内容来源于网络,如有侵权,请联系作者删除!