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


Java PlayerShearEntityEvent类代码示例

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


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

示例1: onShear

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
@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()));

}
 
开发者ID:Staartvin,项目名称:Statz,代码行数:18,代码来源:TimesShornListener.java

示例2: onShear

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
@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()) });
}
 
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:20,代码来源:ShearObjective.java

示例3: onShear

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:15,代码来源:IslandGuard.java

示例4: onShear

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
@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));
} 
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:10,代码来源:PlayerShearEventListener.java

示例5: onShear

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
@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);
}
 
开发者ID:satoshinm,项目名称:WebSandboxMC,代码行数:15,代码来源:EntityListener.java

示例6: onPlayerShearEntity

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
@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);
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:15,代码来源:AchieveShearListener.java

示例7: a

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
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);
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:33,代码来源:EntitySheep.java

示例8: onShear

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:14,代码来源:PlayerMovementListener.java

示例9: onShearEvent

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:14,代码来源:GriefEvents.java

示例10: onPlayerShearEntity

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:zDevelopers,项目名称:BelovedBlocks,代码行数:15,代码来源:BlocksListener.java

示例11: a

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
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);
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:33,代码来源:EntitySheep.java

示例12: onShear

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:16,代码来源:IslandGuard.java

示例13: itemInteractionForEntity

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
@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;
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:40,代码来源:ItemShears.java

示例14: onEntityShear

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:13,代码来源:ListenerPlayerEntity.java

示例15: PlayerShear

import org.bukkit.event.player.PlayerShearEntityEvent; //导入依赖的package包/类
@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);
}
 
开发者ID:ST-DDT,项目名称:CrazyLogin,代码行数:11,代码来源:DynamicPlayerListener.java


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