本文整理汇总了Java中org.bukkit.event.inventory.ClickType类的典型用法代码示例。如果您正苦于以下问题:Java ClickType类的具体用法?Java ClickType怎么用?Java ClickType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClickType类属于org.bukkit.event.inventory包,在下文中一共展示了ClickType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: __handleInvClick
import org.bukkit.event.inventory.ClickType; //导入依赖的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();
}
}
}
}
示例2: onInteract
import org.bukkit.event.inventory.ClickType; //导入依赖的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);
}
}
示例3: onInventoryClick
import org.bukkit.event.inventory.ClickType; //导入依赖的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);
}
}
}
}
示例4: onInteract
import org.bukkit.event.inventory.ClickType; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(final PlayerInteractEvent event) {
if(cancelUnlessInteracting(event, event.getPlayer())) {
// Allow the how-to book to be read
if(event.getMaterial() == Material.WRITTEN_BOOK) {
event.setUseItemInHand(Event.Result.ALLOW);
} else {
event.setUseItemInHand(Event.Result.DENY);
event.setUseInteractedBlock(Event.Result.DENY);
}
MatchPlayer player = getMatch().getPlayer(event.getPlayer());
if(player == null) return;
if(!player.isSpawned()) {
ClickType clickType = convertClick(event.getAction(), event.getPlayer());
if(clickType == null) return;
getMatch().callEvent(new ObserverInteractEvent(player, clickType, event.getClickedBlock(), null, event.getItem()));
}
// Right-clicking armor will put it on unless we do this
event.getPlayer().updateInventory();
}
}
示例5: rightClickIcon
import org.bukkit.event.inventory.ClickType; //导入依赖的package包/类
@EventHandler
public void rightClickIcon(final ObserverInteractEvent event) {
if(event.getClickType() != ClickType.RIGHT) return;
MatchPlayer player = event.getPlayer();
if(!canUse(player)) return;
ItemStack hand = event.getClickedItem();
if(ItemUtils.isNothing(hand)) return;
String displayName = hand.getItemMeta().getDisplayName();
if(displayName == null) return;
if(hand.getType() == Button.JOIN.material) {
event.setCancelled(true);
if(canOpenWindow(player)) {
showWindow(player);
} else {
// If there is nothing to pick, just join immediately
jmm.requestJoin(player, JoinRequest.user());
}
} else if(hand.getType() == Button.LEAVE.material) {
event.setCancelled(true);
jmm.requestObserve(player);
}
}
示例6: showInventories
import org.bukkit.event.inventory.ClickType; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void showInventories(final ObserverInteractEvent event) {
if(event.getClickType() != ClickType.RIGHT) return;
if(event.getPlayer().isDead()) return;
if(event.getClickedParticipant() != null) {
event.setCancelled(true);
if(canPreviewInventory(event.getPlayer(), event.getClickedParticipant())) {
this.previewPlayerInventory(event.getPlayer().getBukkit(), event.getClickedParticipant().getInventory());
}
} else if(event.getClickedEntity() instanceof InventoryHolder && !(event.getClickedEntity() instanceof Player)) {
event.setCancelled(true);
this.previewInventory(event.getPlayer().getBukkit(), ((InventoryHolder) event.getClickedEntity()).getInventory());
} else if(event.getClickedBlockState() instanceof InventoryHolder) {
event.setCancelled(true);
this.previewInventory(event.getPlayer().getBukkit(), ((InventoryHolder) event.getClickedBlockState()).getInventory());
}
}
示例7: onInteract
import org.bukkit.event.inventory.ClickType; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onInteract(PlayerInteractEvent event) {
if(!event.hasItem()) return;
final ClickType click;
switch(event.getAction()) {
case LEFT_CLICK_AIR:
case LEFT_CLICK_BLOCK:
click = ClickType.LEFT;
break;
case RIGHT_CLICK_AIR:
case RIGHT_CLICK_BLOCK:
click = ClickType.RIGHT;
break;
default:
return;
}
if(onButtonClick(event.getItem(), event.getActor(), click, event)) {
event.setUseItemInHand(Event.Result.DENY);
event.setUseInteractedBlock(Event.Result.DENY);
}
}
示例8: onClick
import org.bukkit.event.inventory.ClickType; //导入依赖的package包/类
@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
if (action.equals("craft"))
{
if (SamaGamesAPI.get().getPlayerManager().getPlayerData(player.getUniqueId()).getPowders() >= 64)
{
this.hub.getGuiManager().openGui(player, new GuiWellCraft(this.hub, this.parent));
}
else
{
player.sendMessage(Well.TAG + ChatColor.RED + "Vous n'avez pas assez de poussières d'\u272F !");
}
}
else if (action.equals("back"))
{
this.hub.getGuiManager().closeGui(player);
this.parent.stop(player);
}
}
示例9: enableCosmetic
import org.bukkit.event.inventory.ClickType; //导入依赖的package包/类
@Override
public void enableCosmetic(Player player, JukeboxDiskCosmetic cosmetic, ClickType clickType, boolean login)
{
if (cosmetic.isOwned(player))
{
if (cosmetic.getAccessibility().canAccess(player))
{
this.play(cosmetic, player);
AbstractGui gui = (AbstractGui) this.hub.getGuiManager().getPlayerGui(player);
if (gui != null)
gui.update(player);
}
else
{
player.sendMessage(PlayerManager.COSMETICS_TAG + ChatColor.RED + "Vous n'avez pas le grade nécessaire pour utiliser cette cosmétique.");
}
}
else
{
player.sendMessage(PlayerManager.COSMETICS_TAG + ChatColor.RED + "Vous ne possédez pas ce cosmétique. Tentez de le débloquer auprès de Graou !");
}
}
示例10: enableCosmetic
import org.bukkit.event.inventory.ClickType; //导入依赖的package包/类
@Override
public void enableCosmetic(Player player, ParticleCosmetic cosmetic, ClickType clickType, boolean login, NullType useless)
{
try
{
Effect particleEffectObject = cosmetic.getParticleEffect().getConstructor(EffectManager.class).newInstance(this.effectManager);
particleEffectObject.setEntity(player);
particleEffectObject.infinite();
particleEffectObject.start();
this.playersParticleEffect.put(player.getUniqueId(), particleEffectObject);
if (!login)
player.sendMessage(PlayerManager.COSMETICS_TAG + ChatColor.GREEN + "Vous voilà noyé sous les particules...");
}
catch (ReflectiveOperationException e)
{
this.hub.getCosmeticManager().log(Level.SEVERE, "Can't create EntityEffect object to " + player.getName() + "'s particle effect!");
}
}
示例11: onClick
import org.bukkit.event.inventory.ClickType; //导入依赖的package包/类
@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
if (action.startsWith("cosmetic_"))
{
int cosmetic = Integer.parseInt(action.split("_")[1]);
this.manager.enableCosmetic(player, this.manager.getRegistry().getElementByStorageId(cosmetic), clickType, false);
}
else if (action.equals("delete"))
{
this.manager.disableCosmetics(player, false, false);
}
else if (action.equals("back"))
{
this.hub.getGuiManager().openGui(player, new GuiCosmetics(this.hub));
}
}
示例12: onClick
import org.bukkit.event.inventory.ClickType; //导入依赖的package包/类
@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
if (action.startsWith("cosmetic_"))
{
int cosmetic = Integer.parseInt(action.split("_")[1]);
this.hub.getCosmeticManager().getClothManager().enableCosmetic(player, this.hub.getCosmeticManager().getClothManager().getRegistry().getElementByStorageId(cosmetic), clickType, false);
}
else if (action.equals("delete"))
{
this.hub.getCosmeticManager().getClothManager().disableCosmetics(player, false, false);
}
else if (action.equals("back"))
{
this.hub.getGuiManager().openGui(player, new GuiClothingSets(this.hub));
}
}
示例13: onClick
import org.bukkit.event.inventory.ClickType; //导入依赖的package包/类
@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
if (action.startsWith("set_"))
{
int setStorageId = Integer.parseInt(action.split("_")[1]);
this.hub.getGuiManager().openGui(player, new GuiClothingSet(this.hub, ((ClothRegistry) this.hub.getCosmeticManager().getClothManager().getRegistry()).getClothingSetByStorageId(setStorageId)));
}
else if (action.equals("delete"))
{
this.hub.getCosmeticManager().getClothManager().disableCosmetics(player, false, false);
}
else if (action.equals("back"))
{
this.hub.getGuiManager().openGui(player, new GuiCosmetics(this.hub));
}
}
示例14: onClick
import org.bukkit.event.inventory.ClickType; //导入依赖的package包/类
@Override
public void onClick(Player player, ItemStack stack, String action, ClickType clickType)
{
if (action.equals("back"))
{
if (this.before != null)
this.hub.getGuiManager().openGui(player, this.before);
else
this.hub.getGuiManager().closeGui(player);
}
else if (!action.equals("none"))
{
String iconAction = action.split("_")[1];
ShopIcon shopIcon = this.category.getIconByAction(iconAction);
shopIcon.execute(player, clickType);
}
}
示例15: GUICounter
import org.bukkit.event.inventory.ClickType; //导入依赖的package包/类
public GUICounter() {
label = new GUILabel( "§a" + count, Material.REDSTONE );
label.setPosition( position );
label.setAmount( count );
addEvent( new GUIEvent() {
@Override
public void onClick( ComponentClickEvent event ) {
if ( event.getClick() == ClickType.LEFT ) {
count += steps;
if ( count < 64 ) {
label.setAmount( count );
label.setTitle( "§a" + GUICounter.this.count );
label.draw();
}
}
else if ( event.getClick() == ClickType.RIGHT ) {
count -= steps;
if ( count > 0 ) {
label.setAmount( count );
label.setTitle( "§a" + GUICounter.this.count );
label.draw();
}
}
}
} );
}