类org.bukkit.entity.Enderman源码实例Demo

下面列出了怎么用org.bukkit.entity.Enderman的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Skript   文件: EndermanData.java
@Override
protected boolean init(final @Nullable Class<? extends Enderman> c, final @Nullable Enderman e) {
	if (e != null) {
		if (useBlockData) {
			BlockData data = e.getCarriedBlock();
			if (data != null) {
				Material type = data.getMaterial();
				assert type != null;
				hand = new ItemType[] {new ItemType(type)};
			}
		} else {
			MaterialData m = e.getCarriedMaterial();
			if (m != null) {
				final ItemStack i = m.toItemStack(1);
				if (i == null)
					return false;
				hand = new ItemType[] {new ItemType(i)};
			}
		}
	}
	return true;
}
 
源代码2 项目: Skript   文件: EndermanData.java
@Override
public void set(final Enderman entity) {
	if (hand != null) {
		final ItemType t = CollectionUtils.getRandom(hand);
		assert t != null;
		final ItemStack i = t.getBlock().getRandom();
		if (i != null) {
			if (useBlockData) { // 1.13: item->block usually keeps only material
				entity.setCarriedBlock(Bukkit.createBlockData(i.getType()));
			} else {
				MaterialData data = i.getData();
				assert data != null;
				entity.setCarriedMaterial(data);
			}
		}
	}
	
}
 
源代码3 项目: askyblock   文件: IslandGuard.java
/**
 * Allows or prevents enderman griefing
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanGrief(final EntityChangeBlockEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!(e.getEntity() instanceof Enderman)) {
        return;
    }
    if (!inWorld(e.getEntity())) {
        return;
    }
    // Prevent Enderman griefing at spawn
    if (plugin.getGrid() != null && plugin.getGrid().isAtSpawn(e.getEntity().getLocation())) {
        e.setCancelled(true);
    }
    if (Settings.allowEndermanGriefing)
        return;
    // Stop the Enderman from griefing
    // plugin.getLogger().info("Enderman stopped from griefing);
    e.setCancelled(true);
}
 
源代码4 项目: askyblock   文件: IslandGuard.java
/**
 * Drops the Enderman's block when he dies if he has one
 *
 * @param e - event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Settings.endermanDeathDrop)
        return;
    if (!inWorld(e.getEntity())) {
        return;
    }
    if (!(e.getEntity() instanceof Enderman)) {
        // plugin.getLogger().info("Not an Enderman!");
        return;
    }
    // Get the block the enderman is holding
    Enderman ender = (Enderman) e.getEntity();
    MaterialData m = ender.getCarriedMaterial();
    if (m != null && !m.getItemType().equals(Material.AIR)) {
        // Drop the item
        // plugin.getLogger().info("Dropping item " + m.toString());
        e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
    }
}
 
源代码5 项目: Skript   文件: EndermanData.java
@Override
public boolean match(final Enderman entity) {
	return hand == null || SimpleExpression.check(hand, new Checker<ItemType>() {
		@SuppressWarnings("null")
		@Override
		public boolean check(final @Nullable ItemType t) {
			// TODO {Block/Material}Data -> Material conversion is not 100% accurate, needs a better solution
			if (useBlockData)
				return t != null && t.isOfType(entity.getCarriedBlock().getMaterial());
			else
				return t != null && t.isOfType(entity.getCarriedMaterial().getItemType());
		}
	}, false, false);
}
 
源代码6 项目: Kettle   文件: EndermanAttackPlayerEvent.java
public EndermanAttackPlayerEvent(Enderman entity, Player player) {
    super(entity);
    this.player = player;
}
 
源代码7 项目: Kettle   文件: EndermanEscapeEvent.java
public EndermanEscapeEvent(Enderman entity, Reason reason) {
    super(entity);
    this.reason = reason;
}
 
源代码8 项目: Kettle   文件: EndermanEscapeEvent.java
@Override
public Enderman getEntity() {
    return (Enderman) super.getEntity();
}
 
源代码9 项目: Skript   文件: EndermanData.java
@Override
public Class<Enderman> getType() {
	return Enderman.class;
}
 
源代码10 项目: SonarPet   文件: EntityEndermanPet.java
@Override
public Enderman getBukkitEntity() {
    return (Enderman) super.getBukkitEntity();
}
 
源代码11 项目: Kettle   文件: EndermanAttackPlayerEvent.java
/**
 * The enderman considering attacking
 *
 * @return The enderman considering attacking
 */
@Override
public Enderman getEntity() {
    return (Enderman) super.getEntity();
}
 
 类所在包
 类方法
 同包方法