Advertisement
Guest User

Untitled

a guest
Jul 15th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. public class StatCalculation {
  2.  
  3. public Consumer<PlayerStats> CalculateStats(Player player, final Consumer<PlayerStats> stats) {
  4.  
  5. PlayerInventory inv = player.getInventory();
  6.  
  7.  
  8. Bukkit.getScheduler().runTaskAsynchronously(AvarionFight.getPlugin(), new Runnable() {
  9. @Override
  10. public void run() {
  11.  
  12. ItemStack[] Content = inv.getContents();
  13. ItemStack[] Extra = inv.getExtraContents();
  14. ItemStack[] All = (ItemStack[]) ArrayUtils.addAll(Content, Extra);
  15.  
  16. PlayerStats playerStats;
  17.  
  18. double MeeleDamage = 0.0;
  19. double RangedDamage = 0.0;
  20. double Armor = 0.0;
  21. double ArmorPenetration = 0.0;
  22. double BlockChance = 0.0;
  23. double CritChance = 0.0;
  24. double CritDamage = 0.0;
  25.  
  26. for (ItemStack item : All) {
  27.  
  28. // Leere Slots und leere Lore checken
  29. if (item == null)
  30. continue;
  31. if (item.getType() == Material.AIR)
  32. continue;
  33. if (!item.hasItemMeta())
  34. continue;
  35. if (!item.getItemMeta().hasLore())
  36. continue;
  37.  
  38. for (String line : item.getItemMeta().getLore()) {
  39.  
  40. if (line.contains("Schaden")) {
  41.  
  42. MeeleDamage = MeeleDamage + Double.parseDouble(line.replaceAll("[\\D]", ""));
  43.  
  44. }
  45.  
  46. if (line.contains("Fernkampf")) {
  47.  
  48. RangedDamage = RangedDamage + Double.parseDouble(line.replaceAll("[\\D]", ""));
  49.  
  50. }
  51.  
  52. if (line.contains("Rüstung")) {
  53.  
  54. Armor = Armor + Double.parseDouble(line.replaceAll("[\\D]", ""));
  55.  
  56. }
  57.  
  58. if (line.contains("Durchdringung")) {
  59.  
  60. ArmorPenetration = ArmorPenetration + Double.parseDouble(line.replaceAll("[\\D]", ""));
  61.  
  62. }
  63.  
  64. if (line.contains("BlockChance")) {
  65.  
  66. BlockChance = BlockChance + Double.parseDouble(line.replaceAll("[\\D]", ""));
  67.  
  68. }
  69.  
  70. if (line.contains("Kritische Trefferchance")) {
  71.  
  72. CritChance = CritChance + Double.parseDouble(line.replaceAll("[\\D]", ""));
  73.  
  74. }
  75.  
  76. if (line.contains("Kritischer Zusatzschaden")) {
  77.  
  78. CritDamage = CritDamage + Double.parseDouble(line.replaceAll("[\\D]", ""));
  79.  
  80. }
  81. }
  82.  
  83. playerStats = new PlayerStats();
  84. stats.accept(playerStats);
  85.  
  86. }
  87.  
  88. }
  89. });
  90.  
  91. // Ende Async
  92.  
  93. }
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement