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


Java InteractEntityEvent.Secondary方法代码示例

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


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

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

示例2: onInteractEntitySecondaryMain

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onInteractEntitySecondaryMain(InteractEntityEvent.Secondary event, @Root Player player) {
    Optional<ItemStack> itemStackOptional = player.getItemInHand(event.getHandType());
    if(itemStackOptional.isPresent()) {

        EntityType entityType = event.getTargetEntity().getType();
        String entityId = entityType.getId();

        ItemType itemType = itemStackOptional.get().getType();
        String itemId = itemType.getId();

        PermHandler ph = PermHandler.getInstance();

        if (!ph.checkPerm(player, "protectionperms.item.use." + itemId + ".on." + entityId + ".primary")) {
            event.setCancelled(true);
            player.sendMessage(ChatTypes.ACTION_BAR,
                    Text.of(TextColors.RED, "You don't have permission to secondary use " + itemType.getName() + " on " + entityType.getName() + "s!"));
        }
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:21,代码来源:SecondaryEntityListener.java

示例3: onInteractEvent

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onInteractEvent(InteractEntityEvent.Secondary e, @First Player p){
	Entity et = e.getTargetEntity();
	Location<World> l = et.getLocation();
	Region r = RedProtect.get().rm.getTopRegion(l);	
	
	RedProtect.get().logger.debug("entity","RPEntityListener - InteractEntityEvent.Secondary entity "+et.getType().getName()); 
	
	if (r != null && !r.canInteractPassives(p) && (et instanceof Animal || et instanceof Villager || et instanceof Golem || et instanceof Ambient)) {
		if (RedProtect.get().getPVHelper().checkHorseOwner(et, p)){
			return;
		}
	    e.setCancelled(true);
		RPLang.sendMessage(p, "entitylistener.region.cantinteract");
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:17,代码来源:RPEntityListener.java

示例4: onRightClick

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onRightClick(InteractEntityEvent.Secondary event, @First(typeFilter = Player.class) Player pl) {

	Optional<ItemStack> itemInHand = pl.getItemInHand(HandTypes.MAIN_HAND);
	if (itemInHand.isPresent()) {
		ItemStack itemStack = itemInHand.get();
		if (ItemStackUtils.any_armor.contains(itemStack.getItem())) {
			event.setCancelled(true); //restrict armor equip on rightclick
			return;
		} else {
			IActiveCharacter character = characterService.getCharacter(pl.getUniqueId());
			if (character.isStub())
				return;
			inventoryService.onRightClick(character, 0);
		}
	}

}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:19,代码来源:BasicListener.java

示例5: onRightClickEntity

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onRightClickEntity(InteractEntityEvent.Secondary event, @First Player player)
{
    if (isPlayerInteract(player))
    {
        return;
    }
    LockAction lockAction = lockActions.get(player.getUniqueId());

    if (lockAction != null)
    {
        Entity target = event.getTargetEntity();
        Location<World> location = target.getLocation();

        Lock lock = this.manager.getLockForEntityUID(target.getUniqueId());

        lockAction.apply(lock, location, target);

        cmdUsed(player);
        event.setCancelled(true);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:23,代码来源:CommandListener.java

示例6: onRightClickEntity

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onRightClickEntity(InteractEntityEvent.Secondary evt, @Root Player player) {
    PlayerRightClicksEntityScriptEvent event = (PlayerRightClicksEntityScriptEvent) clone();
    event.internal = evt;
    event.player = new PlayerTag(player);
    event.entity = new EntityTag(evt.getTargetEntity());
    event.hInternal = evt.getHandType();
    event.hand = new TextTag(Utilities.getIdWithoutDefaultPrefix(evt.getHandType().getId()));
    event.cancelled = evt.isCancelled();
    event.run();
    evt.setCancelled(event.cancelled);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:13,代码来源:PlayerRightClicksEntityScriptEvent.java

示例7: onInteractEntitySecondary

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onInteractEntitySecondary(InteractEntityEvent.Secondary event, @Root Player player) {

    EntityType entityType = event.getTargetEntity().getType();
    String entityId = entityType.getId();

    PermHandler ph = PermHandler.getInstance();

    if (!ph.checkPerm(player, "protectionperms.entity.interact." + entityId + ".secondary")) {
        event.setCancelled(true);
        player.sendMessage(ChatTypes.ACTION_BAR,
                Text.of(TextColors.RED, "You don't have permission to secondary interact with " + entityType.getName() + "s!"));
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:15,代码来源:SecondaryListener.java

示例8: onPlayerInteractEntity

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerInteractEntity(InteractEntityEvent.Secondary event) {
	Optional<Player> cause = event.getCause().first(Player.class);
	Entity target = event.getTargetEntity();
	if (cause.isPresent())
		if (InteractionHandler.clickEntity(cause.get(), target, InteractionHandler.Button.right))
				event.setCancelled(true);
}
 
开发者ID:DosMike,项目名称:VillagerShops,代码行数:9,代码来源:EventListeners.java

示例9: onEntityInteract

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的package包/类
@Listener
public void onEntityInteract(InteractEntityEvent event, @First Player player) {
    HandType hand = Utils.getEventHand(event);
    CustomWorld world = WorldManager.toCustomWorld(event.getTargetEntity().getWorld());
    EntityTracker tracker = world.getEntityTracker(event.getTargetEntity());
    if (tracker == null) {
        return;
    }
    if (event instanceof InteractEntityEvent.Primary) {
        tracker.onEntityHit(event.getTargetEntity(), player, hand);
    } else if (event instanceof InteractEntityEvent.Secondary) {
        tracker.onEntityActivated(event.getTargetEntity(), player, hand);
    }
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:15,代码来源:EntityEventListeners.java

示例10: onRMBClick

import org.spongepowered.api.event.entity.InteractEntityEvent; //导入方法依赖的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


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