本文整理汇总了Java中org.bukkit.event.inventory.InventoryClickEvent类的典型用法代码示例。如果您正苦于以下问题:Java InventoryClickEvent类的具体用法?Java InventoryClickEvent怎么用?Java InventoryClickEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InventoryClickEvent类属于org.bukkit.event.inventory包,在下文中一共展示了InventoryClickEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@Override
protected void onClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
int rawSlot = event.getRawSlot();
boolean isFrame = isFrame(rawSlot);
if (isFrame) {
event.setCancelled(true);
}
if (rawSlot == prevPageBtnIndex) {
prevPage(player);
} else if (rawSlot == nextPageBtnIndex) {
nextPage(player);
} else if (!isFrame) {
InventoryClickEvent converted = convert(event);
getHandlers().notify(converted);
event.setCancelled(converted.isCancelled());
return;
}
open(event.getWhoClicked());
}
示例2: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent e) {
guiMap.getOptional(e.getWhoClicked()).ifPresent(gui -> {
InventoryAction action = e.getAction();
Inventory inv = e.getInventory();
if (action == InventoryAction.COLLECT_TO_CURSOR) {
for (ItemStack item : inv) {
if (e.getCursor().isSimilar(item)) {
e.setCancelled(true);
break;
}
}
}
gui.getHandlers().notify(e);
});
}
示例3: onInventoryClick2
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryClick2(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack is = event.getCurrentItem();
if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Here Menu - Page 1")) {
event.setCancelled(true);
for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {
Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
Location location = player.getLocation();
if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.YELLOW + " to you."))) {
player.closeInventory();
targetPlayer.teleport(player);
player.sendMessage(ChatColor.YELLOW + "You've teleported " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + " to you!");
player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
player.playEffect(location, Effect.ENDER_SIGNAL, 1);
targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
}
}
}
}
}
示例4: onInventoryClick1
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryClick1(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
ItemStack is = event.getCurrentItem();
if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Menu - Page 1")) {
event.setCancelled(true);
for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {
Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
Location location = player.getLocation();
if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport to " + ChatColor.GREEN + targetPlayer.getName()))) {
player.closeInventory();
player.teleport(targetPlayer);
player.sendMessage(ChatColor.YELLOW + "You've teleported to " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + "!");
player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
player.playEffect(location, Effect.ENDER_SIGNAL, 1);
targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
}
}
}
}
}
示例5: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
/**
* Event fired when a player clicks in the team selection GUI
*
* @param event Event
*/
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
if (this.game.getStatus().equals(Status.IN_GAME))
{
event.getHandlers().unregister(this);
}
else if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null && event.getView().getType() != InventoryType.PLAYER)
{
AbstractGui gui = this.playersGui.get(event.getWhoClicked().getUniqueId());
if (gui != null)
{
String action = gui.getAction(event.getSlot());
if (action != null)
gui.onClick((Player) event.getWhoClicked(), event.getCurrentItem(), action, event.getClick());
event.setCancelled(true);
}
}
}
示例6: onInventoryMove
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryMove(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player)) {
return;
}
Player player = (Player) event.getWhoClicked();
PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);
if (profile.getStatus() == PlayerStatus.EDITING_KITS || profile.getStatus() == PlayerStatus.PLAYING) {
return;
}
if ((player.hasPermission("practice.admin") || player.isOp()) && player.getGameMode() == GameMode.CREATIVE) {
return;
}
event.setCancelled(true);
}
示例7: call
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@Override
public void call(Event event) {
if (event instanceof InventoryClickEvent) {
final InventoryClickEvent ice = (InventoryClickEvent) event;
if (ice.getCurrentItem().getType() == Material.BOWL) {
final int slot = ice.getSlot();
if (!slotsChosen.containsKey(slot)) {
slotsChosen.put(slot, 1);
} else {
slotsChosen.put(slot, slotsChosen.get(slot) + 1);
}
if (getStackChance() >= 100.0) {
callback(true);
}
}
}
}
示例8: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的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();
}
}
示例9: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@Override
public void onClick(InventoryClickEvent event) {
if (buffer == null)
throw new IllegalStateException("Cannot click a non-existant inventory");
int slot = event.getSlot();
if (slot < 0)
return;
int footerStart = buffer.getSize() - footer.size() - 1;
Icon clicked;
if(slot > footerStart) {
clicked = footer.get(slot - footerStart - 1);
} else if(slot < buffer.getSize()) {
clicked = icons.get(slot);
} else return;
if (clicked != null)
clicked.getClick().run((Player) event.getWhoClicked());
}
示例10: onClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@Override
public void onClick(InventoryClickEvent event) {
int slot = event.getSlot();
if(slot < 0)
return;
Player clicker = (Player) event.getWhoClicked();
int page = pageRegistry.getOrDefault(clicker, 0);
Icon clicked = getIcon(page, slot);
if(clicked != null)
clicked.getClick().run(clicker);
}
示例11: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
DankMenu menu = DankMenu.getByPlayer(player);
if (menu == null) {
return;
}
event.setCancelled(true);
if (event.getClickedInventory() != null && event.getClickedInventory().getTitle().equals(menu.getInventory().getTitle())) {
menu.onClickItem(event.getCurrentItem(), event.isRightClick());
if (menu.getPlayer() != null && menu.getInventory() != null) {
menu.updateInventory();
}
}
}
示例12: onInventoryClick
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
/**
* Disable putting items in inventory
*
* @param event Click event instance
*/
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
if (event.getClickedInventory() == null || !event.getClickedInventory().equals(this.inventory))
return;
switch (event.getAction())
{
case PICKUP_ALL:
case PICKUP_HALF:
case PICKUP_ONE:
case PICKUP_SOME:
event.setCancelled(false);
break;
default:
event.setCancelled(true);
break;
}
}
示例13: click
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
/**
* On a player click on an item call InventoryBase.
*
* @param e The bukkit event.
*/
private boolean click(InventoryClickEvent e) {
for (InventoryBase inv : InventoryBase.getInventories()) {
//Filter items
if (!inv.getItems().containsKey(e.getSlot()) || !inv.getItems().containsValue(e.getCurrentItem()))
continue;
//Setup methods
if (e.isLeftClick())
inv.onLeftClick((Player) e.getWhoClicked(), e.getCurrentItem());
else
inv.onRightClick((Player) e.getWhoClicked(), e.getCurrentItem());
return inv.isCancelled();
}
return false;
}
示例14: 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);
}
}
示例15: onMove
import org.bukkit.event.inventory.InventoryClickEvent; //导入依赖的package包/类
@EventHandler
public void onMove(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Move.Disable")) {
if (!ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Move.World.All_World")) {
if (WorldUtils.getWMoveItem().contains(p.getWorld().getName())) {
if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Move.Bypass")) {
if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.moveitem")) {
e.setCancelled(true);
}
} else {
e.setCancelled(true);
}
}
} else {
if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Move.Bypass")) {
if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.moveitem")) {
e.setCancelled(true);
}
} else {
e.setCancelled(true);
}
}
}
}