本文整理汇总了Java中org.bukkit.event.inventory.InventoryType类的典型用法代码示例。如果您正苦于以下问题:Java InventoryType类的具体用法?Java InventoryType怎么用?Java InventoryType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InventoryType类属于org.bukkit.event.inventory包,在下文中一共展示了InventoryType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAnvilOpen
import org.bukkit.event.inventory.InventoryType; //导入依赖的package包/类
@EventHandler
public void onAnvilOpen(InventoryOpenEvent e) {
if (e.getPlayer().equals(null)) {
return;
}
if (e.getInventory().equals(null)) {
return;
}
Game bw = io.github.yannici.bedwars.Main.getInstance().getGameManager()
.getGameOfPlayer((Player) e.getPlayer());
if (bw == null) {
return;
}
if (!Config.isGameEnabledXP(bw.getName())) {
return;
}
if (e.getInventory().getType().equals(InventoryType.ANVIL)) {
e.setCancelled(true);
}
}
示例2: ChestGui
import org.bukkit.event.inventory.InventoryType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected ChestGui(Plugin plugin, Config config) {
if (config.has("type")) {
type = config.getEnum("type", InventoryType.class);
icons = new ConfigIcon[type.getDefaultSize()];
} else if (config.has("size")) {
size = config.getInt("size");
if (size % 9 != 0) {
plugin.getLogger().warning("In a gui: size must be a multiple of 9");
size = GuiSize.min(size);
}
icons = new ConfigIcon[size];
} else
throw new InvalidConfigException("Both 'type' and 'size' are empty!");
updateInterval = config.getInt("update-interval", -1);
title = config.getMessageStrRequired("title");
Collection<Map<String, Object>> iconsData = (Collection<Map<String, Object>>) config.getCollection("icons");
if (iconsData != null) {
for (Map<String, Object> data : iconsData) {
ConfigIcon item = ConfigIcon.deserialize(plugin, Config.wrap(data));
icons[(int) data.get("slot")] = item;
}
}
}
示例3: onClose
import org.bukkit.event.inventory.InventoryType; //导入依赖的package包/类
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onClose(InventoryCloseEvent event) {
if (!(event.getInventory().getHolder() instanceof MenuLink))
return;
final VPPlayer player = VanillaPlusCore.getPlayerManager().getPlayer((Player) event.getPlayer());
final MenuLink menu = ((MenuLink) event.getInventory().getHolder());
Bukkit.getScheduler().scheduleSyncDelayedTask(VanillaPlus.getInstance(), new Runnable() {
@Override
public void run() {
if(player.getPlayer().getOpenInventory().getTopInventory().getType() == InventoryType.CRAFTING){
menu.getIconMenu().closed(player, menu);
}else{
menu.getIconMenu().changed(player, menu);
}
}
});
}
示例4: CraftContainer
import org.bukkit.event.inventory.InventoryType; //导入依赖的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);
}
示例5: equipWeaponEvent
import org.bukkit.event.inventory.InventoryType; //导入依赖的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.
}
}
示例6: Menu
import org.bukkit.event.inventory.InventoryType; //导入依赖的package包/类
public Menu(MessageManager messageManager, YamlConfiguration section) {
ConfigurationSection settings = section.getConfigurationSection(Node.SETTINGS.get());
if(settings == null){
Error.MISSING_NODE.add(Node.SETTINGS.get());
title = new MComponent(VanillaPlusCore.getDefaultLang(), " ");
icons = new Icon[37];
type = InventoryType.CHEST;
refresh = 0;
return;
}else{
title = messageManager.getComponentManager().get(settings.getString(Node.NAME_PATH.get()));
type = InventoryType.valueOf(settings.getString(Node.TYPE.get(), "CHEST"));
if(type == InventoryType.CHEST) {
int size = settings.getInt("ROWS");
if(size < 0 || size > 12)
ErrorLogger.addError("ROWS must be between 0 and 12 inclulsive !");
icons = new Icon[9*size+1];
}
else
icons = new Icon[type.getDefaultSize()+1];
refresh = (byte) settings.getInt("REFRESH", 0);
}
}
示例7: guiSignature
import org.bukkit.event.inventory.InventoryType; //导入依赖的package包/类
@Test
public void guiSignature() {
ItemStack itemA = ItemFactory.createRandomItem();
ItemStack itemB = ItemFactory.createRandomItem();
GUISignature signature = new GUISignature(InventoryType.CHEST)
.title("Serialize Test")
.size(18)
.addHandlerIndexes(1, 2, 3)
.item(itemA, 0)
.item(itemA, 1)
.item(ItemFactory.createRandomItem(), 2)
.item(itemB, 3)
.item(itemB, 4)
.item(ItemFactory.createRandomItem(), 5);
StringWriter writer = new StringWriter();
GsonUtils.write(writer, signature, e -> {
throw new AssertionError(e);
});
GUISignature deserialized = GsonUtils.read(new StringReader(writer.toString()), GUISignature.class);
assertEquals(signature, deserialized);
}
示例8: AddItemMenu
import org.bukkit.event.inventory.InventoryType; //导入依赖的package包/类
public AddItemMenu(KingdomFactionsPlayer player, String type, String level, int buyPrice, int sellprice,
boolean useDisplayname, String extraData, int limit) {
this.type = type;
this.level = level;
this.buyPrice = buyPrice;
this.sellprice = sellprice;
this.useDisplayname = useDisplayname;
this.playerName = player.getName();
this.extraData = extraData;
this.limit = limit;
player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "Zet het item op het EERSTE slot!");
player.openInventory(Bukkit.createInventory(null, InventoryType.DISPENSER, "addItem " + player.getName()));
Bukkit.getPluginManager().registerEvents(this, KingdomFactionsPlugin.getInstance());
}
示例9: rowType
import org.bukkit.event.inventory.InventoryType; //导入依赖的package包/类
public static boolean rowType(Integer row, Integer slot, Inventory inventory) {
if (slot != null && row != null) {
Integer mod = 9;
if (inventory != null) {
if (inventory.getType() == InventoryType.DISPENSER ||inventory.getType() == InventoryType.WORKBENCH || inventory.getType() == InventoryType.DROPPER) {
mod = 3;
} else if (inventory.getType() == InventoryType.CHEST || inventory.getType() == InventoryType.ENDER_CHEST || inventory.getType() == InventoryType.PLAYER){
mod = 9;
} else {
mod = inventory.getSize();
}
}
Integer calculate = row * mod;
return slot >= calculate - mod && slot < calculate;
}
return false;
}
示例10: onInventoryClick
import org.bukkit.event.inventory.InventoryType; //导入依赖的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);
}
}
}
示例11: validateClick
import org.bukkit.event.inventory.InventoryType; //导入依赖的package包/类
/**
* Check
*
* @return Click is valid
*/
private boolean validateClick(Player player, PlayerWrapper playerWrapper, Slot slot,
ActionType actionType, ItemStack currentItem, InventoryType.SlotType slotType) {
if (playerWrapper != null) {
if (player != playerWrapper.getPlayer()) {
return false;
}
if (!PlayerUtils.checkLevel(player, slot.getRequiredLevel())) {
PlayerUtils.sendMessage(player, RPGInventory.getLanguage().getMessage("error.level", slot.getRequiredLevel()));
return false;
}
if (!slot.isFree() && !playerWrapper.isBuyedSlot(slot.getName()) && !InventoryManager.buySlot(player, playerWrapper, slot)) {
return false;
}
}
return !((actionType == ActionType.GET && slot.getSlotType() != Slot.SlotType.ACTION
|| actionType == ActionType.DROP) && slot.isCup(currentItem) && slotType != InventoryType.SlotType.QUICKBAR);
}
示例12: onPacketSending
import org.bukkit.event.inventory.InventoryType; //导入依赖的package包/类
@Override
public void onPacketSending(PacketEvent event) {
Player player = event.getPlayer();
//noinspection ConstantConditions
if (event.isCancelled() || !InventoryManager.playerIsLoaded(player)
|| isNotNeededHere(player)) {
return;
}
WrapperPlayServerWindowItems packet = new WrapperPlayServerWindowItems(event.getPacket());
if (player.getOpenInventory().getType() == InventoryType.WORKBENCH) {
List<ItemStack> contents = packet.getSlotData();
List<CraftExtension> extensions = CraftManager.getExtensions(player);
for (CraftExtension extension : extensions) {
for (int slot : extension.getSlots()) {
contents.set(slot, extension.getCapItem());
}
}
packet.setSlotData(contents);
}
}
示例13: onInventoryClick
import org.bukkit.event.inventory.InventoryType; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onInventoryClick(InventoryClickEvent event) {
final Player player = (Player) event.getWhoClicked();
//noinspection ConstantConditions
if (!InventoryManager.playerIsLoaded(player)
|| event.getInventory().getType() != InventoryType.WORKBENCH
|| isNotNeededHere(player)) {
return;
}
List<CraftExtension> extensions = CraftManager.getExtensions(player);
for (CraftExtension extension : extensions) {
for (int slot : extension.getSlots()) {
if (slot == event.getRawSlot()) {
event.setCancelled(true);
PlayerUtils.updateInventory(player);
return;
}
}
}
}
示例14: matches
import org.bukkit.event.inventory.InventoryType; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean matches(CraftingInventory craftingInventory, World world) {
int width, heigth;
//check boundaries for the crafting inventory
InventoryType type = craftingInventory.getType();
switch(type) {
case CRAFTING:
width = heigth = 2;
break;
case WORKBENCH:
width = heigth = 3;
break;
default: return false; //unknown crafting inventory type.
}
for (int w = 0; w <= width - this.width; w++) {
for (int h = 0; h <= heigth - this.heigth; h++) {
if (matrixMatch(craftingInventory, w, h, true)) {
return true;
}
if (matrixMatch(craftingInventory, w, h, false)) {
return true;
}
}
}
return false;
}
示例15: WorldRecipeHolder
import org.bukkit.event.inventory.InventoryType; //导入依赖的package包/类
public WorldRecipeHolder(CustomRecipesPlugin plugin, ItemStack result, MinecraftKey key, String group, Player callbackPlayer, UUID world) {
this.plugin = plugin;
this.result = result;
this.key = key;
this.group = group;
this.world = world;
this.callbackPlayer = callbackPlayer;
this.dispenserInventory = plugin.getServer().createInventory(this, InventoryType.DISPENSER, "Create a world recipe!");
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}