RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
DropItemLogEvent.java
1package com.osroyale.game.event.impl.log;
2
3import com.jcabi.jdbc.JdbcSession;
4import com.jcabi.jdbc.SingleOutcome;
5import com.osroyale.game.service.PostgreService;
6import com.osroyale.game.world.entity.mob.player.Player;
7import com.osroyale.game.world.items.ground.GroundItem;
8
31
32public class DropItemLogEvent extends LogEvent {
33 private final Player player;
34 private final GroundItem groundItem;
35
36 public DropItemLogEvent(Player player, GroundItem groundItem) {
37 this.player = player;
38 this.groundItem = groundItem;
39 }
40
41 @Override
42 public void onLog() throws Exception {
43 if ((groundItem.item.getValue() * groundItem.item.getAmount()) < 250_000) {
44 return;
45 }
46
47 final JdbcSession session = new JdbcSession(PostgreService.getConnectionPool());
48 long logId = session.autocommit(false)
49 .sql("INSERT INTO log.log(log_time) VALUES (?::timestamp) RETURNING id")
50 .set(dateTime)
51 .insert(new SingleOutcome<>(Long.class));
52
53 session.sql("INSERT INTO log.drop_item_log(player_id, item_id, item_amount, log_id) VALUES (?, ?, ?, ?)")
54 .set(player.getMemberId())
55 .set(groundItem.item.getId())
56 .set(groundItem.item.getAmount())
57 .set(logId)
58 .execute()
59 .commit();
60 }
61
62}