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


Java PlayerInventory.setItem方法代码示例

本文整理汇总了Java中org.bukkit.inventory.PlayerInventory.setItem方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInventory.setItem方法的具体用法?Java PlayerInventory.setItem怎么用?Java PlayerInventory.setItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.inventory.PlayerInventory的用法示例。


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

示例1: displayVIPContents

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static void displayVIPContents(BPPlayer bpPlayer, PlayerInventory pi)
{
	BPEquipment[] contents = bpPlayer.getLobbyInventory().getContents();
	int k = 0;
	
	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 4; j++)
		{
			int slotId = 14 + i * 9 + 3 - j;
			BPEquipment bpEquipment = contents[k + 16];
			if (bpEquipment != null)
			{
				ItemStack is = bpEquipment.getItemStack();
				pi.setItem(slotId, is);
				k++;
				continue;
			}
			pi.setItem(slotId, null);
			k++;
		}
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:22,代码来源:InventoryMenuManager.java

示例2: onJoin

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@EventHandler
public void onJoin(PlayerJoinEvent e){
	Player p = e.getPlayer();
	p.setHealth(p.getMaxHealth());
	p.setFoodLevel(20); //TODO
	PlayerInventory i = p.getInventory();
	i.clear();
	i.setHeldItemSlot(4);
	i.setItem(4, JOIN_ITEM);
	
	User u = new User(p);
	UserManager.addUser(u);
	u.setChampion(ChampType.YASUO);
	u.setTeam(TeamType.NONE);
	TabTitle tab = new TabTitle("�2Witaj na serwerze \n Grzybie", "�5League Of Legends!");
	Title title = new Title("�6�lWitamy", "�a�lXD Prodaksh�n", 10, 10, 30);
	bar.addPlayer(p);
	tab.send(p);
	title.send(p);
	runTask(ScoreBoard.get(p)); //test
	ProfileLoader profile = new ProfileLoader(p.getUniqueId().toString(), p.getName(), "skkf");
	profile.loadProfile();
}
 
开发者ID:xdev-pl,项目名称:LeagueOfLegends,代码行数:24,代码来源:PlayerJoinList.java

示例3: putItem

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@Override
public void putItem(PlayerInventory inv, ItemStack stack) {
    if(isEquipment()) {
        inv.setItem(toEquipmentSlot(), stack);
    } else {
        super.putItem(inv, stack);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:Slot.java

示例4: fillInventory

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static void fillInventory(Player p) {
    PlayerInventory inv = p.getInventory();
    for (int i = 0; i <= 35; i++) {
        inv.setItem(i, ItemManager.getForbidden(1));
    }
    for (int i = 2; i <= 4; i++) {
        inv.setItem(i, ItemManager.getForbidden(i + 1));
    }
    flushSkillSelection(p);
    p.updateInventory();
    p.setLevel(0);
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:13,代码来源:Utils.java

示例5: flushSkillSelection

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static void flushSkillSelection(Player p) {
    PlayerInventory inv = p.getInventory();
    List<Skill> skills = SkillManager.getInstance().getRandomSkills();
    int i = 2;
    for (Skill s : skills) {
        ItemStack item = s.getSelector();
        item.setAmount(i + 1);
        inv.setItem(i, item);
        i++;
    }
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:12,代码来源:Utils.java

示例6: onHeld

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@EventHandler
public void onHeld(PlayerItemHeldEvent e) {
    if (e.isCancelled()) {
        return;
    }
    if (!Utils.isInArena(e.getPlayer())) {
        return;
    }
    if (e.getNewSlot() == 0) {
        return;
    }
    if (e.getNewSlot() >= 2 && e.getNewSlot() <= 4) {
        int slot = e.getNewSlot();
        Player p = e.getPlayer();
        PlayerInventory inv = p.getInventory();
        ItemStack item = inv.getItem(slot).clone();
        item.setAmount(1);
        if (SkillManager.getInstance().isSkillSelector(item)) {
            Skill skill = SkillManager.getInstance().getSkillBySelector(item);
            if(skill.getSkillType().equals(SkillType.ITEM)){
                inv.setItem(0, skill.getShow());
            }
            else{
                Class<?> skillClazz=skill.getClass();
                try {
                    Method method =skillClazz.getMethod("doUpgrade",Player.class);
                    if(method!=null){
                        method.invoke(SkillManager.getInstance().getSkillByName(skill.getName()),p);
                    }
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            inv.setItem(2, ItemManager.getForbidden(3));
            inv.setItem(3, ItemManager.getForbidden(4));
            inv.setItem(4, ItemManager.getForbidden(5));
        }
    }
    e.setCancelled(true);
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:41,代码来源:InventoryListener.java

示例7: apply

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@Override
public void apply(GamePlayer player) {
    PlayerInventory inventory = player.getBukkit().getInventory();

    if (this.hasSlot()) {
        inventory.setItem(this.getSlot(), this.getResult());
    } else {
        inventory.addItem(this.getResult());
    }
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:11,代码来源:ItemStackContent.java

示例8: showOptions

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void showOptions(BPPlayer bpPlayer)
{
	Player player = bpPlayer.getPlayer();
	PlayerInventory inv = player.getInventory();
	PlayerManager.clearHotBar(inv);
	for (int i = 0; i < maps.length; i++)
		if (maps[i] != null)
			inv.setItem(i, getMapItem(i));
	updateOptions(player);
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:11,代码来源:MapPoll.java

示例9: showIngameMenu

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void showIngameMenu(BPPlayer bpPlayer)
{
	Player player = bpPlayer.getPlayer();
	PlayerInventory pi = player.getInventory();
	Game game = bpPlayer.getGame();
	
	for (int i = 0; i < 27; i++)
		pi.setItem(9 + i, ingameItems[i]);
	
	pi.setItem(15, getScoreMap(bpPlayer));
	pi.setItem(17, getMoneyEmerald(bpPlayer));
	game.showInGameMenu(bpPlayer);
	player.updateInventory();
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:16,代码来源:InventoryMenuManager.java

示例10: showLobbyMenu

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void showLobbyMenu(BPPlayer bpPlayer)
{
	Breakpoint plugin = Breakpoint.getInstance();
	
	if(plugin.hasEvent())
		plugin.getEventManager().showLobbyMenu(bpPlayer);
	
	Player player = bpPlayer.getPlayer();
	PlayerInventory pi = player.getInventory();
	// Container
	// Border
	pi.setItem(13, getBorder());
	pi.setItem(22, getTrashbin());
	pi.setItem(31, getBorder());
	// Contents
	displayContents(bpPlayer, pi);
	// VIP Slots
	if (player.hasPermission("Breakpoint.vip"))
		displayVIPContents(bpPlayer, pi);
	else
		for (int i = 0; i < 3; i++)
			for (int j = 0; j < 4; j++)
				pi.setItem(14 + i * 9 + j, getVipSlot());
	// Hotbar
	pi.setItem(0, MapManager.getBreakpointMap(player));
	pi.setItem(1, MapManager.getPlayerGraphMap(player));
	pi.setItem(4, getWikiBook());
	pi.setItem(5, getPerkButton());
	pi.setItem(6, getSettingsButton());
	pi.setItem(7, getAchievementButton(bpPlayer));
	pi.setItem(8, getMoneyEmerald(bpPlayer));
	MapManager.updateLobbyMapsForPlayer(bpPlayer);
	player.updateInventory();
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:36,代码来源:InventoryMenuManager.java

示例11: showLobbyMenu

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@Override
public void showLobbyMenu(BPPlayer bpPlayer)
{
	Player player = bpPlayer.getPlayer();
	PlayerInventory pi = player.getInventory();
	pi.setItem(2, getCalendarMap(player));
}
 
开发者ID:Limeth,项目名称:Breakpoint,代码行数:8,代码来源:AdventManager.java

示例12: giveItem

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static void giveItem(Player player, ItemStack item) {
	PlayerInventory inv = player.getInventory();
	for (int i = 0; i < inv.getSize(); i++) {
		if (inv.getItem(i) == null) {
			inv.setItem(i, item);
			return;
		}
	}
	player.getWorld().dropItem(player.getLocation(), item);
}
 
开发者ID:bobmandude9889,项目名称:iZenith-PVP,代码行数:11,代码来源:Util.java

示例13: onPlayerItemHoldEvent

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerItemHoldEvent(final PlayerItemHeldEvent event) {
    final Player bukkitPlayer = event.getPlayer();
    if (bukkitPlayer.isSneaking()) {
        return;
    }
    FawePlayer<Object> fp = FawePlayer.wrap(bukkitPlayer);
    com.sk89q.worldedit.entity.Player player = fp.getPlayer();
    LocalSession session = fp.getSession();
    Tool tool = session.getTool(player);
    if (tool instanceof ScrollTool) {
        final int slot = event.getNewSlot();
        final int oldSlot = event.getPreviousSlot();
        final int ri;
        if ((((slot - oldSlot) <= 4) && ((slot - oldSlot) > 0)) || (((slot - oldSlot) < -4))) {
            ri = 1;
        } else {
            ri = -1;
        }
        ScrollTool scrollable = (ScrollTool) tool;
        if (scrollable.increment(player, ri)) {
            if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES) {
                bukkitPlayer.getInventory().setHeldItemSlot(oldSlot);
            } else {
                final PlayerInventory inv = bukkitPlayer.getInventory();
                final ItemStack item = inv.getItem(slot);
                final ItemStack newItem = inv.getItem(oldSlot);
                inv.setItem(slot, newItem);
                inv.setItem(oldSlot, item);
                bukkitPlayer.updateInventory();
            }
        }
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:35,代码来源:BrushListener.java

示例14: onPlayerMove

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
   	Player p = e.getPlayer();
   	
   	//set velocities
   	if (!p.hasPermission("redprotect.bypass.velocity")){
   		if (RPConfig.getGlobalFlagFloat(p.getWorld().getName()+".player-velocity.walk-speed") >= 0){
       		p.setWalkSpeed(RPConfig.getGlobalFlagFloat(p.getWorld().getName()+".player-velocity.walk-speed"));
       	}
       	if (RPConfig.getGlobalFlagFloat(p.getWorld().getName()+".player-velocity.fly-speed") >= 0){
       		p.setFlySpeed(RPConfig.getGlobalFlagFloat(p.getWorld().getName()+".player-velocity.fly-speed"));
       	}
   	}
   	
   	if (RedProtect.get().version >= 191){    		
   		if (!RPConfig.getGlobalFlagBool(p.getWorld().getName()+".elytra.allow")){
   			ItemStack item = p.getInventory().getChestplate();
   			if (item != null && item.getType().equals(Material.ELYTRA)){
   				PlayerInventory inv = p.getInventory();
   				inv.setChestplate(new ItemStack(Material.AIR));
   				if (inv.firstEmpty() == -1){
   					p.getWorld().dropItem(p.getLocation(), item);
   				} else {
   					inv.setItem(inv.firstEmpty(),item);
   				}    				
   				p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 10, 1);
   				RPLang.sendMessage(p, "globallistener.elytra.cantequip");
   				return;
   			}
   		}
   		    		 		    		
   		double boost = RPConfig.getGlobalFlagDouble(p.getWorld().getName()+".elytra.boost");
   		if (boost > 0 && p.isGliding() && RPConfig.getGlobalFlagBool(p.getWorld().getName()+".elytra.allow")){
   			Vector vec = new Vector(0.0D, p.getLocation().getDirection().getY(), 0.0D);
               p.setVelocity(p.getVelocity().add(vec.multiply(0.1D*boost/2)));
   		}
   	}    	
   }
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:39,代码来源:RPGlobalListener.java

示例15: loadInventory

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
private void loadInventory(PlayerInventory inv) {
    inv.clear();
    inv.setArmorContents(new ItemStack[] {null, null, null, null});
    if(!this.database.contains(this.key + ".inventory")) {
        return;
    }

    Map<String, Object> inventory = null;
    try {
        BukkitObjectInputStream in = new BukkitObjectInputStream(new ByteArrayInputStream(this.database.getBytes(this.key + ".inventory")));
        inventory = (Map<String, Object>) in.readObject();
    } catch(Exception e) {
        this.module.getLogger().log(Level.SEVERE, "Failed to load inventory.", e);
        return;
    }

    for(int slot = 0; slot < inv.getSize(); slot++) {
        if(inventory.containsKey(String.valueOf(slot))) {
            inv.setItem(slot, ItemStack.deserialize((Map<String, Object>) inventory.get(String.valueOf(slot))));
        } else {
            inv.setItem(slot, null);
        }
    }

    if(inventory.containsKey("helmet")) {
        inv.setHelmet(ItemStack.deserialize((Map<String, Object>) inventory.get(String.valueOf("helmet"))));
    }

    if(inventory.containsKey("chestplate")) {
        inv.setChestplate(ItemStack.deserialize((Map<String, Object>) inventory.get(String.valueOf("chestplate"))));
    }

    if(inventory.containsKey("leggings")) {
        inv.setLeggings(ItemStack.deserialize((Map<String, Object>) inventory.get(String.valueOf("leggings"))));
    }

    if(inventory.containsKey("boots")) {
        inv.setBoots(ItemStack.deserialize((Map<String, Object>) inventory.get(String.valueOf("boots"))));
    }
}
 
开发者ID:Steveice10,项目名称:Peacecraft,代码行数:41,代码来源:WorldPlayerData.java


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