本文整理匯總了Java中org.bukkit.event.block.Action.LEFT_CLICK_BLOCK屬性的典型用法代碼示例。如果您正苦於以下問題:Java Action.LEFT_CLICK_BLOCK屬性的具體用法?Java Action.LEFT_CLICK_BLOCK怎麽用?Java Action.LEFT_CLICK_BLOCK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.bukkit.event.block.Action
的用法示例。
在下文中一共展示了Action.LEFT_CLICK_BLOCK屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onWalkieTalkieInteract
@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());
}
}
}
示例2: onPlayerInteract
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK && event.hasItem()) {
// The player didn't click an enchantment table, Creative players will instantly destroy.
Player player = event.getPlayer();
if (event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && player.getGameMode() != GameMode.CREATIVE) {
// The player didn't click with an enchanted book.
ItemStack stack = event.getItem();
if (stack != null && stack.getType() == Material.ENCHANTED_BOOK) {
ItemMeta meta = stack.getItemMeta();
if (meta instanceof EnchantmentStorageMeta) {
EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) meta;
for (Enchantment enchantment : enchantmentStorageMeta.getStoredEnchants().keySet()) {
enchantmentStorageMeta.removeStoredEnchant(enchantment);
}
event.setCancelled(true);
player.setItemInHand(EMPTY_BOOK);
player.sendMessage(ChatColor.GREEN + "You reverted this item to its original form.");
}
}
}
}
}
示例3: onClick
@SuppressWarnings("deprecation")
@EventHandler
public void onClick(PlayerInteractEvent e) {
if(e.getAction() == Action.PHYSICAL) return;
KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
if(p.getPlayer().getInventory() == null) return;
if(p.getPlayer().getItemInHand() == null) return;
if(p.getPlayer().getItemInHand().getType() != Material.BLAZE_ROD) return;
if(!p.getPlayer().getItemInHand().hasItemMeta()) return;
if(!p.getPlayer().getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.RED + "Empire Wand")) return;
e.setCancelled(true);
if(e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
if(p.hasCooldown(CooldownType.WAND)) {
p.sendMessage(ChatColor.GOLD + "[" + ChatColor.GRAY + "X" + ChatColor.GOLD + "] "
+ "Je moet nog " + ChatColor.GRAY + p.getCooldown(CooldownType.WAND).getCooldown() + " seconde(n)" + ChatColor.GOLD + " wachten!");
return;
}
if(p.getSpell() == null) {
p.setSpell(SpellModule.getInstance().getSpell("Spark"));
}
p.getSpell().execute(p);
p.addCooldown(new Cooldown(CooldownType.WAND, p, 60));
} else if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
p.rotateSpells();
}
}
示例4: getDatas
@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());
}
}
示例5: onPlayerInteract
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if (e != null && e.getPlayer() != null && e.getClickedBlock() != null) {
if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
return;
}
if (e.getAction() == Action.LEFT_CLICK_AIR) {
return;
}
if (e.getAction() == Action.RIGHT_CLICK_AIR) {
return;
}
ChunkHelper.cancelEventIfNotOwned(e.getPlayer(), e.getClickedBlock().getChunk(), e);
}
}
示例6: onCellPhoneInteract
@EventHandler
public void onCellPhoneInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (p.getInventory().getItemInMainHand().getType() != Material.WATCH)
return;
e.setCancelled(true);
CellularPhone phone = new CellularPhone(main);
// Left click for recipient toggle
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
if (p.isSneaking()) {
phone.getNextContact(p);
} else {
phone.getPreviousContact(p);
}
}
// Right click for text messages
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (p.isSneaking()) {
phone.checkTextMessages(p);
} else {
phone.deleteTextMessage(p);
}
}
}
示例7: onInteract
@EventHandler
public void onInteract(final PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) return;
ItemStack item = event.getItem();
if (item instanceof PlayerheadItemStack) {
event.setCancelled(true);
Player player = event.getPlayer();
//Use the item
if (item.getAmount() > 1) item.setAmount(item.getAmount() - 1);
else player.getInventory().remove(item);
MainConfiguration config = UHC.getInstance().getMainConfig();
//Give effects & crap
PlayerheadItemStack playerhead = (PlayerheadItemStack) item;
boolean golden = playerhead.isGolden();
player.sendMessage(colour("&aYou ate " + playerhead.getFrom() + "'s playerhead!"));
int regenDuration = golden ? config.getGoldenHeadRegenerationDuration() : config.getHeadRegenerationDuration();
int regenAmpf = golden ? config.getGoldenHeadRegenerationAmplifier() : config.getHeadRegenerationAmplifier();
int absorpDuration = golden ? config.getGoldenHeadAbsorptionDuration() : config.getHeadAbsorptionDuration();
int absorpAmpf = golden ? config.getGoldenHeadAbsorptionAmplifier() : config.getHeadAbsorptionAmplifier();
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, regenDuration, regenAmpf, false, true));
player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, absorpDuration, absorpAmpf, false, true));
}
}
示例8: onSpellClicks
@EventHandler
public void onSpellClicks(PlayerInteractEvent event) {
Player p = event.getPlayer();
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
click(p, true);
else if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
click(p, false);
}
示例9: onPlayerInteract
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if(e.getPlayer().getGameMode() != GameMode.CREATIVE)
e.setCancelled(true);
GamePlayer player = Absorption.getPlayer(e.getPlayer());
if(player == null) return;
if(e.getPlayer().getItemInHand().getType() == Material.AIR) return;
if(player.getState() == PlayerState.WAITING) {
} else if(player.getState() == PlayerState.PLAYING) {
int slot = e.getPlayer().getInventory().getHeldItemSlot();
if(e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
if(slot == 0) {
player.getKit().onLeftClick(player);
} else if(slot == 1) {
player.getKit().getSecondaryWeapon().onLeftClick(player);
} else if(slot == 2) {
player.getKit().getSpecialWeapon().onLeftClick(player);
}
} else if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(slot == 0) {
player.getKit().onRightClick(player);
} else if(slot == 1) {
player.getKit().getSecondaryWeapon().onRightClick(player);
} else if(slot == 2) {
player.getKit().getSpecialWeapon().onRightClick(player);
}
}
} else if(player.getState() == PlayerState.RESPAWNING) {
} else if(player.getState() == PlayerState.END) {
// Nothing
}
}
示例10: onInteract
@EventHandler
public void onInteract(PlayerInteractEvent e){
Player p = e.getPlayer();
Weapon weapon;
if (e.getItem() == null || e.getHand() != EquipmentSlot.HAND) return;
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
if (e.getItem().getType() == Material.POTION) return;
if (e.getItem() == null || Weapon.getWeaponByItemStack(e.getItem()) == null || !Weapon.isWeapon(e.getItem())) return;
weapon = Weapon.getWeaponByItemStack(e.getItem());
if (weapon != null) e.setCancelled(true);
if (weapon == null) return;
weapon.shoot(p);
return;
}
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK){
if (e.getItem() == null || Weapon.getWeaponByItemStack(e.getItem()) == null || !Weapon.isWeapon(e.getItem())) return;
weapon = Weapon.getWeaponByItemStack(e.getItem());
if (weapon != null) e.setCancelled(true);
if (weapon == null) return;
if (weapon.getId() == 0) return;
weapon.watch(p);
}
}
示例11: isValidProjectileAction
private static boolean isValidProjectileAction(Action action, ClickAction clickAction) {
switch(clickAction) {
case RIGHT:
return action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK;
case LEFT:
return action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK;
case BOTH:
return action != Action.PHYSICAL;
}
return false;
}
示例12: onUse
@EventHandler
public void onUse(PlayerInteractEvent e) {
try {
if (e.getAction() != Action.LEFT_CLICK_BLOCK) {
return;
}
if (e.getItem() == null) return;
if (!e.getItem().hasItemMeta()) return;
if (!e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase(WreckingBallModule.WRECKINGBALL_NAME))
return;
if (e.isCancelled()) return;
KingdomFactionsPlayer player = PlayerModule.getInstance().getPlayer(e.getPlayer());
if (player.isVanished()) return;
if (!player.isStaff()) {
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), null);
player.sendMessage(Messages.getInstance().getPrefix() + "Het is voor jou niet toegestaan om dit item te gebruiken");
return;
}
if (e.getClickedBlock() == null) return;
if (e.isCancelled()) return;
BlockWreckedEvent ev = new BlockWreckedEvent(e.getClickedBlock(), player.getPlayer());
Bukkit.getPluginManager().callEvent(ev);
e.getClickedBlock().breakNaturally();
} catch (NullPointerException npe) {
//bad practise!
}
}
示例13: onPlayerInteract
@EventHandler
@SuppressWarnings("unused")
public void onPlayerInteract(PlayerInteractEvent e) {
Player player = e.getPlayer();
Action action = e.getAction();
if(action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) {
if(DynamicAC.instance.cpsChecking.containsKey(player)) {
DynamicAC.instance.cpsChecking.get(player).incrementAndGet();
}
}
}
示例14: onPlayerInteract
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
return;
Player p = event.getPlayer();
Gamer g = Gamer.get(p);
Block b = event.getClickedBlock();
for (Course c : Course.getList()) {
Block test1 = c.getButton();
Block test2 = c.getEnd();
if (test1 != null && test1.getX() == b.getX() && test1.getY() == b.getY() && test1.getZ() == b.getZ()) {
g.setVariable("parkour", c);
p.teleport(c.getStart());
return;
}
if (test2 != null && test2.getX() == b.getX() && test2.getY() == b.getY() && test2.getZ() == b.getZ()) {
Chat.server(Gamer.get(p.getName()).getRank().getPrefix() + p.getDisplayName() + " &ejust beat &2&l" + c.getTitle() + "");
if (c.getNextCourse() != null) {
Course next = Course.get(c.getNextCourse());
if (next != null) {
g.setVariable("parkour", next);
p.teleport(next.getStart());
return;
}
}
p.teleport(c.getStart());
return;
}
}
}
示例15: clickable
@EventHandler(priority = EventPriority.HIGHEST)
public void clickable(PlayerInteractEvent evt) {
Action act = evt.getAction();
if ((evt.isCancelled() && act != Action.LEFT_CLICK_AIR && act != Action.LEFT_CLICK_AIR) || evt.isAsynchronous()) return;
ItemStack stack = evt.getItem();
if (stack == null) return;
ItemMeta meta = stack.getItemMeta();
if (!meta.hasLore()) return;
for (String lore : meta.getLore()) {
Item item = ItemFactory.items.get(lore);
if (item instanceof ClickableItem) {
if (item instanceof LeftClickOnly) {
if (act == Action.LEFT_CLICK_BLOCK || act == Action.LEFT_CLICK_AIR) {
((ClickableItem) item).run(evt);
}
continue;
}
if (item instanceof RightClickOnly) {
if (act == Action.RIGHT_CLICK_BLOCK || act == Action.RIGHT_CLICK_AIR) {
((ClickableItem) item).run(evt);
}
continue;
}
// common type
((ClickableItem) item).run(evt);
}
}
}