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


Java InteractEntityEvent.getTargetEntity方法代码示例

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


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

示例1: onInteractEntity

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onInteractEntity(final InteractEntityEvent event) {
    if (event.getTargetEntity() instanceof Hanging || event.getTargetEntity() instanceof Minecart || event.getTargetEntity() instanceof Boat) {
        Optional<Player> player = event.getCause().first(Player.class);
        if (player.isPresent()) {
            // Staff
            if (player.get().hasPermission("safeguard.mod")) {
                return;
            }

            if (!SafeGuard.getZoneManager().allows(player.get(), blockLikeEntityFlag, event.getTargetEntity().getLocation())) {
                player.get().sendMessage(Format.error("Sorry, this zone doesn't allow you to do that."));
                event.setCancelled(true);
            }
        } else {
            if (!SafeGuard.getZoneManager().allows(blockLikeEntityFlag, event.getTargetEntity().getLocation())) {
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:prism,项目名称:SafeGuard,代码行数:22,代码来源:InteractEntityListener.java

示例2: onPlayerInteractEntity

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener(order=Order.LAST)
public void onPlayerInteractEntity(InteractEntityEvent event, @First Player player_sponge) {
	EPlayer player = this.plugin.getEServer().getEPlayer(player_sponge);
		
	// GameMode : Painting
	if (event instanceof InteractEntityEvent.Secondary && event.getTargetEntity() instanceof Painting) {
		if (this.plugin.getConfigs().isGameModePaint() && player.isSneaking() && player.isCreative()) {
			Painting paint = (Painting) event.getTargetEntity();
			if (paint.get(Keys.ART).isPresent()) {
				Art art = paint.get(Keys.ART).get();
				Art next = UtilsPainting.next(art);
				while (!paint.offer(Keys.ART, next).isSuccessful() && !art.equals(next)){
					next = UtilsPainting.next(next);
				}
			}
		}
	}
	
	// AFK
	player.updateLastActivated();
	
	// Freeze
	if(player.isFreeze()) {
		event.setCancelled(true);
	}
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:27,代码来源:EEPlayerListeners.java

示例3: onPlayerInteract

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)	
   public void onPlayerInteract(InteractEntityEvent e, @First Player p) {
	
       Entity ent = e.getTargetEntity();
       Location<World> l = ent.getLocation();
       Region r = RedProtect.get().rm.getTopRegion(l);
               
       if (!canInteract(p, r)){
       	e.setCancelled(true);
       }
       
       if (r != null){
		return;
	}
       
       if (ent.getType().getName().contains("minecart") || ent.getType().getName().contains("boat")){
       	if (!RedProtect.get().cfgs.getGlobalFlag(ent.getWorld().getName(),"use-minecart") && !p.hasPermission("RedProtect.get().bypass.world")) {
               e.setCancelled(true);
           }
       } else {
       	if (!RedProtect.get().cfgs.getGlobalFlag(ent.getWorld().getName(),"interact") && !p.hasPermission("RedProtect.get().bypass.world") && (!(ent instanceof Player))) {
               e.setCancelled(true);
           }
       }      
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:26,代码来源:RPGlobalListener.java

示例4: onPlayerInteractEntity

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerInteractEntity(InteractEntityEvent event, @First Player player)
{
    if (!this.module.getConfig().protectEntityFromRClick) return;
    Entity entity = event.getTargetEntity();
    if (!player.hasPermission(module.perms().ALLOW_ENTITY.getId()))
    {
        i18n.send(player, NEGATIVE, "Strong magic prevents you from reaching this entity!");
        event.setCancelled(true);
        return;
    }
    Lock lock = this.manager.getLockForEntityUID(entity.getUniqueId());
    if (lock == null) return;
    if (entity instanceof Carrier || (entity.getType() == HORSE && player.get(Keys.IS_SNEAKING).get()))
    {
        // Handled by InteractInventoryEvent.Open
        lock.handleInventoryOpen(event, ((Carrier) entity).getInventory(), null, player);
    }
    else
    {
        lock.handleEntityInteract(event, player);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:24,代码来源:LockerListener.java

示例5: onInteract

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onInteract(InteractEntityEvent event, @First Player player)
{
	if (!ConfigHandler.getNode("worlds").getNode(player.getWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.interact"))
	{
		return;
	}
	Entity target = event.getTargetEntity();
	if (target instanceof Player || target instanceof Monster)
	{
		return;
	}
	if (target instanceof ItemFrame || target instanceof ArmorStand)
	{
		if (player.hasPermission("nations.admin.bypass.perm.build"))
		{
			return;
		}
		if (!DataHandler.getPerm("build", player.getUniqueId(), event.getTargetEntity().getLocation()))
		{
			event.setCancelled(true);
			player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD));
		}
		return;
	}
	if (!DataHandler.getPerm("interact", player.getUniqueId(), event.getTargetEntity().getLocation()))
	{
		event.setCancelled(true);
		player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_INTERACT));
	}
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:36,代码来源:InteractPermListener.java

示例6: onPlayerInteract

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPlayerInteract(InteractEntityEvent e, @First Player p) {
    Entity ent = e.getTargetEntity();
    RedProtect.get().logger.debug("player","RPPlayerListener - Is InteractEntityEvent event: " + ent.getType().getName());
    
    Location<World> l = ent.getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l);
    if (r == null){
    	return;
    }
    
    if (RedProtect.get().tpWait.contains(p.getName())){
		RedProtect.get().tpWait.remove(p.getName());
		RPLang.sendMessage(p, "cmdmanager.region.tpcancelled");
	}
            
    if (ent instanceof Hanging || ent.getType().equals(EntityTypes.ARMOR_STAND)) {        	
        if (!r.canBuild(p)) {
            RPLang.sendMessage(p, "playerlistener.region.cantedit");
            e.setCancelled(true);
        }
    } 
    
    else if ((ent.getType().getName().contains("minecart") || ent.getType().getName().contains("boat")) && !r.canMinecart(p)) {
    	RPLang.sendMessage(p, "blocklistener.region.cantenter");
        e.setCancelled(true);
    }
            
    else if (!r.allowMod(p) && !RPUtil.isBukkitEntity(ent) && (!(ent instanceof Player))){
    	RedProtect.get().logger.debug("player","PlayerInteractEntityEvent - Block is " + ent.getType().getName());
    	RPLang.sendMessage(p, "playerlistener.region.cantinteract");
    	e.setCancelled(true);        	       
    }        
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:35,代码来源:RPPlayerListener.java

示例7: onInteract

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onInteract(InteractEntityEvent event, @First Player player) {
  Entity target = event.getTargetEntity();

  if (target.getType() != EntityTypes.PLAYER && check(player, target.getLocation())) {
    event.setCancelled(true);
    if (event.getCause().root().equals(player)) {
      player.sendMessage(Text.of(TextColors.RED, "You can't interact with entities here!"));
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:12,代码来源:RegionServiceImpl.java

示例8: openEntityCase

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.LATE)
public void openEntityCase(InteractEntityEvent event) {
    Entity entity = event.getTargetEntity();
    Optional<Player> optional_player = event.getCause().first(Player.class);
    if (!optional_player.isPresent()) return;
    Player player = optional_player.get();
    for (Manager manager : GWMCrates.getInstance().getCreatedManagers()) {
        Case caze = manager.getCase();
        if (!(caze instanceof EntityCase)) {
            continue;
        }
        if (((EntityCase) caze).getEntityUuid().equals(entity.getUniqueId())) {
            event.setCancelled(true);
            if (event instanceof InteractEntityEvent.Secondary.MainHand) {
                OpenManager open_manager = manager.getOpenManager();
                if (!open_manager.canOpen(player, manager)) {
                    player.sendMessage(LanguageUtils.getText("CAN_NOT_OPEN_CASE"));
                    return;
                }
                Key key = manager.getKey();
                if (key.get(player) < 1) {
                    player.sendMessage(LanguageUtils.getText("HAVE_NOT_KEY"));
                    return;
                }
                key.add(player, -1);
                open_manager.open(player, manager);
                return;
            } else if (event instanceof InteractEntityEvent.Primary.MainHand) {
                Optional<Preview> optional_preview = manager.getPreview();
                if (!optional_preview.isPresent()) {
                    player.sendMessage(LanguageUtils.getText("PREVIEW_NOT_AVAILABLE",
                            new Pair<String, String>("%MANAGER%", manager.getName())));
                    return;
                }
                Preview preview = optional_preview.get();
                if (!player.hasPermission("gwm_crates.preview." + manager.getId())) {
                    player.sendMessage(LanguageUtils.getText("HAVE_NOT_PERMISSION"));
                    return;
                }
                preview.preview(player, manager);
                player.sendMessage(LanguageUtils.getText("PREVIEW_STARTED",
                        new Pair<String, String>("%MANAGER%", manager.getName())));
                return;
            }
        }
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:48,代码来源:EntityCaseListener.java

示例9: onAttemptInteractAS

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onAttemptInteractAS(InteractEntityEvent e, @First Player p) {
            
    Entity ent = e.getTargetEntity();
    Location<World> l = ent.getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l);
    
    if (r == null){
    	//global flags
    	if (ent.getType().equals(EntityTypes.ARMOR_STAND)) {
            if (!RedProtect.get().cfgs.getGlobalFlag(l.getExtent().getName(),"build")) {
            	e.setCancelled(true);
                return;
            }
        }
    	return;
    }
    
    ItemType itemInHand = ItemTypes.NONE;
    if (p.getItemInHand(HandTypes.MAIN_HAND).isPresent()){
    	itemInHand = p.getItemInHand(HandTypes.MAIN_HAND).get().getItem();
    } else if (p.getItemInHand(HandTypes.OFF_HAND).isPresent()){
    	itemInHand = p.getItemInHand(HandTypes.OFF_HAND).get().getItem();
    }
    
    if (!itemInHand.equals(ItemTypes.NONE) && itemInHand.getType().equals(ItemTypes.ARMOR_STAND)){
    	if (r != null && !r.canBuild(p)){
    		e.setCancelled(true);
    		RPLang.sendMessage(p, "blocklistener.region.cantbuild");
        	return;
    	}    	
	}
    
    //TODO Not working!
    if (ent.getType().equals(EntityTypes.ARMOR_STAND)) {
        if (r != null && !r.canBuild(p)) {
            if (!RedProtect.get().ph.hasPerm(p, "redprotect.bypass")) {
            	RPLang.sendMessage(p, "playerlistener.region.cantedit");
                e.setCancelled(true);
            }
        }
    }
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:44,代码来源:RPMine18.java


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