当前位置: 首页>>代码示例>>Java>>正文


Java LeashHitch类代码示例

本文整理汇总了Java中org.bukkit.entity.LeashHitch的典型用法代码示例。如果您正苦于以下问题:Java LeashHitch类的具体用法?Java LeashHitch怎么用?Java LeashHitch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LeashHitch类属于org.bukkit.entity包,在下文中一共展示了LeashHitch类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.bukkit.entity.LeashHitch; //导入依赖的package包/类
@Override
protected void execute(Event e) {
	Entity hitch = null;
	if (block.getSingle(e) == null) return;
	if (block.getSingle(e).getType() != Material.FENCE) {
		Material type = block.getSingle(e).getType();
		block.getSingle(e).setType(Material.FENCE);
		hitch = block.getSingle(e).getLocation().getWorld().spawn(block.getSingle(e).getLocation(), LeashHitch.class);
		block.getSingle(e).setType(type);
	} else {
		hitch = block.getSingle(e).getLocation().getWorld().spawn(block.getSingle(e).getLocation(), LeashHitch.class);
	}
	if (hitch != null && entities.getAll(e) != null ) {
		for (LivingEntity entity : entities.getAll(e)) {
			entity.setLeashHolder(hitch);
		}
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:19,代码来源:EffLeashBlock.java

示例2: onEntityDamage

import org.bukkit.entity.LeashHitch; //导入依赖的package包/类
/**
 * Protects animals on a beacon from damage
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event) {
    World world = event.getEntity().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        return;
    }
    //getLogger().info("DEBUG: " + event.getEntityType());
    if (!(event.getEntity() instanceof Animals || event.getEntity() instanceof LeashHitch)) {
        return;
    }
    // Check beacon defense            
    BeaconObj beacon = getRegister().getBeaconAt(event.getEntity().getLocation());
    if (beacon != null) {                
        event.setCancelled(true);
    }
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:21,代码来源:BeaconProtectionListener.java

示例3: onHangingEntityBreak

import org.bukkit.entity.LeashHitch; //导入依赖的package包/类
/**
 * Handles breaking paintings, item frames, leashes
 *
 * @param event The event
 */
@EventHandler
public void onHangingEntityBreak(HangingBreakByEntityEvent event) {
	if(!(event.getRemover() instanceof Player)) {
		return;
	}

	Player player = (Player) event.getRemover();
	NovaPlayer nPlayer = PlayerManager.getPlayer(player);
	boolean isLeash = event.getEntity() instanceof LeashHitch;

	if(RegionManager.get(event.getEntity()) != null
			&& (!plugin.getRegionManager().canInteract(player, event.getEntity()) || (!nPlayer.getPreferences().getBypass() && !nPlayer.hasPermission(isLeash ? GuildPermission.MOB_LEASH : GuildPermission.BLOCK_BREAK)))) {
		event.setCancelled(true);
		(isLeash ? Message.CHAT_REGION_DENY_UNLEASH : Message.CHAT_REGION_DENY_INTERACT).send(player);
	}
}
 
开发者ID:MarcinWieczorek,项目名称:NovaGuilds,代码行数:22,代码来源:RegionInteractListener.java

示例4: getHitch

import org.bukkit.entity.LeashHitch; //导入依赖的package包/类
/**
 * Get the {@link org.bukkit.entity.LeashHitch} of a leashed entity.
 *
 * @param entity  The {@link org.bukkit.entity.Entity} to check.
 *
 * @return  The {@link org.bukkit.entity.LeashHitch} or null if the entity
 * is not leashed or is leashed to a player.
 */
@Nullable
public static LeashHitch getHitch(Entity entity) {
    PreCon.notNull(entity);

    if (!(entity instanceof LivingEntity))
        return null;

    LivingEntity living = (LivingEntity) entity;

    if (!living.isLeashed())
        return null;

    Entity leash = living.getLeashHolder();

    if (leash instanceof LeashHitch)
        return (LeashHitch) leash;

    return null;
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:28,代码来源:LeashUtils.java

示例5: getHangingType

import org.bukkit.entity.LeashHitch; //导入依赖的package包/类
private static Material getHangingType(Hanging hanging) {
    if(hanging instanceof Painting) {
        return Material.PAINTING;
    } else if(hanging instanceof ItemFrame) {
        return Material.ITEM_FRAME;
    } else if(hanging instanceof LeashHitch) {
        return Material.LEASH;
    } else {
        return null;
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:12,代码来源:EventRuleMatchModule.java

示例6: getLeash

import org.bukkit.entity.LeashHitch; //导入依赖的package包/类
private org.bukkit.entity.Entity getLeash(IWorld world1, Leash leash, com.worldcretornica.plotme_core.api.Vector loc, int originX, int originY,
        int originZ) {
    org.bukkit.entity.Entity ent = null;
    World world = ((BukkitWorld) world1).getWorld();

    int x = leash.getX() - originX;
    int y = leash.getY() - originY;
    int z = leash.getZ() - originZ;

    org.bukkit.Location etloc = new org.bukkit.Location(world, x + loc.getBlockX(), y + loc.getBlockY(), z + loc.getBlockZ());

    Block block = world.getBlockAt(etloc);

    if (block.getType() == Material.FENCE || block.getType() == Material.NETHER_FENCE) {
        etloc.setX(Math.floor(etloc.getX()));
        etloc.setY(Math.floor(etloc.getY()));
        etloc.setZ(Math.floor(etloc.getZ()));

        ent = world.spawnEntity(etloc, EntityType.LEASH_HITCH);

        List<org.bukkit.entity.Entity> nearbyentities = ent.getNearbyEntities(1, 1, 1);

        for (org.bukkit.entity.Entity nearby : nearbyentities) {
            if (nearby instanceof LeashHitch) {
                if (nearby.getLocation().distance(ent.getLocation()) == 0) {
                    ent.remove();
                    return nearby;
                }
            }
        }
    }

    return ent;
}
 
开发者ID:WorldCretornica,项目名称:PlotMe-Core,代码行数:35,代码来源:SchematicUtil.java


注:本文中的org.bukkit.entity.LeashHitch类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。