當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。