Пример #1
0
 public RLocation getSpawn(Boolean firstjoin) {
   JsonConfig conf = new JsonConfig(UltimateFileLoader.Dspawns);
   String loc;
   Player p = r.searchPlayer(uuid);
   Boolean world = conf.contains("worlds.world." + p.getWorld().getName() + ".global");
   String world_ =
       world ? conf.getString("worlds.world." + p.getWorld().getName() + ".global") : null;
   Boolean group =
       r.getVault() != null
           && r.getVault().getPermission() != null
           && r.getVault().getPermission().getPrimaryGroup(p) != null
           && conf.contains("global.group." + r.getVault().getPermission().getPrimaryGroup(p));
   String group_ =
       r.getVault() != null
               && r.getVault().getPermission() != null
               && r.getVault().getPermission().getPrimaryGroup(p) != null
           ? (group
               ? conf.getString("global.group." + r.getVault().getPermission().getPrimaryGroup(p))
               : null)
           : null;
   Boolean gw =
       r.getVault() != null
           && r.getVault().getPermission() != null
           && r.getVault().getPermission().getPrimaryGroup(p) != null
           && conf.contains(
               "worlds.world."
                   + p.getWorld().getName()
                   + ".group."
                   + r.getVault().getPermission().getPrimaryGroup(p));
   String gw_ =
       r.getVault() != null
               && r.getVault().getPermission() != null
               && r.getVault().getPermission().getPrimaryGroup(p) != null
           ? conf.getString(
               "worlds.world."
                   + p.getWorld().getName()
                   + ".group."
                   + r.getVault().getPermission().getPrimaryGroup(p))
           : null;
   if (firstjoin && conf.contains("global.firstjoin")) {
     loc = conf.getString("global.firstjoin");
   } else if (gw) {
     loc = gw_;
   } else if (world && group) {
     if (r.getCnfg().getBoolean("Command.Spawn.WorldOrGroup")) {
       loc = world_;
     } else {
       loc = group_;
     }
   } else if (world) {
     loc = world_;
   } else if (group) {
     loc = group_;
   } else if (conf.contains("global")) {
     loc = conf.getString("global");
   } else {
     return null;
   }
   return LocationUtil.convertStringToLocation(loc);
 }
  public void revertActiveVisual(Player player) {
    if (this.visualRevertTask != null) {
      this.visualRevertTask.cancel();
    }

    if (this.visualClaimId != null) {
      Claim claim =
          GriefPrevention.instance.dataStore.getClaim(this.worldProperties, this.visualClaimId);
      if (claim != null) {
        claim.playersWatching.remove(this.playerID);
      }
    }
    this.visualClaimId = null;
    if (this.visualBlocks == null
        || !player
            .getWorld()
            .equals(this.visualBlocks.get(0).getFinal().getLocation().get().getExtent())) {
      return;
    }

    for (int i = 0; i < this.visualBlocks.size(); i++) {
      BlockSnapshot snapshot = this.visualBlocks.get(i).getOriginal();
      player.sendBlockChange(snapshot.getPosition(), snapshot.getState());
    }
  }
 public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException {
   if (src instanceof Player) {
     Player player = (Player) src;
     if (Utils.isSpawnInConfig()) {
       if (!Objects.equals(player.getWorld().getName(), Utils.getSpawnWorldName())) {
         Vector3d position =
             new Vector3d(
                 Utils.getSpawn(player).getX(),
                 Utils.getSpawn(player).getY(),
                 Utils.getSpawn(player).getZ());
         player.transferToWorld(Utils.getSpawnWorldName(), position);
         src.sendMessage(
             Texts.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Teleported to Spawn"));
         return CommandResult.success();
       } else {
         Location<World> spawn =
             new Location<>(
                 player.getWorld(),
                 Utils.getSpawn(player).getX(),
                 Utils.getSpawn(player).getY(),
                 Utils.getSpawn(player).getZ());
         player.setLocation(spawn);
       }
       src.sendMessage(
           Texts.of(TextColors.GREEN, "Success! ", TextColors.YELLOW, "Teleported to Spawn"));
     } else {
       src.sendMessage(
           Texts.of(
               TextColors.DARK_RED, "Error! ", TextColors.RED, "Spawn has not been set yet!"));
     }
   } else if (src instanceof ConsoleSource) {
     src.sendMessage(
         Texts.of(
             TextColors.DARK_RED,
             "Error! ",
             TextColors.RED,
             "Must be an in-game player to use /spawn!"));
   } else if (src instanceof CommandBlockSource) {
     src.sendMessage(
         Texts.of(
             TextColors.DARK_RED,
             "Error! ",
             TextColors.RED,
             "Must be an in-game player to use /spawn!"));
   }
   return CommandResult.success();
 }
Пример #4
0
  @Listener(order = Order.LATE)
  public void onMessageChannelEventChat(MessageChannelEvent.Chat event, @First Player player) {
    Builder playerTag = Text.builder().onHover(TextActions.showText(Text.of(player.getName())));

    Optional<PlayerTag> optionalPlayerTag = PlayerTag.get(player);

    if (!optionalPlayerTag.isPresent()) {
      playerTag.append(PlayerTag.getDefault(player));
    } else {
      playerTag.append(optionalPlayerTag.get().getTag());
    }

    Text worldTag = Text.EMPTY;

    Optional<WorldTag> optionalWorldTag = WorldTag.get(player.getWorld().getProperties());

    if (optionalWorldTag.isPresent()) {
      worldTag = optionalWorldTag.get().getTag();
    }

    Builder groupTagBuilder = Text.builder();

    for (Entry<Set<Context>, List<Subject>> parent :
        player.getSubjectData().getAllParents().entrySet()) {
      for (Subject subject : parent.getValue()) {
        String group = subject.getIdentifier();

        if (group.equalsIgnoreCase("op_0")
            || group.equalsIgnoreCase("op_1")
            || group.equalsIgnoreCase("op_2")
            || group.equalsIgnoreCase("op_3")
            || group.equalsIgnoreCase("op_4")) {
          group = "op";
        }

        Optional<GroupTag> optionalGroupTag = GroupTag.get(group);

        if (optionalGroupTag.isPresent()) {
          groupTagBuilder.append(optionalGroupTag.get().getTag());
        }
      }
    }

    MessageFormatter formatter = event.getFormatter();

    String oldStr = TextSerializers.FORMATTING_CODE.serialize(formatter.getHeader().toText());

    String name = oldStr.substring(oldStr.indexOf("<"), oldStr.lastIndexOf(">") + 1);

    Text old = TextSerializers.FORMATTING_CODE.deserialize(oldStr.replace(name, ""));

    formatter.setHeader(
        TextTemplate.of(
            worldTag, groupTagBuilder.build(), playerTag.build(), old, TextColors.RESET));
  }
Пример #5
0
  @Listener
  public void onStopped(MinigameStoppedEvent event) {
    if (event.getMinigame().equals(this)) {
      for (Player player : players()) {
        player.setScoreboard(null);

        if (this.teamAPoints > this.teamBPoints)
          player.sendMessage(
              Text.of(
                  TextColors.BLUE,
                  "[UltimateGames]: ",
                  TextColors.GREEN,
                  "Team A has won the Deathmatch!"));
        else if (this.teamBPoints > this.teamAPoints)
          player.sendMessage(
              Text.of(
                  TextColors.BLUE,
                  "[UltimateGames]: ",
                  TextColors.GREEN,
                  "Team B has won the Deathmatch!"));
        else
          player.sendMessage(
              Text.of(
                  TextColors.BLUE,
                  "[UltimateGames]: ",
                  TextColors.GRAY,
                  "The deathmatch has ended with a draw!"));

        player.sendMessage(
            Text.of(
                TextColors.BLUE, "[UltimateGames]: ", TextColors.GREEN, "Deathmatch has ended!"));

        if (player
            .getWorld()
            .getUniqueId()
            .equals(this.arena.getSpawn().getLocation().getExtent().getUniqueId())) {
          player.setLocation(this.arena.getSpawn().getLocation());
        } else {
          player.transferToWorld(
              this.arena.getSpawn().getLocation().getExtent().getUniqueId(),
              this.arena.getSpawn().getLocation().getPosition());
        }

        player.sendMessage(
            Text.of(
                TextColors.BLUE,
                "[UltimateGames]: ",
                TextColors.GREEN,
                "Teleported back to lobby."));
      }
    }
  }
Пример #6
0
  @Listener(order = Order.POST)
  public void onAffectSlotEvent(AffectSlotEvent event, @Root Player player) {
    for (SlotTransaction transaction : event.getTransactions()) {
      ItemStack itemStack = transaction.getFinal().createStack();

      BigDecimal amount = WalletDrop.getValue(itemStack);

      if (amount.compareTo(BigDecimal.ZERO) == 0) {
        continue;
      }

      WorldSettings settings = WorldSettings.get(player.getWorld());

      if (player.gameMode().get().equals(GameModes.CREATIVE) && !settings.isCreativeModeAllowed()) {
        event.setCancelled(true);
        return;
      }

      if (settings.isUsePermissions()) {
        if (!player.hasPermission("walletdrop.enable")) {
          return;
        }
      }

      WalletPickupEvent moneyPickupEvent =
          new WalletPickupEvent(itemStack, amount, Cause.of(NamedCause.source(player)));

      if (!Sponge.getEventManager().post(moneyPickupEvent)) {
        Sponge.getScheduler()
            .createTaskBuilder()
            .delayTicks(2)
            .execute(
                c -> {
                  player.getInventory().query(itemStack).clear();
                })
            .submit(Main.getPlugin());

        WalletDrop.depositOrWithdraw(player, moneyPickupEvent.getAmount());

        WalletDrop.sendPickupMessage(player, amount);
      }
    }
  }
Пример #7
0
  @Listener
  public void onInteractInventoryEvent(InteractInventoryEvent.Open event, @Root Player player) {
    if (!event.getTargetInventory().getArchetype().getId().equals("minecraft:player")) {
      WorldSettings settings = WorldSettings.get(player.getWorld());

      if (settings.isNonPlayerPickupAllowed()) {
        return;
      }

      Iterable<Inventory> iterable;

      try {
        iterable = event.getTargetInventory().slots();
      } catch (Exception e) {
        return;
      }

      for (Inventory inventory : iterable) {
        Slot slot = (Slot) inventory;

        Optional<ItemStack> optionalItemStack = slot.peek();

        if (!optionalItemStack.isPresent()) {
          continue;
        }
        ItemStack itemStack = optionalItemStack.get();

        BigDecimal amount = WalletDrop.getValue(itemStack);

        if (amount.compareTo(BigDecimal.ZERO) == 0) {
          continue;
        }

        slot.clear();
      }
    }
  }
Пример #8
0
  @Listener
  public void onStart(MinigameStartedEvent event) {
    if (event.getMinigame().equals(this)) {
      for (Player player : players()) {
        player.sendMessage(
            Text.of(
                TextColors.BLUE, "[UltimateGames]: ", TextColors.GREEN, "Deathmatch starting..."));
      }

      for (Player player : this.teamA) {
        player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
        player.setScoreboard(scoreboard);
        this.teamAScoreboardTeam.addMember(player.getTeamRepresentation());

        if (this.arena.getTeamALoadout() != null)
          UltimateGames.game
              .getCommandManager()
              .process(
                  Sponge.getServer().getConsole(),
                  "kit " + this.arena.getTeamALoadout() + " " + player.getName());

        if (player
            .getWorld()
            .getUniqueId()
            .equals(this.arena.getTeamASpawn().getLocation().getExtent().getUniqueId())) {
          player.setLocation(this.arena.getTeamASpawn().getLocation());
        } else {
          player.transferToWorld(
              this.arena.getTeamASpawn().getLocation().getExtent().getUniqueId(),
              this.arena.getTeamASpawn().getLocation().getPosition());
        }

        player.sendMessage(
            Text.of(TextColors.BLUE, "[UltimateGames]: ", TextColors.GOLD, "May the games begin!"));
      }

      for (Player player : this.teamB) {
        player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
        player.setScoreboard(scoreboard);
        this.teamBScoreboardTeam.addMember(player.getTeamRepresentation());

        if (this.arena.getTeamBLoadout() != null)
          UltimateGames.game
              .getCommandManager()
              .process(
                  Sponge.getServer().getConsole(),
                  "kit " + this.arena.getTeamBLoadout() + " " + player.getName());

        if (player
            .getWorld()
            .getUniqueId()
            .equals(this.arena.getTeamBSpawn().getLocation().getExtent().getUniqueId())) {
          player.setLocation(this.arena.getTeamBSpawn().getLocation());
        } else {
          player.transferToWorld(
              this.arena.getTeamBSpawn().getLocation().getExtent().getUniqueId(),
              this.arena.getTeamBSpawn().getLocation().getPosition());
        }

        player.sendMessage(
            Text.of(TextColors.BLUE, "[UltimateGames]: ", TextColors.GOLD, "May the games begin!"));
      }

      Scheduler scheduler = UltimateGames.game.getScheduler();
      Task.Builder taskBuilder = scheduler.createTaskBuilder();

      taskBuilder
          .execute(
              () -> {
                try {
                  Ember.unregister(this.arena);
                } catch (Exception e) {
                  System.out.println(
                      "[UltimateGames]: Error when ending deathmatch in arena " + arena.getName());
                }
              })
          .delay(this.arena.getLength(), TimeUnit.MINUTES)
          .name("UltimateGames - End Deathmatch")
          .submit(
              UltimateGames.game
                  .getPluginManager()
                  .getPlugin("io.github.hsyyid.ultimategames")
                  .get()
                  .getInstance()
                  .get());
    }
  }
  @Override
  public CommandResult execute(CommandSource src, CommandContext ctx) {
    Player player;
    try {
      player = GriefPrevention.checkPlayer(src);
    } catch (CommandException e) {
      src.sendMessage(e.getText());
      return CommandResult.success();
    }
    // which claim is being abandoned?
    PlayerData playerData =
        GriefPrevention.instance.dataStore.getOrCreatePlayerData(
            player.getWorld(), player.getUniqueId());
    Claim claim =
        GriefPrevention.instance.dataStore.getClaimAtPlayer(playerData, player.getLocation(), true);
    UUID ownerId = claim.ownerID;
    if (claim.parent != null) {
      ownerId = claim.parent.ownerID;
    }
    if (claim.isWildernessClaim()) {
      GriefPrevention.sendMessage(player, TextMode.Instr, Messages.AbandonClaimMissing);
      return CommandResult.success();
    } else if (claim.allowEdit(player) != null
        || (!claim.isAdminClaim() && !player.getUniqueId().equals(ownerId))) {
      // verify ownership
      GriefPrevention.sendMessage(player, TextMode.Err, Messages.NotYourClaim);
      return CommandResult.success();
    }

    // warn if has children and we're not explicitly deleting a top level claim
    else if (claim.children.size() > 0 && !deleteTopLevelClaim) {
      GriefPrevention.sendMessage(player, TextMode.Instr, Messages.DeleteTopLevelClaim);
      return CommandResult.empty();
    } else {
      // delete it
      claim.removeSurfaceFluids(null);
      // remove all context permissions
      player.getSubjectData().clearPermissions(ImmutableSet.of(claim.getContext()));
      GriefPrevention.GLOBAL_SUBJECT
          .getSubjectData()
          .clearPermissions(ImmutableSet.of(claim.getContext()));
      GriefPrevention.instance.dataStore.deleteClaim(claim, true);

      // if in a creative mode world, restore the claim area
      if (GriefPrevention.instance.claimModeIsActive(
          claim.getLesserBoundaryCorner().getExtent().getProperties(), ClaimsMode.Creative)) {
        GriefPrevention.addLogEntry(
            player.getName()
                + " abandoned a claim @ "
                + GriefPrevention.getfriendlyLocationString(claim.getLesserBoundaryCorner()));
        GriefPrevention.sendMessage(player, TextMode.Warn, Messages.UnclaimCleanupWarning);
        GriefPrevention.instance.restoreClaim(claim, 20L * 60 * 2);
      }

      // this prevents blocks being gained without spending adjust claim blocks when abandoning a
      // top level claim
      if (!claim.isSubdivision() && !claim.isAdminClaim()) {
        int newAccruedClaimCount =
            playerData.getAccruedClaimBlocks()
                - ((int) Math.ceil(claim.getArea() * (1 - playerData.optionAbandonReturnRatio)));
        playerData.setAccruedClaimBlocks(newAccruedClaimCount);
      }

      // tell the player how many claim blocks he has left
      int remainingBlocks = playerData.getRemainingClaimBlocks();
      GriefPrevention.sendMessage(
          player, TextMode.Success, Messages.AbandonSuccess, String.valueOf(remainingBlocks));
      // revert any current visualization
      playerData.revertActiveVisual(player);
      playerData.warnedAboutMajorDeletion = false;
    }

    return CommandResult.success();
  }
Пример #10
0
 @Subscribe
 public void onPlayerChat(PlayerChatEvent event) {
   // This is how events sort of work?
   Player player = event.getUser();
   log(player.getWorld().getName());
 }
Пример #11
0
  public CommandTicketCreate(CommandSource sender, String[] args) {

    if (sender instanceof Player == false) {
      sender.sendMessage(
          Texts.builder("Cannot be run by the console!").color(TextColors.RED).build());
      return;
    }

    if (args.length < 2) {
      sender.sendMessage(
          Texts.of(TextColors.YELLOW, "Usage: ", TextColors.GRAY, "/ticket create <message>"));
      return;
    }

    Player player = (Player) sender;
    String message = CommandUtils.combineArgs(1, args);

    int tickets = 0;
    for (Entry<Integer, CoreTicket> e : CoreDatabase.getTickets().entrySet()) {
      CoreTicket ticket = e.getValue();
      if (!ticket.getStatus().equalsIgnoreCase("open")) continue;
      if (!ticket.getUUID().equalsIgnoreCase(player.getUniqueId().toString())) continue;
      tickets += 1;
    }

    int possible = 0;
    for (int i = 1; i <= 100; i++) {
      if (PermissionsUtils.has(player, "core.ticket.create." + i)) possible = i;
    }

    if (!PermissionsUtils.has(player, "core.ticket.create-unlimited") && possible <= tickets) {
      if (possible == 1)
        sender.sendMessage(
            Texts.builder("You are only allowed to own " + possible + " open tickets!")
                .color(TextColors.RED)
                .build());
      else
        sender.sendMessage(
            Texts.builder("You are only allowed to own " + possible + " open tickets!")
                .color(TextColors.RED)
                .build());
      return;
    }

    int id = CoreDatabase.getTickets().size() + 1;

    String world = player.getWorld().getName();

    double x = player.getLocation().getX();
    double y = player.getLocation().getY();
    double z = player.getLocation().getZ();
    double yaw = player.getRotation().getX();
    double pitch = player.getRotation().getY();

    double time = System.currentTimeMillis();

    CoreTicket ticket =
        new CoreTicket(
            id,
            player.getUniqueId().toString(),
            message,
            time,
            new ArrayList<String>(),
            world,
            x,
            y,
            z,
            yaw,
            pitch,
            "",
            "medium",
            "open");
    ticket.insert();

    sender.sendMessage(
        Texts.of(
            TextColors.GRAY,
            "Ticket ",
            TextColors.GREEN,
            "#",
            id,
            TextColors.GRAY,
            " has been created!"));
  }
Пример #12
0
  @Listener
  public void PlayerMoveEvent(DisplaceEntityEvent event) {
    /*
     * Check the plugin is running.
     */
    if (!(BorderLands.isOperate())) {
      return;
    }
    /*
     * Check this movement is of a player.
     */
    if (!(event.getTargetEntity() instanceof Player)) {
      return;
    }
    locO = event.getFromTransform().getLocation();
    loc = event.getToTransform().getLocation();
    player = (Player) event.getTargetEntity();

    /*
     * Check if it's more than 1 block change for X or Z.
     */
    if ((locO.getBlockX() == loc.getBlockX()) && (locO.getBlockZ() == loc.getBlockZ())) {
      return;
    }

    DebugLog.DLog("PlayerMoveEvent");
    DebugLog.DLog("Player at: " + loc.getBlockX() + "," + loc.getBlockZ());
    DebugLog.DLog("In world:  " + player.getWorld().getName().toLowerCase());
    /*
     * For all borders.
     */
    for (String[] x : BorderLands.getBorders()) {
      /*
       * Check if the world matches.
       */
      if (!(player.getWorld().getName().toLowerCase().equals(x[0].toLowerCase()))) {
        continue;
      }
      /*
       * Check if the player is inside the border.
       */
      if (((loc.getBlockX() > (Integer.parseInt(x[1]) - Integer.parseInt(x[3])))
              && (loc.getBlockZ() > (Integer.parseInt(x[2]) - Integer.parseInt(x[4]))))
          && ((loc.getBlockX() < (Integer.parseInt(x[1]) + Integer.parseInt(x[5])))
              && (loc.getBlockZ() < (Integer.parseInt(x[2]) + Integer.parseInt(x[6]))))) {
        if (NotifiedInside.containsKey(player)) {
          if (NotifiedInside.get(player) == 0) {
            player.sendMessage(
                Texts.of(
                    TextColors.BLUE,
                    "[BorderLands]",
                    TextColors.GOLD,
                    " You are now",
                    TextColors.GREEN,
                    " inside ",
                    TextColors.GOLD,
                    "the border."));
            NotifiedInside.put(player, 1);
            Utilities.PassNotifyList.put(player, 0L);
          }
        } else {
          NotifiedInside.put(player, 1);
        }
      }
      /*
       * Check if player is above the max X value.
       */
      if (Utilities.isPostXPos(loc.getBlockX(), Integer.parseInt(x[1]), Integer.parseInt(x[5]))) {
        if (!(player.hasPermission(movePerm) || player.hasPermission("borderlands.move." + x[7]))) {
          Utilities.Notify(player);
          this.postXPosTele(player, Integer.parseInt(x[1]), Integer.parseInt(x[5]), true);
        } else {
          Utilities.PassNotify(player);
          NotifiedInside.put(player, 0);
        }
        continue;
      }
      /*
       * Check if player is below the minimum X value.
       */
      if (Utilities.isPreXNeg(loc.getBlockX(), Integer.parseInt(x[1]), Integer.parseInt(x[3]))) {
        if (!(player.hasPermission(movePerm) || player.hasPermission("borderlands.move." + x[7]))) {
          Utilities.Notify(player);
          this.postXPosTele(player, Integer.parseInt(x[1]), Integer.parseInt(x[3]), false);
        } else {
          Utilities.PassNotify(player);
          NotifiedInside.put(player, 0);
        }
        continue;
      }
      /*
       * Check if player is above the max Z value.
       */
      if (Utilities.isPostZPos(loc.getBlockZ(), Integer.parseInt(x[2]), Integer.parseInt(x[6]))) {
        if (!(player.hasPermission(movePerm) || player.hasPermission("borderlands.move." + x[7]))) {
          Utilities.Notify(player);
          this.postZPosTele(player, Integer.parseInt(x[2]), Integer.parseInt(x[6]), true);
        } else {
          Utilities.PassNotify(player);
          NotifiedInside.put(player, 0);
        }
        continue;
      }
      /*
       * Check if player is below the minimum Z value.
       */
      if (Utilities.isPreZNeg(loc.getBlockZ(), Integer.parseInt(x[2]), Integer.parseInt(x[4]))) {
        if (!(player.hasPermission(movePerm) || player.hasPermission("borderlands.move." + x[7]))) {
          Utilities.Notify(player);
          this.postZPosTele(player, Integer.parseInt(x[2]), Integer.parseInt(x[4]), false);
        } else {
          Utilities.PassNotify(player);
          NotifiedInside.put(player, 0);
        }
        continue;
      }
      continue;
    }
  }
Пример #13
0
  @Listener(order = Order.PRE)
  public void onDestructEntityEventDeathPlayer(
      DestructEntityEvent.Death event, @First EntityDamageSource damageSrc) {
    if (!(event.getTargetEntity() instanceof Player)) {
      return;
    }
    Player player = (Player) event.getTargetEntity();

    WorldSettings settings = WorldSettings.get(player.getWorld());

    DeathReason reason = DeathReason.GENERIC;

    Entity src = damageSrc.getSource();

    if (src instanceof Player) {
      reason = DeathReason.PLAYER;
    } else if (src instanceof Projectile) {
      Projectile projectile = (Projectile) src;

      Optional<UUID> optionalUUID = projectile.getCreator();

      if (!optionalUUID.isPresent()) {
        return;
      }

      Optional<Player> optionalPlayer = Sponge.getServer().getPlayer(optionalUUID.get());

      if (optionalPlayer.isPresent()) {
        reason = DeathReason.PLAYER;
      } else {
        reason = DeathReason.PROJECTILE;
      }
    } else {
      DamageType cause = damageSrc.getType();
      reason = DeathReason.valueOf(cause.getName().toUpperCase());
    }

    Optional<EconomyService> optionalEconomy =
        Sponge.getServiceManager().provide(EconomyService.class);

    if (!optionalEconomy.isPresent()) {
      Main.instance().getLog().error("Economy plugin not found");
      return;
    }
    EconomyService economy = optionalEconomy.get();

    BigDecimal balance =
        economy
            .getOrCreateAccount(player.getUniqueId())
            .get()
            .getBalance(WorldSettings.get(player.getWorld()).getCurrency());

    PlayerWallet wallet = settings.getPlayerWallet();

    BigDecimal amount = wallet.getAmount(reason, balance);

    WalletDropEvent walletDropEvent = new WalletDropEvent(amount, player);

    if (walletDropEvent.getAmount().compareTo(BigDecimal.ZERO) != 0
        && (!Sponge.getEventManager().post(walletDropEvent))) {
      WalletDrop.depositOrWithdraw(
          player, walletDropEvent.getAmount().multiply(BigDecimal.valueOf(-1)));

      if (settings.isDropsEnabled()) {
        for (MoneyStack moneyStack : walletDropEvent.getMoneyStacks()) {
          moneyStack.drop(walletDropEvent.getLocation());
        }
      }

      WalletDrop.sendDeathMessage(
          WorldSettings.get(player.getWorld()), player, walletDropEvent.getAmount());
    }
  }