當前位置: 首頁>>代碼示例>>Java>>正文


Java Action類代碼示例

本文整理匯總了Java中org.bukkit.event.block.Action的典型用法代碼示例。如果您正苦於以下問題:Java Action類的具體用法?Java Action怎麽用?Java Action使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Action類屬於org.bukkit.event.block包,在下文中一共展示了Action類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerInteract

import org.bukkit.event.block.Action; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent e) {
	if (!cm.isDisableChangeSpawnerType) {
		return;
	}
	if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
		if (e.getClickedBlock().getType() == Material.MOB_SPAWNER) {
			if (e.getItem() == null) {
				return;
			}
			if (e.getPlayer().isOp()) {
				return;
			}
			if (e.getItem().getType() == Material.MONSTER_EGG || e.getItem().getType() == Material.MONSTER_EGGS) {
				e.setCancelled(true);
			}
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:20,代碼來源:AntiUseEggsChangeSpawnerType.java

示例2: onWalkieTalkieInteract

import org.bukkit.event.block.Action; //導入依賴的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

示例3: handleInteract

import org.bukkit.event.block.Action; //導入依賴的package包/類
@EventHandler
public void handleInteract(PlayerInteractEvent e)
{
    if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && (e.getClickedBlock().getType().equals(Material.SIGN_POST) || e.getClickedBlock().getType().equals(Material.WALL_SIGN)))
    {
        if (containsPosition(e.getClickedBlock().getLocation()))
        {
            Sign sign = getSignByPosition(e.getClickedBlock().getLocation());
            if (sign.getServerInfo() != null)
            {
                String s = sign.getServerInfo().getServiceId().getServerId();
                ByteArrayDataOutput output = ByteStreams.newDataOutput();
                output.writeUTF("Connect");
                output.writeUTF(s);
                e.getPlayer().sendPluginMessage(CloudServer.getInstance().getPlugin(), "BungeeCord", output.toByteArray());
            }
        }
    }
}
 
開發者ID:Dytanic,項目名稱:CloudNet,代碼行數:20,代碼來源:SignSelector.java

示例4: onPlayerInteract

import org.bukkit.event.block.Action; //導入依賴的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

示例5: onPlayerInteract

import org.bukkit.event.block.Action; //導入依賴的package包/類
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    Player p = event.getPlayer();
    ItemStack item = event.getPlayer().getEquipment().getItemInMainHand();
    if (event.getHand() == EquipmentSlot.HAND && item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
        String name = item.getItemMeta().getDisplayName();
        if (itemNameToIdentifierMap.containsKey(name)) {
            String identifier = itemNameToIdentifierMap.get(name);
            if (itemIdentifierToRunnableMap.containsKey(identifier)) {
                PlayerDataRPG pd = plugin.getPD(p);
                if (pd != null)
                    itemIdentifierToRunnableMap.get(identifier).run(event, p, pd);
                event.setCancelled(true);
            }
        }
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:18,代碼來源:ItemManager.java

示例6: healWithPotion

import org.bukkit.event.block.Action; //導入依賴的package包/類
public static void healWithPotion(int amount, String name, Event event, Player p) {
    if (!(event instanceof PlayerInteractEvent))
        return;
    PlayerInteractEvent e = (PlayerInteractEvent) event;
    if (!(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK))
        return;
    if (lastHealItem.containsKey(p.getName()) && System.currentTimeMillis() - lastHealItem.get(p.getName()) < 500) {
        return;
    }
    lastHealItem.put(p.getName(), System.currentTimeMillis());
    p.getEquipment().setItemInMainHand(new ItemStack(Material.AIR));
    PlayerDataRPG pd = plugin.getPD(p);
    pd.heal(amount, HealType.POTION);
    for (int k = 0; k < p.getInventory().getContents().length; k++) {
        if (ItemManager.isItem(p.getInventory().getItem(k), name)) {
            p.getEquipment().setItemInMainHand(p.getInventory().getItem(k));
            p.getInventory().setItem(k, new ItemStack(Material.AIR));
            break;
        }
    }
    RSound.playSound(p, Sound.ENTITY_GENERIC_DRINK);
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:23,代碼來源:EtcItem.java

示例7: onEnderChestEvent

import org.bukkit.event.block.Action; //導入依賴的package包/類
/**
 * Prevents usage of an Ender Chest
 *
 * @param event
 */

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEnderChestEvent(PlayerInteractEvent event) {
    if (DEBUG) {
        plugin.getLogger().info("Ender chest " + event.getEventName());
    }
    Player player = (Player) event.getPlayer();
    if (Util.inWorld(player) || player.getWorld().equals(IslandWorld.getNetherWorld())) {
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if (event.getClickedBlock().getType() == Material.ENDER_CHEST) {
                if (!(event.getPlayer().hasPermission(Settings.PERMPREFIX + "craft.enderchest"))) {
                    Util.sendMessage(player, plugin.getLocale(player.getUniqueId()).get("general.errors.no-permission"));
                    event.setCancelled(true);
                }
            }
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:24,代碼來源:IslandGuard.java

示例8: onPlayerInteract

import org.bukkit.event.block.Action; //導入依賴的package包/類
@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() + '.');
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:25,代碼來源:SignSubclaimListener.java

示例9: onPlayerInteract

import org.bukkit.event.block.Action; //導入依賴的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

示例10: openVoteMenu

import org.bukkit.event.block.Action; //導入依賴的package包/類
@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());
    }
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLibv2,代碼行數:21,代碼來源:VoteFeature.java

示例11: grenadeEvent

import org.bukkit.event.block.Action; //導入依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler
public void grenadeEvent(PlayerInteractEvent e){
	final Player p = e.getPlayer();
	if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
		if(p.getItemInHand().hasItemMeta()){
			if(p.getItemInHand().getItemMeta().getLore() == null) return;
			if(p.getItemInHand().getItemMeta().getLore().contains(ChatColor.GRAY + "Grenade I")){
				p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() - 4));
				final Item grenade = p.getWorld().dropItem(p.getEyeLocation(), new ItemStack(Material.CLAY_BALL));
				grenade.setVelocity(p.getEyeLocation().getDirection().normalize().multiply(0.8D));
				Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
					public void run(){
						p.getWorld().createExplosion(grenade.getLocation().getX(), grenade.getLocation().getY(), 
								grenade.getLocation().getZ(), 3, false, false);
						grenade.remove();
					}
				},30L);
			}
		}
	}
}
 
開發者ID:OverloadedCore,項目名稱:chaoticWeapons,代碼行數:23,代碼來源:Core.java

示例12: playerInteract

import org.bukkit.event.block.Action; //導入依賴的package包/類
@EventHandler
public void playerInteract(final PlayerInteractEvent event) {
    if(event.getAction() == Action.PHYSICAL
            || !(Gizmos.gizmoMap.get(event.getPlayer()) instanceof GunGizmo)
            || event.getItem() == null || event.getItem().getType() != this.getIcon()) return;

    final Player player = event.getPlayer();
    RaindropUtil.giveRaindrops(Users.playerId(player), -1, new RaindropResult() {
        @Override
        public void run() {
            if(success) {
                Vector velocity = player.getLocation().getDirection().multiply(1.75D);

                Item item = player.getWorld().dropItem(event.getPlayer().getEyeLocation(), new ItemStack(Material.GHAST_TEAR));
                item.setVelocity(velocity);
                item.setTicksLived((5 * 60 * 20) - (5 * 20)); // 5 minutes - 5 seconds
                items.put(item, player.getUniqueId());
            } else {
                player.sendMessage(ChatColor.RED + LobbyTranslations.get().t("gizmo.gun.empty", player));
                player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 1f, 1f);
            }
        }
    }, null, false, true, false);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:25,代碼來源:GunGizmo.java

示例13: onQuickEquip

import org.bukkit.event.block.Action; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onQuickEquip(PlayerInteractEvent event) {
    final Player player = event.getPlayer();
    if (!InventoryManager.playerIsLoaded(player) || event.getAction() != Action.RIGHT_CLICK_AIR &&
            event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK &&
            !event.getClickedBlock().getState().getClass().getSimpleName().contains("BlockState")) {
        return;
    }

    ItemStack item = event.getItem();
    if (ItemUtils.isEmpty(item)) {
        return;
    }

    ArmorType armorType = ArmorType.matchType(item);
    if (InventoryUtils.playerNeedArmor(player, armorType)) {
        Slot armorSlot = SlotManager.instance().getSlot(armorType.name());
        if (armorSlot == null) {
            return;
        }

        event.setCancelled(!InventoryManager.validateArmor(player, InventoryAction.PLACE_ONE, armorSlot, item));

        PlayerUtils.updateInventory(player);
    }
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:27,代碼來源:ArmorEquipListener.java

示例14: onClick

import org.bukkit.event.block.Action; //導入依賴的package包/類
@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();
	}
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:27,代碼來源:EmpireWandInteractEventListener.java

示例15: onUseBackpack

import org.bukkit.event.block.Action; //導入依賴的package包/類
@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();
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:19,代碼來源:BackpackListener.java


注:本文中的org.bukkit.event.block.Action類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。