RuneHive-Game
Loading...
Searching...
No Matches
PrivateMessageChatLogEvent.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
8
public
class
PrivateMessageChatLogEvent
extends
LogEvent
{
9
10
private
final
Player
sender
;
11
private
final
Player
receiver
;
12
private
final
String
decoded
;
13
14
public
PrivateMessageChatLogEvent
(
Player
sender
,
Player
receiver
, String
decoded
) {
15
this.sender =
sender
;
16
this.receiver =
receiver
;
17
this.decoded =
decoded
;
18
}
19
20
@Override
21
public
void
onLog
() throws Exception {
22
JdbcSession session =
new
JdbcSession(
PostgreService
.
getConnectionPool
());
23
long
logId = session.autocommit(
false
)
24
.sql(
"INSERT INTO log.log(log_time) VALUES (?::timestamp) RETURNING id"
)
25
.set(
dateTime
)
26
.insert(
new
SingleOutcome<>(Long.class));
27
28
session.sql(
"INSERT INTO log.pm_log(log_id, sender_id, receiver_id, message) VALUES (?, ?, ?, ?)"
)
29
.set(logId)
30
.set(
sender
.getMemberId())
31
.set(
receiver
.getMemberId())
32
.set(
decoded
)
33
.execute()
34
.commit();
35
}
36
37
}
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.event.impl.log.PrivateMessageChatLogEvent.sender
final Player sender
Definition
PrivateMessageChatLogEvent.java:10
com.runehive.game.event.impl.log.PrivateMessageChatLogEvent.onLog
void onLog()
Definition
PrivateMessageChatLogEvent.java:21
com.runehive.game.event.impl.log.PrivateMessageChatLogEvent.receiver
final Player receiver
Definition
PrivateMessageChatLogEvent.java:11
com.runehive.game.event.impl.log.PrivateMessageChatLogEvent.decoded
final String decoded
Definition
PrivateMessageChatLogEvent.java:12
com.runehive.game.event.impl.log.PrivateMessageChatLogEvent.PrivateMessageChatLogEvent
PrivateMessageChatLogEvent(Player sender, Player receiver, String decoded)
Definition
PrivateMessageChatLogEvent.java:14
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