Java Code Examples for org.bukkit.inventory.PlayerInventory#setLeggings()

The following examples show how to use org.bukkit.inventory.PlayerInventory#setLeggings() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MiscUtils.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void giveItemsToPlayer(List<ItemStack> itemStackList, Player player, TeamColor teamColor) {
    for (ItemStack itemStack : itemStackList) {
        final String materialName = itemStack.getType().toString();
        final PlayerInventory playerInventory = player.getInventory();

        if (materialName.contains("HELMET")) {
            playerInventory.setHelmet(Main.applyColor(teamColor, itemStack));
        } else if (materialName.contains("CHESTPLATE")) {
            playerInventory.setChestplate(Main.applyColor(teamColor, itemStack));
        } else if (materialName.contains("LEGGINGS")) {
            playerInventory.setLeggings(Main.applyColor(teamColor, itemStack));
        } else if (materialName.contains("BOOTS")) {
            playerInventory.setBoots(Main.applyColor(teamColor, itemStack));
        } else {
            playerInventory.addItem(Main.applyColor(teamColor, itemStack));
        }
    }
}
 
Example 2
Source File: MiscUtils.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void giveItemsToPlayer(List<ItemStack> itemStackList, Player player, TeamColor teamColor) {
    for (ItemStack itemStack : itemStackList) {
        final String materialName = itemStack.getType().toString();
        final PlayerInventory playerInventory = player.getInventory();

        if (materialName.contains("HELMET")) {
            playerInventory.setHelmet(Main.applyColor(teamColor, itemStack));
        } else if (materialName.contains("CHESTPLATE")) {
            playerInventory.setChestplate(Main.applyColor(teamColor, itemStack));
        } else if (materialName.contains("LEGGINGS")) {
            playerInventory.setLeggings(Main.applyColor(teamColor, itemStack));
        } else if (materialName.contains("BOOTS")) {
            playerInventory.setBoots(Main.applyColor(teamColor, itemStack));
        } else {
            playerInventory.addItem(Main.applyColor(teamColor, itemStack));
        }
    }
}
 
Example 3
Source File: ArmorKeep.java    From CardinalPGM with MIT License 6 votes vote down vote up
@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));
        }
    }
}
 
Example 4
Source File: ArmorKeep.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
    Player player = event.getEntity();
    PlayerInventory inventory = player.getInventory();
    Map<Integer, ItemStack> itemsToKeep = new HashMap<>();
    if (inventory.getHelmet() != null) {
        if (inventory.getHelmet().getType().equals(type) && inventory.getHelmet().getDurability() == damageValue) {
            helmet.put(player, inventory.getHelmet());
            inventory.setHelmet(null);
        }
    }
    if (inventory.getChestplate() != null) {
        if (inventory.getChestplate().getType().equals(type) && inventory.getChestplate().getDurability() == damageValue) {
            chestplate.put(player, inventory.getChestplate());
            inventory.setChestplate(null);
        }
    }
    if (inventory.getLeggings() != null) {
        if (inventory.getLeggings().getType().equals(type) && inventory.getLeggings().getDurability() == damageValue) {
            leggings.put(player, inventory.getLeggings());
            inventory.setLeggings(null);
        }
    }
    if (inventory.getBoots() != null) {
        if (inventory.getBoots().getType().equals(type) && inventory.getBoots().getDurability() == damageValue) {
            boots.put(player, inventory.getBoots());
            inventory.setBoots(null);
        }
    }
}
 
Example 5
Source File: FlagTeamLeatherArmor.java    From HeavySpleef with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onGameStart(GameStartEvent event) {
	FlagTeam flagTeam = (FlagTeam) getParent();
	Map<SpleefPlayer, TeamColor> players = flagTeam.getPlayers();
	
	for (SpleefPlayer player : event.getGame().getPlayers()) {
		if (!players.containsKey(player)) {
			continue;
		}
		
		TeamColor color = players.get(player);
		
		ItemStack leatherHelmet = LEATHER_HELMET_DATA.toItemStack(1);
		ItemStack leatherChestplate = LEATHER_CHESTPLATE_DATA.toItemStack(1);
		ItemStack leatherLeggings = LEATHER_LEGGINGS_DATA.toItemStack(1);
		ItemStack leatherBoots = LEATHER_BOOTS_DATA.toItemStack(1);
		
		LeatherArmorMeta meta = (LeatherArmorMeta) leatherHelmet.getItemMeta();
		meta.setColor(color.getRGB());
		
		leatherHelmet.setItemMeta(meta);
		leatherChestplate.setItemMeta(meta);
		leatherLeggings.setItemMeta(meta);
		leatherBoots.setItemMeta(meta);
		
		PlayerInventory inventory = player.getBukkitPlayer().getInventory();
		inventory.setHelmet(leatherHelmet);
		inventory.setChestplate(leatherChestplate);
		inventory.setLeggings(leatherLeggings);
		inventory.setBoots(leatherBoots);
	}
}