下面列出了怎么用org.bukkit.entity.Golem的API类实例代码及写法,或者点击链接到github查看源代码。
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onItemFrameDamage(final HangingBreakByEntityEvent e) {
if (DEBUG) {
plugin.getLogger().info("DEBUG: Hanging break by entity event");
plugin.getLogger().info("DEBUG: cause = " + e.getCause());
plugin.getLogger().info("DEBUG: entity = " + e.getEntity());
plugin.getLogger().info("DEBUG: remover = " + e.getRemover());
}
// Check world
if (!inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) {
return;
}
if (e.getRemover() instanceof Skeleton || e.getRemover() instanceof Golem) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Remover is mob");
if (!Settings.allowMobDamageToItemFrames) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Damage not allowed, cancelling");
e.setCancelled(true);
}
}
}
public CreatureType getCreatureType(EntityType entityType) {
if (Monster.class.isAssignableFrom(entityType.getEntityClass())
|| WaterMob.class.isAssignableFrom(entityType.getEntityClass())
|| Slime.class.isAssignableFrom(entityType.getEntityClass())
|| Ghast.class.isAssignableFrom(entityType.getEntityClass())
) {
return CreatureType.MONSTER;
} else if (Animals.class.isAssignableFrom(entityType.getEntityClass())) {
return CreatureType.ANIMAL;
} else if (Villager.class.isAssignableFrom(entityType.getEntityClass())) {
return CreatureType.VILLAGER;
} else if (Golem.class.isAssignableFrom(entityType.getEntityClass())) {
return CreatureType.GOLEM;
}
return CreatureType.UNKNOWN;
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onItemFrameDamage(final EntityDamageByEntityEvent e) {
// Check world
if (!inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) {
return;
}
if (e.getDamager() instanceof Projectile) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Projectile damage to itemframe");
// Find out who fired the arrow
Projectile p = (Projectile) e.getDamager();
if (DEBUG)
plugin.getLogger().info("DEBUG: Shooter is " + p.getShooter().toString());
if (p.getShooter() instanceof Skeleton || p.getShooter() instanceof Golem) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Shooter is mob");
if (!Settings.allowMobDamageToItemFrames) {
if (DEBUG)
plugin.getLogger().info("DEBUG: Damage not allowed, cancelling");
e.setCancelled(true);
}
}
}
}
public CreatureType getCreatureType(LivingEntity creature) {
if (creature instanceof Monster
|| creature instanceof WaterMob
|| creature instanceof Slime
|| creature instanceof Ghast) {
return CreatureType.MONSTER;
} else if (creature instanceof Animals) {
return CreatureType.ANIMAL;
} else if (creature instanceof Villager) {
return CreatureType.VILLAGER;
} else if (creature instanceof Golem) {
return CreatureType.GOLEM;
}
return CreatureType.UNKNOWN;
}