本文整理汇总了Java中org.bukkit.inventory.PlayerInventory.setArmorContents方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInventory.setArmorContents方法的具体用法?Java PlayerInventory.setArmorContents怎么用?Java PlayerInventory.setArmorContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.PlayerInventory
的用法示例。
在下文中一共展示了PlayerInventory.setArmorContents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearKit
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static void clearKit(Player player) {
PlayerInventory inv = player.getInventory();
inv.clear();
inv.setArmorContents(new ItemStack[4]);
for (PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}
IPlayer iPlayer = IPlayerHandler.getPlayer(player);
if (iPlayer.isGhost()) {
iPlayer.setGhost(false);
iPlayer.setTeam();
}
iPlayer.gotKit = false;
}
示例2: pushInventory
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
* Pushes the inventory of the given player into persistent storage.
*
* @param player The {@link Player} to push the inventory of
* @throws IOException If an exception occurs while saving into persistent
* storage
*/
@SuppressWarnings("deprecation")
public static void pushInventory(Player player) throws IOException {
PlayerInventory inv = player.getInventory();
// the file to store the inventory in
File storage = new File(SteelDataFiles.PLAYER_INVENTORY_DIR.getFile(), player.getUniqueId() + ".yml");
if (storage.exists()) { // verify file isn't already present on disk (meaning it wasn't popped the last time)
SteelCore.logVerbose("Inventory push requested for player " + player.getName() + ", but "
+ "inventory was already present in persistent storage. Popping stored inventory first.");
try {
popInventory(player);
} catch (InvalidConfigurationException ex) {
throw new IOException(ex); // this is probably a bad thing of me to do but it's for a fringe case anyway
}
}
YamlConfiguration yaml = new YamlConfiguration();
yaml.set(PLAYER_INVENTORY_PRIMARY_KEY, InventoryHelper.serializeInventory(inv));
yaml.set(PLAYER_INVENTORY_ARMOR_KEY, InventoryHelper.serializeInventory(inv.getArmorContents()));
yaml.save(storage); // save to disk
inv.clear(); // clear the inventory to complete the push to disk
inv.setArmorContents(new ItemStack[inv.getArmorContents().length]);
player.updateInventory();
}
示例3: setInventory
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
* Sets the Inventory using an ItemStack array constructed from a JsonObject.
*
* @param player The InventoryHolder to which the Inventory will be set
* @param inv The reference JsonArray
* @param format Data format being used; 0 is old, 1 is new
*/
public void setInventory(Player player, JsonObject inv, int format) {
PlayerInventory inventory = player.getInventory();
ItemStack[] armor = deserializeInventory(inv.getAsJsonArray("armor"), 4, format);
ItemStack[] inventoryContents = deserializeInventory(inv.getAsJsonArray("inventory"), inventory.getSize(), format);
inventory.clear();
if (armor != null) {
inventory.setArmorContents(armor);
}
if (inventoryContents != null) {
inventory.setContents(inventoryContents);
}
}
示例4: mockPlayer
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
private Player mockPlayer(String name, GameMode gameMode) {
Player mock = mock(Player.class);
PlayerInventory inv = mock(PlayerInventory.class);
inv.setContents(new ItemStack[39]);
inv.setArmorContents(new ItemStack[4]);
Inventory enderChest = mock(Inventory.class);
enderChest.setContents(new ItemStack[27]);
given(mock.getInventory()).willReturn(inv);
given(mock.getEnderChest()).willReturn(enderChest);
given(mock.getName()).willReturn(name);
given(mock.getUniqueId()).willReturn(TestHelper.TEST_UUID);
given(mock.getGameMode()).willReturn(gameMode);
AttributeInstance attribute = mock(AttributeInstance.class);
given(mock.getAttribute(Attribute.GENERIC_MAX_HEALTH)).willReturn(attribute);
given(attribute.getBaseValue()).willReturn(20.0);
return mock;
}
示例5: apply
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
default void apply(Backend backend, Player player, boolean health) {
PlayerInventory inventory = player.getInventory();
inventory.setContents(getContents());
inventory.setArmorContents(getArmor());
player.getActivePotionEffects().forEach(potionEffect -> player.removePotionEffect(potionEffect.getType()));
player.addPotionEffects(Arrays.asList(getPotionEffects()));
if (health) {
player.setHealthScaled(true);
player.setHealthScale(getHealthScale());
player.setMaxHealth(getMaxHealth());
player.setHealth(getHealth());
player.setFoodLevel(getFoodLevel());
player.setExhaustion(getExhaustion());
player.setSaturation(getSaturation());
player.setFireTicks(getFireTicks());
player.setTotalExperience(getTotalExperience());
player.setMaximumAir(getMaximumAir());
player.setRemainingAir(getRemainingAir());
}
backend.getProfileRegistry().fromPlayer(backend, player).setKit(backend, this);
}
示例6: loadInventory
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void loadInventory(Player p){
UUID id = p.getUniqueId();
PlayerInventory inv = p.getInventory();
File invFile = HTConfigHandler.getInventoryFile(id);
if(!invFile.exists()){ Mes.mes(p, "chat.creationMode.inventory.restoreFail"); return; }
YamlConfiguration invConfig = YamlConfiguration.loadConfiguration(invFile);
List<ItemStack> inventoryItems = (List<ItemStack>) invConfig.getList("inventory");
inv.setContents(inventoryItems.toArray(new ItemStack[inventoryItems.size()]));
List<ItemStack> armourItems = (List<ItemStack>) invConfig.getList("armour");
inv.setArmorContents(armourItems.toArray(new ItemStack[armourItems.size()]));
try{
List<ItemStack> extraItems = (List<ItemStack>) invConfig.getList("extra");
inv.setExtraContents(extraItems.toArray(new ItemStack[extraItems.size()]));
}
catch(Exception et){ } //Must be in a pre-1.9 version
Mes.mes(p, "chat.creationMode.inventory.restoreSuccess");
invFile.delete();
}
示例7: mergeIntoPlayerInventory
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void mergeIntoPlayerInventory(Player player, Location overflowDropLocation) {
PlayerInventory inventory = player.getInventory();
LinkedList<ItemStack> overflows = new LinkedList<ItemStack>();
inventory.setArmorContents(itemsToSet(inventory.getArmorContents(), savedArmorContents, overflows));
inventory.setContents(itemsToSet(inventory.getContents(), savedInventoryContents, overflows));
// Now add any overflows
HashMap<Integer, ItemStack> failedToAdd = inventory.addItem(overflows.toArray(new ItemStack[overflows.size()]));
// If we failed to add any items (due to a full inventory), drop them near the player
// This can only occur if another plugin has filled up the player's inventory before us
for (ItemStack item : failedToAdd.values()) {
player.sendMessage("Dropping " + item.getAmount() + " " + item.getType() + " due to full inventory!");
player.getWorld().dropItem(overflowDropLocation, item);
}
}
示例8: restore
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void restore(Player p) {
PlayerInventory inv = p.getInventory();
inv.setContents(items);
inv.setArmorContents(armorItems);
p.setLevel(level);
p.setExp(exp);
p.updateInventory();
}
示例9: colorChestplate
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void colorChestplate()
{
Color color;
if(team == Team.RED)
color = Color.RED;
else if(team == Team.BLUE)
color = Color.BLUE;
else
return;
BPPlayer bpPlayer = getPlayer();
Player player = bpPlayer.getPlayer();
PlayerInventory inv = player.getInventory();
ItemStack[] contents = inv.getArmorContents();
ItemStack chestplate = contents[2];
ItemMeta im = chestplate.getItemMeta();
if(!(im instanceof LeatherArmorMeta))
return;
LeatherArmorMeta lam = (LeatherArmorMeta) im;
lam.setColor(color);
chestplate.setItemMeta(lam);
inv.setArmorContents(contents);
}
示例10: colorArmorByFlag
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static void colorArmorByFlag(Player player, Team flagTeam)
{
PlayerInventory inv = player.getInventory();
ItemStack[] armor = inv.getArmorContents();
for (ItemStack piece : armor)
{
Material mat = piece.getType();
if (piece != null && BPArmor.getTypeId(mat) >= 0)
{
Color color = flagTeam.getColor();
BPArmor.colorArmor(piece, color);
}
}
inv.setArmorContents(armor);
}
示例11: colorArmor
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void colorArmor()
{
Player player = getPlayer();
PlayerInventory inv = player.getInventory();
ItemStack[] armor = inv.getArmorContents();
BPEquipment[] contents = getLobbyInventory().getContents();
for (int i = 0; i < 4; i++)
{
if (!(contents[i] instanceof BPArmor) || armor[i] == null)
continue;
BPArmor bpArmor = ((BPArmor) contents[i]).clone();
bpArmor.colorArmor(armor[i]);
}
inv.setArmorContents(armor);
}
示例12: equipArmor
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void equipArmor()
{
Player player = getPlayer();
PlayerInventory pi = player.getInventory();
ItemStack[] armor = getWornArmor();
armor[2] = applyPerks(armor[2]);
pi.setArmorContents(armor);
}
示例13: clearInventory
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void clearInventory()
{
Player player = getPlayer();
PlayerInventory pi = player.getInventory();
pi.clear();
pi.setArmorContents(new ItemStack[] { null, null, null, null });
}
示例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"))));
}
}
示例15: setPlayerInventory
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
* Sets the Inventory using an ItemStack array constructed from a JSONObject.
*
* @param player The InventoryHolder to which the Inventory will be set
* @param inv The reference JSONArray
* @param format Data format being used; 0 is old, 1 is new
*/
public static void setPlayerInventory(Player player, JSONObject inv, int format) {
try {
PlayerInventory inventory = player.getInventory();
ItemStack[] armor = getInventory(inv.getJSONArray("armor"), 4, format);
inventory.clear();
inventory.setArmorContents(armor);
setInventory(player, inv.getJSONArray("inventory"), format);
} catch (JSONException e) {
e.printStackTrace();
}
}