当前位置: 首页>>代码示例>>Java>>正文


Java SlotType类代码示例

本文整理汇总了Java中org.bukkit.event.inventory.InventoryType.SlotType的典型用法代码示例。如果您正苦于以下问题:Java SlotType类的具体用法?Java SlotType怎么用?Java SlotType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SlotType类属于org.bukkit.event.inventory.InventoryType包,在下文中一共展示了SlotType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testOnItemsPickup

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
/**
 * Make sure the "onItemsPickup" method is invoked when
 * items are picked up in the inventory view.
 */
@Test
public void testOnItemsPickup() {

    MockChestView view = new MockChestView(plugin, null);

    _session.next(view);
    BukkitTester.pause(2);

    BukkitTester.viewClick(player,
            SlotType.CONTAINER, 0, ClickType.LEFT, InventoryAction.PICKUP_ALL);

    BukkitTester.pause(2);

    // check "onItemsPickup" is invoked
    assertTrue(view.itemsPickup != null);
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:21,代码来源:ChestViewTest.java

示例2: testOnItemsPlaced

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
/**
 * Make sure the "onItemsPlaced" method is invoked when
 * items are placed in the inventory view.
 */
@Test
public void testOnItemsPlaced() {
    MockChestView view = new MockChestView(plugin, null);

    _session.next(view);
    BukkitTester.pause(2);

    BukkitTester.viewClick(player,
            SlotType.CONTAINER, 0, ClickType.LEFT, InventoryAction.PLACE_ALL);

    BukkitTester.pause(2);

    // check "onItemsPlaced" is invoked
    assertTrue(view.itemsPlaced != null);
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:20,代码来源:ChestViewTest.java

示例3: testOnItemsDropped

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
/**
 * Make sure the "onItemsDropped" method is invoked when
 * items are dropped from the inventory view.
 */
@Test
public void testOnItemsDropped() {

    MockChestView view = new MockChestView(plugin, null);

    _session.next(view);
    BukkitTester.pause(2);

    BukkitTester.viewClick(player,
            SlotType.CONTAINER, 0, ClickType.LEFT, InventoryAction.DROP_ALL_CURSOR);

    BukkitTester.pause(2);

    // check "onItemsDropped" is invoked
    assertTrue(view.itemsDropped != null);
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:21,代码来源:ChestViewTest.java

示例4: testOnItemSelected

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
/**
 * Make sure {@link #onItemSelect} is invoked when a menu item is clicked
 * and that the correct {@link MenuItem} is passed into the invoked method.
 */
@Test
public void testOnItemSelected() {
    MockMenuView view = new MockMenuView(plugin, null);

    _session.next(view);
    BukkitTester.pause(2);

    MenuItem menuItem = new MenuItemBuilder(Material.WOOD).build(0);
    menuItem.setVisible(view, true);

    // select/click the menu item
    BukkitTester.viewClick(player,
            SlotType.CONTAINER, 0, ClickType.LEFT, InventoryAction.PICKUP_ALL);

    BukkitTester.pause(2);

    // check "onItemSelected" is invoked with correct menu item
    assertEquals(menuItem, view.selected);
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:24,代码来源:MenuViewTest.java

示例5: InventoryClickEvent

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) {
    super(view);
    this.slot_type = type;
    this.rawSlot = slot;
    this.whichSlot = view.convertSlot(slot);
    this.click = click;
    this.action = action;
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:9,代码来源:InventoryClickEvent.java

示例6: getCurrentItem

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
/**
 * Gets the ItemStack currently in the clicked slot.
 *
 * @return the item in the clicked
 */
public ItemStack getCurrentItem() {
    if (slot_type == SlotType.OUTSIDE) {
        return current;
    }
    return getView().getItem(rawSlot);
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:12,代码来源:InventoryClickEvent.java

示例7: setCurrentItem

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
/**
 * Sets the ItemStack currently in the clicked slot.
 *
 * @param stack the item to be placed in the current slot
 */
public void setCurrentItem(ItemStack stack) {
    if (slot_type == SlotType.OUTSIDE) {
        current = stack;
    } else {
        getView().setItem(rawSlot, stack);
    }
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:13,代码来源:InventoryClickEvent.java

示例8: onVillagerTrade

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onVillagerTrade(final InventoryClickEvent event) {

	final PlayerStat stat = PlayerStat.VILLAGER_TRADES;

	// Thanks to Lolmewn for this code (https://bitbucket.org/Lolmewn/stats/src/4eae2db1b21038a91b7d39181f27bdd3cd987324/src/main/java/nl/lolmewn/stats/stats/bukkit/BukkitTrades.java?at=3.0&fileviewer=file-view-default)

	if (event.getInventory().getType() != InventoryType.MERCHANT) {
		return;
	}
	if (!event.getSlotType().equals(SlotType.RESULT)) {
		return;
	}
	if (!event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY)
			&& !event.getAction().equals(InventoryAction.PICKUP_ALL)) {
		return;
	}
	if (!(event.getWhoClicked() instanceof Player)) {
		return;
	}

	Player player = (Player) event.getWhoClicked();

	// Do general check
	if (!plugin.doGeneralCheck(player, stat))
		return;

	ItemStack item = event.getCurrentItem();

	// Update value to new stat.
	plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat,
			StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", item.getAmount(), "world",
					player.getWorld().getName(), "trade", item.getType().toString()));

}
 
开发者ID:Staartvin,项目名称:Statz,代码行数:36,代码来源:VillagerTradesListener.java

示例9: onInventoryClick

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled=true)
public void onInventoryClick(InventoryClickEvent event) {
    Inventory inventory = event.getInventory(); // The inventory that was clicked in
    if (inventory.getName() == null) {
        return;
    }
    // The player that clicked the item
    Player player = (Player) event.getWhoClicked();
    if (!inventory.getTitle().equals(plugin.myLocale(player.getUniqueId()).topTenGuiTitle)) {
        return;
    }
    event.setCancelled(true);
    player.updateInventory();
    if(event.getCurrentItem() != null && event.getCurrentItem().getType().equals(Material.SKULL_ITEM) && event.getCurrentItem().hasItemMeta()){
        Util.runCommand(player, "is warp " + ((SkullMeta)event.getCurrentItem().getItemMeta()).getOwner());
    	player.closeInventory();
    	return;
    }
    if (event.getSlotType().equals(SlotType.OUTSIDE)) {
        player.closeInventory();
        return;
    }
    if (event.getClick().equals(ClickType.SHIFT_RIGHT)) {
        player.closeInventory();
        return;
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:29,代码来源:TopTen.java

示例10: onHelmetChange

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
@EventHandler
public void onHelmetChange(final InventoryClickEvent event) {

	if (event.getSlotType().equals(SlotType.ARMOR) && (103 == event.getSlot())) {
		this.checkIfSuffocating((Player) event.getWhoClicked());
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:8,代码来源:SQSpace.java

示例11: onShiftCrafting

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
@EventHandler(priority=EventPriority.LOW)
public void onShiftCrafting(InventoryClickEvent event) {
	if (event.getSlotType() == SlotType.RESULT
			&& event.getClick().equals(ClickType.SHIFT_LEFT)
			&& event.getWhoClicked() instanceof Player) {
		Player player = (Player) event.getWhoClicked();
		String playerID = PlayerConverter.getID(player);
		if (containsPlayer(playerID)) {
			event.setCancelled(true);
		}
	}
}
 
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:13,代码来源:CraftingObjective.java

示例12: InventoryClickEvent

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) {
    super(view);
    this.slot_type = type;
    this.rawSlot = slot;
    if (slot < 0) {
        this.clickedInventory = null;
    } else if (view.getTopInventory() != null && slot < view.getTopInventory().getSize()) {
        this.clickedInventory = view.getTopInventory();
    } else {
        this.clickedInventory = view.getBottomInventory();
    }
    this.whichSlot = view.convertSlot(slot);
    this.click = click;
    this.action = action;
}
 
开发者ID:AlmuraDev,项目名称:Almura-API,代码行数:16,代码来源:InventoryClickEvent.java

示例13: testOnClick

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
/**
 * Make sure the on-click callbacks are run when the menu item
 * is clicked..
 */
@Test
public void testOnClick() throws Exception {

    MenuItem menuItem = new MenuItemBuilder(Material.STONE)
            .title("test")
            .onClick(new Runnable() {
                @Override
                public void run() {
                    _isOnClickRun = true;
                }
            })
            .build(0);

    MockMenuView view = new MockMenuView(plugin, null);
    ViewSession session = ViewSession.get(player, null);

    // open a menu view
    session.next(view);
    BukkitTester.pause(5);

    // set the item in the menu view
    menuItem.setVisible(view, true);
    BukkitTester.pause(5);

    // click the menu item
    BukkitTester.viewClick(player,
            SlotType.CONTAINER, 0, ClickType.LEFT, InventoryAction.PICKUP_ALL);
    BukkitTester.pause(5);

    // make sure the items on click runnables ran
    assertEquals(true, _isOnClickRun);
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:37,代码来源:MenuItemTest.java

示例14: testSelectPage

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
/**
 * Make sure selecting a page works properly.
 */
@Test
public void testSelectPage() {

    ArrayListPaginator<String> paginator = new ArrayListPaginator<String>(PageStartIndex.ONE, 9);

    // add enough to produce 2 pages
    paginator.addAll(ArrayUtils.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"));

    PaginatorView view = new PaginatorView(plugin, paginator, null);

    // show the paginator to the player
    _session.next(view);
    BukkitTester.pause(5);

    // ensure that page 2 items are shown in the view
    assertTrue(view.getInventoryView().getItem(0) != null);
    assertTrue(view.getInventoryView().getItem(1) != null);
    assertTrue(view.getInventoryView().getItem(2) == null);

    // click on inventory slot index 1 (page 2)
    BukkitTester.viewClick(player,
            SlotType.CONTAINER, 1, ClickType.LEFT, InventoryAction.PICKUP_ALL);

    BukkitTester.pause(5);

    // make sure the paginator reports that page 2 was selected.
    assertEquals(2, view.getSelectedPage());

    // make sure paginator closes itself when page is selected
    assertEquals(null, _session.getCurrent());
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:35,代码来源:PaginatorViewTest.java

示例15: getCurrentItem

import org.bukkit.event.inventory.InventoryType.SlotType; //导入依赖的package包/类
/**
 * Gets the ItemStack currently in the clicked slot. Returns air for empty
 * slots and null for clicking outside the inventory.
 *
 * @return the item in the clicked slot
 */
public ItemStack getCurrentItem() {
    if (slot_type == SlotType.OUTSIDE) {
        return current;
    }
    return getView().getItem(rawSlot);
}
 
开发者ID:Bukkit,项目名称:Bukkit-JavaDoc,代码行数:13,代码来源:InventoryClickEvent.java


注:本文中的org.bukkit.event.inventory.InventoryType.SlotType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。