Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class StatCalculation {
- public Consumer<PlayerStats> CalculateStats(Player player, final Consumer<PlayerStats> stats) {
- PlayerInventory inv = player.getInventory();
- Bukkit.getScheduler().runTaskAsynchronously(AvarionFight.getPlugin(), new Runnable() {
- @Override
- public void run() {
- ItemStack[] Content = inv.getContents();
- ItemStack[] Extra = inv.getExtraContents();
- ItemStack[] All = (ItemStack[]) ArrayUtils.addAll(Content, Extra);
- PlayerStats playerStats;
- double MeeleDamage = 0.0;
- double RangedDamage = 0.0;
- double Armor = 0.0;
- double ArmorPenetration = 0.0;
- double BlockChance = 0.0;
- double CritChance = 0.0;
- double CritDamage = 0.0;
- for (ItemStack item : All) {
- // Leere Slots und leere Lore checken
- if (item == null)
- continue;
- if (item.getType() == Material.AIR)
- continue;
- if (!item.hasItemMeta())
- continue;
- if (!item.getItemMeta().hasLore())
- continue;
- for (String line : item.getItemMeta().getLore()) {
- if (line.contains("Schaden")) {
- MeeleDamage = MeeleDamage + Double.parseDouble(line.replaceAll("[\\D]", ""));
- }
- if (line.contains("Fernkampf")) {
- RangedDamage = RangedDamage + Double.parseDouble(line.replaceAll("[\\D]", ""));
- }
- if (line.contains("Rüstung")) {
- Armor = Armor + Double.parseDouble(line.replaceAll("[\\D]", ""));
- }
- if (line.contains("Durchdringung")) {
- ArmorPenetration = ArmorPenetration + Double.parseDouble(line.replaceAll("[\\D]", ""));
- }
- if (line.contains("BlockChance")) {
- BlockChance = BlockChance + Double.parseDouble(line.replaceAll("[\\D]", ""));
- }
- if (line.contains("Kritische Trefferchance")) {
- CritChance = CritChance + Double.parseDouble(line.replaceAll("[\\D]", ""));
- }
- if (line.contains("Kritischer Zusatzschaden")) {
- CritDamage = CritDamage + Double.parseDouble(line.replaceAll("[\\D]", ""));
- }
- }
- playerStats = new PlayerStats();
- stats.accept(playerStats);
- }
- }
- });
- // Ende Async
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement