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


Java PlayerInteractEvent.getAction方法代码示例

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


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

示例1: onInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(PlayerInteractEvent event) {
    Action action = event.getAction();
    ItemStack item = event.getItem();

    if (item == null) {
        return;
    }

    if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) {
        Player player = event.getPlayer();
        InventoryData data = InventoryData.getData(player);
        // check if we are consuming an item.
        if (item.getType().isEdible() || item.getType() == Material.POTION) {
            // update data.
            data.setConsumeTime(System.currentTimeMillis());
        }
    }

}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:21,代码来源:InventoryListener.java

示例2: getDatas

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
private void getDatas(PlayerInteractEvent e){
	if(!(e.getAction()==Action.LEFT_CLICK_BLOCK||e.getAction()==Action.LEFT_CLICK_AIR))return;
	if(!canUsePeople.contains(e.getPlayer().getUniqueId()))return;
	e.setCancelled(true);
	Block block=e.getPlayer().getWorld().getBlockAt(e.getPlayer().getTargetBlock((Set<Material>)null, 6).getLocation()); 
	if(block!=null)
		e.getPlayer().sendMessage("��b������: ��3��l"+block.getType());
	if(e.getPlayer().getInventory().getItemInMainHand()!=null)
		e.getPlayer().sendMessage("��b��Ʒ��: ��3��l"+e.getPlayer().getInventory().getItemInMainHand().getType());
	double _temper1=getTemper(e.getPlayer(),e.getPlayer().getWorld().getTemperature(e.getPlayer().getLocation().getBlockX(), e.getPlayer().getLocation().getBlockZ()));
	e.getPlayer().sendMessage("��b�����¶�: ��3��l"+_temper1+"��");
	if(block!=null){
		double _temper2=getTemper(e.getPlayer(),e.getPlayer().getWorld().getTemperature(block.getX(), block.getZ()));
		e.getPlayer().sendMessage("��bĿ�귽���¶�: ��3��l"+_temper2+"��");
		e.getPlayer().sendMessage("��bĿ�귽������Ⱥϵ: ��3��l"+block.getBiome());
	}
	
	
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:21,代码来源:TestCMD.java

示例3: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) {
        Block block = event.getClickedBlock();
        // Don't prevent opening chests, etc, as these won't throw the Enderpearls anyway
        if (block.getType().isSolid() && !(block.getState() instanceof InventoryHolder)) {
            Faction factionAt = HCF.getPlugin().getFactionManager().getFactionAt(block.getLocation());
            if (!(factionAt instanceof ClaimableFaction)) {
                return;
            }

            event.setCancelled(true);
            Player player = event.getPlayer();
            player.setItemInHand(event.getItem()); // required to update Enderpearl count
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:18,代码来源:PearlGlitchListener.java

示例4: onWalkieTalkieInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onWalkieTalkieInteract(PlayerInteractEvent e) {
	if (e.getPlayer().getInventory().getItemInMainHand().getType() != Material.REDSTONE_COMPARATOR)
		return;
	if (e.getHand() == EquipmentSlot.OFF_HAND)
		return;

	WalkieTalkie wt = new WalkieTalkie(main,
			main.getPlayerManager().getPlayer(e.getPlayer()).getCurrentWalkieTalkieFrequency());

	// Left click to tune frequency.
	if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
		if (e.getPlayer().isSneaking()) {
			wt.decreaseFrequency(e.getPlayer());
		} else {
			wt.increaseFrequency(e.getPlayer());
		}
	}

}
 
开发者ID:kadeska,项目名称:MT_Communication,代码行数:21,代码来源:WalkieTalkieListener.java

示例5: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
	if (e.getAction() == Action.RIGHT_CLICK_AIR && e.getItem() != null && e.getItem().getType() != null && e.getItem().getType() == getItem().getType() && e.getItem().getDurability() == getItem().getDurability() && ((e.getPlayer().getFoodLevel() < 20 && hasToBeHungry()) || (!hasToBeHungry())) ) {
		if (e.getItem().getAmount() - 1 != 0) {
			ItemStack it = e.getItem();
			it.setAmount(e.getItem().getAmount() - 1);
			e.getPlayer().getInventory().setItem(e.getPlayer().getInventory().first(e.getItem()), it);
		}
		
		else {
			e.getPlayer().getInventory().clear(e.getPlayer().getInventory().first(e.getItem()));
		}
		e.getPlayer().setFoodLevel(e.getPlayer().getFoodLevel() + getNutritionLevel() <= 20 ? e.getPlayer().getFoodLevel() + getNutritionLevel() : 20);
		e.getPlayer().setSaturation(e.getPlayer().getSaturation() + getNutritionLevel() <= 20 ? e.getPlayer().getSaturation() + getSaturationLevel() : 20);
		e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.ENTITY_PLAYER_BURP, 100, 1);
		onEat(e.getPlayer());
		e.setCancelled(true);
	}
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:20,代码来源:CustomFood.java

示例6: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {   
    if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { // This check needs to be there, 'cause RightClickAction has only the getType function, LeftClickAction doesnt and boooom!!
        Player player = (Player) e.getPlayer();
        ItemStack item = e.getItem();
        Block block = e.getClickedBlock();
        String bankId = BukkitUtils.getNBTTag(item, "bankid");
        
        if (item == null || block == null) return;
        
        if (bankId != null && bankId.length() > 0 && item.getType() == Material.PAPER && block.getType() == Material.ENDER_STONE) {
            // got a foreign card?
            if (!bankId.equals(player.getUniqueId().toString())) {
                player.getInventory().remove(item);
                BankomatCommand.appendCreditCardToUser(player); 
            } 
            
            player.openInventory(bankUi); // Dispatch our event by opening bankUi here:
        }   
    }
}
 
开发者ID:srbinas,项目名称:bankomat,代码行数:22,代码来源:BankMenuListener.java

示例7: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();

    if (!(Gizmos.gizmoMap.get(player) instanceof LauncherGizmo)) return;

    if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) return;
    if (player.getItemInHand().getType() != this.getIcon()) return;

    Firework oldFirework = this.launchedPlayers.get(player);
    if (oldFirework == null || oldFirework.isDead()) {
        Firework firework = this.buildFirework(player.getLocation());
        firework.setPassenger(player);
        this.launchedPlayers.put(player, firework);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:LauncherGizmo.java

示例8: onInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onInteract(PlayerInteractEvent evt) {
    if (!evt.getPlayer().equals(currentPainter))
        return;

    Block target = evt.getPlayer().getTargetBlock((Set<Material>) null, 50);
    if (target.getZ() != ARENA_Z || target.getX() < MIN_X || target.getX() > MAX_X)
        return; // Not clicking on the canvas.

    if (target.getY() > MAX_Y && target.getY() <= MAX_Y + 5) { // Pick color.
        penTime = 0;
        currentColor = target.getData();
        updateActionBar();
        currentPainter.playSound(currentPainter.getLocation(), Sound.BLOCK_BREWING_STAND_BREW, 0.75F, 1.75F);
    } else if (evt.getAction() == Action.RIGHT_CLICK_AIR) { // Pen Tool
        penTime = System.currentTimeMillis() + 200;
        placeInk();
        evt.setCancelled(true); // Prevent "cl
    } else if (evt.getAction() == Action.LEFT_CLICK_AIR) { // Fill
        playSound(Sound.ENTITY_BOBBER_SPLASH, 1.5F, 0.5F);
        floodFill(target);
    }
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:24,代码来源:Pictionary.java

示例9: onLeverOrButton

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onLeverOrButton(PlayerInteractEvent event) {
	Block clickedBlock = event.getClickedBlock();
	Player player = event.getPlayer();

	if (clickedBlock == null)
		return;

	String chunk = clickedBlock.getLocation().getChunk().getX() + ";"
			+ clickedBlock.getLocation().getChunk().getZ();
	if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
		return;
	if (!powerable.containsKey(clickedBlock.getWorld().getName()))
		return;
	if (powerable.get(clickedBlock.getWorld().getName()).getList(chunk).contains(clickedBlock.getLocation()))
		return;

	// We cancel; send smoke particles for button, and we just turn off the
	// lever (if it was, for some reason, on).
	if (clickedBlock.getType() == Material.STONE_BUTTON || clickedBlock.getType() == Material.WOOD_BUTTON) {

		clickedBlock.getWorld().spawnParticle(Particle.SMOKE_NORMAL, clickedBlock.getLocation().add(0.5, 1, 0.5), 7,
				0, 0.2, 0, 0.03);
		player.sendMessage(MortuusTerraCore.NOTI_PREFIX + ChatColor.RED + " There is no generator in range!");

	} else if (clickedBlock.getType() == Material.LEVER) {
		BlockState state = clickedBlock.getState();
		Lever lever = (Lever) state.getData();

		lever.setPowered(false);
		state.setData(lever);
		state.update();
		clickedBlock.getWorld().spawnParticle(Particle.SMOKE_NORMAL, clickedBlock.getLocation().add(0.5, 1, 0.5), 7,
				0, 0.2, 0, 0.03);
		player.sendMessage(MortuusTerraCore.NOTI_PREFIX + ChatColor.RED + " There is no generator in range!");
	}

}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:39,代码来源:GeneratorListener.java

示例10: onInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onInteract(PlayerInteractEvent event) {
	Game game = Chambers.getInstance().getGameManager().getGame();
	if (!game.hasStarted()) {
		return;
	}
	if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
		return;
	}
	Material material = event.getClickedBlock().getType();
	Location location = event.getClickedBlock().getLocation();
	Profile profile = Chambers.getInstance().getProfileManager().getProfileByUuid(event.getPlayer().getUniqueId());
	if (profile.isBypassMode()) {
		event.setCancelled(false);
		return;
	}
	if (profile.getTeam() == null) {
		event.setCancelled(true);
		return;
	}
	if (material.name().contains("FENCE") || material.name().contains("DOOR") || material.name().contains("CHEST") || material.name().contains("PLATE")) {
		Team team = Chambers.getInstance().getClaimManager().getTeamAt(location);
		if (team.isRaidable()) {
			event.setCancelled(false);
			return;
		}
		if (team != profile.getTeam()) {
			event.setCancelled(true);
			profile.sendMessage(ChatColor.YELLOW + "You cannot do that in the territory of " + team.getFormattedName() + ChatColor.YELLOW + ".");
		}
	}
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:33,代码来源:TeamInteractListener.java

示例11: cloneCraftingWindow

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void cloneCraftingWindow(final PlayerInteractEvent event) {
    if(!AntiGrief.CraftProtect.enabled()) {
        return;
    }

    if(!event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getPlayer().getOpenInventory().getType() == InventoryType.CRAFTING /* nothing open */) {
        Block block = event.getClickedBlock();
        if(block != null && block.getType() == Material.WORKBENCH && !event.getPlayer().isSneaking()) {
            // create the window ourself
            event.setCancelled(true);
            event.getPlayer().openWorkbench(null, true); // doesn't check reachable
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:16,代码来源:CraftingProtect.java

示例12: soilChangePlayer

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void soilChangePlayer(PlayerInteractEvent e) {
      if(e.getClickedBlock() == null) return;
	if ((e.getAction() == Action.PHYSICAL) && (e.getClickedBlock().getType() == Material.SOIL)) {
		KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
		if(p.isVanished()) return;
		if(e.isCancelled()) return;
		if(!p.canBuild(e.getClickedBlock().getLocation())) {
			e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 50));
		} 

	}
	}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:14,代码来源:BuildEventListener.java

示例13: CheckInterackBed

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void CheckInterackBed(PlayerInteractEvent e) {
    if (ConfigPatch.noBedExplore == true) {
        Player p = e.getPlayer();
        Block block = e.getClickedBlock();
        if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if (block.getType() == Material.BED_BLOCK) {
                if (p.getWorld().getEnvironment() == World.Environment.NETHER || p.getWorld().getEnvironment() == World.Environment.THE_END) {
                    e.setCancelled(true);
                    AzureAPI.log(p, ConfigPatch.AntiBedExplodeTipMessage);
                }
            }
        }
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:16,代码来源:AntiBedExplode.java

示例14: onModify

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onModify(PlayerInteractEvent evt) {
    if (!preventSpawnerModify || evt.getItem() == null || evt.getAction() != Action.RIGHT_CLICK_BLOCK) return;
    
    Player player = evt.getPlayer();
    if (Perms.has(player)) return;
    
    if (evt.getClickedBlock().getType() == Material.MOB_SPAWNER) {
        Material type = evt.getItem().getType();
        if (type == Material.MONSTER_EGG || type == Material.MONSTER_EGGS) {
            evt.setCancelled(true);
            AzureAPI.log(player, messagePreventSpawnerModify);
        }
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:16,代码来源:SpawnerController.java

示例15: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
	Gamer g = Gamer.get(event.getPlayer());
	
	if (event.getAction() != Action.PHYSICAL)
		return;
	
	Block b = event.getClickedBlock();
	if (!b.hasMetadata("Mine"))
		return;
	
	Mine mine = Mine.getList().get(b.getMetadata("Mine").get(0).asInt());
	
	Team playerTeam = Nexus.getRotary().getCurrentMap().getTeam(g);
	Team targetTeam = Nexus.getRotary().getCurrentMap().getTeam(mine.getGamer());
	
	if (playerTeam == targetTeam)
		return;
	
	mine.setIgnited(true);
	
	TNTPrimed e = (TNTPrimed) event.getPlayer().getWorld().spawnEntity(event.getPlayer().getEyeLocation(), EntityType.PRIMED_TNT);
	e.setFuseTicks(10);
	e.setYield(2.7F);
	e.setMetadata("Player", new FixedMetadataValue(Nexus.getPlugin(), mine.getGamer().getName()));
	e.setMetadata("Cause", new FixedMetadataValue(Nexus.getPlugin(), CustomDamageCause.TNT_MINE.name()));
	event.getClickedBlock().setType(Material.AIR);
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:29,代码来源:KitEvents.java


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