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


Java HumanEntity類代碼示例

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


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

示例1: onClick

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
/**
 * Called when a player clicks on the inventory, the filters to check if the Player clicked on the GUi's inventory should be made outside of this method
 *
 * @param event the click event
 */
public void onClick(InventoryClickEvent event) {
    HumanEntity h = event.getWhoClicked();
    if (!(h instanceof Player))
        return;
    LinkedList<Gui> g = histories.get(h);
    if (g != null && !g.isEmpty()) {
        Gui gui = g.peek();
        GuiClickEvent e = new GuiClickEvent(event, (Player) h, gui);
        Bukkit.getPluginManager().callEvent(e);
        if (e.isCancelled())
            return;

        //Event cancelled BEFORE the method call to permit the un-cancelling
        event.setCancelled(true);
        gui.onClick(event);
        //Creative idiots could copy the links
        if (event.isShiftClick() && event.getWhoClicked().getGameMode() == GameMode.CREATIVE)
            ((Player) event.getWhoClicked()).updateInventory();
    }
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:26,代碼來源:GuiManager.java

示例2: CraftContainer

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
public CraftContainer(final Inventory inventory, final HumanEntity player, int id) {
    this(new InventoryView() {
        @Override
        public Inventory getTopInventory() {
            return inventory;
        }

        @Override
        public Inventory getBottomInventory() {
            return player.getInventory();
        }

        @Override
        public HumanEntity getPlayer() {
            return player;
        }

        @Override
        public InventoryType getType() {
            return inventory.getType();
        }
    }, id);
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:24,代碼來源:CraftContainer.java

示例3: equipWeaponEvent

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void equipWeaponEvent(InventoryDragEvent event) {
	if (Result.DENY.equals(event.getResult())) return;
	HumanEntity human = event.getWhoClicked();
	
	Inventory inv = event.getInventory();
	ItemStack prior = event.getOldCursor();
	StandardGun priorGun = findGun(prior); 
	
	// Don't really care what sort of drag, if we have a gun in inv and this was a gun, deny.
	if (priorGun != null && inv != null && !InventoryType.PLAYER.equals(inv.getType()) && priorGun.isLimitToOne() && priorGun.hasGun(human)) {
		event.setResult(Result.DENY);
		// yes this will prevent drag style of weapon in chest invs. Oh well.
	}
	
}
 
開發者ID:ProgrammerDan,項目名稱:AddGun,代碼行數:17,代碼來源:Guns.java

示例4: equipWeaponEvent

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void equipWeaponEvent(InventoryDragEvent event) {
	if (!enabled) return;
	HumanEntity human = event.getWhoClicked();
	boolean alreadyHasGun = hasGun(human);
	
	Inventory inv = event.getInventory();
	ItemStack prior = event.getOldCursor();
	
	// Don't really care what sort of drag, if we have a gun in inv and this was a gun, deny.
	if (alreadyHasGun && (inv != null && !InventoryType.PLAYER.equals(inv.getType()))
			&& (prior != null && isGun(prior))) {
		event.setResult(Result.DENY);
		// yes this will prevent drag style of weapon in chest invs. Oh well.
	}
	
}
 
開發者ID:ProgrammerDan,項目名稱:AddGun,代碼行數:18,代碼來源:RailGun.java

示例5: onClick

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
@EventHandler
public void onClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    Inventory inventory = event.getClickedInventory();
    if (inventory == null || !gui.getTitle().equals(inventory.getTitle())) {
        return;
    }
    event.setCancelled(true);
    PageGUI.playSound(event);
    ItemStack button = inventory.getItem(event.getSlot());
    if (button == null) {
        return;
    }
    Resource resource = getResource(gui);
    int current = faction.getConsumableResources().get(resource);
    if (button.equals(GUIButton.BACK)) {
        faction.getPopulationMenu().openDemands(player);
        return;
    } else if (button.equals(DENY_BUTTON)) {
        faction.getConsumableResources().put(resource, current - 1);
    } else if (button.equals(GRANT_BUTTON)) {
        faction.getConsumableResources().put(resource, current + 1);
    }
    update(resource);
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:26,代碼來源:SaturationMenu.java

示例6: onClick

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
@EventHandler
public void onClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    Inventory inventory = event.getClickedInventory();
    if (inventory == null || gui == null || !gui.getTitle().equals(inventory.getTitle())) {
        return;
    }
    event.setCancelled(true);
    PageGUI.playSound(event);
    ItemStack button = event.getCurrentItem();
    if (BACK.equals(button)) {
        faction.getPopulationMenu().openDemands(player);
        return;
    }
    Resource resource = Resource.getByIcon(button);
    if (resource != null && faction.isPrivileged(player)) {
        saturationMenu.open(player, resource);
    }
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:20,代碼來源:DemandMenu.java

示例7: onClick

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
@EventHandler
public void onClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    Inventory inventory = event.getClickedInventory();
    if (inventory == null || !gui.getTitle().equals(inventory.getTitle())) {
        return;
    }
    event.setCancelled(true);
    PageGUI.playSound(event);
    ItemStack button = event.getCurrentItem();
    if (INCOME_MANAGEMENT.equals(button)) {
        faction.getTradeMenu().open(player);
    } else if (TRADE_OFFER.equals(button)) {
        plugin.getCommandCache().tradeOffer.onExecute(new String[]{"tradeOffer", faction.getName()}, player);
    } else if (STORAGE.equals(button)) {
        plugin.getCommandCache().storage.onExecute(new String[]{"storage", faction.getName()}, player);
    }
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:19,代碼來源:EconomyMenu.java

示例8: onInvClick

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
@EventHandler
public void onInvClick(InventoryClickEvent event) {
    HumanEntity human = event.getWhoClicked();
    if (human instanceof Player) {
        Player player = (Player) human;
        Inventory inv = event.getView().getTopInventory();
        if (inv.getHolder() != null && inv.getHolder() instanceof InventoryMenu && event.getRawSlot() >= 0 && event.getRawSlot() < size) {
            event.setCancelled(true);
            MenuIcon icon = slots.get(event.getSlot());
            if (icon != null) {
                icon.onClick(player);
                player.closeInventory();
            }
        }
    }
}
 
開發者ID:Borlea,項目名稱:EchoPet,代碼行數:17,代碼來源:InventoryMenu.java

示例9: onClick

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
@EventHandler
public void onClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    Inventory inventory = event.getClickedInventory();
    if (inventory == null || !gui.getTitle().equals(inventory.getTitle())) {
        return;
    }
    event.setCancelled(true);
    PageGUI.playSound(event);
    ItemStack button = inventory.getItem(event.getSlot());
    if (button == null) {
        return;
    }
    int current = faction.getImportValue(resource);
    if (button.equals(BACK)) {
        faction.getTradeMenu().open(player);
        return;
    } else if (button.equals(exportButton)) {
        faction.getGroceryList().put(resource, current - 1);
    } else if (button.equals(importButton)) {
        faction.getGroceryList().put(resource, current + 1);
    }
    update();
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:25,代碼來源:ResourceMenu.java

示例10: onClick

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
@EventHandler
public void onClick(InventoryClickEvent event) {
    ItemStack button = event.getCurrentItem();
    if (button == null || button.getType() == Material.AIR) {
        return;
    }
    Inventory inventory = event.getInventory();
    PageGUI gui = PageGUI.getByInventory(inventory);
    if (gui == null) {
        return;
    }

    event.setCancelled(true);
    PageGUI.playSound(event);
    int index = gui.getPages().indexOf(inventory);
    HumanEntity player = event.getWhoClicked();
    if (button.equals(NEXT_PAGE)) {
        gui.open(player, index + 1);
    } else if (button.equals(PREVIOUS_PAGE)) {
        gui.open(player, index - 1);
    }
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:23,代碼來源:PageGUICache.java

示例11: onIdeasClick

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
private void onIdeasClick(InventoryClickEvent event) {
    event.setCancelled(true);
    PageGUI.playSound(event);
    ItemStack button = event.getCurrentItem();
    if (button == null) {
        return;
    }

    HumanEntity player = event.getWhoClicked();
    if (button.equals(BACK)) {
        openGroups(player);
        return;
    } else if (!faction.isPrivileged(player)) {
        return;
    }

    Idea idea = IdeaGroup.getIdeaByIcon(button);
    if (faction.getIdeaGroups().contains(idea.getGroup()) && !faction.getIdeas().contains(idea) && event.getClick() == ClickType.SHIFT_LEFT) {
        boolean purchased = idea.purchase(faction);
        MessageUtil.sendMessage(player, (purchased ? FMessage.MISC_PURCHASE_SUCCESS : FMessage.MISC_PURCHASE_FAIL).getMessage(idea.getName()));
    }
    openIdeas(player, idea.getGroup());
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:24,代碼來源:IdeaMenu.java

示例12: show

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
/**
 * Shows the menu to the viewers
 *
 * @param viewers Array of {@link HumanEntity}
 * @return the ChatMenuBuilder
 */
@Override
public ChatMenuBuilder show(HumanEntity... viewers) {
	BaseComponent[] components = build();
	for (HumanEntity viewer : viewers) {
		if (viewer instanceof Player) {
			for (BaseComponent component : components) {
				((Player) viewer).spigot().sendMessage(component);
			}
			if (!this.viewers.contains(viewer)) {
				this.viewers.add(viewer);
			}
		}
	}
	return this;
}
 
開發者ID:InventivetalentDev,項目名稱:MenuBuilder,代碼行數:22,代碼來源:ChatMenuBuilder.java

示例13: onInventoryOpen

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onInventoryOpen(InventoryOpenEvent event) {
    Inventory inventory = event.getInventory();
    HumanEntity player = event.getPlayer();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (InventoryAPI.isRPGInventory(inventory)) {
        PlayerWrapper playerWrapper = (PlayerWrapper) inventory.getHolder();
        InventoryManager.syncQuickSlots(playerWrapper);
        InventoryManager.syncInfoSlots(playerWrapper);
        InventoryManager.syncShieldSlot(playerWrapper);
        InventoryManager.syncArmor(playerWrapper);
    }
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:18,代碼來源:InventoryListener.java

示例14: onInventoryDrag

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onInventoryDrag(InventoryDragEvent event) {
    HumanEntity humanEntity = event.getWhoClicked();
    if (humanEntity instanceof Player) {
        Player player = (Player) humanEntity;
        PearlNameFaker pearlNameFaker = itemNameFakes.get(player.getUniqueId());
        if (pearlNameFaker == null)
            return;
        for (Map.Entry<Integer, ItemStack> entry : event.getNewItems().entrySet()) {
            if (entry.getKey() == player.getInventory().getHeldItemSlot()) {
                pearlNameFaker.setFakeItem(CraftItemStack.asNMSCopy(player.getItemInHand()), player.getInventory().getHeldItemSlot());
                break;
            }
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:17,代碼來源:EnderPearlTimer.java

示例15: onInventoryClick

import org.bukkit.entity.HumanEntity; //導入依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onInventoryClick(InventoryClickEvent event) {
    HumanEntity humanEntity = event.getWhoClicked();
    if (humanEntity instanceof Player) {
        Player player = (Player) humanEntity;
        PearlNameFaker pearlNameFaker = itemNameFakes.get(player.getUniqueId());
        if (pearlNameFaker == null)
            return;

        // Required to prevent ghost items.
        int heldSlot = player.getInventory().getHeldItemSlot();
        if (event.getSlot() == heldSlot) {
            pearlNameFaker.setFakeItem(CraftItemStack.asNMSCopy(player.getItemInHand()), heldSlot);
        } else if (event.getHotbarButton() == heldSlot) {
            pearlNameFaker.setFakeItem(CraftItemStack.asNMSCopy(event.getCurrentItem()), event.getSlot());
            new BukkitRunnable() {
                @Override
                public void run() {
                    player.updateInventory();
                }
            }.runTask(plugin);
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:25,代碼來源:EnderPearlTimer.java


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