Home›Java›Mods›AttributeDemo
ModsJava

AttributeDemo

Java mod listed for Minecraft 1.9. Download on the author's site.

⬇ Download on Spigot
*** 1.9 ONLY ***

This is a demo plugin to show the new Attribute API in 1.9. By default it will simply change the attack speed to 4x its value (4 -> 16) to implement 1.8-esque attacking. You may simply add additional attributes to config.yml to modify them too.

Code (YAML):
GENERIC_ATTACK_SPEED : 16
Source Code:
Code (Java):
package net.md_5 ;

import org.bukkit.attribute.Attribute ;
import org.bukkit.attribute.AttributeInstance ;
import org.bukkit.event.EventHandler ;
import org.bukkit.event.Listener ;
import org.bukkit.event.player.PlayerJoinEvent ;
import org.bukkit.plugin.java.JavaPlugin ;

public class AttributeDemo extends JavaPlugin implements Listener
{

    @Override
    public void onEnable ( )
    {
        getConfig ( ). addDefault ( Attribute. GENERIC_ATTACK_SPEED. name ( ), 16 ) ;
        getConfig ( ). options ( ). copyDefaults ( true ) ;
        saveConfig ( ) ;

        getServer ( ). getPluginManager ( ). registerEvents ( this, this ) ;
    }

    @EventHandler
    public void playerJoin (PlayerJoinEvent event )
    {
        for ( String key : getConfig ( ). getKeys ( false ) )
        {
            AttributeInstance instance = event. getPlayer ( ). getAttribute ( Attribute. valueOf ( key ) ) ;
            if ( instance != null )
            {
                instance. setBaseValue ( getConfig ( ). getDouble ( key, instance. getBaseValue ( ) ) ) ;
            }
        }
    }
}
 

Plugin details

Read from the plugin's own plugin.yml.

Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

AttributeDemo is a free Minecraft Java mod. Compatible with Minecraft 1.9. Downloaded 1,206 times (via Spigot). Download it and open it directly in the game.

Explore more