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


Java PlayerInteractEntityEvent.isCancelled方法代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerInteractEntityEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEntityEvent.isCancelled方法的具体用法?Java PlayerInteractEntityEvent.isCancelled怎么用?Java PlayerInteractEntityEvent.isCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.player.PlayerInteractEntityEvent的用法示例。


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

示例1: onPlayerClickItemFram

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerClickItemFram(PlayerInteractEntityEvent event) {
    if (!event.isCancelled() && event.getRightClicked() != null && event.getRightClicked() instanceof ItemFrame) {
        for (Region region : regions) {
            if (region.contains(event.getRightClicked().getLocation())) {
                for (MatchTeam matchTeam : teams) {
                    if (matchTeam.containsPlayer(event.getPlayer())) {
                        FilterResult filterResult = evaluator.evaluate(event.getPlayer());
                        if (filterResult == FilterResult.DENY) {
                            event.setCancelled(true);
                            event.getPlayer().sendMessage(message);
                        } else if (filterResult == FilterResult.ALLOW) {
                            event.setCancelled(false);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:21,代码来源:BuildFilterType.java

示例2: onInteractEvent

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onInteractEvent(PlayerInteractEntityEvent e){
   	RedProtect.get().logger.debug("RPEntityListener - Is PlayerInteractEntityEvent");
   	if (e.isCancelled()) {
           return;
       }
	Player p = e.getPlayer();
	if (p == null){
		return;
	}
	Location l = e.getRightClicked().getLocation();
	Region r = RedProtect.get().rm.getTopRegion(l);	
	Entity et = e.getRightClicked();
	if (r != null && !r.canInteractPassives(p) && (et instanceof Animals || et instanceof Villager || et instanceof Golem)) {
		if (et instanceof Tameable){
			Tameable tam = (Tameable) et;
			if (tam.isTamed() && tam.getOwner() != null && tam.getOwner().getName().equals(p.getName())){
				return;
			}
		}
	    e.setCancelled(true);
		RPLang.sendMessage(p, "entitylistener.region.cantinteract");
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:25,代码来源:RPEntityListener.java

示例3: onInteractEntity

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW) 
public void onInteractEntity(PlayerInteractEntityEvent event) {
	if (event.isCancelled()) {
		return;
	}
	
	ItemStack stack = event.getPlayer().getItemInHand();
	if (stack == null) {
		return;
	}

	LoreMaterial material = LoreMaterial.getMaterial(stack);
	if (material != null) {
		material.onInteractEntity(event);
	}
	
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:18,代码来源:CustomItemManager.java

示例4: onPlayerInteractWithEntity

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteractWithEntity(final PlayerInteractEntityEvent event) {
	try {
		if (!this.entityHandlers.isEmpty() && !event.isCancelled()) {
			final Menu menu = new Menu("Kontextmen�: " + event.getRightClicked().getType());

			for (final BiConsumer<PlayerInteractEntityEvent, Menu> consumer : this.entityHandlers) {
				try { consumer.accept(event, menu); }
				catch (final Exception e) { CraftoMessenger.report(this.getClass(), "A playerinteractentityevent consumer ("+consumer+") got an exception!", e); }
			}

			if (!menu.isEmpty()) {
				menu.show(event.getPlayer());
				event.setCancelled(true);
				event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.BLOCK_WOODEN_DOOR_OPEN, 1.0f, 2.0f);
			}
		}
	}
	catch (Exception outsideException) { CraftoMessenger.report(getClass(), "Failed to handle PlayerInteractEntityEvent!", outsideException); }
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:21,代码来源:ContextModule.java

示例5: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEntityEvent e){
	if (!e.isCancelled())
		if (e.getRightClicked().getUniqueId().equals(id)) {
			e.setCancelled(true);
		}
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:8,代码来源:NPC.java

示例6: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler
   public void onPlayerInteract(PlayerInteractEntityEvent e) {
   	if (e.isCancelled()) {
           return;
       }

   	Player p = e.getPlayer();
       Entity ent = e.getRightClicked();
       Location l = ent.getLocation();
       Region r = RedProtect.get().rm.getTopRegion(l);
       if (r != null){
		return;
	}
       
       if (ent instanceof ItemFrame || ent instanceof Painting) {
           if (!bypassBuild(p, null, 0)) {
               e.setCancelled(true);
               return;
           }
       } 
       
       if (ent instanceof Minecart || ent instanceof Boat){
       	if (!RPConfig.getGlobalFlagBool(l.getWorld().getName()+".use-minecart") && !p.hasPermission("redprotect.bypass.world")) {
               e.setCancelled(true);
               return;
           }
       } 
       
       if (!RPConfig.getGlobalFlagBool(l.getWorld().getName()+".interact") && !p.hasPermission("redprotect.bypass.world") && (!(ent instanceof Player))) {
   		if (RPConfig.getGlobalFlagList(p.getWorld().getName() + ".if-interact-false.allow-entities").contains(ent.getType().name())){
   			return;
   		} 
           e.setCancelled(true);
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:36,代码来源:RPGlobalListener.java

示例7: onFeedEvent

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onFeedEvent(PlayerInteractEntityEvent event) {
    Player player = event.getPlayer();
    if (player == null || event.isCancelled() || !plugin.isSkyWorld(player.getWorld())) {
        return; // Bail out, we don't care
    }
    if (Animals.class.isAssignableFrom(event.getRightClicked().getType().getEntityClass()) && player.getItemInHand() != null) {
        if (isFodder(event.getRightClicked(), player.getItemInHand())) {
            checkLimits(event, event.getRightClicked().getType(), player.getLocation());
            if (event.isCancelled()) {
                plugin.notifyPlayer(player, tr("\u00a7cYou have reached your spawn-limit for your island."));
            }
        }
    }
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:16,代码来源:SpawnEvents.java

示例8: entityInteractEvent

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void entityInteractEvent(PlayerInteractEntityEvent event){
    if (!event.isCancelled() && event.getRightClicked() != null) {
        boolean allowed = protectionManager.CanUseItem(event.getPlayer(), event.getPlayer().getLocation(), ItemType.Item);
        if (!allowed)
            event.setCancelled(true);
    }
}
 
开发者ID:TheFantasyCraft,项目名称:Forge-Permittor,代码行数:9,代码来源:ProtectionListener.java

示例9: onItemFramePlace

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemFramePlace(final PlayerInteractEntityEvent event) { // Used to override worldguard
	if (event.isCancelled() && event.getRightClicked() instanceof ItemFrame && event.getPlayer().getInventory().getItemInMainHand() != null 
			&& !event.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.AIR)) {
		
		final Block block = event.getRightClicked().getLocation().getBlock();
		if (block.getType().equals(Material.STONE_BUTTON)) {
			final Optional<Craftomat> craftomat = this.storage.getCraftomat(block.getLocation());
			if (craftomat.isPresent()) {
				event.setCancelled(false);
			}
		}
	}
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:15,代码来源:CraftomatListener.java

示例10: onEntityInteract

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false)
void onEntityInteract(PlayerInteractEntityEvent event) {
	if (!(event.getRightClicked() instanceof LivingEntity)) return;
	LivingEntity shopEntity = (LivingEntity) event.getRightClicked();
	Player player = event.getPlayer();
	String playerName = player.getName();
	Log.debug("Player " + playerName + " is interacting with entity at " + shopEntity.getLocation());
	Shopkeeper shopkeeper = plugin.getShopkeeperByEntity(shopEntity); // also check for citizens npc shopkeepers

	if (event.isCancelled() && !Settings.bypassShopInteractionBlocking) {
		Log.debug("  Cancelled by another plugin");
	} else if (shopkeeper != null) {
		// only trigger shopkeeper interaction for main-hand events:
		if (NMSManager.getProvider().isMainHandInteraction(event)) {
			shopkeeper.onPlayerInteraction(player);
		}

		// if citizens npc: don't cancel the event, let Citizens perform other actions as appropriate
		if (shopkeeper.getShopObject().getObjectType() != DefaultShopObjectTypes.CITIZEN()) {
			// always cancel interactions with shopkeepers, to prevent any default behavior:
			event.setCancelled(true);

			// update inventory in case interaction would trigger feeding normally:
			player.updateInventory();
		}
	} else {
		Log.debug("  Non-shopkeeper");
	}
}
 
开发者ID:nisovin,项目名称:Shopkeepers,代码行数:30,代码来源:LivingEntityShopListener.java

示例11: a

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
public void a(PacketPlayInUseEntity packetplayinuseentity) {
    if (this.player.dead) return; // CraftBukkit
    WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
    Entity entity = packetplayinuseentity.a((World) worldserver);

    this.player.v();
    if (entity != null) {
        boolean flag = this.player.hasLineOfSight(entity);
        double d0 = 36.0D;

        if (!flag) {
            d0 = 9.0D;
        }

        if (this.player.f(entity) < d0) {
            ItemStack itemInHand = this.player.inventory.getItemInHand(); // CraftBukkit
            if (packetplayinuseentity.c() == EnumEntityUseAction.INTERACT) {
                // CraftBukkit start
                boolean triggerTagUpdate = itemInHand != null && itemInHand.getItem() == Items.NAME_TAG && entity instanceof EntityInsentient;
                boolean triggerChestUpdate = itemInHand != null && itemInHand.getItem() == Item.getItemOf(Blocks.CHEST) && entity instanceof EntityHorse;
                boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEASH && entity instanceof EntityInsentient;
                PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity());
                this.server.getPluginManager().callEvent(event);

                if (triggerLeashUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Items.LEASH)) {
                    // Refresh the current leash state
                    this.sendPacket(new PacketPlayOutAttachEntity(1, entity, ((EntityInsentient) entity).getLeashHolder()));
                }

                if (triggerTagUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Items.NAME_TAG)) {
                    // Refresh the current entity metadata
                    this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true));
                }
                if (triggerChestUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Item.getItemOf(Blocks.CHEST))) {
                    this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true));
                }

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

                this.player.q(entity);

                // CraftBukkit start
                if (itemInHand != null && itemInHand.count <= -1) {
                    this.player.updateInventory(this.player.activeContainer);
                }
                // CraftBukkit end
            } else if (packetplayinuseentity.c() == EnumEntityUseAction.ATTACK) {
                if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || entity == this.player) {
                    this.disconnect("Attempting to attack an invalid entity");
                    this.minecraftServer.warning("Player " + this.player.getName() + " tried to attack an invalid entity");
                    return;
                }

                this.player.attack(entity);

                // CraftBukkit start
                if (itemInHand != null && itemInHand.count <= -1) {
                    this.player.updateInventory(this.player.activeContainer);
                }
                // CraftBukkit end
            }
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:68,代码来源:PlayerConnection.java

示例12: onArmorStandClick

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onArmorStandClick(PlayerInteractAtEntityEvent event) {
    if (event.getRightClicked() instanceof ArmorStand) {
        PlayerInteractEntityEvent pie = new PlayerInteractEntityEvent(event.getPlayer(), event.getRightClicked());
        plugin.getServer().getPluginManager().callEvent(pie);
        if (pie.isCancelled()) {
            return;
        }

        ArmorStand armorStand = (ArmorStand) event.getRightClicked();

        if (plugin.hasWaitingAction(event.getPlayer())) {
            event.setCancelled(true);
            plugin.calculateAction(event.getPlayer(), armorStand, plugin.getWaitingAction(event.getPlayer()));
            plugin.removeWaitingAction(event.getPlayer());
            return;
        }

        if (plugin.getPersistentAction(event.getPlayer()) != null) {
            event.setCancelled(true);
            plugin.calculateAction(event.getPlayer(), armorStand, plugin.getPersistentAction(event.getPlayer()));
            return;
        }

        if (event.getPlayer().getItemInHand().getType() == Material.NAME_TAG) {
            ItemStack hi = event.getPlayer().getItemInHand();
            if (hi.hasItemMeta() && hi.getItemMeta().hasDisplayName()) {
                if (event.getPlayer().hasPermission("editarmorstands.nametag.name")) {
                    event.setCancelled(true);
                    String name = hi.getItemMeta().getDisplayName();
                    if (event.getPlayer().hasPermission("editarmorstands.nametag.name.colored")) {
                        name = ChatColor.translateAlternateColorCodes('&', name);
                    } else {
                        name = ChatColor.ITALIC + name;
                    }
                    armorStand.setCustomName(name + ChatColor.RESET);
                    armorStand.setCustomNameVisible(true);
                    if (event.getPlayer().getGameMode() != GameMode.CREATIVE) {
                        if (hi.getAmount() > 1) {
                            hi.setAmount(hi.getAmount() - 1);
                        } else {
                            event.getPlayer().setItemInHand(new ItemStack(Material.AIR));
                        }
                        event.getPlayer().updateInventory();
                    }
                    return;
                }
            } else if (event.getPlayer().hasPermission("editarmorstands.nametag.name.clear")) {
                event.setCancelled(true);
                armorStand.setCustomName("");
                armorStand.setCustomNameVisible(false);
                return;
            }

        } else if (!event.getPlayer().isSneaking() && event.getPlayer().hasPermission("editarmorstands.openinventory")) {
            event.setCancelled(true);
            ArmorStandGui gui = new ArmorStandGui(plugin, armorStand, event.getPlayer());
            gui.show();
        }
    }
}
 
开发者ID:Phoenix616,项目名称:EditArmorStands,代码行数:62,代码来源:ArmorStandListener.java

示例13: a

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
public void a(Packet7UseEntity packet7useentity) {
    if (this.player.dead) return; // CraftBukkit

    WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
    Entity entity = worldserver.getEntity(packet7useentity.target);
    // Spigot Start
    if ( entity == player )
    {
        disconnect( "Cannot interact with self!" );
        return;
    }
    // Spigot End

    this.player.u();
    if (entity != null) {
        boolean flag = this.player.o(entity);
        double d0 = 36.0D;

        if (!flag) {
            d0 = 9.0D;
        }

        if (this.player.e(entity) < d0) {
            ItemStack itemInHand = this.player.inventory.getItemInHand(); // CraftBukkit
            if (packet7useentity.action == 0) {
                // CraftBukkit start
                boolean triggerTagUpdate = itemInHand != null && itemInHand.id == Item.NAME_TAG.id && entity instanceof EntityInsentient;
                boolean triggerChestUpdate = itemInHand != null && itemInHand.id == Block.CHEST.id && entity instanceof EntityHorse;
                boolean triggerLeashUpdate = itemInHand != null && itemInHand.id == Item.LEASH.id && entity instanceof EntityInsentient;
                PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity());
                this.server.getPluginManager().callEvent(event);

                if (triggerLeashUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().id != Item.LEASH.id)) {
                    // Refresh the current leash state
                    this.sendPacket(new Packet39AttachEntity(1, entity, ((EntityInsentient) entity).getLeashHolder()));
                }

                if (triggerTagUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().id != Item.NAME_TAG.id)) {
                    // Refresh the current entity metadata
                    this.sendPacket(new Packet40EntityMetadata(entity.id, entity.datawatcher, true));
                }
                if (triggerChestUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().id != Block.CHEST.id)) {
                    this.sendPacket(new Packet40EntityMetadata(entity.id, entity.datawatcher, true));
                }

                if (event.isCancelled()) {
                    return;
                }
                // CraftBukkit end
                this.player.p(entity);
                // CraftBukkit start - Update the client if the item is an infinite one
                if (itemInHand != null && itemInHand.count <= -1) {
                    this.player.updateInventory(this.player.activeContainer);
                }
            } else if (packet7useentity.action == 1) {
                // CraftBukkit - Check for player
                if ((entity instanceof EntityItem) || (entity instanceof EntityExperienceOrb) || (entity instanceof EntityArrow) || (entity == this.player)) {
                    String type = entity.getClass().getSimpleName();
                    disconnect("Attacking an " + type + " is not permitted");
                    System.out.println("Player " + player.getName() + " tried to attack an " + type + ", so I have disconnected them for exploiting.");
                    return;
                }

                this.player.attack(entity);

                if (itemInHand != null && itemInHand.count <= -1) {
                    this.player.updateInventory(this.player.activeContainer);
                }
                // CraftBukkit end
            }
        }
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:74,代码来源:PlayerConnection.java

示例14: a

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
public void a(PacketPlayInUseEntity packetplayinuseentity) {
    if (this.player.dead) return; // CraftBukkit
    WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
    Entity entity = packetplayinuseentity.a((World) worldserver);
    // Spigot Start
    if ( entity == player )
    {
        disconnect( "Cannot interact with self!" );
        return;
    }
    // Spigot End
    // Spigot start
    if ( player.activeContainer != player.defaultContainer )
    {
        getPlayer().closeInventory();
    }
    // Spigot end

    this.player.v();
    if (entity != null) {
        boolean flag = this.player.hasLineOfSight(entity);
        double d0 = 36.0D;

        if (!flag) {
            d0 = 9.0D;
        }

        if (this.player.f(entity) < d0) {
            ItemStack itemInHand = this.player.inventory.getItemInHand(); // CraftBukkit
            if (packetplayinuseentity.c() == EnumEntityUseAction.INTERACT) {
                // CraftBukkit start
                boolean triggerTagUpdate = itemInHand != null && itemInHand.getItem() == Items.NAME_TAG && entity instanceof EntityInsentient;
                boolean triggerChestUpdate = itemInHand != null && itemInHand.getItem() == Item.getItemOf(Blocks.CHEST) && entity instanceof EntityHorse;
                boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEASH && entity instanceof EntityInsentient;
                PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity());
                this.server.getPluginManager().callEvent(event);

                if (triggerLeashUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Items.LEASH)) {
                    // Refresh the current leash state
                    this.sendPacket(new PacketPlayOutAttachEntity(1, entity, ((EntityInsentient) entity).getLeashHolder()));
                }

                if (triggerTagUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Items.NAME_TAG)) {
                    // Refresh the current entity metadata
                    this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true));
                }
                if (triggerChestUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Item.getItemOf(Blocks.CHEST))) {
                    this.sendPacket(new PacketPlayOutEntityMetadata(entity.getId(), entity.datawatcher, true));
                }

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

                this.player.q(entity);

                // CraftBukkit start
                if (itemInHand != null && itemInHand.count <= -1) {
                    this.player.updateInventory(this.player.activeContainer);
                }
                // CraftBukkit end
            } else if (packetplayinuseentity.c() == EnumEntityUseAction.ATTACK) {
                if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || entity == this.player) {
                    this.disconnect("Attempting to attack an invalid entity");
                    this.minecraftServer.warning("Player " + this.player.getName() + " tried to attack an invalid entity");
                    return;
                }

                this.player.attack(entity);

                // CraftBukkit start
                if (itemInHand != null && itemInHand.count <= -1) {
                    this.player.updateInventory(this.player.activeContainer);
                }
                // CraftBukkit end
            }
        }
    }
}
 
开发者ID:pvginkel,项目名称:Tweakkit-Server,代码行数:81,代码来源:PlayerConnection.java

示例15: a

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
public void a(Packet7UseEntity packet7useentity) {
    if (this.player.dead) return; // CraftBukkit

    WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
    Entity entity = worldserver.getEntity(packet7useentity.target);

    if (entity != null) {
        boolean flag = this.player.n(entity);
        double d0 = 36.0D;

        if (!flag) {
            d0 = 9.0D;
        }

        if (this.player.e(entity) < d0) {
            ItemStack itemInHand = this.player.inventory.getItemInHand(); // CraftBukkit
            if (packet7useentity.action == 0) {
                // CraftBukkit start
                PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) this.getPlayer(), entity.getBukkitEntity());
                this.server.getPluginManager().callEvent(event);

                if (event.isCancelled()) {
                    return;
                }
                // CraftBukkit end
                this.player.p(entity);
                // CraftBukkit start - Update the client if the item is an infinite one
                if (itemInHand != null && itemInHand.count <= -1) {
                    this.player.updateInventory(this.player.activeContainer);
                }
            } else if (packet7useentity.action == 1) {
                if ((entity instanceof EntityItem) || (entity instanceof EntityExperienceOrb) || (entity instanceof EntityArrow)) {
                    String type = entity.getClass().getSimpleName();
                    disconnect("Attacking an " + type + " is not permitted");
                    System.out.println("Player " + player.name + " tried to attack an " + type + ", so I have disconnected them for exploiting.");
                    return;
                }

                this.player.attack(entity);

                if (itemInHand != null && itemInHand.count <= -1) {
                    this.player.updateInventory(this.player.activeContainer);
                }
                // CraftBukkit end
            }
        }
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:49,代码来源:PlayerConnection.java


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