本文整理汇总了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());
}
}
}
示例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());
}
}
示例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
}
}
}
示例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());
}
}
}
示例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);
}
}
示例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:
}
}
}
示例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);
}
}
示例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);
}
}
示例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!");
}
}
示例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 + ".");
}
}
}
示例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
}
}
}
示例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));
}
}
}
示例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);
}
}
}
}
}
示例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);
}
}
}
示例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);
}