• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InteractEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



InteractEvent类属于org.spongepowered.api.event.action包,在下文中一共展示了InteractEvent类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: onInteract

import org.spongepowered.api.event.action.InteractEvent; //导入依赖的package包/类
@Listener
public void onInteract(InteractEvent event, @Root Player player) {
    if (player.getItemInHand(HandTypes.MAIN_HAND).isPresent()) {
        if (ArmorType.isArmor(player.getItemInHand(HandTypes.MAIN_HAND).get().getItem().getId()))
            sendDelayedArmorUpdate(player);
    }
}
 
开发者ID:MylesIsCool,项目名称:ViaVersion,代码行数:8,代码来源:Sponge5ArmorListener.java


示例5: onInteract

import org.spongepowered.api.event.action.InteractEvent; //导入依赖的package包/类
@Listener
public void onInteract(InteractEvent event, @Root Player player) {
    if (player.getItemInHand().isPresent()) {
        if (ArmorType.isArmor(player.getItemInHand().get().getItem().getId()))
            sendDelayedArmorUpdate(player);
    }
}
 
开发者ID:MylesIsCool,项目名称:ViaVersion,代码行数:8,代码来源:Sponge4ArmorListener.java


示例6: getEventHand

import org.spongepowered.api.event.action.InteractEvent; //导入依赖的package包/类
public static HandType getEventHand(InteractEvent event) {
    HandType hand;
    if (event instanceof InteractBlockEvent.Primary.OffHand) {
        hand = HandTypes.OFF_HAND;
    } else if (event instanceof InteractBlockEvent.Secondary.OffHand) {
        hand = HandTypes.OFF_HAND;
    } else if (event instanceof InteractEntityEvent.Primary.OffHand) {
        hand = HandTypes.OFF_HAND;
    } else if (event instanceof InteractEntityEvent.Secondary.OffHand) {
        hand = HandTypes.OFF_HAND;
    } else {
        hand = HandTypes.MAIN_HAND;
    }
    return hand;
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:16,代码来源:Utils.java


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: onCancelRepair

import org.spongepowered.api.event.action.InteractEvent; //导入依赖的package包/类
@Listener
public void onCancelRepair(InteractEvent event, @First Player player)
{
    if (event instanceof InteractBlockEvent || event instanceof InteractItemEvent)
    {
        return;
    }
    this.cancelRequest(event, player);
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:10,代码来源:ItemRepairListener.java


示例13: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XdmAtomicValue类代码示例发布时间:2022-05-22
下一篇:
Java RowBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap