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