1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Entity Attribute API (1.9+)

Discussion in 'Addon Suggestions' started by sapphyrusxyz, Apr 16, 2017.

  1. sapphyrusxyz

    sapphyrusxyz Member

    Joined:
    Mar 29, 2017
    Messages:
    49
    Likes Received:
    8
    This is a new API that was added in Spigot 1.9 and can be used to change things like the attack speed of a player.

    Code (Java):
    1. package net.md_5;
    2.  
    3. import org.bukkit.attribute.Attribute;
    4. import org.bukkit.attribute.AttributeInstance;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerJoinEvent;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class AttributeDemo extends JavaPlugin implements Listener
    11. {
    12.  
    13.     @Override
    14.     public void onEnable()
    15.     {
    16.         getConfig().addDefault( Attribute.GENERIC_ATTACK_SPEED.name(), 16 );
    17.         getConfig().options().copyDefaults( true );
    18.         saveConfig();
    19.  
    20.         getServer().getPluginManager().registerEvents( this, this );
    21.     }
    22.  
    23.     @EventHandler
    24.     public void playerJoin(PlayerJoinEvent event)
    25.     {
    26.         for ( String key : getConfig().getKeys( false ) )
    27.         {
    28.             AttributeInstance instance = event.getPlayer().getAttribute( Attribute.valueOf( key ) );
    29.             if ( instance != null )
    30.             {
    31.                 instance.setBaseValue( getConfig().getDouble( key, instance.getBaseValue() ) );
    32.             }
    33.         }
    34.     }
    35. }
    36.  
    All possible attributes are listed here: http://minecraft.gamepedia.com/Attribute#Attributes_available_on_all_living_entities

    This probably isn't enough stuff for a single addon but I think it would fit into Skellett or skUtilities. Maybe @tim740 or @LimeGlass could add this?
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    Can this not be achieved using nbt?
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    skUtilities only has non-minecraft related stuff, and as the above guy stated, you can use NBT for it (skStuff)
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    That's great, I'll check out skStuff.. is it compatible with 1.11?
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    the above guy has a name grr :emoji_frowning: :emoji_frowning: :emoji_frowning:
     

Share This Page

Loading...