RuneHive-Game
Loading...
Searching...
No Matches
ChatLogEvent.java
Go to the documentation of this file.
1package com.runehive.game.event.impl.log;
2
3import com.jcabi.jdbc.JdbcSession;
4import com.jcabi.jdbc.SingleOutcome;
5import com.runehive.game.service.PostgreService;
6import com.runehive.game.world.entity.mob.player.Player;
7
8public final class ChatLogEvent extends LogEvent {
9
10 private final Player player;
11 private final String message;
12
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}
ChatLogEvent(Player player, String message)
static HikariDataSource getConnectionPool()
This class represents a character controlled by a player.
Definition Player.java:125