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


Java InteractEvent.setCancelled方法代码示例

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


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

示例1: onPrimary

import org.spongepowered.api.event.action.InteractEvent; //导入方法依赖的package包/类
@Listener
// TODO @Include(value = {InteractBlockEvent.Primary.class, InteractEntityEvent.Primary.class})
public void onPrimary(InteractEvent event, @First Player player)
{
    if (!(event instanceof InteractBlockEvent.Primary))
    {
        // TODO remove when include works as intended
        return;
    }
    if (player.getItemInHand(HandTypes.MAIN_HAND).map(ItemStack::getType).orElse(null) != COMPASS
            || !player.hasPermission(module.perms().COMPASS_JUMPTO_LEFT.getId()))
    {
        return;
    }

    Location<World> loc = LocationUtil.getBlockInSight(player);
    if (loc == null)
    {
        i18n.send(ACTION_BAR, player, NEGATIVE, "No block in sight");
        return;
    }
    player.setLocation(LocationUtil.getLocationUp(loc).add(0.5, 0, 0.5));
    i18n.send(ACTION_BAR, player, NEUTRAL, "Poof!");
    event.setCancelled(true);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:26,代码来源:TeleportListener.java

示例2: onSecondary

import org.spongepowered.api.event.action.InteractEvent; //导入方法依赖的package包/类
@Listener
// TODO @Include(value = {InteractBlockEvent.Secondary.class, InteractEntityEvent.Secondary.class})
public void onSecondary(InteractEvent event, @First Player player)
{
    if (!(event instanceof InteractBlockEvent.Secondary))
    {
        // TODO remove when include works as intended
        return;
    }
    if (player.getItemInHand(HandTypes.MAIN_HAND).map(ItemStack::getType).orElse(null) != COMPASS
            || !player.hasPermission(module.perms().COMPASS_JUMPTO_RIGHT.getId()))
    {
        return;
    }

    Optional<Location<World>> end = LocationUtil.getBlockBehindWall(player, module.getConfig().navigation.thru.maxRange, module.getConfig().navigation.thru.maxWallThickness);
    if (!end.isPresent())
    {
        i18n.send(player, NEGATIVE, "Nothing to pass through!");
        return;
    }

    player.setLocation(end.get().add(0.5, 0, 0.5));
    i18n.send(ChatTypes.ACTION_BAR, player, NEUTRAL, "You passed through a wall");
    event.setCancelled(true);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:27,代码来源:TeleportListener.java

示例3: onInteract

import org.spongepowered.api.event.action.InteractEvent; //导入方法依赖的package包/类
@Listener
public void onInteract(InteractEvent event, @Root @Has(ViewerData.class) Player player) {
    Optional<String> camId = player.get(VigilateKeys.CAMERA);

    if(camId.isPresent() && Vigilate.getInstance().getCameras().containsKey(camId.get())){
        Vigilate.getInstance().getCameras().get(camId.get()).endViewCamera(player);
    } else {
        Camera.resetPlayer(player);
    }

    event.setCancelled(true);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:13,代码来源:ClickListener.java

示例4: onPlayerClick

import org.spongepowered.api.event.action.InteractEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerClick(InteractEvent event, @Root Player player)
{
	if (EssentialCmds.frozenPlayers.contains(player.getUniqueId()))
	{
		player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot click while frozen."));
		event.setCancelled(true);
		return;
	}

	if (EssentialCmds.jailedPlayers.contains(player.getUniqueId()))
	{
		player.sendMessage(Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You cannot click while jailed."));
		event.setCancelled(true);
		return;
	}

	Powertool foundTool = null;

	for (Powertool powertool : EssentialCmds.powertools)
	{
		if (powertool.getPlayer().equals(player))
		{
			if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent() && powertool.getItemID().equals(player.getItemInHand(HandTypes.MAIN_HAND).get().getItem().getName()))
			{
				foundTool = powertool;
				break;
			}
		}
	}

	if (foundTool != null)
	{
		Sponge.getGame().getCommandManager().process(player, foundTool.getCommand());
	}
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:37,代码来源:PlayerClickListener.java

示例5: onPlayerInteract

import org.spongepowered.api.event.action.InteractEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)	
public void onPlayerInteract(InteractEvent e, @First Player p){
	RedProtect.get().logger.debug("default","RPGlobalListener - Is InteractEvent event! Cancelled? " + e.isCancelled());
	if (!e.getInteractionPoint().isPresent()){
		return;
	}
	BlockSnapshot b = p.getWorld().createSnapshot(e.getInteractionPoint().get().toInt());
	String bname = b.getState().getName().toLowerCase();
	Location<World> loc = new Location<>(p.getWorld(), e.getInteractionPoint().get());
	
	//Temporary fix until this event return wrong location
	if (new Location<>(p.getWorld(), e.getInteractionPoint().get()).getBlockY() <= 2){
		loc = p.getLocation();
	}
	
	Region r = RedProtect.get().rm.getTopRegion(loc);
	   
	if (!canInteract(p, r)){
       	e.setCancelled(true);
       }
	
	if (r != null){
		return;
	}
	
	if (bname.contains("rail") || bname.contains("water")){
           if (!RedProtect.get().cfgs.getGlobalFlag(p.getWorld().getName(),"use-minecart") && !p.hasPermission("RedProtect.get().bypass")){
       		e.setCancelled(true);
           }
       } else {
       	if (!RedProtect.get().cfgs.getGlobalFlag(p.getWorld().getName(),"interact") && !p.hasPermission("RedProtect.get().bypass")){
   			e.setCancelled(true);
   			return;
   		}
       	if (!RedProtect.get().cfgs.getGlobalFlag(p.getWorld().getName(),"build") && !p.hasPermission("RedProtect.get().bypass") 
       			&& bname.contains("leaves")){
   			e.setCancelled(true);
           }
       }	
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:41,代码来源:RPGlobalListener.java

示例6: onRMBClick

import org.spongepowered.api.event.action.InteractEvent; //导入方法依赖的package包/类
@Listener
@Include({
		InteractBlockEvent.Secondary.class,
		InteractEntityEvent.Secondary.class,
		InteractItemEvent.Secondary.class
})
public void onRMBClick(InteractEvent e, @Root Player player) {
	IActiveCharacter character = characterService.getCharacter(player);
	e.setCancelled(characterService.processUserAction(character, UserActionType.R));
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:11,代码来源:ComboListener.java

示例7: onLMBClick

import org.spongepowered.api.event.action.InteractEvent; //导入方法依赖的package包/类
@Listener
@Include({
		InteractBlockEvent.Primary.class,
		InteractEntityEvent.Primary.class,
		InteractItemEvent.Primary.class
})
public void onLMBClick(InteractEvent e, @Root Player player) {
	IActiveCharacter character = characterService.getCharacter(player);
	e.setCancelled(characterService.processUserAction(character, UserActionType.L));
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:11,代码来源:ComboListener.java

示例8: onInteract

import org.spongepowered.api.event.action.InteractEvent; //导入方法依赖的package包/类
@Listener
public void onInteract(InteractEvent event, @First Player player)
{
    if (module.isHidden(player) && !player.hasPermission(module.perms().INTERACT.getId()))
    {
        event.setCancelled(true);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:9,代码来源:HideListener.java

示例9: cancelRequest

import org.spongepowered.api.event.action.InteractEvent; //导入方法依赖的package包/类
private void cancelRequest(InteractEvent event, Player player)
{
    if (this.repairRequests.containsKey(player.getUniqueId()))
    {
        i18n.send(player, NEUTRAL, "The repair has been cancelled!");
        this.repairRequests.remove(player.getUniqueId());
        event.setCancelled(true);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:10,代码来源:ItemRepairListener.java


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