Advertisement
Guest User

Untitled

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