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


Java Hanging类代码示例

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


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

示例1: move

import org.bukkit.entity.Hanging; //导入依赖的package包/类
public void move(double d0, double d1, double d2) {
    if (!this.world.isStatic && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
        if (this.dead) return; // CraftBukkit

        // CraftBukkit start - fire break events
        // TODO - Does this need its own cause? Seems to only be triggered by pistons
        HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS);
        this.world.getServer().getPluginManager().callEvent(event);

        if (this.dead || event.isCancelled()) {
            return;
        }
        // CraftBukkit end

        this.die();
        this.b((Entity) null);
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:19,代码来源:EntityHanging.java

示例2: onEntityDamage

import org.bukkit.entity.Hanging; //导入依赖的package包/类
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    if(event.getEntity() != null) {
        Lot lot = this.module.getLotManager().getLot(event.getEntity().getLocation());
        Town town = this.module.getLotManager().getTown(event.getEntity().getLocation());
        if(event.getEntity() instanceof Player && (lot != null || town != null)) {
            event.setCancelled(true);
        } else if(lot != null && event instanceof EntityDamageByEntityEvent && (event.getEntity() instanceof Hanging || event.getEntity() instanceof ArmorStand)) {
            EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) event;
            if(entityEvent.getDamager() instanceof Player && !entityEvent.getDamager().getName().equals(lot.getOwner()) && !entityEvent.getDamager().hasPermission(LotPermissions.BUILD_ANYWHERE)) {
                sendMessage(entityEvent.getDamager(), "lots.cannot-do");
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:Steveice10,项目名称:Peacecraft,代码行数:17,代码来源:LotsListener.java

示例3: getTargetEntities

import org.bukkit.entity.Hanging; //导入依赖的package包/类
@Override
public Collection<Entity> getTargetEntities()
{
    if (cloneTarget == null || mage == null) return null;

    if (mode == BrushMode.CLONE || mode == BrushMode.REPLICATE || mode == BrushMode.SCHEMATIC)
    {
        List<Entity> targetData = new ArrayList<Entity>();
        World targetWorld = cloneTarget.getWorld();
        List<Entity> targetEntities = targetWorld.getEntities();
        for (Entity entity : targetEntities) {
            // Schematics currently only deal with Hanging entities
            if (mode == BrushMode.SCHEMATIC && !(entity instanceof Hanging)) continue;

            // Note that we ignore players and NPCs
            if (!(entity instanceof Player) && !mage.getController().isNPC(entity)) {
                targetData.add(entity);
            }
        }

        return targetData;
    }

    return null;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:26,代码来源:MaterialBrush.java

示例4: moveEntity

import org.bukkit.entity.Hanging; //导入依赖的package包/类
public void moveEntity(double p_70091_1_, double p_70091_3_, double p_70091_5_)
{
    if (!this.worldObj.isRemote && !this.isDead && p_70091_1_ * p_70091_1_ + p_70091_3_ * p_70091_3_ + p_70091_5_ * p_70091_5_ > 0.0D)
    {
        if (this.isDead)
        {
            return;    // CraftBukkit
        }

        // CraftBukkit start
        // TODO - Does this need its own cause? Seems to only be triggered by pistons
        HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS);
        this.worldObj.getServer().getPluginManager().callEvent(event);

        if (this.isDead || event.isCancelled())
        {
            return;
        }

        // CraftBukkit end
        this.setDead();
        this.onBroken((Entity)null);
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:25,代码来源:EntityHanging.java

示例5: onHangingPlace

import org.bukkit.entity.Hanging; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onHangingPlace(HangingPlaceEvent event)
{
    Hanging hanging = event.getEntity();
    HangingPlace action;
    if (hanging instanceof Painting)
    {
        action = this.newAction(PaintingPlace.class, hanging.getWorld());
        if (action != null)
        {
            ((PaintingPlace)action).art = ((Painting)hanging).getArt();
        }
    }
    else
    {
        action = this.newAction(HangingPlace.class, hanging.getWorld());
    }
    if (action != null)
    {
        action.setLocation(hanging.getLocation());
        action.setHanging(hanging);
        action.setPlayer(event.getPlayer());
        this.logAction(action);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:26,代码来源:ListenerHanging.java

示例6: move

import org.bukkit.entity.Hanging; //导入依赖的package包/类
public void move(double d0, double d1, double d2) {
    if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
        if (this.dead) return; // CraftBukkit

        // CraftBukkit start - fire break events
        // TODO - Does this need its own cause? Seems to only be triggered by pistons
        HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS);
        this.world.getServer().getPluginManager().callEvent(event);

        if (this.dead || event.isCancelled()) {
            return;
        }
        // CraftBukkit end

        this.die();
        this.a((Entity) null);
    }

}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:20,代码来源:EntityHanging.java

示例7: checkItemFrameItemRemove

import org.bukkit.entity.Hanging; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void checkItemFrameItemRemove(EntityDamageByEntityEvent event) {
    // This event is fired when popping an item out of an item frame, without breaking the frame itself
    if(event.getEntity() instanceof ItemFrame && ((ItemFrame) event.getEntity()).getItem() != null) {
        this.handleHangingBreak(event, (Hanging) event.getEntity(), event.getDamager());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:8,代码来源:EventRuleMatchModule.java

示例8: handleHangingBreak

import org.bukkit.entity.Hanging; //导入依赖的package包/类
private void handleHangingBreak(Event event, Hanging hanging, Entity breaker) {
    BlockState blockState = getHangingBlockState(hanging);
    if(blockState == null) return;

    IEventQuery query = makeBlockQuery(event, breaker, blockState);

    for(EventRule rule : this.ruleContext.get(EventRuleScope.BLOCK_BREAK)) {
        if(rule.region().contains(blockState)) {
            if(processQuery(rule, query)) {
                sendCancelMessage(rule, query);
                if(this.useRegionPriority) break;
            }
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:16,代码来源:EventRuleMatchModule.java

示例9: getHangingType

import org.bukkit.entity.Hanging; //导入依赖的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

示例10: serializeState

import org.bukkit.entity.Hanging; //导入依赖的package包/类
public static String serializeState(Entity entity) {
    YamlConfiguration yaml = new YamlConfiguration();
    if (Support.ARMOR_STAND && entity instanceof ArmorStand) {
        EulerAngleSerializer eas = EulerAngleSerializer.getInstance();
        ArmorStand stand = (ArmorStand) entity;
        yaml.set(PITCH, stand.getLocation().getPitch());
        yaml.set(YAW, stand.getLocation().getYaw());
        yaml.set(ARMOR_STAND_HELMET, stand.getHelmet());
        yaml.set(ARMOR_STAND_CHESTPLATE, stand.getChestplate());
        yaml.set(ARMOR_STAND_LEGGINGS, stand.getLeggings());
        yaml.set(ARMOR_STAND_BOOTS, stand.getBoots());
        yaml.set(ARMOR_STAND_HAND, stand.getItemInHand());
        yaml.set(ARMOR_STAND_POSE_HEAD, eas.serialize(stand.getHeadPose()));
        yaml.set(ARMOR_STAND_POSE_BODY, eas.serialize(stand.getBodyPose()));
        yaml.set(ARMOR_STAND_POSE_ARM_LEFT, eas.serialize(stand.getLeftArmPose()));
        yaml.set(ARMOR_STAND_POSE_ARM_RIGHT, eas.serialize(stand.getRightArmPose()));
        yaml.set(ARMOR_STAND_POSE_LEG_LEFT, eas.serialize(stand.getLeftLegPose()));
        yaml.set(ARMOR_STAND_POSE_LEG_RIGHT, eas.serialize(stand.getRightLegPose()));
        yaml.set(ARMOR_STAND_ARMS, stand.hasArms());
        yaml.set(ARMOR_STAND_BASE_PLATE, stand.hasBasePlate());
        yaml.set(ARMOR_STAND_GRAVITY, stand.hasGravity());
        yaml.set(ARMOR_STAND_SMALL, stand.isSmall());
        yaml.set(ARMOR_STAND_VISIBLE, stand.isVisible());
    } else if (entity instanceof Hanging) {
        yaml.set(HANGING_FACING, ((Hanging) entity).getFacing().name());
        if (entity instanceof ItemFrame) {
            yaml.set(ITEM_FRAME_ITEM, ((ItemFrame) entity).getItem());
            yaml.set(ITEM_FRAME_ROTATION, ((ItemFrame) entity).getRotation().name());
        } else if (entity instanceof Painting) {
            yaml.set(PAINTING_ART, ((Painting) entity).getArt().name());
        }
    }

    return yaml.saveToString();
}
 
开发者ID:caseif,项目名称:Steel,代码行数:36,代码来源:EntityStateSerializer.java

示例11: onHangingBreak

import org.bukkit.entity.Hanging; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onHangingBreak(HangingBreakEvent event) {
  Hanging hanging = event.getEntity();
  if (event.getCause().equals(RemoveCause.OBSTRUCTION)) {
    hanging.getLocation().getBlock().breakNaturally();
    event.setCancelled(true);
  } else if (event.getCause().equals(RemoveCause.EXPLOSION)) {
    event.setCancelled(true);
  }

}
 
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:12,代码来源:HangingListener.java

示例12: clearMobs

import org.bukkit.entity.Hanging; //导入依赖的package包/类
private void clearMobs(World world) {
   for (Entity entity : world.getEntities()) {
      if (!(entity instanceof Hanging) && !(entity instanceof Player)) {
         entity.remove();
      }
   }
}
 
开发者ID:PaulBGD,项目名称:MiniMiniGames,代码行数:8,代码来源:MMGames.java

示例13: onEntityDamage

import org.bukkit.entity.Hanging; //导入依赖的package包/类
/**
 * On entity damage.
 *
 * @param event the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) {

    if (conf.isOverrideExplosions()
            && event.getEntity() instanceof Hanging
            && (event.getCause() == DamageCause.BLOCK_EXPLOSION || event.getCause() == DamageCause.ENTITY_EXPLOSION
            || event.getCause() == DamageCause.PROJECTILE)) {
        // Check for ItemFrame
        Factoid.getThisPlugin().iLog().write("Cancel HangingBreak : " + event.getEntity() + ", Cause: " + event.getCause());
        event.setCancelled(true);
    }
}
 
开发者ID:Tabinol,项目名称:Factoid,代码行数:18,代码来源:WorldListener.java

示例14: logAttachedBlocks

import org.bukkit.entity.Hanging; //导入依赖的package包/类
public static void logAttachedBlocks(LogListener ll, EventManager em, Block block, ActionBlock action)
{
    if (!block.getType().isSolid() && !(block.getType() == SUGAR_CANE_BLOCK))
    {
        return; // cannot have attached
    }

    for (Block aBlock : BlockUtil.getAttachedBlocks(block))
    {
        em.fireEvent(new BlockPreBreakEvent(aBlock.getLocation(), action));
    }
    for (Block dBlock : BlockUtil.getDetachableBlocksOnTop(block))
    {
        if (isNotUpperDoorHalf(dBlock)) // ignore upper door halfs
        {
            em.fireEvent(new BlockPreBreakEvent(dBlock.getLocation(), action));
        }
    }

    if (ll.isActive(HangingBreak.class, block.getWorld()))
    {
        Location location = block.getLocation();
        Location entityLocation = block.getLocation();
        for (Entity entity : block.getChunk().getEntities())
        {
            if (entity instanceof Hanging && location.distanceSquared(entity.getLocation(entityLocation)) < 4)
            {
                em.fireEvent(new HangingPreBreakEvent(entityLocation, action));
            }
        }
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:33,代码来源:ListenerBlock.java

示例15: onLightningStrike

import org.bukkit.entity.Hanging; //导入依赖的package包/类
public void onLightningStrike(EntityLightning entitylightning) {
    // CraftBukkit start
    final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
    final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity();
    final PluginManager pluginManager = Bukkit.getPluginManager();

    if (thisBukkitEntity instanceof Hanging) {
        HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity);
        pluginManager.callEvent(hangingEvent);

        if (hangingEvent.isCancelled()) {
            return;
        }
    }

    if (this.fireProof) {
        return;
    }
    CraftEventFactory.entityDamage = entitylightning;
    if (!this.damageEntity(DamageSource.LIGHTNING, 5.0F)) {
        CraftEventFactory.entityDamage = null;
        return;
    }
    // CraftBukkit end
    ++this.fireTicks;
    if (this.fireTicks == 0) {
        // CraftBukkit start - Call a combust event when lightning strikes
        EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8);
        pluginManager.callEvent(entityCombustEvent);
        if (!entityCombustEvent.isCancelled()) {
            this.setOnFire(entityCombustEvent.getDuration());
        }
        // CraftBukkit end
    }

}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:37,代码来源:Entity.java


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