本文整理汇总了Java中org.bukkit.inventory.PlayerInventory.getArmorContents方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInventory.getArmorContents方法的具体用法?Java PlayerInventory.getArmorContents怎么用?Java PlayerInventory.getArmorContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.PlayerInventory
的用法示例。
在下文中一共展示了PlayerInventory.getArmorContents方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCommand
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@Override
public void onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player player = (Player) sender;
PlayerInventory inv = player.getInventory();
ItemStack[][] contents = { inv.getContents(), inv.getArmorContents() };
String world = player.getWorld().getName().split("_")[0];
try {
if(KitManager.getKit(world,args[0]) == null){
KitManager.createKit(world,args[0], "temp", "temp", 1, (short) 0, contents);
player.sendMessage(Util.parseColors("&7Kit &a" + args[0] + " &7created!"));
} else {
KitManager.setKit(world,args[0], contents);
player.sendMessage(Util.parseColors("&7Kit &a" + args[0] + " &7modified!"));
}
} catch (Exception e) {
player.sendMessage(ChatColor.RED + "Invalid arguments");
player.sendMessage("/setkit <name>");
}
}
示例2: InventoryToString
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static String InventoryToString (Inventory invInventory)
{
String serialization = invInventory.getSize() + ";";
for (int i = 0; i < invInventory.getSize(); i++)
{
ItemStack is = invInventory.getItem(i);
if (is != null)
{
String serializedItemStack = getSerializedItemStack(is);
serialization += i + "#" + serializedItemStack + ";";
}
}
if (invInventory instanceof PlayerInventory) {
serialization += "&[email protected]";
PlayerInventory pInv = (PlayerInventory)invInventory;
for (ItemStack stack : pInv.getArmorContents()) {
if (stack != null) {
serialization += getSerializedItemStack(stack) + ";";
}
}
}
return serialization;
}
示例3: playerInventoryToString
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static String playerInventoryToString(PlayerInventory inv) {
StringBuilder builder = new StringBuilder();
ItemStack[] armor = inv.getArmorContents();
for (int i = 0; i < armor.length; i++) {
if (i == 3) {
if (armor[i] == null) {
builder.append(itemStackToString(new ItemStack(Material.AIR)));
} else {
builder.append(itemStackToString(armor[3]));
}
} else {
if (armor[i] == null) {
builder.append(itemStackToString(new ItemStack(Material.AIR))).append(";");
} else {
builder.append(itemStackToString(armor[i])).append(";");
}
}
}
builder.append("|");
for (int i = 0; i < inv.getContents().length; ++i) {
builder.append(i).append("#").append(itemStackToString(inv.getContents()[i]))
.append((i == inv.getContents().length - 1) ? "" : ";");
}
return builder.toString();
}
示例4: isIventoryEmpty
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static boolean isIventoryEmpty(PlayerInventory playerInventory) {
if (isIventoryEmpty((Inventory) playerInventory)) {
for (ItemStack item : playerInventory.getArmorContents()) {
if (item != null && item.getType() != Material.AIR) {
return false;
}
}
}
return true;
}
示例5: onPlayerShoot
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerShoot(EntityDamageByEntityEvent evt) {
Player damager = null;
if (evt.getDamager() instanceof Arrow) {
Arrow arrow = (Arrow)evt.getDamager();
if (arrow.getShooter() instanceof Player) {
damager = (Player)arrow.getShooter();
}
}
if (damager != null) {// && perkService.playerHasPerk((Player)damager, ArcherTree.LeatherExpertId)) {
PlayerInventory inventory = damager.getInventory();
ItemStack[] armorContents = inventory.getArmorContents();
double damageBoost = 1;
for(ItemStack armor : armorContents) {
if (armor.getType().equals(Material.LEATHER_BOOTS)) {
damageBoost += 0.10;
} else if (armor.getType().equals(Material.LEATHER_CHESTPLATE)) {
damageBoost += 0.10;
} else if (armor.getType().equals(Material.LEATHER_HELMET)) {
damageBoost += 0.10;
} else if (armor.getType().equals(Material.LEATHER_LEGGINGS)) {
damageBoost += 0.10;
}
}
if (damageBoost == 0.4) {
damageBoost = 0.5;
}
int baseDamage = evt.getDamage();
int finalDamage = (int) (baseDamage * damageBoost);
evt.setDamage(finalDamage);
}
}
示例6: getRegenerationInterval
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
private long getRegenerationInterval(Player p)
{
long regenerationInterval = 12000; // Base is 10 seconds
PlayerInventory inventory = p.getInventory();
ItemStack[] armorContents = inventory.getArmorContents();
for(ItemStack armor : armorContents)
{
if (armor.getType().equals(Material.GOLD_BOOTS))
{
regenerationInterval -= 2000;
}
else if (armor.getType().equals(Material.GOLD_CHESTPLATE))
{
regenerationInterval -= 2000;
}
else if (armor.getType().equals(Material.GOLD_HELMET))
{
regenerationInterval -= 2000;
}
else if (armor.getType().equals(Material.GOLD_LEGGINGS))
{
regenerationInterval -= 2000;
}
}
// Should be 4 seconds if all 4 gold pieces
return regenerationInterval;
}
示例7: 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);
}
示例8: 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);
}
示例9: enchantArmor
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static PlayerInventory enchantArmor(PlayerInventory inv, Object[]... enchObjs)
{
ItemStack[] armor = inv.getArmorContents();
for (int i = 0; i < 4; i++)
enchantItem(armor[i], enchObjs);
return inv;
}
示例10: 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);
}
示例11: checkPvpProtectionNeeded
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public void checkPvpProtectionNeeded(Player player)
{
//if anti spawn camping feature is not enabled, do nothing
if(!this.config_pvp_protectFreshSpawns) return;
//if pvp is disabled, do nothing
if(!this.config_pvp_enabledWorlds.contains(player.getWorld())) return;
//if player is in creative mode, do nothing
if(player.getGameMode() == GameMode.CREATIVE) return;
//if the player has the damage any player permission enabled, do nothing
if(player.hasPermission("griefprevention.nopvpimmunity")) return;
//check inventory for well, anything
PlayerInventory inventory = player.getInventory();
ItemStack [] armorStacks = inventory.getArmorContents();
//check armor slots, stop if any items are found
for(int i = 0; i < armorStacks.length; i++)
{
if(!(armorStacks[i] == null || armorStacks[i].getType() == Material.AIR)) return;
}
//check other slots, stop if any items are found
ItemStack [] generalStacks = inventory.getContents();
for(int i = 0; i < generalStacks.length; i++)
{
if(!(generalStacks[i] == null || generalStacks[i].getType() == Material.AIR)) return;
}
//otherwise, apply immunity
PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
playerData.pvpImmune = true;
//inform the player
GriefPrevention.sendMessage(player, TextMode.Success, Messages.PvPImmunityStart);
}
示例12: repairAll
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
* Repair all repairable items in an inventory. If the inventory
* is a {@link org.bukkit.inventory.PlayerInventory}, the armor contents are also
* repaired.
*
* @param inventory The inventory with items to repair.
*/
public static void repairAll(Inventory inventory) {
PreCon.notNull(inventory);
ItemStack[] contents = inventory.getContents();
repairAll(contents);
if (inventory instanceof PlayerInventory) {
PlayerInventory playerInventory = (PlayerInventory)inventory;
ItemStack[] armor = playerInventory.getArmorContents();
repairAll(armor);
}
}
示例13: PlayerBackup
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public PlayerBackup(PlayerInventory inv, float exp, int level) {
this.items = inv.getContents();
this.armorItems = inv.getArmorContents();
this.exp = exp;
this.level = level;
}
示例14: fromPlayerInventory
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
public static PlayerInv fromPlayerInventory(PlayerInventory inv) {
return new PlayerInv(inv.getContents(), inv.getArmorContents());
}