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


Java PlayerInventory.setChestplate方法代码示例

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


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

示例1: onWorldChange

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@EventHandler (priority = EventPriority.HIGHEST)
public void onWorldChange(PlayerChangedWorldEvent e){
	Player p = e.getPlayer();
	World w = p.getWorld();
	if(!isEnabled(w)) return;

	PlayerInventory inv = p.getInventory();

	ItemStack chestplate = inv.getChestplate();

	if(chestplate == null || chestplate.getType() != Material.ELYTRA) return;

	inv.setChestplate(new ItemStack(Material.AIR));

	if(inv.firstEmpty() != -1)
		inv.addItem(chestplate);
	else
		w.dropItem(p.getLocation(), chestplate);
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:20,代码来源:ModuleDisableElytra.java

示例2: onPgmSpawn

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPgmSpawn(CardinalSpawnEvent event){
    Player player = event.getPlayer();
    PlayerInventory inventory = player.getInventory();
    if (helmet.containsKey(player)) {
        if (helmet.get(player) != null) {
            inventory.setHelmet(helmet.get(player));
        }
    }
    if (chestplate.containsKey(player)) {
        if (chestplate.get(player) != null) {
            inventory.setChestplate(chestplate.get(player));
        }
    }
    if (leggings.containsKey(player)) {
        if (leggings.get(player) != null) {
            inventory.setLeggings(leggings.get(player));
        }
    }
    if (boots.containsKey(player)) {
        if (boots.get(player) != null) {
            inventory.setBoots(boots.get(player));
        }
    }
}
 
开发者ID:dentmaged,项目名称:Cardinal-Plus,代码行数:26,代码来源:ArmorKeep.java

示例3: clearInventory

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void clearInventory(Player p) {
	PlayerInventory inv = p.getInventory();
	inv.clear();
	inv.setHelmet(null);
	inv.setChestplate(null);
	inv.setLeggings(null);
	inv.setBoots(null);
	InventoryView view = p.getOpenInventory();
	if (view != null) {
		view.setCursor(null);
		Inventory i = view.getTopInventory();
		if (i != null) {
			i.clear();
		}
	}
}
 
开发者ID:Hansdekip,项目名称:BlockParty-1.8,代码行数:17,代码来源:InventoryManager.java

示例4: clear

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
 * Completely clears an inventory, including armor, if applicable.
 * 
 * @param inventory Inventory to clear
 */
public static void clear(Inventory inventory)
{
	Validate.notNull(inventory, "inventory cannot be null!");

	inventory.clear();

	if (inventory instanceof PlayerInventory)
	{
		PlayerInventory pInventory = (PlayerInventory) inventory;
		pInventory.setHelmet(null);
		pInventory.setChestplate(null);
		pInventory.setLeggings(null);
		pInventory.setBoots(null);
	}
}
 
开发者ID:dmulloy2,项目名称:SwornAPI,代码行数:21,代码来源:InventoryUtil.java

示例5: commandUse

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public boolean commandUse(CommandSender sender, String[] args) {
    Variables var = Necessities.getVar();
    if (sender instanceof Player) {
        Player p = (Player) sender;
        PlayerInventory inv = p.getInventory();
        ItemStack hand = inv.getItemInMainHand();
        ItemStack chestplate = inv.getChestplate();
        if (hand.getType() != Material.AIR) {
            inv.setChestplate(hand);
            inv.setItemInMainHand(chestplate);
            p.sendMessage(var.getMessages() + "Chestplate equipped.");
        } else {
            if (chestplate != null)
                inv.setItemInMainHand(chestplate);
            inv.setChestplate(new ItemStack(Material.AIR));
            p.sendMessage(var.getMessages() + "Chestplate removed.");
        }
    } else
        sender.sendMessage(var.getEr() + "Error: " + var.getErMsg() + "You do not have armor.");
    return true;
}
 
开发者ID:pupnewfster,项目名称:Necessities,代码行数:22,代码来源:CmdChest.java

示例6: unpack

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void unpack(Player p) {

		p.setFoodLevel(this.hunger);
		p.setHealth(this.health);
		p.setExp(this.xp);
		p.setLevel(this.xpLevel);
		p.addPotionEffects(CardboardPotionEffect.unboxPotions(this.potions));
		this.inventory.unpack(p.getInventory());
		ItemStack[] armor = this.armor.unpackItemArray();
		PlayerInventory inv = p.getInventory();
		inv.setHelmet(armor[3]);
		inv.setChestplate(armor[2]);
		inv.setLeggings(armor[1]);
		inv.setBoots(armor[0]);

	}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:17,代码来源:Knapsack.java

示例7: onPlayerRespawnEvent

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@EventHandler
public void onPlayerRespawnEvent(PlayerRespawnEvent event) {
	if (event.getPlayer().getName().equals("Esaych")) {
		PlayerInventory eInv = event.getPlayer().getInventory();
		if (eInv.getHelmet() != null)
			return;
		if (eInv.getChestplate() != null)
			return;
		if (eInv.getLeggings() != null)
			return;
		if (eInv.getBoots() != null)
			return;
		eInv.setHelmet(new ItemStack(Material.LEATHER_HELMET));
		eInv.setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
		eInv.setLeggings(new ItemStack(Material.LEATHER_LEGGINGS));
		eInv.setBoots(new ItemStack(Material.LEATHER_BOOTS));
		PlayerInventory inv = event.getPlayer().getInventory();
		colorize(inv.getHelmet(), 47, 0, 111);
		colorize(inv.getChestplate(), 47, 0, 111);
		colorize(inv.getLeggings(), 47, 0, 111);
		colorize(inv.getBoots(), 47, 0, 111);
	}
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:24,代码来源:CustomPlugin.java

示例8: clearAll

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
 * Clear an inventory. If the inventory is a {@link org.bukkit.inventory.PlayerInventory},
 * the armor contents are also cleared.
 *
 * @param inventory  The inventory to clear.
 */
public static void clearAll(Inventory inventory) {
    PreCon.notNull(inventory);

    inventory.clear();
    inventory.setContents(new ItemStack[inventory.getSize()]); // 36

    if (inventory instanceof PlayerInventory) {
        PlayerInventory playerInventory = (PlayerInventory)inventory;
        playerInventory.setHelmet(null);
        playerInventory.setChestplate(null);
        playerInventory.setLeggings(null);
        playerInventory.setBoots(null);
        playerInventory.setItemInHand(null);
    }
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:22,代码来源:InventoryUtils.java

示例9: onPgmSpawn

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPgmSpawn(CardinalSpawnEvent event) {
    Player player = event.getPlayer();
    PlayerInventory inventory = player.getInventory();
    if (helmet.containsKey(player)) {
        if (helmet.get(player) != null) {
            inventory.setHelmet(helmet.get(player));
        }
    }
    if (chestplate.containsKey(player)) {
        if (chestplate.get(player) != null) {
            inventory.setChestplate(chestplate.get(player));
        }
    }
    if (leggings.containsKey(player)) {
        if (leggings.get(player) != null) {
            inventory.setLeggings(leggings.get(player));
        }
    }
    if (boots.containsKey(player)) {
        if (boots.get(player) != null) {
            inventory.setBoots(boots.get(player));
        }
    }
}
 
开发者ID:twizmwazin,项目名称:CardinalPGM,代码行数:26,代码来源:ArmorKeep.java

示例10: clearInventory

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void clearInventory(boolean armor) {
    PlayerInventory inventory = this.getBukkit().getInventory();
    inventory.clear();

    if (armor) {
        inventory.setHelmet(null);
        inventory.setChestplate(null);
        inventory.setLeggings(null);
        inventory.setBoots(null);
    }
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:12,代码来源:ArcadePlayer.java

示例11: apply

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@Override
public void apply(GamePlayer player) {
    PlayerInventory inventory = player.getBukkit().getInventory();
    inventory.setHelmet(this.getHelmet());
    inventory.setChestplate(this.getChestplate());
    inventory.setLeggings(this.getLeggings());
    inventory.setBoots(this.getBoots());
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:9,代码来源:ArmorContent.java

示例12: initPlayer

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void initPlayer(String name){
    Player player;
    if(Bukkit.getPlayer(name)!=null){
      player=Bukkit.getPlayer(name);
    }
    else{
        System.out.print("玩家不存在,初始化个屁啊。。");
        return;
    }
    player.setWalkSpeed(0.2f);
    player.setMaxHealth(20);
    player.setFoodLevel(20);
    player.setExp(0);
    player.eject();
    player.setHealth(player.getMaxHealth());
    for(PotionEffect effect : player.getActivePotionEffects())//清空药水效果
    {
      player.removePotionEffect(effect.getType());
    }
    player.teleport(gameworld.getSpawnLocation());//传送进等待区
    
    ItemStack[] inventory=player.getInventory().getContents();//保存背包信息
    this.mySavedItems.put(player.getName(), inventory);
    this.mySavedArmors.put(player.getName(), player.getInventory().getArmorContents());
    
    player.getInventory().clear();//清空背包
    PlayerInventory inv = player.getInventory();
    inv.setHelmet(new ItemStack(Material.AIR));
    inv.setChestplate(new ItemStack(Material.AIR));
    inv.setLeggings(new ItemStack(Material.AIR));
    inv.setBoots(new ItemStack(Material.AIR));//到这里就清空了
    
    
}
 
开发者ID:D0048,项目名称:CraftPlugins,代码行数:35,代码来源:Blockode.java

示例13: 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

示例14: 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

示例15: setArmor

import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
 * Set the kit armor for given player
 *
 * @param player The player
 */
public void setArmor(Player player){
    PlayerInventory inv = player.getInventory();
    ItemStack[] armor = getContents(this.armor);

    if(!inv.contains(armor[3]))
        inv.setHelmet(armor[3]);
    if(!inv.contains(armor[2]))
        inv.setChestplate(armor[2]);
    if(!inv.contains(armor[1]))
        inv.setLeggings(armor[1]);
    if(!inv.contains(armor[0]))
        inv.setBoots(armor[0]);
}
 
开发者ID:Superioz,项目名称:CastleRush,代码行数:19,代码来源:ItemKit.java


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