public PlayerState(final Player player) {
    name = player.getName();
    debug.i("creating PlayerState of " + name, player);

    fireticks = player.getFireTicks();
    foodlevel = player.getFoodLevel();
    gamemode = player.getGameMode().getValue();
    health = player.getHealth();
    maxhealth = player.getMaxHealth();

    exhaustion = player.getExhaustion();
    experience = player.getExp();
    explevel = player.getLevel();
    saturation = player.getSaturation();

    potionEffects = player.getActivePotionEffects();

    flying = player.isFlying();

    final ArenaPlayer aPlayer = ArenaPlayer.parsePlayer(player.getName());
    final Arena arena = aPlayer.getArena();

    if (arena.getArenaConfig().getBoolean(CFG.CHAT_COLORNICK)) {
      displayname = player.getDisplayName();
    }

    fullReset(arena, player);
    final int time = arena.getArenaConfig().getInt(CFG.GENERAL_TIME);
    if (time != -1) {
      player.setPlayerTime(time, false);
    }
  }
Exemple #2
0
  public void reply(Player target, CommandSender commandSender) {
    UserStatus userStatus = new UserStatus();
    User essUser = plugin.essentials.getUser(target);

    // Nick
    userStatus.addRow(new UserStatusRow("Ник: ", target.getName()));
    // HP
    userStatus.addRow(
        new UserStatusRow(
            "Здоровье: ",
            target.getHealth()
                + "/"
                + target.getMaxHealth()
                + " ( +"
                + target.getFoodLevel()
                + " насыщение )"));
    // XP
    userStatus.addRow(
        new UserStatusRow("Уровень: ", target.getExp() + "(уровень " + target.getLevel() + " )"));
    // location
    // TODO: Make output readable
    userStatus.addRow(new UserStatusRow("Местоположение: ", target.getLocation().toString()));
    // balance
    userStatus.addRow(new UserStatusRow("Баланс: ", essUser.getMoney().toString()));
    // IP
    userStatus.addRow(new UserStatusRow("IP: ", target.getAddress().toString()));
    // GameMode
    userStatus.addRow(new UserStatusRow("Игровой режим: ", target.getGameMode().name()));
    // GodMode
    userStatus.addRow(new UserStatusRow("В режиме бога: ", essUser.isGodModeEnabled()));
    // OP
    userStatus.addRow(new UserStatusRow("OP: ", target.isOp()));
    // Fly
    userStatus.addRow(new UserStatusRow("Летает: ", target.isFlying()));
    // AFK
    userStatus.addRow(new UserStatusRow("AFK: ", essUser.isAfk()));
    // InJail
    userStatus.addRow(new UserStatusRow("В тюрьме: ", essUser.isJailed()));
    // InMute
    userStatus.addRow(new UserStatusRow("В муте: ", essUser.isMuted()));
    // InSasVanish
    userStatus.addRow(
        new UserStatusRow(
            "В сас ванише: ",
            ((SasVanish) plugin.sasCommandExecuter.commands.get("sasvanish")).inVanish(target)));
    // PEX
    userStatus.addRow(
        new UserStatusRow(
            "Группы: ", StringUtils.join(PermissionsEx.getUser(target).getGroupsNames(), ", ")));
    // TODO: Display only permissions added customly (not inherited from groups)
    // This commented line displays ALL the permissions of a player
    //        userStatus.addRow(new UserStatusRow("Пермишены: ",
    // StringUtils.join(PermissionsEx.getUser(target).getPermissions(target.getWorld().getName()),
    // ", ")));

    userStatus.send(commandSender);
  }
	@SuppressWarnings("deprecation")
	public void saveState() {
		bukkitPlayer.setGameMode(GameMode.SURVIVAL);//Set to survival
		
		//Define player states variables
		ItemStack[] contents = bukkitPlayer.getInventory().getContents();
		
		ItemStack helmet = bukkitPlayer.getInventory().getHelmet();
		ItemStack chestplate = bukkitPlayer.getInventory().getChestplate();
		ItemStack leggings = bukkitPlayer.getInventory().getLeggings();
		ItemStack boots = bukkitPlayer.getInventory().getBoots();
		
		float exhaustion = bukkitPlayer.getExhaustion();
		float saturation = bukkitPlayer.getSaturation();
		
		int foodLevel = bukkitPlayer.getFoodLevel();
		double health = bukkitPlayer.getHealth();
		
		GameMode gm = bukkitPlayer.getGameMode();
		Collection<PotionEffect> potionEffects = bukkitPlayer.getActivePotionEffects();
		
		float exp = bukkitPlayer.getExp();
		int level = bukkitPlayer.getLevel();
		
		boolean fly = bukkitPlayer.getAllowFlight();
		
		//Save state
		state = new PlayerState(contents, helmet, chestplate, leggings, boots, exhaustion, saturation, foodLevel, health, gm, potionEffects, exp, level, fly);
		
		//Set to default state
		bukkitPlayer.setFoodLevel(20);
		bukkitPlayer.setHealth(20.0);
		bukkitPlayer.setAllowFlight(false);//Disable fly mode (Essentials etc.)
		bukkitPlayer.setFireTicks(0);
		bukkitPlayer.getInventory().clear();
		bukkitPlayer.getInventory().setArmorContents(new ItemStack[4]);
		bukkitPlayer.setLevel(0);
		bukkitPlayer.setExp(0);
		
		for (PotionEffect effect : bukkitPlayer.getActivePotionEffects()) {
			bukkitPlayer.removePotionEffect(effect.getType());
		}
		
		bukkitPlayer.sendMessage(I18N._("stateSaved"));
		bukkitPlayer.updateInventory();
	}
Exemple #4
0
  public void addPlayer() {
    spawnBack = player.getLocation().clone().add(0.5D, 0.5D, 0.5D);
    health = player.getHealth();
    hunger = player.getFoodLevel();
    setInventory(player.getInventory().getContents());
    gamemode = player.getGameMode();
    xpAmount = player.getExp();

    /** Clear all of this * */
    player.setHealth(20.0);
    player.setFoodLevel(20);
    player.getInventory().clear();
    player.getInventory().setHelmet(null);
    player.getInventory().setChestplate(null);
    player.getInventory().setLeggings(null);
    player.getInventory().setBoots(null);
    player.setGameMode(GameMode.SURVIVAL);
    player.setExp(0);
    player.setLevel(0);
  }
 private void saveInventory(Player p, Inventory i, World w) {
   if (!Config.separateInv) return;
   String group = getWorldGroup(w);
   if (group == null) return;
   PlayerConfiguration pcm = PlayerConfigurationManager.getConfiguration(p);
   for (int slot = 0; slot < i.getSize(); slot++) {
     pcm.set("inventory." + group + ".slot." + slot, i.getItem(slot));
   }
   if (i instanceof PlayerInventory) {
     PlayerInventory pi = (PlayerInventory) i;
     pcm.set("inventory." + group + ".slot.helm", pi.getHelmet());
     pcm.set("inventory." + group + ".slot.chestplate", pi.getChestplate());
     pcm.set("inventory." + group + ".slot.leggings", pi.getLeggings());
     pcm.set("inventory." + group + ".slot.boots", pi.getBoots());
   }
   pcm.set("inventory." + group + ".size", i.getSize());
   if (Config.separateXP) {
     pcm.set("inventory." + group + ".xp", p.getExp());
     pcm.set("inventory." + group + ".xplevel", p.getLevel());
   }
 }
  public static void saveInventory(Player player) {
    armourContents.put(player.getName(), player.getInventory().getArmorContents());
    inventoryContents.put(player.getName(), player.getInventory().getContents());
    locations.put(player.getName(), player.getLocation());
    xp.put(player.getName(), Float.valueOf(player.getExp()));
    xpLevel.put(player.getName(), Integer.valueOf(player.getLevel()));
    gameModes.put(player.getName(), player.getGameMode());
    potions.put(player.getName(), player.getActivePotionEffects());
    foodLevel.put(player.getName(), Integer.valueOf(player.getFoodLevel()));
    Health.put(player.getName(), Double.valueOf(player.getHealth()));
    flight.put(player.getName(), Boolean.valueOf(player.getAllowFlight()));

    player.setAllowFlight(false);
    player.setHealth(20.0D);
    player.setFoodLevel(20);
    for (PotionEffect effect : player.getActivePotionEffects()) {
      player.removePotionEffect(effect.getType());
    }
    player.getInventory().clear();
    player.setLevel(0);
    player.setExp(0.0F);
    player.setGameMode(GameMode.SURVIVAL);
  }
 public void cmdCollect(Player player) {
   if (player.hasPermission(PERM_SAVE_INV)) {
     if (plugin.config.shouldNotify()) {
       plugin.message(player, plugin.config.msgSaving());
     }
     Restoration restoration = new Restoration();
     restoration.enabled = false;
     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();
     restoration.level = player.getLevel();
     restoration.exp = player.getExp();
     player.setLevel(0);
     player.setExp(0f);
     player.getInventory().clear();
     addRestoration(player, restoration);
   } else {
     plugin.message(player, plugin.config.msgNoPerm());
   }
 }
 @Override
 public float getExp() {
   return caller.getExp();
 }
Exemple #9
0
  public static void playerJoinArena(Player player, String arenaname) {
    boolean found = false;
    boolean alreadyJoined = false;
    for (Arena arena : W.arenaList) {
      if (arena.playersInArena != null) {
        if (arena.playersInArena.contains(player)) {
          alreadyJoined = true;
        }
      }
    }

    if (!alreadyJoined) {
      for (Arena arena : W.arenaList) {
        if (arena.arenaName.equalsIgnoreCase(arenaname)) {
          found = true;
          if (arena.disguiseBlocks.isEmpty()) {
            MessageM.sendFMessage(player, ConfigC.error_joinNoBlocksSet, true);
          } else {
            LocationSerializable zero =
                new LocationSerializable(Bukkit.getWorld("world"), 0, 0, 0, 0, 0);
            if (arena.lobbyWarp != null && arena.hidersWarp != null && arena.seekersWarp != null) {
              if (!arena.lobbyWarp.equals(zero)
                  && !arena.hidersWarp.equals(zero)
                  && !arena.seekersWarp.equals(zero)) {
                if (arena.gameState == ArenaState.WAITING
                    || arena.gameState == ArenaState.STARTING) {
                  if (arena.playersInArena.size() >= arena.maxPlayers) {
                    if (!PlayerM.hasPerm(player, PermsC.joinfull, false)) {
                      MessageM.sendFMessage(player, ConfigC.error_joinFull, true);
                      return;
                    }
                  }
                  arena.playersInArena.add(player);

                  W.pLocation.put(player, player.getLocation());
                  W.pGameMode.put(player, player.getGameMode());

                  player.teleport(arena.lobbyWarp);
                  player.setGameMode(GameMode.SURVIVAL);

                  W.pInventory.put(player, player.getInventory().getContents());
                  player.getInventory().clear();
                  player.updateInventory();
                  W.pArmor.put(player, player.getInventory().getArmorContents());
                  player.getInventory().setHelmet(new ItemStack(Material.AIR));
                  player.getInventory().setChestplate(new ItemStack(Material.AIR));
                  player.getInventory().setLeggings(new ItemStack(Material.AIR));
                  player.getInventory().setBoots(new ItemStack(Material.AIR));
                  W.pEXP.put(player, player.getExp());
                  player.setExp(0);
                  W.pEXPL.put(player, player.getLevel());
                  player.setLevel(0);
                  W.pHealth.put(player, player.getHealth());
                  player.setHealth(20);
                  W.pFood.put(player, player.getFoodLevel());
                  player.setFoodLevel(20);

                  ArenaHandler.sendFMessage(
                      arena,
                      ConfigC.normal_joinJoinedArena,
                      true,
                      "playername-" + player.getName(),
                      "1-" + arena.playersInArena.size(),
                      "2-" + arena.maxPlayers);
                  if (arena.playersInArena.size() < arena.minPlayers) {
                    ArenaHandler.sendFMessage(
                        arena, ConfigC.warning_lobbyNeedAtleast, true, "1-" + arena.minPlayers);
                  }
                } else {
                  MessageM.sendFMessage(player, ConfigC.error_joinArenaIngame, true);
                }
              } else {
                MessageM.sendFMessage(player, ConfigC.error_joinWarpsNotSet, true);
              }
            } else {
              MessageM.sendFMessage(player, ConfigC.error_joinWarpsNotSet, true);
            }
          }
        }
      }
    } else {
      MessageM.sendFMessage(player, ConfigC.error_joinAlreadyJoined, true);
      return;
    }

    if (!found) {
      MessageM.sendFMessage(player, ConfigC.error_noArena, true, "name-" + arenaname);
    }

    SignsHandler.updateSigns();
  }
Exemple #10
0
  public void endDuel(BukkitDuel plugin, boolean initiatorWins) {
    this.isActive = false;
    this.arena.setInUse(false);
    this.initiator.teleport(initiatorOriginalPosition);
    this.challengee.teleport(challengeeOriginalPosition);

    this.initiator.setHealth(20);
    this.initiator.setFoodLevel(20);
    this.challengee.setHealth(20);
    this.challengee.setFoodLevel(20);

    if (initiatorWins) {
      initiator.sendMessage(ChatColor.GREEN + "You have won the duel! Winnings are listed below:");
      if (stakesChallengee.getWagerMoneyAmount() > 0 && BukkitDuel.economy.isEnabled()) {
        BukkitDuel.economy.bankDeposit(initiator.getName(), stakesChallengee.getWagerMoneyAmount());
        initiator.sendMessage("Money: " + stakesChallengee.getWagerMoneyAmount() + " Dollars");
      }
      if (stakesChallengee.getWagerExperienceAmount() > 0) {
        // adjust for levels rather than exp amount
        initiator.setExp(initiator.getExp() + stakesChallengee.getWagerExperienceAmount());
        initiator.sendMessage("Experience: " + stakesChallengee.getWagerExperienceAmount());
        if (challengee.isOnline())
          challengee.setExp(initiator.getExp() - stakesChallengee.getWagerExperienceAmount());
      }
      if (stakesInitiator.getWagerItems().getSize() > 0) {
        for (ItemStack items : stakesInitiator.getWagerItems().getContents()) {
          initiator.getInventory().addItem(items);
        }
      }
      if (stakesChallengee.getWagerItems().getSize() > 0) {
        for (ItemStack items : stakesChallengee.getWagerItems().getContents()) {
          initiator.getInventory().addItem(items);
          initiator.sendMessage("Item: " + items.getType() + "x " + items.getAmount());
        }
      }
      if (stakesChallengee.getWagerPowerAmount() > 0) {
        // Do faction power handling here.
      }

      if (challengee.isOnline())
        challengee.sendMessage(ChatColor.GREEN + "You have lost the duel, tough luck!");
    } else {
      challengee.sendMessage(ChatColor.GREEN + "You have won the duel! Winnings are listed below:");

      if (stakesInitiator.getWagerMoneyAmount() > 0 && BukkitDuel.economy.isEnabled()) {
        BukkitDuel.economy.bankDeposit(challengee.getName(), stakesInitiator.getWagerMoneyAmount());
        challengee.sendMessage("Money: " + stakesChallengee.getWagerMoneyAmount() + " Dollars");
      }
      if (stakesInitiator.getWagerExperienceAmount() > 0) {
        // adjust for levels rather than exp amount
        challengee.setExp(initiator.getExp() + stakesInitiator.getWagerExperienceAmount());
        challengee.sendMessage("Experience: " + stakesChallengee.getWagerExperienceAmount());
        if (initiator.isOnline())
          initiator.setExp(initiator.getExp() - stakesInitiator.getWagerExperienceAmount());
      }
      if (stakesChallengee.getWagerItems().getSize() > 0) {
        for (ItemStack items : stakesChallengee.getWagerItems().getContents()) {
          challengee.getInventory().addItem(items);
        }
      }
      if (stakesInitiator.getWagerItems().getSize() > 0) {
        for (ItemStack items : stakesInitiator.getWagerItems()) {
          challengee.getInventory().addItem(items);
          challengee.sendMessage("Item: " + items.getType() + "x " + items.getAmount());
        }
      }
      if (stakesInitiator.getWagerPowerAmount() > 0) {
        // Do faction power handling here.
      }

      if (initiator.isOnline())
        initiator.sendMessage(ChatColor.GREEN + "You have lost the duel, tough luck!");
    }
  }
 /**
  * Get the player's current XP total.
  *
  * @return the player's total XP
  */
 public int getCurrentExp() {
   Player player = getPlayer();
   int lvl = player.getLevel();
   return getXpForLevel(lvl) + (int) (xpRequiredForNextLevel[lvl] * player.getExp());
 }
  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);
  }