RuneHive-Game
Loading...
Searching...
No Matches
CommandLogEvent.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.entity.mob.player.command.CommandParser;
8
9
import
java.util.Arrays;
10
11
public
class
CommandLogEvent
extends
LogEvent
{
12
13
private
final
Player
player
;
14
private
final
CommandParser
parser
;
15
16
public
CommandLogEvent
(
Player
player
,
CommandParser
parser
) {
17
this.player =
player
;
18
this.parser =
parser
;
19
}
20
21
@Override
22
public
void
onLog
() throws Exception {
23
JdbcSession session =
new
JdbcSession(
PostgreService
.
getConnectionPool
());
24
long
logId = session.autocommit(
false
)
25
.sql(
"INSERT INTO log.log(log_time) VALUES (?::timestamp) RETURNING id"
)
26
.set(
dateTime
)
27
.insert(
new
SingleOutcome<>(Long.class));
28
29
session.sql(
"INSERT INTO log.command_log(player_id, name, argument, log_id) VALUES (?, ?, ?, ?)"
)
30
.set(
player
.getMemberId())
31
.set(
parser
.getCommand())
32
.set(Arrays.toString(
parser
.getArguments()).replace(
"["
,
""
).replace(
"]"
,
""
))
33
.set(logId)
34
.execute()
35
.commit();
36
}
37
38
}
com.runehive.game.event.impl.log.CommandLogEvent.parser
final CommandParser parser
Definition
CommandLogEvent.java:14
com.runehive.game.event.impl.log.CommandLogEvent.onLog
void onLog()
Definition
CommandLogEvent.java:22
com.runehive.game.event.impl.log.CommandLogEvent.CommandLogEvent
CommandLogEvent(Player player, CommandParser parser)
Definition
CommandLogEvent.java:16
com.runehive.game.event.impl.log.CommandLogEvent.player
final Player player
Definition
CommandLogEvent.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
com.runehive.game.world.entity.mob.player.command.CommandParser
Definition
CommandParser.java:9