SHARE
TWEET

Untitled

a guest May 19th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package mystic.pack.attributes;
  2.  
  3. import java.math.RoundingMode;
  4. import java.text.DecimalFormat;
  5.  
  6. import org.bukkit.ChatColor;
  7.  
  8. import mystic.core.attributes.Attributes;
  9. import mystic.core.user.User;
  10.  
  11. public class Agility extends Attributes {
  12.  
  13.     private double MOVEMENT_SPEED = 0.005;
  14.     private double ATTACK_SPEED = 0.05;
  15.     private double DODGE_CHANCE = 0.05;
  16.  
  17.     public Agility() {
  18.         init();
  19.     }
  20.  
  21.     @Override
  22.     public void applyEffect(User u, boolean f) {
  23.         u.addMovementSpeed((float) (f ? MOVEMENT_SPEED * LEVEL : MOVEMENT_SPEED));
  24.         u.addAttackSpeed(f ? ATTACK_SPEED * LEVEL : ATTACK_SPEED);
  25.         u.addDodgeChance(f ? DODGE_CHANCE * LEVEL : DODGE_CHANCE);
  26.     }
  27.  
  28.     @Override
  29.     public void save() {
  30.         getConfig().set("Agility.Movement_Speed_Per_Level", MOVEMENT_SPEED);
  31.         getConfig().set("Agility.Attack_Speed_Per_Level", ATTACK_SPEED);
  32.         getConfig().set("Agility.Dodge_Chance_Per_level", DODGE_CHANCE);
  33.         saveConfig();
  34.     }
  35.  
  36.     @Override
  37.     public void init() {
  38.         if (getConfig().get("Agility") == null)
  39.             save();
  40.         this.MOVEMENT_SPEED = getConfig().getDouble("Agility.Movement_Speed_Per_Level", 0.005);
  41.         this.ATTACK_SPEED = getConfig().getDouble("Agility.Attack_Speed_Per_Level", 0.05);
  42.         this.DODGE_CHANCE = getConfig().getDouble("Agility.Dodge_Chance_Per_level", 0.05);
  43.         for (int i = 1; i <= 50; i++) {
  44.             LEVEL_EXP.put(i, 100);
  45.         }
  46.     }
  47.  
  48.     @Override
  49.     public StringBuilder getInfo() {
  50.         StringBuilder ss = new StringBuilder();
  51.         DecimalFormat numberFormat = new DecimalFormat("#.##");
  52.         numberFormat.setRoundingMode(RoundingMode.CEILING);
  53.         ss.append(ChatColor.GREEN + "➡ Movement Speed: +" + numberFormat.format(MOVEMENT_SPEED * LEVEL) + "\n")
  54.                 .append(ChatColor.GREEN + "➡ Attack Speed: -" + ATTACK_SPEED * LEVEL + "\n")
  55.                 .append(ChatColor.GREEN + "➡ Dodge Chance: +" + numberFormat.format(DODGE_CHANCE * LEVEL) + "%\n\n")
  56.                 .append(proggres());
  57.         return ss;
  58.     }
  59.  
  60.     @Override
  61.     public int getMaxLevel() {
  62.         return 50;
  63.     }
  64.  
  65. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top