本文整理汇总了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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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;
}