本文整理匯總了Java中org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK屬性的典型用法代碼示例。如果您正苦於以下問題:Java Action.RIGHT_CLICK_BLOCK屬性的具體用法?Java Action.RIGHT_CLICK_BLOCK怎麽用?Java Action.RIGHT_CLICK_BLOCK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.bukkit.event.block.Action
的用法示例。
在下文中一共展示了Action.RIGHT_CLICK_BLOCK屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPlayerInteract
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE && player.hasPermission(ProtectionListener.PROTECTION_BYPASS_PERMISSION)) {
return;
}
if (plugin.getEotwHandler().isEndOfTheWorld()) {
return;
}
Block block = event.getClickedBlock();
if (!this.isSubclaimable(block)) {
return;
}
if (!this.checkSubclaimIntegrity(player, block)) {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You do not have access to this subclaimed " + block.getType().toString() + '.');
}
}
示例2: onPlayerInteract
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.useInteractedBlock() == Result.DENY)
return;
//For using a hoe for farming
if (event.getItem() != null &&
event.getItem().getType() != null &&
(event.getMaterial() == Material.DIRT || event.getMaterial() == Material.GRASS) &&
((event.getItem().getType() == Material.WOOD_HOE) ||
(event.getItem().getType() == Material.IRON_HOE) ||
(event.getItem().getType() == Material.GOLD_HOE) ||
(event.getItem().getType() == Material.DIAMOND_HOE)))
{
BlockUpdate.Update(event.getClickedBlock());
}
}
示例3: onUseBackpack
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST)
public void onUseBackpack(PlayerInteractEvent event) {
ItemStack item = event.getItem();
if (!event.hasItem() || !ItemUtils.hasTag(item, ItemUtils.BACKPACK_TAG)) {
return;
}
Player player = event.getPlayer();
Action action = event.getAction();
if ((action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)
&& InventoryManager.isQuickSlot(player.getInventory().getHeldItemSlot())) {
BackpackManager.open(player, item);
}
event.setCancelled(true);
player.updateInventory();
}
示例4: openVoteMenu
@GameEvent
public void openVoteMenu(@Nonnull PlayerInteractEvent event, User user) {
if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && openMenuItem.equals(event.getItem())) {
int pos = 0;
BasicInventory basicInventory = inventoryHandler.createInventory(BasicInventory.class, user, "Vote for a map", availableMaps.size());
for (int id : availableMaps.keySet()) {
MapInfo info = availableMaps.get(id);
ItemStack item = new ItemBuilder(Material.PAPER).amount(id).name(info.getName()).lore(info.getAuthor()).build();
basicInventory.getBukkitInventory().setItem(pos++, item);
basicInventory.addClickAction(item, ((itemStack, inventoryClickEvent) -> {
confirmVote(user, id);
basicInventory.close();
// Destroy the inventory, we don't need it anymore
inventoryHandler.removeInventory(basicInventory.getIdentifier());
}));
}
user.getPlayer().openInventory(basicInventory.getBukkitInventory());
}
}
示例5: onArcherJumpClick
@EventHandler(ignoreCancelled=false, priority=EventPriority.HIGH)
public void onArcherJumpClick(PlayerInteractEvent event)
{
Action action = event.getAction();
if (((action == Action.RIGHT_CLICK_AIR) || (action == Action.RIGHT_CLICK_BLOCK)) &&
(event.hasItem()) && (event.getItem().getType() == Material.FEATHER))
{
if (this.plugin.getPvpClassManager().getEquippedClass(event.getPlayer()) != this) {
return;
}
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
long timestamp = this.archerJumpCooldowns.get(uuid);
long millis = System.currentTimeMillis();
long remaining = timestamp == this.archerJumpCooldowns.getNoEntryValue() ? -1L : timestamp - millis;
if (remaining > 0L)
{
player.sendMessage(ChatColor.RED + "Cannot use Jump Boost for another " + DurationFormatUtils.formatDurationWords(remaining, true, true) + ".");
}
else
{
ItemStack stack = player.getItemInHand();
if (stack.getAmount() == 1) {
player.setItemInHand(new ItemStack(Material.AIR, 1));
} else {
stack.setAmount(stack.getAmount() - 1);
}
player.sendMessage(ChatColor.GREEN + "Jump Boost 4 activated for 7 seconds.");
this.plugin.getEffectRestorer().setRestoreEffect(player, ARCHER_JUMP_EFFECT);
this.archerJumpCooldowns.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + ARCHER_JUMP_COOLDOWN_DELAY);
}
}
}
示例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: onPlayerInteract_equipItem
@EventHandler
public void onPlayerInteract_equipItem(final PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
RScheduler.schedule(plugin, new Runnable() {
public void run() {
PlayerDataRPG pd = plugin.getPD((Player) (event.getPlayer()));
if (pd != null)
pd.updateEquipmentStats();
}
});
}
}
示例8: onMyPetItemUse
@EventHandler
public void onMyPetItemUse(PlayerInteractEvent event) {
if (event.getItem() != null) {
Player player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
Inventory inventory = InventoryManager.get(player).getInventory();
if (isMyPetItem(event.getItem())
&& (event.getAction() == Action.RIGHT_CLICK_BLOCK
|| event.getAction() == Action.RIGHT_CLICK_AIR)) {
Slot petSlot = getMyPetSlot();
ItemStack currentPet = inventory.getItem(petSlot.getSlotId());
boolean hasPet = !petSlot.isCup(currentPet);
ItemStack newPet = event.getItem();
if (!hasPet) {
currentPet = null;
}
player.getEquipment().setItemInMainHand(currentPet);
inventory.setItem(petSlot.getSlotId(), newPet);
swapMyPets(player, hasPet, newPet);
}
}
}
示例9: onItemUse
@EventHandler(priority = EventPriority.HIGHEST)
public void onItemUse(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player) || !event.hasItem()) {
return;
}
if (!ItemManager.allowedForPlayer(player, event.getItem(), true)) {
event.setCancelled(true);
PlayerUtils.updateInventory(player);
return;
}
if (CustomItem.isCustomItem(event.getItem())) {
CustomItem customItem = ItemManager.getCustomItem(event.getItem());
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
customItem.onRightClick(player);
} else {
customItem.onLeftClick(player);
}
if (event.getItem().getType() != Material.BOW) {
event.setCancelled(true);
}
}
ItemManager.updateStats(player);
}
示例10: onInteract
@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: onClickBed
@EventHandler
public void onClickBed(PlayerInteractEvent event)
{
if(event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
Block clicked = event.getClickedBlock();
if(clicked.getType() == Material.BED_BLOCK)
{
event.setCancelled(true);
sleepPlayer(event.getPlayer(), clicked.getX(), clicked.getY(), clicked.getZ());
}
}
}
示例12: onPlayerInteract
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Player player = event.getPlayer();
BlockState state = event.getClickedBlock().getState();
if (state instanceof Skull) {
Skull skull = (Skull) state;
player.sendMessage(ChatColor.YELLOW + "This is " + ChatColor.WHITE
+ (skull.getSkullType() == SkullType.PLAYER && skull.hasOwner() ? skull.getOwner() : "a " + WordUtils.capitalizeFully(skull.getSkullType().name()) + " skull") + ChatColor.YELLOW
+ '.');
}
}
}
示例13: onPlayerInteract
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if ((e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && e.getItem() != null && e.getItem().getType().equals(Material.KNOWLEDGE_BOOK)) {
//e.getPlayer().sendMessage("HE");
e.getPlayer().openInventory(getKnowledgeMain().inv);
e.setCancelled(true);
}
}
示例14: 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);
}
}
示例15: handle
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void handle(PlayerInteractEvent evt) {
if (evt.getAction() != Action.RIGHT_CLICK_BLOCK) return;
Block source = evt.getClickedBlock();
Structure s = match(source);
if (s == null) return;
if (s instanceof ClickableStructure) {
((ClickableStructure) s).run(evt);
}
}