Set armor if player have got permission

Discussion in 'Plugin Development' started by mr_snake302, Mar 31, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    mr_snake302

    Hello! I need help, for simple, if player have got
    bluearmor.permission on it sets full leather armor with #344CB2
    if player have got redarmor.permission on it sets full leather armor with #994444
    if player have got yellowarmor.permisison on it sets full leather armor with #E5E533


    How I can make this?
     
  2. Offline

    Aperx

    Do you want this to happen on a command?
    Or do you want them to have it permanently?

    If you want it through a command, say /armor

    Code:java
    1. cmd.equalsIgnoreCase("armor"){
    2. if(Player.hasPermission("bluearmor.permission"){
    3. //set players armor ect ect
    4. }
    5. }
    6.  


    if you want them to have it permanetly you could use a PlayerMoveEvent, or make it so when they join their armour is set, and they cannot move it, take it off, damage it or lose it.
     
  3. Offline

    mr_snake302

    I already have got reset Inventory event and I want add setting armor))


    Code:java
    1.  
    2. @SuppressWarnings("deprecation")
    3. private void resetInventory(Player player) {
    4. player.updateInventory();
    5. }
    6.  


    You mean this?
    Code:java
    1. @SuppressWarnings("deprecation")
    2. private void resetInventory(Player player) {
    3. if(Player.hasPermission("bluearmor.permission"){
    4. player.getInventory().setArmorContents(new ItemStack[] { new ItemStack(Material.LEATHER_BOOTS, 1), new ItemStack(Material.LEATHER_LEGGINGS, 1), new ItemStack(Material.LEATHER_CHESTPLATE, 1), new ItemStack(Material.LEATHER_HELMET, 1) });
    5. }
    6. player.updateInventory();
    7. }


    But ...
    View attachment 18883

    (And how add color?)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    Aperx

    For one your player is capatilized there but you declare the player variable non-capitalized.

    with your reset method, i would suggest creating 4 itemstacks,helmet, chest, legs and boots, and setting them individually, and no need to update the inventory. If you want to clear it , just do plaer.getInventory().clear()
     
    mr_snake302 likes this.
  5. Offline

    mr_snake302

    Thank you! All works!


    Code:java
    1. if (player.hasPermission("armor.permission")){
    2.  
    3.  
    4. ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
    5. LeatherArmorMeta meta = (LeatherArmorMeta) helm.getItemMeta();
    6. meta.setColor(Color.fromRGB(100,100,100));
    7. helm.setItemMeta(meta);
    8. player.getInventory().setHelmet(helm);
    9.  
    10. }
     
Thread Status:
Not open for further replies.

Share This Page