Java 类org.bukkit.event.player.PlayerShearEntityEvent 实例源码

项目:Statz    文件:TimesShornListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onShear(final PlayerShearEntityEvent event) {

    final PlayerStat stat = PlayerStat.TIMES_SHORN;

    // Get player
    final Player player = (Player) event.getPlayer();

    // Do general check
    if (!plugin.doGeneralCheck(player, stat))
        return;

    // Update value to new stat.
    plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid",
            player.getUniqueId().toString(), "value", 1, "world", player.getWorld().getName()));

}
项目:BetonQuest    文件:ShearObjective.java   
@EventHandler
public void onShear(PlayerShearEntityEvent event) {
    if (event.getEntity().getType() != EntityType.SHEEP)
        return;
    String playerID = PlayerConverter.getID(event.getPlayer());
    if (!containsPlayer(playerID))
        return;
    if (name != null && (event.getEntity().getCustomName() == null || !event.getEntity().getCustomName().equals(name)))
        return;
    if (color != null && !((Sheep) event.getEntity()).getColor().toString().equalsIgnoreCase(color))
        return;
    SheepData data = (SheepData) dataMap.get(playerID);
    if (checkConditions(playerID))
        data.shearSheep();
    if (data.getAmount() <= 0)
        completeObjective(playerID);
    else if (notify)
        Config.sendMessage(playerID, "sheep_to_shear", new String[] { String.valueOf(data.getAmount()) });
}
项目:bskyblock    文件:IslandGuard.java   
@EventHandler(priority = EventPriority.LOW)
public void onShear(final PlayerShearEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (Util.inWorld(e.getPlayer())) {
        if (actionAllowed(e.getPlayer(), e.getEntity().getLocation(), SettingsFlag.SHEARING)) {
            return;
        }
        // Not allowed
        Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
        e.setCancelled(true);
    }
}
项目:KingdomFactions    文件:PlayerShearEventListener.java   
@EventHandler
public void onShear(PlayerShearEntityEvent e) {

KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
if(p.getSettingsProfile().hasAdminMode()) return;
if(!p.canBuild(e.getEntity().getLocation())) {
    e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 100));
} 
}
项目:WebSandboxMC    文件:EntityListener.java   
@EventHandler(ignoreCancelled = true)
public void onShear(PlayerShearEntityEvent event) {
    Entity entity = event.getEntity();

    String username = webPlayerBridge.entityId2Username.get(entity.getEntityId());
    if (username == null) {
        return;
    }

    Player player = event.getPlayer();
    String playerName = player.getDisplayName();

    webPlayerBridge.notifySheared(username, playerName);
}
项目:AdvancedAchievements    文件:AchieveShearListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerShearEntity(PlayerShearEntityEvent event) {
    if (!(event.getEntity() instanceof Sheep)) {
        return;
    }

    Player player = event.getPlayer();
    NormalAchievements category = NormalAchievements.SHEARS;
    if (!shouldIncreaseBeTakenIntoAccount(player, category)) {
        return;
    }

    updateStatisticAndAwardAchievementsIfAvailable(player, category, 1);
}
项目:CraftBukkit    文件:EntitySheep.java   
public boolean a(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) {
        if (!this.world.isStatic) {
            // CraftBukkit start
            PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return false;
            }
            // CraftBukkit end

            this.setSheared(true);
            int i = 1 + this.random.nextInt(3);

            for (int j = 0; j < i; ++j) {
                EntityItem entityitem = this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor()), 1.0F);

                entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
                entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
                entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            }
        }

        itemstack.damage(1, entityhuman);
        this.makeSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.a(entityhuman);
}
项目:beaconz    文件:PlayerMovementListener.java   
/**
 * Prevents shearing outside the game area
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onShear(final PlayerShearEntityEvent event) {
    if (event.getEntity().getWorld().equals(getBeaconzWorld())) {
        if (getGameMgr().getGame(event.getEntity().getLocation()) == null) {
            event.setCancelled(true);
            event.getPlayer().sendMessage(ChatColor.RED + Lang.errorYouCannotDoThat);
        }
    }
}
项目:uSkyBlock    文件:GriefEvents.java   
@EventHandler
public void onShearEvent(PlayerShearEntityEvent event) {
    Player player = event.getPlayer();
    if (!shearingEnabled || !plugin.isSkyAssociatedWorld(player.getWorld())) {
        return; // Not our concern
    }
    if (hasPermission(player, "usb.mod.bypassprotection")) {
        return;
    }
    if (!plugin.playerIsOnIsland(player)) {
        event.setCancelled(true);
    }
}
项目:BelovedBlocks    文件:BlocksListener.java   
/**
 * Used to prevent our tool from shearing sheeps or mushroom cows.
 * <p>
 * The cow seems to disappear, a relog fix that. Cannot be fixed on our side
 * (Minecraft or CBukkit bug).
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerShearEntity(PlayerShearEntityEvent ev)
{
    if (BelovedBlocks.getToolsManager().getFromItem(ev.getPlayer().getItemInHand()) instanceof StoneCutter)
    {
        ev.setCancelled(true);
    }
}
项目:Almura-Server    文件:EntitySheep.java   
public boolean a(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.id == Item.SHEARS.id && !this.isSheared() && !this.isBaby()) {
        if (!this.world.isStatic) {
            // CraftBukkit start
            PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return false;
            }
            // CraftBukkit end

            this.setSheared(true);
            int i = 1 + this.random.nextInt(3);

            for (int j = 0; j < i; ++j) {
                EntityItem entityitem = this.a(new ItemStack(Block.WOOL.id, 1, this.getColor()), 1.0F);

                entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
                entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
                entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            }
        }

        itemstack.damage(1, entityhuman);
        this.makeSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.a(entityhuman);
}
项目:acidisland    文件:IslandGuard.java   
@EventHandler(priority = EventPriority.LOW)
public void onShear(final PlayerShearEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (inWorld(e.getPlayer())) {
        if (actionAllowed(e.getPlayer(), e.getEntity().getLocation(), SettingsFlag.SHEARING)) {
            return;
        }
        // Not allowed
        Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
        e.setCancelled(true);
        return;
    }
}
项目:Tweakkit-Server    文件:EntitySheep.java   
public boolean a(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) {
        if (!this.world.isStatic) {
            // CraftBukkit start
            PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return false;
            }
            // CraftBukkit end

            this.setSheared(true);
            int i = 1 + this.random.nextInt(3);

            for (int j = 0; j < i; ++j) {
                EntityItem entityitem = this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor()), 1.0F);

                entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
                entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
                entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            }
        }

        itemstack.damage(1, entityhuman);
        this.makeSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.a(entityhuman);
}
项目:askyblock    文件:IslandGuard.java   
@EventHandler(priority = EventPriority.LOW)
public void onShear(final PlayerShearEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (inWorld(e.getPlayer())) {
        if (actionAllowed(e.getPlayer(), e.getEntity().getLocation(), SettingsFlag.SHEARING)) {
            return;
        }
        // Not allowed
        Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
        e.setCancelled(true);
        return;
    }
}
项目:Cauldron    文件:ItemShears.java   
@Override
public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity)
{
    if (entity.worldObj.isRemote)
    {
        return false;
    }
    if (entity instanceof IShearable)
    {
        IShearable target = (IShearable)entity;
        if (target.isShearable(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ))
        {
            // Cauldron start
            PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) player.getBukkitEntity(), entity.getBukkitEntity());
            player.worldObj.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled())
            {
                return false;
            }

            // Cauldron end
            ArrayList<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ,
                    EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));

            Random rand = new Random();
            for(ItemStack stack : drops)
            {
                EntityItem ent = entity.entityDropItem(stack, 1.0F);
                ent.motionY += rand.nextFloat() * 0.05F;
                ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
                ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
            }
            itemstack.damageItem(1, entity);
        }
        return true;
    }
    return false;
}
项目:modules-extra    文件:ListenerPlayerEntity.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityShear(PlayerShearEntityEvent event)
{
    EntityShear action = this.newAction(EntityShear.class, event.getEntity().getWorld());
    if (action != null)
    {
        action.setEntity(event.getEntity());
        action.setPlayer(event.getPlayer());
        action.setLocation(event.getEntity().getLocation());
        this.logAction(action);
    }
}
项目:CrazyLogin    文件:DynamicPlayerListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void PlayerShear(final PlayerShearEntityEvent event)
{
    if (!(event.getEntity() instanceof Player))
        return;
    final Player player = (Player) event.getEntity();
    if (plugin.isLoggedIn(player))
        return;
    event.setCancelled(true);
}
项目:SpigotSource    文件:EntitySheep.java   
public boolean a(EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack) {
    if (itemstack != null && itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) {
        if (!this.world.isClientSide) {
            // CraftBukkit start
            PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return false;
            }
            // CraftBukkit end

            this.setSheared(true);
            int i = 1 + this.random.nextInt(3);

            for (int j = 0; j < i; ++j) {
                this.forceDrops = true; // CraftBukkit
                EntityItem entityitem = this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor().getColorIndex()), 1.0F);
                this.forceDrops = false; // CraftBukkit

                entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
                entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
                entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            }
        }

        itemstack.damage(1, entityhuman);
        this.a(SoundEffects.eP, 1.0F, 1.0F);
    }

    return super.a(entityhuman, enumhand, itemstack);
}
项目:NPlugins    文件:FarmFlagListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerShearEntity(final PlayerShearEntityEvent event) {
    final GeneralRegion cuboid = this.getPlugin().getDb().getPriorByLocation(event.getEntity().getLocation());
    if (cuboid != null && cuboid.getFlag(Flag.FARM) && !cuboid.isUser(event.getPlayer())) {
        event.setCancelled(true);
    }
}
项目:simple-survival-games    文件:SSGPlayerListener.java   
@EventHandler
public void onPlayerShearEntity(PlayerShearEntityEvent event) {
    Player p = event.getPlayer();
    ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();

    // Is the current player playing
    if(am.isInArena(p)) {
        ArenaPlayer ap = am.getPlayer(p);

        // Is the player in the lobby of the arena
        if(ap.isInLobby()) {

            // Has the player a arena spawn assigned
            if(ap.hasAssignedAreanSpawn()) {

                // Cancel the event and send a status message
                event.setCancelled(true);
                p.sendMessage(ChatColor.DARK_RED + "It's a shame to make this sheep naked inside the lobby of an arena!");
            }
        }

        // Is the player an spectators
        if(ap.isSpectator()) {
            event.setCancelled(true);
            ap.sendMessage(ChatColor.DARK_RED + "You can't make this sheep naked while spectating!");
        }
    }
}
项目:AuthMeReloaded    文件:PlayerListenerTest.java   
@Test
public void shouldHandleSimpleCancelableEvents() {
    withServiceMock(listenerService)
        .check(listener::onPlayerShear, PlayerShearEntityEvent.class)
        .check(listener::onPlayerFish, PlayerFishEvent.class)
        .check(listener::onPlayerBedEnter, PlayerBedEnterEvent.class)
        .check(listener::onPlayerDropItem, PlayerDropItemEvent.class)
        .check(listener::onPlayerHitPlayerEvent, EntityDamageByEntityEvent.class)
        .check(listener::onPlayerConsumeItem, PlayerItemConsumeEvent.class)
        .check(listener::onPlayerInteract, PlayerInteractEvent.class)
        .check(listener::onPlayerPickupItem, PlayerPickupItemEvent.class)
        .check(listener::onPlayerInteractEntity, PlayerInteractEntityEvent.class);
}
项目:Craft-city    文件:EntitySheep.java   
public boolean a_(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.id == Item.SHEARS.id && !this.isSheared() && !this.isBaby()) {
        if (!this.world.isStatic) {
            // CraftBukkit start
            PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
            this.world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return false;
            }
            // CraftBukkit end

            this.setSheared(true);
            int i = 1 + this.random.nextInt(3);

            for (int j = 0; j < i; ++j) {
                EntityItem entityitem = this.a(new ItemStack(Block.WOOL.id, 1, this.getColor()), 1.0F);

                entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
                entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
                entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            }
        }

        itemstack.damage(1, entityhuman);
        this.makeSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.a_(entityhuman);
}
项目:DiscoSheep    文件:PartyEvents.java   
/**
 * Handler that prevents sheep shearing
 *
 * @param e The event
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerShear(PlayerShearEntityEvent e) {
    if (e.getEntity() instanceof Sheep && isFromParty(e.getEntity())) {
        e.setCancelled(true);
    }
}
项目:ZentrelaRPG    文件:EnvironmentManager.java   
@EventHandler
public void onShear(PlayerShearEntityEvent event) {
    event.setCancelled(true);
}
项目:FactionsXL    文件:EntityProtectionListener.java   
@EventHandler
public void onPlayerShearEntity(PlayerShearEntityEvent event) {
    forbidIfInProtectedTerritory(event.getPlayer(), event.getEntity(), event, SHEAR);
}
项目:CraftBukkit    文件:EntityMushroomCow.java   
public boolean a(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.getItem() == Items.BOWL && this.getAge() >= 0) {
        if (itemstack.count == 1) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, new ItemStack(Items.MUSHROOM_SOUP));
            return true;
        }

        if (entityhuman.inventory.pickup(new ItemStack(Items.MUSHROOM_SOUP)) && !entityhuman.abilities.canInstantlyBuild) {
            entityhuman.inventory.splitStack(entityhuman.inventory.itemInHandIndex, 1);
            return true;
        }
    }

    if (itemstack != null && itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
        // CraftBukkit start
        PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        this.die();
        this.world.addParticle("largeexplode", this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D);
        if (!this.world.isStatic) {
            EntityCow entitycow = new EntityCow(this.world);

            entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
            entitycow.setHealth(this.getHealth());
            entitycow.aM = this.aM;
            this.world.addEntity(entitycow);

            for (int i = 0; i < 5; ++i) {
                this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Blocks.RED_MUSHROOM)));
            }

            itemstack.damage(1, entityhuman);
            this.makeSound("mob.sheep.shear", 1.0F, 1.0F);
        }

        return true;
    } else {
        return super.a(entityhuman);
    }
}
项目:Almura-Server    文件:EntityMushroomCow.java   
public boolean a(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.id == Item.BOWL.id && this.getAge() >= 0) {
        if (itemstack.count == 1) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, new ItemStack(Item.MUSHROOM_SOUP));
            return true;
        }

        if (entityhuman.inventory.pickup(new ItemStack(Item.MUSHROOM_SOUP)) && !entityhuman.abilities.canInstantlyBuild) {
            entityhuman.inventory.splitStack(entityhuman.inventory.itemInHandIndex, 1);
            return true;
        }
    }

    if (itemstack != null && itemstack.id == Item.SHEARS.id && this.getAge() >= 0) {
        // CraftBukkit start
        PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        this.die();
        this.world.addParticle("largeexplode", this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D);
        if (!this.world.isStatic) {
            EntityCow entitycow = new EntityCow(this.world);

            entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
            entitycow.setHealth(this.getHealth());
            entitycow.aN = this.aN;
            this.world.addEntity(entitycow);

            for (int i = 0; i < 5; ++i) {
                this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Block.RED_MUSHROOM)));
            }
        }

        return true;
    } else {
        return super.a(entityhuman);
    }
}
项目:Tweakkit-Server    文件:EntityMushroomCow.java   
public boolean a(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.getItem() == Items.BOWL && this.getAge() >= 0) {
        if (itemstack.count == 1) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, new ItemStack(Items.MUSHROOM_SOUP));
            return true;
        }

        if (entityhuman.inventory.pickup(new ItemStack(Items.MUSHROOM_SOUP)) && !entityhuman.abilities.canInstantlyBuild) {
            entityhuman.inventory.splitStack(entityhuman.inventory.itemInHandIndex, 1);
            return true;
        }
    }

    if (itemstack != null && itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
        // CraftBukkit start
        PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        this.die();
        this.world.addParticle("largeexplode", this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D);
        if (!this.world.isStatic) {
            EntityCow entitycow = new EntityCow(this.world);

            entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
            entitycow.setHealth(this.getHealth());
            entitycow.aM = this.aM;
            this.world.addEntity(entitycow);

            for (int i = 0; i < 5; ++i) {
                this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Blocks.RED_MUSHROOM)));
            }

            itemstack.damage(1, entityhuman);
            this.makeSound("mob.sheep.shear", 1.0F, 1.0F);
        }

        return true;
    } else {
        return super.a(entityhuman);
    }
}
项目:SpigotSource    文件:EntityMushroomCow.java   
public boolean a(EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack) {
    if (itemstack != null && itemstack.getItem() == Items.BOWL && this.getAge() >= 0 && !entityhuman.abilities.canInstantlyBuild) {
        if (--itemstack.count == 0) {
            entityhuman.a(enumhand, new ItemStack(Items.MUSHROOM_STEW));
        } else if (!entityhuman.inventory.pickup(new ItemStack(Items.MUSHROOM_STEW))) {
            entityhuman.drop(new ItemStack(Items.MUSHROOM_STEW), false);
        }

        return true;
    } else if (itemstack != null && itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
        // CraftBukkit start
        PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end
        this.die();
        this.world.addParticle(EnumParticle.EXPLOSION_LARGE, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D, new int[0]);
        if (!this.world.isClientSide) {
            EntityCow entitycow = new EntityCow(this.world);

            entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
            entitycow.setHealth(this.getHealth());
            entitycow.aN = this.aN;
            if (this.hasCustomName()) {
                entitycow.setCustomName(this.getCustomName());
            }

            this.world.addEntity(entitycow);

            for (int i = 0; i < 5; ++i) {
                this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Blocks.RED_MUSHROOM)));
            }

            itemstack.damage(1, entityhuman);
            this.a(SoundEffects.dx, 1.0F, 1.0F);
        }

        return true;
    } else {
        return super.a(entityhuman, enumhand, itemstack);
    }
}
项目:AuthMeReloaded    文件:PlayerListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerShear(PlayerShearEntityEvent event) {
    if (listenerService.shouldCancelEvent(event)) {
        event.setCancelled(true);
    }
}
项目:Craft-city    文件:EntityMushroomCow.java   
public boolean a_(EntityHuman entityhuman) {
    ItemStack itemstack = entityhuman.inventory.getItemInHand();

    if (itemstack != null && itemstack.id == Item.BOWL.id && this.getAge() >= 0) {
        if (itemstack.count == 1) {
            entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, new ItemStack(Item.MUSHROOM_SOUP));
            return true;
        }

        if (entityhuman.inventory.pickup(new ItemStack(Item.MUSHROOM_SOUP)) && !entityhuman.abilities.canInstantlyBuild) {
            entityhuman.inventory.splitStack(entityhuman.inventory.itemInHandIndex, 1);
            return true;
        }
    }

    if (itemstack != null && itemstack.id == Item.SHEARS.id && this.getAge() >= 0) {
        // CraftBukkit start
        PlayerShearEntityEvent event = new PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        this.die();
        this.world.addParticle("largeexplode", this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D);
        if (!this.world.isStatic) {
            EntityCow entitycow = new EntityCow(this.world);

            entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
            entitycow.setHealth(this.getHealth());
            entitycow.ay = this.ay;
            this.world.addEntity(entitycow);

            for (int i = 0; i < 5; ++i) {
                this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Block.RED_MUSHROOM)));
            }
        }

        return true;
    } else {
        return super.a_(entityhuman);
    }
}
项目:StarQuestCode    文件:Events.java   
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerShearEntity (PlayerShearEntityEvent event) {

    int sheepShearMultiplier = Main.getPluginMain().getConfig().getInt("sheep shearing multiplier");
    sheepShearMultiplier = sheepShearMultiplier - 1;

    if (sheepShearMultiplier > 0) {

        Entity entity = event.getEntity();

        if (entity.getType().equals(EntityType.SHEEP)) {

            Sheep sheep = (Sheep) entity;

            int woolAmount = 0;

            for (int i = 0; i < sheepShearMultiplier; i ++) {

                woolAmount = woolAmount + ThreadLocalRandom.current().nextInt(1, 4);

            }

            ItemStack wool = new ItemStack(Material.WOOL, woolAmount, sheep.getColor().getData());

            entity.getWorld().dropItem(entity.getLocation(), wool);

        }

    }

}
项目:StarQuestCode    文件:Events.java   
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerShearEntity (PlayerShearEntityEvent event) {

    int sheepShearMultiplier = SQBoosters.multipliers[2];
    sheepShearMultiplier = sheepShearMultiplier - 1;

    if (sheepShearMultiplier > 0) {

        Entity entity = event.getEntity();

        if (entity.getType().equals(EntityType.SHEEP)) {

            Sheep sheep = (Sheep) entity;

            int woolAmount = 0;

            for (int i = 0; i < sheepShearMultiplier; i ++) {

                woolAmount = woolAmount + ThreadLocalRandom.current().nextInt(1, 4);

            }

            ItemStack wool = new ItemStack(Material.WOOL, woolAmount, sheep.getColor().getData());

            entity.getWorld().dropItem(entity.getLocation(), wool);

        }

    }

}