Esempio n. 1
0
 private void dropItem(ItemStack itemStack, List<ItemStack> itemDrops) {
   if (itemStack == null) {
     plugin.logDebug("Ignoring null item");
     return;
   }
   plugin.logDebug("Dropping item " + itemStack.getType());
   itemDrops.add(itemStack.clone());
   itemStack.setAmount(0);
 }
Esempio n. 2
0
 public void enable(Player player) {
   if (hasRestoration(player)) {
     Restoration restoration = getRestoration(player);
     restoration.enabled = true;
     plugin.logDebug("Enabling: " + player.getName());
   } else {
     plugin.logDebug("Not enabling: " + player.getName());
   }
 }
Esempio n. 3
0
 public void addRestoration(Player player, Restoration restoration) {
   UUID uuid = player.getUniqueId();
   if (multipleInventories()) {
     String keyName = uuid + "." + getWorldGroups(player);
     RESTORATIONS.put(keyName, restoration);
     plugin.logDebug("Adding: " + player.getDisplayName() + ":" + keyName);
   } else {
     RESTORATIONS.put(uuid.toString(), restoration);
     plugin.logDebug("Adding: " + player.getDisplayName() + ":" + uuid);
   }
 }
Esempio n. 4
0
 private void checkSingleItemDrops(Player player, ItemStack itemStack, List<ItemStack> itemDrops) {
   plugin.logDebug("checkSingleItemDrops()");
   if (itemStack instanceof ItemStack && !itemStack.getType().equals(Material.AIR)) {
     String itemType = itemStack.getType().name();
     if (checkSingleItemDrop(player, itemStack)) {
       plugin.logDebug("[sd]Dropping item: " + itemType);
       dropItem(itemStack, itemDrops);
     } else {
       plugin.logDebug("[sd]Keeping item: " + itemType);
     }
   }
 }
Esempio n. 5
0
 private void checkChanceToDropItems(ItemStack itemStack, List<ItemStack> itemDrops) {
   if (itemStack instanceof ItemStack && !itemStack.getType().equals(Material.AIR)) {
     Random randomGenerator = new Random();
     int randomInt = randomGenerator.nextInt(plugin.config.chanceToDrop()) + 1;
     plugin.logDebug("Random number is " + randomInt);
     if (randomInt == plugin.config.chanceToDrop()) {
       plugin.logDebug("Randomly dropping item " + itemStack.getType());
       dropItem(itemStack, itemDrops);
     } else {
       plugin.logDebug("Randomly keeping item " + itemStack.getType());
     }
   }
 }
Esempio n. 6
0
 private void checkSlots(
     Player player, String invType, ItemStack itemStack, List<ItemStack> itemDrops, int slot) {
   String itemType;
   if (itemStack != null) {
     itemType = itemStack.getType().name();
   } else {
     itemType = "NULL";
   }
   if (!checkSlot(player, invType, slot, itemType)) {
     plugin.logDebug("[cs]Dropping slot " + slot + ": " + itemType);
     dropItem(itemStack, itemDrops);
   } else {
     plugin.logDebug("[cs]Keeping slot " + slot + ": " + itemType);
   }
 }
Esempio n. 7
0
 private void checkSingleItemKeeps(
     Player player, String invType, ItemStack[] itemStackArray, List<ItemStack> itemDrops) {
   plugin.logDebug("checkSingleItemKeeps(" + invType + ")");
   for (int slot = 0; slot < itemStackArray.length; slot++) {
     checkSingleItemKeeps(player, invType, itemStackArray[slot], itemDrops, slot);
   }
 }
Esempio n. 8
0
 private void checkSingleItemDrops(
     Player player, ItemStack[] itemStackArray, List<ItemStack> itemDrops) {
   plugin.logDebug("checkSingleItemDrops()");
   for (ItemStack itemStack : itemStackArray) {
     checkSingleItemDrops(player, itemStack, itemDrops);
   }
 }
Esempio n. 9
0
 private void checkSingleItemKeeps(
     Player player, String invType, ItemStack itemStack, List<ItemStack> itemDrops, int slot) {
   plugin.logDebug("checkSingleItemKeeps(" + invType + ")");
   if (itemStack instanceof ItemStack && !itemStack.getType().equals(Material.AIR)) {
     String itemType = itemStack.getType().name();
     if (checkSingleItemKeep(player, itemStack)) {
       plugin.logDebug("[sk]Keeping item: " + itemType);
       return;
     }
     if (plugin.config.slotBasedRecovery() && plugin.config.useTheOrMethod()) {
       if (checkSlot(player, invType, slot, itemType)) {
         plugin.logDebug("[cs]Keeping item: " + itemType);
         return;
       }
     }
     plugin.logDebug("[sk]Dropping item: " + itemType);
     dropItem(itemStack, itemDrops);
   }
 }
Esempio n. 10
0
 public Restoration getRestoration(Player player) {
   UUID uuid = player.getUniqueId();
   Restoration restoration = new Restoration();
   restoration.enabled = false;
   if (multipleInventories()) {
     String keyName = uuid + "." + getWorldGroups(player);
     if (RESTORATIONS.containsKey(keyName)) {
       plugin.logDebug("Getting: " + keyName);
       restoration = RESTORATIONS.get(keyName);
     }
   }
   if (!restoration.enabled) {
     String keyName = player.getUniqueId().toString();
     if (RESTORATIONS.containsKey(keyName)) {
       plugin.logDebug("Getting: " + keyName + ":" + player.getName());
       restoration = RESTORATIONS.get(keyName);
     }
   }
   return restoration;
 }
Esempio n. 11
0
  public String getWorldGroups(Player player) {
    World world = player.getWorld();
    List<String> returnData = new ArrayList<>();

    if (plugin.getXInventories() != null) {
      Main xInventories = plugin.getXInventories();
      String xGroup = xInventories.getConfig().getString("worlds." + world.getName());
      plugin.logDebug("xGroup: " + xGroup);
      if (xGroup != null) {
        returnData.add(xGroup);
      }
    }

    if (plugin.getMultiInvAPI() != null) {
      String worldname = world.getName();
      MultiInvAPI multiInvAPI = plugin.getMultiInvAPI();
      if (multiInvAPI.getGroups() != null) {
        if (multiInvAPI.getGroups().containsKey(worldname)) {
          returnData.add(multiInvAPI.getGroups().get(worldname));
        }
      }
    }
    if (plugin.getWorldInvAPI()) {
      String worldname = world.getName();
      try {
        returnData.add(WorldInventoriesAPI.findGroup(worldname).getName());
      } catch (Exception ex) {
      }
    }
    if (plugin.myWorldsHook != null) {
      if (plugin.myWorldsHook.isEnabled()) {
        returnData.add(plugin.myWorldsHook.getLocationName(player.getLocation()));
      }
    }
    try {
      if (plugin.getMultiverseGroupManager() != null) {
        if (plugin.getMultiverseGroupManager().hasGroup(world.getName())) {
          for (WorldGroupProfile wgp :
              plugin.getMultiverseGroupManager().getGroupsForWorld(world.getName())) {
            returnData.add(wgp.getName());
          }
        }
      }
    } catch (Exception ex) {
      plugin.logError(ex.getMessage());
    }
    if (plugin.pwiHook != null) {
      returnData.add(plugin.pwiHook.getLocationName(world.getName()));
    }
    if (returnData.isEmpty()) {
      returnData.add("");
    }
    return returnData.get(0);
  }
Esempio n. 12
0
 public void removeRestoration(Player player) {
   UUID uuid = player.getUniqueId();
   if (multipleInventories()) {
     String keyName = uuid + "." + getWorldGroups(player);
     if (RESTORATIONS.containsKey(keyName)) {
       RESTORATIONS.remove(keyName);
       plugin.logDebug("Removing: " + keyName);
     }
   }
   removeRestoration(uuid);
 }
Esempio n. 13
0
 public void save() {
   HashMap<String, RestorationObject> restorationsForDisk = new HashMap<>();
   for (Map.Entry<String, Restoration> entry : RESTORATIONS.entrySet()) {
     String key = entry.getKey();
     Restoration value = entry.getValue();
     RestorationObject tmpRestoration = new RestorationObject();
     for (ItemStack i : value.inventory) {
       if (i instanceof ItemStack) {
         plugin.logDebug("Serializing inventory: " + i.toString());
         tmpRestoration.inventory.add(new ScavengerItem(i));
       }
     }
     for (ItemStack i : value.armour) {
       if (i instanceof ItemStack) {
         plugin.logDebug("Serializing armour: " + i.toString());
         tmpRestoration.armour.add(new ScavengerItem(i));
       }
     }
     if (plugin.isMc19or110()) {
       if (value.offHand instanceof ItemStack) {
         plugin.logDebug("Serializing offhand: " + value.offHand.toString());
         tmpRestoration.offHand = new ScavengerItem(value.offHand);
       }
     }
     tmpRestoration.enabled = value.enabled;
     tmpRestoration.level = value.level;
     tmpRestoration.exp = value.exp;
     tmpRestoration.playerName = value.playerName;
     restorationsForDisk.put(key, tmpRestoration);
     plugin.logInfo("Saving " + tmpRestoration.playerName + "'s inventory to disk.");
   }
   try {
     File file = new File("plugins/Scavenger/inv3.ser");
     FileOutputStream f_out = new FileOutputStream(file);
     try (ObjectOutputStream obj_out = new ObjectOutputStream(f_out)) {
       obj_out.writeObject(restorationsForDisk);
     }
   } catch (IOException e) {
     plugin.logError(e.getMessage());
   }
 }
Esempio n. 14
0
 private boolean checkPerms(Player player, List<String> perms) {
   String debugMessage = "[p:" + player.getName() + "]";
   boolean bool = false;
   for (String perm : perms) {
     debugMessage += " [" + perm + ":" + player.hasPermission(perm) + "]";
     if (player.hasPermission(perm)) {
       bool = true;
     }
   }
   plugin.logDebug(debugMessage);
   return bool;
 }
Esempio n. 15
0
 private boolean checkSlot(Player player, String type, int slot, String itemType) {
   final String PERM = PERM_PREFIX + type + "." + slot;
   plugin.logDebug(
       "[p:"
           + player.getName()
           + "] "
           + "["
           + PERM
           + ":"
           + player.hasPermission(PERM)
           + "] "
           + "[item:"
           + itemType
           + "]");
   return (player.hasPermission(PERM));
 }
Esempio n. 16
0
  public void restore(Player player) {
    if (!player.isOnline()) {
      plugin.logDebug("Player " + player.getName() + " is offline. Skipping restore...");
      return;
    }

    Restoration restoration = getRestoration(player);

    if (restoration.enabled) {
      player.getInventory().clear();

      player.getInventory().setContents(restoration.inventory);
      player.getInventory().setArmorContents(restoration.armour);
      if (plugin.isMc19or110()) {
        player.getInventory().setItemInOffHand(restoration.offHand);
      }
      if (player.hasPermission(PERM_LEVEL)
          || !plugin.config.permsEnabled()
          || (player.isOp() && plugin.config.opsAllPerms())) {
        plugin.logDebug("Player " + player.getName() + " does have " + PERM_LEVEL + " permission.");
        player.setLevel(restoration.level);
        plugin.logDebug("Player " + player.getName() + " gets " + restoration.level + " level.");
      } else {
        plugin.logDebug(
            "Player " + player.getName() + " does NOT have " + PERM_LEVEL + " permission.");
      }
      if (player.hasPermission(PERM_EXP)
          || !plugin.config.permsEnabled()
          || (player.isOp() && plugin.config.opsAllPerms())) {
        plugin.logDebug("Player " + player.getName() + " does have " + PERM_EXP + " permission.");
        player.setExp(restoration.exp);
        plugin.logDebug("Player " + player.getName() + " gets " + restoration.exp + " XP.");
      } else {
        plugin.logDebug(
            "Player " + player.getName() + " does NOT have " + PERM_EXP + " permission.");
      }
      if (plugin.config.shouldNotify()) {
        plugin.message(player, plugin.config.msgRecovered());
      }
      removeRestoration(player);
      if (hasRestoration(player)) {
        plugin.message(player, "Restore exists!!!");
      }
    }
  }
Esempio n. 17
0
  public void load() {
    Map<String, RestorationObject> restorationsFromDisk;
    File file = new File("plugins/Scavenger/inv3.ser");
    if (!file.exists()) {
      plugin.logDebug("Recovery file '" + file.getAbsolutePath() + "' does not exist.");
      return;
    }
    try {
      FileInputStream f_in = new FileInputStream(file);
      try (ObjectInputStream obj_in = new ObjectInputStream(f_in)) {
        restorationsFromDisk = (Map<String, RestorationObject>) obj_in.readObject();
      }
    } catch (IOException | ClassNotFoundException | ClassCastException e) {
      plugin.logError(e.getMessage());
      return;
    }

    for (Map.Entry<String, RestorationObject> entry : restorationsFromDisk.entrySet()) {
      String key = entry.getKey();
      RestorationObject value = entry.getValue();
      Restoration tmpRestoration = new Restoration();
      tmpRestoration.inventory = new ItemStack[value.inventory.size()];
      tmpRestoration.armour = new ItemStack[value.armour.size()];

      for (int i = 0; i < value.inventory.size(); i++) {
        if (value.inventory.get(i) instanceof ScavengerItem) {
          boolean error = false;
          ItemStack tmpStack = new ItemStack(Material.AIR);
          plugin.logDebug("Deserializing inventory: " + value.inventory.get(i));
          try {
            tmpStack = value.inventory.get(i).getItemStack();
          } catch (Exception e) {
            plugin.logError(e.getMessage() + " => " + value.inventory.get(i));
            error = true;
          } catch (Throwable e) {
            plugin.logError(e.getMessage() + " => " + value.inventory.get(i));
            error = true;
          }
          if (tmpStack == null || error) {
            tmpRestoration.inventory[i] = new ItemStack(Material.AIR);
          } else {
            tmpRestoration.inventory[i] = tmpStack;
          }
          plugin.logDebug("Done: " + tmpRestoration.inventory[i].toString());
        }
      }

      for (int i = 0; i < value.armour.size(); i++) {
        if (value.armour.get(i) instanceof ScavengerItem) {
          ItemStack tmpStack = new ItemStack(Material.AIR);
          plugin.logDebug("Deserializing armour: " + value.armour.get(i));
          try {
            tmpStack = value.armour.get(i).getItemStack();
          } catch (Exception e) {
            plugin.logError(e.getMessage());
          }
          if (tmpStack == null) {
            tmpRestoration.armour[i] = new ItemStack(Material.AIR);
          } else {
            tmpRestoration.armour[i] = tmpStack;
          }
          plugin.logDebug("Done: " + tmpRestoration.armour[i].toString());
        }
      }

      if (plugin.isMc19or110()) {
        if (value.offHand instanceof ScavengerItem) {
          ItemStack tmpStack = new ItemStack(Material.AIR);
          plugin.logDebug("Deserializing offhand: " + value.offHand);
          try {
            tmpStack = value.offHand.getItemStack();
          } catch (Exception e) {
            plugin.logError(e.getMessage());
          }
          if (tmpStack == null) {
            tmpRestoration.offHand = new ItemStack(Material.AIR);
          } else {
            tmpRestoration.offHand = tmpStack;
          }
          plugin.logDebug("Done: " + tmpRestoration.offHand.toString());
        }
      }

      tmpRestoration.enabled = value.enabled;
      tmpRestoration.level = value.level;
      tmpRestoration.exp = value.exp;
      tmpRestoration.playerName = value.playerName;

      RESTORATIONS.put(key, tmpRestoration);
      plugin.logInfo("Loading " + tmpRestoration.playerName + "'s inventory from disk.");
    }
  }
Esempio n. 18
0
 public void removeRestoration(UUID uuid) {
   if (hasRestoration(uuid)) {
     RESTORATIONS.remove(uuid.toString());
     plugin.logDebug("Removing: " + uuid);
   }
 }
Esempio n. 19
0
  public void collect(Player player, List<ItemStack> itemDrops, EntityDeathEvent event) {
    if (itemDrops.isEmpty() && !levelAllow(player) && !expAllow(player)) {
      return;
    }

    if (plugin.config.dropOnPVPDeath() && player.getKiller() instanceof Player) {
      plugin.message(player, plugin.config.msgPVPDeath());
      return;
    }

    if (plugin.config.residence()) {
      ClaimedResidence res = Residence.getResidenceManager().getByLoc(player.getLocation());
      if (res != null) {
        ResidencePermissions perms = res.getPermissions();
        if (perms.playerHas(player.getName(), plugin.config.resFlag(), true)) {
          plugin.logDebug(
              "Player '"
                  + player.getName()
                  + "' is not allowed to use Scavenger in this residence. Items will be dropped.");
          plugin.message(player, plugin.config.msgInsideRes());
          return;
        } else {
          plugin.logDebug(
              "Player '" + player.getName() + "' is allowed to use Scavenger in this residence.");
        }
      }
    }

    if (plugin.config.factionEnemyDrops() && plugin.factionHook != null) {
      if (plugin.factionHook.isPlayerInEnemyFaction(player)) {
        return;
      }
    }

    if (plugin.config.dungeonMazeDrops() && plugin.dmHook != null) {
      plugin.logDebug("Checking if '" + player.getName() + "' is in DungeonMaze.");
      if (plugin.dmHook.isPlayerInDungeon(player)) {
        plugin.logDebug("Player '" + player.getName() + "' is in DungeonMaze.");
        plugin.message(player, plugin.config.msgInsideDungeonMaze());
        return;
      }
    }

    if (plugin.getWorldGuard() != null) {
      plugin.logDebug("Checking region support for '" + player.getWorld().getName() + "'");
      if (plugin.getWorldGuard().getRegionManager(player.getWorld()) != null) {
        try {
          RegionManager regionManager = plugin.getWorldGuard().getRegionManager(player.getWorld());
          ApplicableRegionSet set = regionManager.getApplicableRegions(player.getLocation());
          if (set.allows(DefaultFlag.PVP) && plugin.config.wgPVPIgnore()) {
            plugin.logDebug(
                "This is a WorldGuard PVP zone and WorldGuardPVPIgnore is "
                    + plugin.config.wgPVPIgnore());
            if (!plugin.config.msgInsideWGPVP().isEmpty()) {
              plugin.message(player, plugin.config.msgInsideWGPVP());
            }
            return;
          }
          if (!set.allows(DefaultFlag.PVP) && plugin.config.wgGuardPVPOnly()) {
            plugin.logDebug(
                "This is NOT a WorldGuard PVP zone and WorldGuardPVPOnly is "
                    + plugin.config.wgGuardPVPOnly());
            if (!plugin.config.msgInsideWGPVP().isEmpty()) {
              plugin.message(player, plugin.config.msgInsideWGPVPOnly());
            }
            return;
          }
        } catch (NullPointerException ex) {
          plugin.logDebug(ex.getMessage());
        }
      } else {
        plugin.logDebug("Region support disabled for '" + player.getWorld().getName() + "'");
      }
    }

    if (plugin.getUltimateArena() != null) {
      if (UltimateArenaAPI.hookIntoUA(plugin).isInArena(player)) {
        if (!plugin.config.msgInsideUA().isEmpty()) {
          plugin.message(player, plugin.config.msgInsideUA());
        }
        return;
      }
    }

    if (plugin.maHandler != null && plugin.maHandler.isPlayerInArena(player)) {
      if (!plugin.config.msgInsideMA().isEmpty()) {
        plugin.message(player, plugin.config.msgInsideMA());
      }
      return;
    }

    if (plugin.pvpHandler != null && !PVPArenaAPI.getArenaName(player).equals("")) {
      String x = plugin.config.msgInsidePA();
      if (!x.isEmpty()) {
        x = x.replace("%ARENA%", PVPArenaAPI.getArenaName(player));
        plugin.message(player, x);
      }
      return;
    }

    if (plugin.battleArena) {
      mc.alk.arena.objects.ArenaPlayer ap = mc.alk.arena.BattleArena.toArenaPlayer(player);
      if (ap != null) {
        Match match = BattleArena.getBAController().getMatch(ap);
        if (match != null) {
          if (match.isInMatch(ap)) {
            String x = plugin.config.msgInsideBA();
            if (!x.isEmpty()) {
              plugin.message(player, x);
            }
            return;
          }
        }
      }
    }

    if (plugin.minigames != null) {
      if (plugin.minigames.playerInMinigame(player)) {
        plugin.logDebug(
            "Player '" + player.getName() + "' is in a Minigame. Not recovering items.");
        return;
      }
    }

    if (hasRestoration(player)) {
      plugin.error(player, "Restoration already exists, ignoring.");
      return;
    }

    if (plugin.getEconomy() != null
        && !(player.hasPermission(PERM_FREE) || (player.isOp() && plugin.config.opsAllPerms()))
        && plugin.config.economyEnabled()) {
      NumberFormat formatter = NumberFormat.getInstance(new Locale(plugin.config.countryCode()));
      formatter.setMaximumFractionDigits(plugin.config.decimalPlaces());
      double restoreCost = plugin.config.restoreCost();
      double withdrawAmount;
      double playerBalance = plugin.getEconomy().getBalance(player);
      double percentCost = plugin.config.percentCost();
      double minCost = plugin.config.minCost();
      double maxCost = plugin.config.maxCost();
      EconomyResponse er;
      String currency;
      if (plugin.config.percent()) {
        if (playerBalance < 0) {
          withdrawAmount = 0;
        } else {
          withdrawAmount = playerBalance * (percentCost / 100.0);
        }
        plugin.logDebug("withdrawAmount: " + withdrawAmount);
        plugin.logDebug("playeBalance: " + playerBalance);
        plugin.logDebug("percentCost: " + percentCost + "(" + (percentCost / 100.0) + ")");
        if (plugin.config.addMin()) {
          withdrawAmount = withdrawAmount + minCost;
          plugin.logDebug("withdrawAmount (addMin): " + withdrawAmount);
        } else if (withdrawAmount < minCost) {
          withdrawAmount = minCost;
        }
        if (withdrawAmount > maxCost && maxCost > 0) {
          withdrawAmount = maxCost;
        }
      } else {
        withdrawAmount = restoreCost;
      }
      er = plugin.getEconomy().withdrawPlayer(player, withdrawAmount);
      if (er.transactionSuccess()) {
        plugin.logDebug("Withdraw success!");
        if (withdrawAmount == 1) {
          currency = plugin.getEconomy().currencyNameSingular();
        } else {
          currency = plugin.getEconomy().currencyNamePlural();
        }
        String x = plugin.config.msgSaveForFee();
        if (!x.isEmpty()) {
          x = x.replace("%COST%", formatter.format(withdrawAmount));
          x = x.replace("%CURRENCY%", currency);
          plugin.message(player, x);
        }
        if (!plugin.config.depositDestination().isEmpty()) {
          plugin.logDebug("DepositDesination: " + plugin.config.depositDestination());
          if (plugin.config.depositType().equalsIgnoreCase("bank")) {
            plugin.logDebug("DepositType: BANK");
            if (plugin.getEconomy().hasBankSupport()) {
              plugin.logDebug("Bank support is enabled");
              plugin.getEconomy().bankDeposit(plugin.config.depositDestination(), withdrawAmount);
            } else {
              plugin.logDebug("Bank support is NOT enabled");
            }
          } else if (plugin.config.depositType().equalsIgnoreCase("player")) {
            plugin.logDebug("DepositType: PLAYER");
            plugin.logDebug("DepositDestination: " + plugin.config.depositDestination());
            if (plugin.getEconomy().hasAccount(plugin.config.depositDestination())) {
              plugin.logDebug("DepositDestination: VALID");
              plugin.getEconomy().depositPlayer(plugin.config.depositDestination(), withdrawAmount);
            } else {
              plugin.logDebug("DepositDestination: INVALID");
            }
          } else {
            plugin.logDebug("DepositType: INVALID");
          }
        } else {
          plugin.logDebug("No deposit destination!");
        }
      } else {
        plugin.logDebug("Withdraw fail! " + er.errorMessage);
        if (playerBalance == 1) {
          currency = plugin.getEconomy().currencyNameSingular();
        } else {
          currency = plugin.getEconomy().currencyNamePlural();
        }
        String x = plugin.config.msgNotEnoughMoney();
        if (!x.isEmpty()) {
          x = x.replace("%BALANCE%", formatter.format(playerBalance));
          x = x.replace("%COST%", formatter.format(withdrawAmount));
          x = x.replace("%CURRENCY%", currency);
          x = x.replace("%ERRORMESSAGE%", er.errorMessage);
          plugin.message(player, x);
        }
        return;
      }
    } else {
      plugin.message(player, plugin.config.msgSaving());
    }

    Restoration restoration = new Restoration();
    restoration.enabled = false;

    // temporary fix for 1.9
    restoration.inventory = Arrays.copyOfRange(player.getInventory().getContents(), 0, 36);
    restoration.armour = player.getInventory().getArmorContents();
    if (plugin.isMc19or110()) {
      restoration.offHand = player.getInventory().getItemInOffHand();
    }
    restoration.playerName = player.getDisplayName();
    itemDrops.clear();

    if (levelAllow(player)) {
      plugin.logDebug("Collecting level " + player.getLevel() + " for " + player.getName());
      restoration.level = player.getLevel();
    }
    if (expAllow(player)) {
      plugin.logDebug("Collecting exp " + player.getExp() + " for " + player.getName());
      restoration.exp = player.getExp();
      event.setDroppedExp(0);
    }

    String deathCause = "NULL";
    if (player.getLastDamageCause() != null) {
      if (player.getLastDamageCause().getCause() != null) {
        deathCause = player.getLastDamageCause().getCause().toString();
      }
    }
    String deathCausePermission = PERM_SCAVENGE_PREFIX + deathCause;
    plugin.logDebug(
        "[p:"
            + player.getName()
            + "] ["
            + PERM_SCAVENGE
            + ":"
            + player.hasPermission(PERM_SCAVENGE)
            + "]"
            + " ["
            + deathCausePermission
            + ":"
            + player.hasPermission(deathCausePermission)
            + "]");
    if (player.hasPermission(PERM_SCAVENGE) || player.hasPermission(deathCausePermission)) {
      plugin.logDebug("Permissions are okay. Time to scavenge...");
      if (plugin.config.chanceToDrop() > 0 && !player.hasPermission(PERM_NO_CHANCE)) {
        checkChanceToDropItems(restoration.armour, itemDrops);
        checkChanceToDropItems(restoration.inventory, itemDrops);
        if (plugin.isMc19or110()) {
          checkChanceToDropItems(restoration.offHand, itemDrops);
        }
      }
      if (plugin.config.singleItemDrops()) {
        checkSingleItemDrops(player, restoration.armour, itemDrops);
        checkSingleItemDrops(player, restoration.inventory, itemDrops);
        checkSingleItemDrops(player, restoration.offHand, itemDrops);
      } else if (plugin.config.singleItemKeeps()) {
        checkSingleItemKeeps(player, "armour", restoration.armour, itemDrops);
        checkSingleItemKeeps(player, "inv", restoration.inventory, itemDrops);
        if (plugin.isMc19or110()) {
          checkSingleItemKeeps(player, "offhand", restoration.offHand, itemDrops, 1);
        }
      } else if (plugin.config.slotBasedRecovery()) {
        checkSlots(player, "armour", restoration.armour, itemDrops);
        checkSlots(player, "inv", restoration.inventory, itemDrops);
        if (plugin.isMc19or110()) {
          checkSlots(player, "offhand", restoration.offHand, itemDrops, 1);
        }
      }
    } else {
      plugin.logDebug("Permissions are NOT okay. Dropping items...");
      dropItems(restoration.armour, itemDrops);
      dropItems(restoration.inventory, itemDrops);
      dropItem(restoration.offHand, itemDrops);
    }
    addRestoration(player, restoration);
  }