本文整理汇总了Java中org.bukkit.event.inventory.InventoryClickEvent.getClick方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryClickEvent.getClick方法的具体用法?Java InventoryClickEvent.getClick怎么用?Java InventoryClickEvent.getClick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.inventory.InventoryClickEvent
的用法示例。
在下文中一共展示了InventoryClickEvent.getClick方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onIdeasClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的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());
}
示例2: __handleInvClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public final void __handleInvClick(InventoryClickEvent e) {
Inventory clickedInventory = e.getClickedInventory();
ClickType clickType = e.getClick();
Player player = (Player) e.getWhoClicked();
ItemStack clicked = e.getCurrentItem();
if (clickedInventory == null)
return;
if (clickedInventory == inventory) {
e.setCancelled(true);
if (clicked != null) {
BiConsumer<Player, ClickType> b;
if ((b = clicks.get(e.getRawSlot())) != null) {
b.accept(player, clickType);
if (updateOnClick && ! destroyed)
update();
}
}
}
}
示例3: onInteract
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInteract(InventoryClickEvent e) {
Player player = (Player) e.getWhoClicked();
if(!ChatColor.stripColor(e.getClickedInventory().getTitle()).equalsIgnoreCase("HCRiots Donator Kits")) {
return;
}
if(e.getInventory().getSize() != 45) {
return;
}
if(e.getClick() != ClickType.LEFT) {
return;
}
if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Titanium Kit")) {
this.giveTitaniumKit(player);
}
}
示例4: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack clicked = event.getCurrentItem();
Inventory inventory = event.getInventory();
if (inventory.getName().equals("Faction Management")) {
if (clicked.getType() == Material.SKULL_ITEM) {
if (event.getClick() == ClickType.LEFT) {
Bukkit.dispatchCommand(player, "f promote " + clicked.getItemMeta().getDisplayName());
event.setCancelled(true);
}
if (event.getClick() == ClickType.MIDDLE){
Bukkit.dispatchCommand(player, "f leader " + clicked.getItemMeta().getDisplayName());
event.setCancelled(true);
}
if (event.getClick() == ClickType.RIGHT) {
Bukkit.dispatchCommand(player, "f demote " + clicked.getItemMeta().getDisplayName());
event.setCancelled(true);
}
}
}
}
示例5: onGroupsClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
private void onGroupsClick(InventoryClickEvent event) {
HumanEntity player = event.getWhoClicked();
ItemStack button = event.getCurrentItem();
event.setCancelled(true);
PageGUI.playSound(event);
IdeaGroup group = IdeaGroup.getByIcon(button);
if (event.getClick() == ClickType.SHIFT_LEFT) {
boolean selected = group.select(faction);
MessageUtil.sendMessage(player, (selected ? FMessage.IDEA_MENU_GROUPS_SELECTED : FMessage.IDEA_MENU_GROUPS_DESELECTED).getMessage(group.getName()));
openGroups(player);
} else {
openIdeas(player, group);
}
}
示例6: convert
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
private InventoryClickEvent convert(InventoryClickEvent event) {
int rawSlot = event.getRawSlot();
int convertedSlot = rawSlot - 9 + (currPage * spaceSize);
return new InventoryClickEvent(
event.getView(), event.getSlotType(), convertedSlot,
event.getClick(), event.getAction(), event.getHotbarButton()
);
}
示例7: GUIClickEvent
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
public GUIClickEvent(InventoryClickEvent delegate, GUI gui) {
super(delegate.getView(), delegate.getSlotType(), delegate.getRawSlot(), delegate.getClick(), delegate.getAction(), delegate.getHotbarButton());
this.delegate = delegate;
this.gui = gui;
this.rawSlot = delegate.getRawSlot();
this.slot = delegate.getSlot();
}
示例8: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent e) {
if (ChatColor.stripColor(e.getInventory().getTitle()).equals("장신구 장착")) {
if (e.getSlotType() != InventoryType.SlotType.OUTSIDE) {
if ((e.getClick() == ClickType.RIGHT) || (e.getClick() == ClickType.LEFT)) {
if ((e.getRawSlot() == 20) || (e.getRawSlot() == 21) || (e.getRawSlot() == 22) || (e.getRawSlot() == 23) || (e.getRawSlot() == 24)) {
} else if (e.getRawSlot() <= e.getInventory().getSize()) {
e.setCancelled(true);
}
} else e.setCancelled(true);
}
}
}
示例9: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
public boolean onClick(VPPlayer clicker, int slot, Long coolDownUntil, MenuLink ml,
InventoryClickEvent event) {
Icon icon = this.getIcon(clicker, slot);
if (icon != null) {
event.setCancelled(!icon.canMove(clicker));
long now = System.currentTimeMillis();
if (coolDownUntil == null || coolDownUntil < now) {
if(icon.closeOnClick())
clicker.getPlayer().closeInventory();
if(icon.onClick(clicker, event.getClick(), ml)){
return true;
}
}
}
if(!event.isCancelled()) {
if(event.getClick() == ClickType.DOUBLE_CLICK || event.getClick() == ClickType.SHIFT_LEFT || event.getClick() == ClickType.SHIFT_RIGHT || event.getClick() == ClickType.NUMBER_KEY) {
ItemStack item = event.getCurrentItem();
if(item != null && item.getType() != Material.AIR && MinecraftUtils.getExtra(item, Icon.FREEZE).equals("1"))
event.setCancelled(true);
else if(event.getClick() == ClickType.NUMBER_KEY){
item = event.getWhoClicked().getInventory().getItem(event.getHotbarButton());
if(item != null && item.getType() != Material.AIR && MinecraftUtils.getExtra(item, Icon.FREEZE).equals("1"))
event.setCancelled(true);
}
}
}
return false;
}
示例10: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
if(event.getInventory().getTitle() != Survival.Words.get("Firestriker"))
return;
final Player player = (Player) event.getWhoClicked();
switch(event.getRawSlot())
{
case 1:
event.setCancelled(true);
player.closeInventory();
break;
case 2:
event.setCancelled(true);
if(event.getClick() == ClickType.LEFT)
{
if(event.getCursor() == null || event.getCursor().getType() == Material.AIR)
{
if(event.getInventory().getItem(2) == null || event.getInventory().getItem(2).getType() == Material.AIR)
{
if(event.getInventory().getItem(1) != null && event.getInventory().getItem(1).getType() == Material.WOOD_SPADE)
{
if(smeltCheck(event.getInventory(), event.getInventory().getItem(0)))
{
event.setCancelled(true);
Random randBurn = new Random();
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ITEM_FLINTANDSTEEL_USE, 1.0F, randBurn.nextFloat() * 0.4F + 0.8F);
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_GENERIC_BURN, 1.0F, randBurn.nextFloat() * 0.4F + 0.8F);
ItemStack i_smelt = event.getInventory().getItem(0);
i_smelt.setAmount(i_smelt.getAmount() - 1);
event.getInventory().setItem(0, i_smelt);
ItemStack i_firecracker = event.getInventory().getItem(1);
i_firecracker.setDurability((short)(i_firecracker.getDurability() + 7));
if(i_firecracker.getDurability() >= 56)
{
Random rand = new Random();
player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
event.getInventory().setItem(1, null);
}
}
}
}
else
{
event.setCursor(event.getInventory().getItem(2));
event.getInventory().setItem(2, null);
}
}
else
event.setCancelled(true);
}
else
event.setCancelled(true);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, new Runnable()
{
public void run()
{
player.updateInventory();
}
}, 1L);
break;
}
}
示例11: onArmorSlotClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
/**
* It happens when player click on armor slot
*/
private void onArmorSlotClick(InventoryClickEvent event, PlayerWrapper playerWrapper, final Slot slot,
ItemStack cursor, ItemStack currentItem) {
final Player player = playerWrapper.getPlayer().getPlayer();
final Inventory inventory = event.getInventory();
final int rawSlot = event.getRawSlot();
InventoryAction action = event.getAction();
ActionType actionType = ActionType.getTypeOfAction(action);
if (InventoryManager.validateArmor(player, action, slot, cursor) && playerWrapper.getInventoryView() != null) {
// Event of equip armor
InventoryClickEvent fakeEvent = new InventoryClickEvent(playerWrapper.getInventoryView(),
InventoryType.SlotType.ARMOR, InventoryUtils.getArmorSlotId(slot), event.getClick(), action);
Bukkit.getPluginManager().callEvent(fakeEvent);
if (fakeEvent.isCancelled()) {
event.setCancelled(true);
return;
}
InventoryManager.updateArmor(player, inventory, slot, rawSlot, action, currentItem, cursor);
if (actionType == ActionType.GET) {
inventory.setItem(rawSlot, slot.getCup());
} else if (slot.isCup(currentItem)) {
player.setItemOnCursor(new ItemStack(Material.AIR));
}
player.updateInventory();
}
if (actionType == ActionType.DROP) {
new BukkitRunnable() {
@Override
public void run() {
inventory.setItem(rawSlot, slot.getCup());
player.updateInventory();
}
}.runTaskLater(RPGInventory.getInstance(), 1);
} else {
event.setCancelled(true);
}
}