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