本文整理汇总了Java中org.bukkit.entity.Enderman类的典型用法代码示例。如果您正苦于以下问题:Java Enderman类的具体用法?Java Enderman怎么用?Java Enderman使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Enderman类属于org.bukkit.entity包,在下文中一共展示了Enderman类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEndermanGrief
import org.bukkit.entity.Enderman; //导入依赖的package包/类
/**
* 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 (!Util.inWorld(e.getEntity())) {
return;
}
// Prevent Enderman griefing at spawn
if (plugin.getIslands() != null && plugin.getIslands().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);
}
示例2: onEndermanDeath
import org.bukkit.entity.Enderman; //导入依赖的package包/类
/**
* Drops the Enderman's block when he dies if he has one
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (!Settings.endermanDeathDrop)
return;
if (!Util.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));
}
}
示例3: onEntityPickup
import org.bukkit.entity.Enderman; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityPickup(EntityChangeBlockEvent event)
{
//FEATURE: endermen don't steal claimed blocks
//if its an enderman
if(event.getEntity() instanceof Enderman)
{
//and the block is claimed
if(this.dataStore.getClaimAt(event.getBlock().getLocation(), false, null) != null)
{
//he doesn't get to steal it
event.setCancelled(true);
}
}
}
示例4: onEndermanGrief
import org.bukkit.entity.Enderman; //导入依赖的package包/类
/**
* 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);
}
示例5: onEndermanDeath
import org.bukkit.entity.Enderman; //导入依赖的package包/类
/**
* Drops the Enderman's block when he dies if he has one
*
* @param e
*/
@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));
}
}
示例6: init
import org.bukkit.entity.Enderman; //导入依赖的package包/类
@Override
protected boolean init(final @Nullable Class<? extends Enderman> c, final @Nullable Enderman e) {
if (e != null) {
final 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;
}
示例7: set
import org.bukkit.entity.Enderman; //导入依赖的package包/类
@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)
entity.setCarriedMaterial(i.getData());
}
}
示例8: match
import org.bukkit.entity.Enderman; //导入依赖的package包/类
@Override
public boolean match(final Enderman entity) {
return hand == null || SimpleExpression.check(hand, new Checker<ItemType>() {
@SuppressWarnings("deprecation")
@Override
public boolean check(final @Nullable ItemType t) {
return t != null && t.isOfType(entity.getCarriedMaterial().getItemTypeId(), entity.getCarriedMaterial().getData());
}
}, false, false);
}
示例9: onEntityChangeBlock
import org.bukkit.entity.Enderman; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
AttackType attackType = AttackType.UNKNOWN;
if (event instanceof EntityBreakDoorEvent) {
attackType = AttackType.ZOMBIE;
} else if (event.getEntity() instanceof Enderman) {
attackType = AttackType.ENDERMAN;
}
if (plugin.getChestSettings().allowDestroyBy(attackType)) {
return;
}
if (isProtected(event.getBlock())) {
event.setCancelled(true);
}
}
示例10: onEntityChangeBlock
import org.bukkit.entity.Enderman; //导入依赖的package包/类
/**
* Monitor EntityChangeBlock events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
Block block = event.getBlock();
// When the event is fired for the falling block that changes back to a normal block
// event.getBlock().getType() returns AIR
if (!BlockUtils.shouldBeWatched(block.getState()) && block.getType() != Material.AIR) {
return;
}
Entity entity = event.getEntity();
if (entity instanceof FallingBlock || entity instanceof Enderman) {
boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
mcMMO.getPlaceStore().setFalse(block);
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
}
else if (isTracked) {
mcMMO.getPlaceStore().setTrue(block);
}
}
else if ((block.getType() == Material.REDSTONE_ORE || block.getType() == Material.GLOWING_REDSTONE_ORE) && (event.getTo() == Material.REDSTONE_ORE || event.getTo() == Material.GLOWING_REDSTONE_ORE)) {
return;
}
else {
if (mcMMO.getPlaceStore().isTrue(block)) {
mcMMO.getPlaceStore().setFalse(block);
}
}
}
示例11: onEntityChangeBlock
import org.bukkit.entity.Enderman; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlock(final EntityChangeBlockEvent event)
{
ActionEntityBlock action;
if (event.getEntityType() == SHEEP)
{
action = this.newAction(SheepEat.class, event.getBlock().getWorld());
}
else if (event.getEntity() instanceof Enderman)
{
if (event.getTo() == AIR)
{
action = this.newAction(EndermanPickup.class, event.getBlock().getWorld());
}
else
{
action = this.newAction(EndermanPlace.class, event.getBlock().getWorld());
}
}
else
{
action = this.newAction(EntityChange.class, event.getBlock().getWorld());
}
if (action != null)
{
action.setNewBlock(event.getTo());
this.setAndLog(action, event.getBlock().getState(), event.getEntity());
}
}
示例12: onEntityChangeBlock
import org.bukkit.entity.Enderman; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityChangeBlock(final EntityChangeBlockEvent event) {
if (event.getEntityType() == EntityType.ENDERMAN) {
final GeneralRegion region = this.getPlugin().getDb().getPriorByLocation(event.getBlock().getLocation());
if (region != null && region.getFlag(Flag.ENDERMANGRIEF)) {
((Enderman)event.getEntity()).setCarriedMaterial(Material.JACK_O_LANTERN.getNewData((byte)0));
event.setCancelled(true);
}
}
}
示例13: getType
import org.bukkit.entity.Enderman; //导入依赖的package包/类
@Override
public Class<Enderman> getType() {
return Enderman.class;
}
示例14: getBukkitEntity
import org.bukkit.entity.Enderman; //导入依赖的package包/类
@Override
public Enderman getBukkitEntity() {
return (Enderman) super.getBukkitEntity();
}
示例15: CanaryEnderman
import org.bukkit.entity.Enderman; //导入依赖的package包/类
public CanaryEnderman(net.canarymod.api.entity.living.monster.Enderman entity) {
super(entity);
}