RuneHive-Game
Loading...
Searching...
No Matches
DropItemLogEvent.java
Go to the documentation of this file.
1
package
com.runehive.game.event.impl.log;
2
3
import
com.jcabi.jdbc.JdbcSession;
4
import
com.jcabi.jdbc.SingleOutcome;
5
import
com.runehive.game.service.PostgreService;
6
import
com.runehive.game.world.entity.mob.player.Player;
7
import
com.runehive.game.world.items.ground.GroundItem;
8
9
public
class
DropItemLogEvent
extends
LogEvent
{
10
private
final
Player
player
;
11
private
final
GroundItem
groundItem
;
12
13
public
DropItemLogEvent
(
Player
player
,
GroundItem
groundItem
) {
14
this.player =
player
;
15
this.groundItem =
groundItem
;
16
}
17
18
@Override
19
public
void
onLog
() throws Exception {
20
if
((
groundItem
.item.getValue() *
groundItem
.item.getAmount()) < 250_000) {
21
return
;
22
}
23
24
final
JdbcSession session =
new
JdbcSession(
PostgreService
.
getConnectionPool
());
25
long
logId = session.autocommit(
false
)
26
.sql(
"INSERT INTO log.log(log_time) VALUES (?::timestamp) RETURNING id"
)
27
.set(
dateTime
)
28
.insert(
new
SingleOutcome<>(Long.class));
29
30
session.sql(
"INSERT INTO log.drop_item_log(player_id, item_id, item_amount, log_id) VALUES (?, ?, ?, ?)"
)
31
.set(
player
.getMemberId())
32
.set(
groundItem
.item.getId())
33
.set(
groundItem
.item.getAmount())
34
.set(logId)
35
.execute()
36
.commit();
37
}
38
39
}
com.runehive.game.event.impl.log.DropItemLogEvent.DropItemLogEvent
DropItemLogEvent(Player player, GroundItem groundItem)
Definition
DropItemLogEvent.java:13
com.runehive.game.event.impl.log.DropItemLogEvent.player
final Player player
Definition
DropItemLogEvent.java:10
com.runehive.game.event.impl.log.DropItemLogEvent.onLog
void onLog()
Definition
DropItemLogEvent.java:19
com.runehive.game.event.impl.log.DropItemLogEvent.groundItem
final GroundItem groundItem
Definition
DropItemLogEvent.java:11
com.runehive.game.event.impl.log.LogEvent
Definition
LogEvent.java:10
com.runehive.game.event.impl.log.LogEvent.dateTime
final LocalDateTime dateTime
Definition
LogEvent.java:13
com.runehive.game.service.PostgreService
Definition
PostgreService.java:14
com.runehive.game.service.PostgreService.getConnectionPool
static HikariDataSource getConnectionPool()
Definition
PostgreService.java:35
com.runehive.game.world.entity.mob.player.Player
This class represents a character controlled by a player.
Definition
Player.java:125
com.runehive.game.world.items.ground.GroundItem
Represents a single Ground item on the world map.
Definition
GroundItem.java:28