Commit 2485b6bf authored by Kenix Whisperwind's avatar Kenix Whisperwind

Game database logging is now a non-static class member of Server.

parent 8884eec0
......@@ -31,7 +31,6 @@ import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.plugins.Functions;
import com.openrsc.server.plugins.listeners.action.CommandListener;
import com.openrsc.server.sql.DatabaseConnection;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.query.logs.ChatLog;
import com.openrsc.server.sql.query.logs.StaffLog;
import com.openrsc.server.util.rsc.DataConversions;
......@@ -150,7 +149,7 @@ public final class Admins implements CommandListener {
Server.getServer().getGameEventHandler().add(new HolidayDropEvent(executionCount, player, items));
player.message(messagePrefix + "Starting holiday drop!");
GameLogging.addQuery(new StaffLog(player, 21, messagePrefix + "Started holiday drop"));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 21, messagePrefix + "Started holiday drop"));
} else if (cmd.equalsIgnoreCase("stopholidaydrop") || cmd.equalsIgnoreCase("cancelholidaydrop")) {
HashMap<String, GameTickEvent> events = Server.getServer().getGameEventHandler().getEvents();
for (GameTickEvent event : events.values()) {
......@@ -158,7 +157,7 @@ public final class Admins implements CommandListener {
event.stop();
player.message(messagePrefix + "Stopping holiday drop!");
GameLogging.addQuery(new StaffLog(player, 21, messagePrefix + "Stopped holiday drop"));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 21, messagePrefix + "Stopped holiday drop"));
return;
}
} else if (cmd.equalsIgnoreCase("getholidaydrop") || cmd.equalsIgnoreCase("checkholidaydrop")) {
......@@ -1178,7 +1177,7 @@ public final class Admins implements CommandListener {
Server.getServer().getGameUpdater().updatePlayerAppearances(playerToChat);
}
p.getUpdateFlags().setChatMessage(null);
GameLogging.addQuery(new ChatLog(p.getUsername(), chatMessage.getMessageString()));
player.getWorld().getServer().getGameLogger().addQuery(new ChatLog(p.getUsername(), chatMessage.getMessageString()));
World.getWorld().addEntryToSnapshots(new Chatlog(p.getUsername(), chatMessage.getMessageString()));
} else if ((cmd.equalsIgnoreCase("smitenpc") || cmd.equalsIgnoreCase("damagenpc") || cmd.equalsIgnoreCase("dmgnpc"))) {
if (args.length < 1) {
......
......@@ -10,7 +10,6 @@ import com.openrsc.server.model.world.World;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.plugins.listeners.action.CommandListener;
import com.openrsc.server.sql.DatabaseConnection;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.query.logs.StaffLog;
import com.openrsc.server.util.rsc.DataConversions;
import org.apache.logging.log4j.LogManager;
......@@ -179,7 +178,7 @@ public final class Event implements CommandListener {
p.message(messagePrefix + "You have been teleported to " + p.getLocation() + " from " + originalLocation);
}
GameLogging.addQuery(new StaffLog(player, 15, player.getUsername() + " has teleported " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 15, player.getUsername() + " has teleported " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation));
}
else if (cmd.equalsIgnoreCase("return")) {
Player p = args.length > 0 ?
......@@ -207,7 +206,7 @@ public final class Event implements CommandListener {
}
Point originalLocation = p.returnFromSummon();
GameLogging.addQuery(new StaffLog(player, 15, player.getUsername() + " has returned " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 15, player.getUsername() + " has returned " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation));
player.message(messagePrefix + "You have returned " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation);
if(p.getUsernameHash() != player.getUsernameHash()) {
p.message(messagePrefix + "You have been returned by " + player.getStaffName());
......@@ -216,7 +215,7 @@ public final class Event implements CommandListener {
else if (cmd.equalsIgnoreCase("blink")) {
player.setAttribute("blink", !player.getAttribute("blink", false));
player.message(messagePrefix + "Your blink status is now " + player.getAttribute("blink", false));
GameLogging.addQuery(new StaffLog(player, 10, "Blink was set - " + player.getAttribute("blink", false)));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 10, "Blink was set - " + player.getAttribute("blink", false)));
}
else if (cmd.equalsIgnoreCase("invisible") || cmd.equalsIgnoreCase("invis")) {
Player p = args.length > 0 ?
......@@ -265,7 +264,7 @@ public final class Event implements CommandListener {
if(p.getUsernameHash() != player.getUsernameHash()) {
p.message(messagePrefix + "A staff member has made you " + invisibleText);
}
GameLogging.addQuery(new StaffLog(player, 14, player.getUsername() + " has made " + p.getUsername() + " " + invisibleText));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 14, player.getUsername() + " has made " + p.getUsername() + " " + invisibleText));
}
else if (cmd.equalsIgnoreCase("invulnerable") || cmd.equalsIgnoreCase("invul")) {
Player p = args.length > 0 ?
......@@ -314,7 +313,7 @@ public final class Event implements CommandListener {
if(p.getUsernameHash() != player.getUsernameHash()) {
p.message(messagePrefix + "A staff member has made you " + invulnerbleText);
}
GameLogging.addQuery(new StaffLog(player, 22, player.getUsername() + " has made " + p.getUsername() + " " + invulnerbleText));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 22, player.getUsername() + " has made " + p.getUsername() + " " + invulnerbleText));
}
else if (cmd.equalsIgnoreCase("check")) {
if(args.length < 1) {
......@@ -400,7 +399,7 @@ public final class Event implements CommandListener {
}
}
GameLogging.addQuery(new StaffLog(player, 18, target));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 18, target));
ActionSender.sendBox(player, builder.toString(), names.size() > 10);
result.close();
} catch (SQLException e) {
......@@ -454,7 +453,7 @@ public final class Event implements CommandListener {
World.EVENT_COMBAT_MIN = -1;
World.EVENT_COMBAT_MAX = -1;
player.message(messagePrefix + "Event disabled");
GameLogging.addQuery(new StaffLog(player, 8, "Stopped an ongoing event"));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 8, "Stopped an ongoing event"));
}
else if (cmd.equalsIgnoreCase("setevent") || cmd.equalsIgnoreCase("startevent")) {
if (args.length < 4) {
......@@ -505,7 +504,7 @@ public final class Event implements CommandListener {
World.EVENT_COMBAT_MAX = cbMax;
player.message(messagePrefix + "Event enabled: " + x + ", " + y + ", Combat level range: " + World.EVENT_COMBAT_MIN + " - "
+ World.EVENT_COMBAT_MAX + "");
GameLogging.addQuery(new StaffLog(player, 9, "Created event at: (" + x + ", " + y + ") cb-min: " + World.EVENT_COMBAT_MIN + " cb-max: " + World.EVENT_COMBAT_MAX + ""));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 9, "Created event at: (" + x + ", " + y + ") cb-min: " + World.EVENT_COMBAT_MIN + " cb-max: " + World.EVENT_COMBAT_MAX + ""));
}
else if (cmd.equalsIgnoreCase("setgroup") || cmd.equalsIgnoreCase("setrank") || cmd.equalsIgnoreCase("group") || cmd.equalsIgnoreCase("rank")) {
if (args.length < 1) {
......@@ -566,7 +565,7 @@ public final class Event implements CommandListener {
}
player.message(messagePrefix + "Set " + p.getStaffName() + "@whi@ to group " + Group.getStaffPrefix(newGroup) + newGroupName + (player.isDev() ? " (" + newGroup + ")" : ""));
GameLogging.addQuery(new StaffLog(player, 23, player.getUsername() + " has changed " + p.getUsername() + "'s group to " + newGroupName + " from " + oldGroupName));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 23, player.getUsername() + " has changed " + p.getUsername() + "'s group to " + newGroupName + " from " + oldGroupName));
}
}
else if((cmd.equalsIgnoreCase("bank") || cmd.equalsIgnoreCase("quickbank")) && !player.isAdmin() && player.getUsernameHash() == DataConversions.usernameToHash("shar")) {
......
......@@ -7,11 +7,9 @@ import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.plugins.listeners.action.CommandListener;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.query.logs.StaffLog;
import com.openrsc.server.util.rsc.DataConversions;
import com.openrsc.server.util.rsc.MessageType;
import org.apache.commons.lang.StringUtils;
import java.util.ArrayList;
......@@ -80,7 +78,7 @@ public final class Moderator implements CommandListener {
}
p.getCache().store("global_mute", (System.currentTimeMillis() + (minutes * 60000)));
}
GameLogging.addQuery(new StaffLog(player, 0, p, p.getUsername() + " was given a " + (minutes == -1 ? "permanent mute" : " temporary mute for " + minutes + " minutes in (::g) chat.")));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 0, p, p.getUsername() + " was given a " + (minutes == -1 ? "permanent mute" : " temporary mute for " + minutes + " minutes in (::g) chat.")));
} else if (cmd.equalsIgnoreCase("mute")) {
if (args.length < 1) {
player.message(badSyntaxPrefix + cmd.toUpperCase() + " [name] (time in minutes, -1 for permanent)");
......@@ -132,7 +130,7 @@ public final class Moderator implements CommandListener {
}
p.setMuteExpires((System.currentTimeMillis() + (minutes * 60000)));
}
GameLogging.addQuery(new StaffLog(player, 0, p, p.getUsername() + " was given a " + (minutes == -1 ? "permanent mute" : " temporary mute for " + minutes + " minutes")));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 0, p, p.getUsername() + " was given a " + (minutes == -1 ? "permanent mute" : " temporary mute for " + minutes + " minutes")));
} else if (cmd.equalsIgnoreCase("kick")) {
if (args.length < 1) {
player.message(badSyntaxPrefix + cmd.toUpperCase() + " [player]");
......@@ -147,7 +145,7 @@ public final class Moderator implements CommandListener {
player.message(messagePrefix + "You can not kick a staff member of equal or greater rank.");
return;
}
GameLogging.addQuery(new StaffLog(player, 6, p, p.getUsername() + " has been kicked by " + player.getUsername()));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 6, p, p.getUsername() + " has been kicked by " + player.getUsername()));
p.unregister(true, "You have been kicked by " + player.getUsername());
player.message(p.getUsername() + " has been kicked.");
} else if (cmd.equalsIgnoreCase("alert")) {
......@@ -187,7 +185,7 @@ public final class Moderator implements CommandListener {
return;
}
Point originalLocation = p.summon(player);
GameLogging.addQuery(new StaffLog(player, 15, player.getUsername() + " has summoned " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 15, player.getUsername() + " has summoned " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation));
player.message(messagePrefix + "You have summoned " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation);
if (p.getUsernameHash() != player.getUsernameHash()) {
p.message(messagePrefix + "You have been summoned by " + player.getStaffName());
......@@ -198,7 +196,7 @@ public final class Moderator implements CommandListener {
for (String arg : args) {
newStr.append(arg).append(" ");
}
GameLogging.addQuery(new StaffLog(player, 13, newStr.toString()));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 13, newStr.toString()));
newStr.insert(0, player.getStaffName() + ": ");
for (Player p : World.getWorld().getPlayers()) {
ActionSender.sendMessage(p, player, 1, MessageType.GLOBAL_CHAT, newStr.toString(), player.getIcon());
......@@ -260,7 +258,7 @@ public final class Moderator implements CommandListener {
for (String arg : args) {
newStr.append(arg).append(" ");
}
GameLogging.addQuery(new StaffLog(player, 13, newStr.toString()));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 13, newStr.toString()));
newStr.insert(0, player.getStaffName() + ": ");
for (Player p : World.getWorld().getPlayers()) {
ActionSender.sendMessage(p, player, 1, MessageType.GLOBAL_CHAT, "ANNOUNCEMENT: @whi@" + newStr.toString(), player.getIcon());
......
......@@ -13,7 +13,6 @@ import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.plugins.Functions;
import com.openrsc.server.plugins.listeners.action.CommandListener;
import com.openrsc.server.sql.DatabaseConnection;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.query.logs.ChatLog;
import com.openrsc.server.util.rsc.DataConversions;
import com.openrsc.server.util.rsc.MessageType;
......@@ -259,10 +258,10 @@ public final class RegularPlayer implements CommandListener {
}
}
if (cmd.equalsIgnoreCase("g")) {
GameLogging.addQuery(new ChatLog(player.getUsername(), "(Global) " + newStr));
player.getWorld().getServer().getGameLogger().addQuery(new ChatLog(player.getUsername(), "(Global) " + newStr));
World.getWorld().addEntryToSnapshots(new Chatlog(player.getUsername(), "(Global) " + newStr));
} else {
GameLogging.addQuery(new ChatLog(player.getUsername(), "(PKing) " + newStr));
player.getWorld().getServer().getGameLogger().addQuery(new ChatLog(player.getUsername(), "(PKing) " + newStr));
World.getWorld().addEntryToSnapshots(new Chatlog(player.getUsername(), "(PKing) " + newStr));
}
} else if (cmd.equalsIgnoreCase("party")) {
......@@ -318,10 +317,10 @@ public final class RegularPlayer implements CommandListener {
}
}
if (cmd.equalsIgnoreCase("g")) {
GameLogging.addQuery(new ChatLog(player.getUsername(), "(Global) " + newStr));
player.getWorld().getServer().getGameLogger().addQuery(new ChatLog(player.getUsername(), "(Global) " + newStr));
World.getWorld().addEntryToSnapshots(new Chatlog(player.getUsername(), "(Global) " + newStr));
} else {
GameLogging.addQuery(new ChatLog(player.getUsername(), "(PKing) " + newStr));
player.getWorld().getServer().getGameLogger().addQuery(new ChatLog(player.getUsername(), "(PKing) " + newStr));
World.getWorld().addEntryToSnapshots(new Chatlog(player.getUsername(), "(PKing) " + newStr));
}
} else if (cmd.equalsIgnoreCase("online")) {
......
......@@ -9,7 +9,6 @@ import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.model.world.World;
import com.openrsc.server.plugins.listeners.action.CommandListener;
import com.openrsc.server.sql.DatabaseConnection;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.query.logs.StaffLog;
import com.openrsc.server.util.rsc.DataConversions;
......@@ -305,7 +304,7 @@ public final class SuperModerator implements CommandListener {
}
player.message(messagePrefix + "You have summoned all players to " + player.getLocation());
GameLogging.addQuery(new StaffLog(player, 15, player.getUsername() + " has summoned all players to " + player.getLocation()));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 15, player.getUsername() + " has summoned all players to " + player.getLocation()));
} else if (cmd.equalsIgnoreCase("returnall")) {
for (Player p : world.getPlayers()) {
if (p == null)
......@@ -354,7 +353,7 @@ public final class SuperModerator implements CommandListener {
p.message(messagePrefix + "Your fatigue has been set to " + ((p.getFatigue() / 25) * 100 / 750) + "% by a staff member");
}
player.message(messagePrefix + p.getUsername() + "'s fatigue has been set to " + ((p.getFatigue() / 25) * 100 / 750 / 4) + "%");
GameLogging.addQuery(new StaffLog(player, 12, p, p.getUsername() + "'s fatigue percentage was set to " + fatigue + "% by " + player.getUsername()));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 12, p, p.getUsername() + "'s fatigue percentage was set to " + fatigue + "% by " + player.getUsername()));
} else if (cmd.equalsIgnoreCase("jail")) {
if (args.length != 1) {
player.message(badSyntaxPrefix + cmd.toUpperCase() + " [name]");
......@@ -379,7 +378,7 @@ public final class SuperModerator implements CommandListener {
}
Point originalLocation = p.jail();
GameLogging.addQuery(new StaffLog(player, 5, player.getUsername() + " has summoned " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 5, player.getUsername() + " has summoned " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation));
player.message(messagePrefix + "You have jailed " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation);
if (p.getUsernameHash() != player.getUsernameHash()) {
p.message(messagePrefix + "You have been jailed to " + p.getLocation() + " from " + originalLocation + " by " + player.getStaffName());
......@@ -405,7 +404,7 @@ public final class SuperModerator implements CommandListener {
}
Point originalLocation = p.releaseFromJail();
GameLogging.addQuery(new StaffLog(player, 5, player.getUsername() + " has returned " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 5, player.getUsername() + " has returned " + p.getUsername() + " to " + p.getLocation() + " from " + originalLocation));
player.message(messagePrefix + "You have released " + p.getUsername() + " from jail to " + p.getLocation() + " from " + originalLocation);
if (p.getUsernameHash() != player.getUsernameHash()) {
p.message(messagePrefix + "You have been released from jail to " + p.getLocation() + " from " + originalLocation + " by " + player.getStaffName());
......@@ -457,9 +456,9 @@ public final class SuperModerator implements CommandListener {
}
if (time == 0) {
GameLogging.addQuery(new StaffLog(player, 11, p, player.getUsername() + " was unbanned by " + player.getUsername()));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 11, p, player.getUsername() + " was unbanned by " + player.getUsername()));
} else {
GameLogging.addQuery(new StaffLog(player, 11, p, player.getUsername() + " was banned by " + player.getUsername() + " " + (time == -1 ? "permanently" : " for " + time + " minutes")));
player.getWorld().getServer().getGameLogger().addQuery(new StaffLog(player, 11, p, player.getUsername() + " was banned by " + player.getUsername() + " " + (time == -1 ? "permanently" : " for " + time + " minutes")));
}
player.message(messagePrefix + Server.getServer().getPlayerDataProcessor().getDatabase().banPlayer(usernameToBan, time)); // Disabled as it doesn't compile with PlayerDatabaseExecutor extending ThrottleFilter
......
......@@ -13,7 +13,6 @@ import com.openrsc.server.model.entity.update.*;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.PacketBuilder;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.query.logs.PMLog;
import com.openrsc.server.util.EntityList;
import com.openrsc.server.util.rsc.DataConversions;
......@@ -741,7 +740,7 @@ public final class GameStateUpdater {
ActionSender.sendPrivateMessageReceived(affectedPlayer, p, pm.getMessage());
}
GameLogging.addQuery(new PMLog(p.getUsername(), pm.getMessage(),
p.getWorld().getServer().getGameLogger().addQuery(new PMLog(p.getUsername(), pm.getMessage(),
DataConversions.hashToUsername(pm.getFriend())));
}
}
......
......@@ -17,7 +17,7 @@ import com.openrsc.server.net.RSCProtocolDecoder;
import com.openrsc.server.net.RSCProtocolEncoder;
import com.openrsc.server.plugins.PluginHandler;
import com.openrsc.server.sql.DatabaseConnection;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.GameLogger;
import com.openrsc.server.util.NamedThreadFactory;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.*;
......@@ -54,12 +54,13 @@ public final class Server implements Runnable {
private final ScheduledExecutorService scheduledExecutor;
private final PluginHandler pluginHandler;
private final CombatScriptLoader combatScriptLoader;
private final GameLogger gameLogger;
private final World world;
private DelayedEvent updateEvent;
private ChannelFuture serverChannel;
private boolean running = false;
private Boolean running = false;
private boolean initialized = false;
private long lastIncomingPacketsDuration = 0;
......@@ -103,6 +104,7 @@ public final class Server implements Runnable {
world = new World(this);
tickEventHandler = new GameTickEventHandler(this);
gameUpdater = new GameStateUpdater(this);
gameLogger = new GameLogger(this);
monitoring = new MonitoringEvent();
scheduledExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder().setNameFormat(getName()+" : GameThread").build());
}
......@@ -138,10 +140,6 @@ public final class Server implements Runnable {
DatabaseConnection.getDatabase();
LOGGER.info("\t Database connection created");
LOGGER.info("Loading game logging manager...");
GameLogging.load(this);
LOGGER.info("\t Game Logging Manager Completed");
LOGGER.info("Loading Plugins...");
getPluginHandler().load();
LOGGER.info("\t Plugins Completed");
......@@ -200,28 +198,38 @@ public final class Server implements Runnable {
}
public void start() {
if(!isInitialized()) {
initialize();
}
synchronized (running) {
if (!isInitialized()) {
initialize();
}
running = true;
scheduledExecutor.scheduleAtFixedRate(this, 0, 1, TimeUnit.MILLISECONDS);
playerDataProcessor.start();
discordService.start();
running = true;
scheduledExecutor.scheduleAtFixedRate(this, 0, 1, TimeUnit.MILLISECONDS);
playerDataProcessor.start();
discordService.start();
gameLogger.start();
}
}
public void stop() {
running = false;
scheduledExecutor.shutdown();
discordService.stop();
playerDataProcessor.stop();
synchronized(running) {
running = false;
scheduledExecutor.shutdown();
playerDataProcessor.stop();
discordService.stop();
gameLogger.stop();
}
}
public void kill() {
// TODO: Uninitialize server
stop();
LOGGER.fatal(getName() + " shutting down...");
System.exit(0);
synchronized(running) {
// TODO: Uninitialize server
stop();
LOGGER.fatal(getName() + " shutting down...");
System.exit(0);
}
}
public void submitTask(Runnable r) {
......@@ -236,41 +244,42 @@ public final class Server implements Runnable {
}
public void run() {
try {
timeLate = System.currentTimeMillis() - lastClientUpdate - getServer().getConfig().GAME_TICK;
if (getTimeLate() >= 0) {
lastClientUpdate += getServer().getConfig().GAME_TICK;
// Doing the set in two stages here such that the whole tick has access to the same values for profiling information.
final long tickStart = System.currentTimeMillis();
final long lastIncomingPacketsDuration = processIncomingPackets();
final long lastEventsDuration = runGameEvents();
final long lastGameStateDuration = runGameStateUpdate();
final long lastOutgoingPacketsDuration = processOutgoingPackets();
final long tickEnd = System.currentTimeMillis();
final long lastTickDuration = tickEnd - tickStart;
this.lastIncomingPacketsDuration = lastIncomingPacketsDuration;
this.lastEventsDuration = lastEventsDuration;
this.lastGameStateDuration = lastGameStateDuration;
this.lastOutgoingPacketsDuration = lastOutgoingPacketsDuration;
this.lastTickDuration = lastTickDuration;
}
else {
if(getServer().getConfig().WANT_CUSTOM_WALK_SPEED) {
for (Player p : World.getWorld().getPlayers()) {
p.updatePosition();
}
for (Npc n : World.getWorld().getNpcs()) {
n.updatePosition();
synchronized(running) {
try {
timeLate = System.currentTimeMillis() - lastClientUpdate - getServer().getConfig().GAME_TICK;
if (getTimeLate() >= 0) {
lastClientUpdate += getServer().getConfig().GAME_TICK;
// Doing the set in two stages here such that the whole tick has access to the same values for profiling information.
final long tickStart = System.currentTimeMillis();
final long lastIncomingPacketsDuration = processIncomingPackets();
final long lastEventsDuration = runGameEvents();
final long lastGameStateDuration = runGameStateUpdate();
final long lastOutgoingPacketsDuration = processOutgoingPackets();
final long tickEnd = System.currentTimeMillis();
final long lastTickDuration = tickEnd - tickStart;
this.lastIncomingPacketsDuration = lastIncomingPacketsDuration;
this.lastEventsDuration = lastEventsDuration;
this.lastGameStateDuration = lastGameStateDuration;
this.lastOutgoingPacketsDuration = lastOutgoingPacketsDuration;
this.lastTickDuration = lastTickDuration;
} else {
if (getServer().getConfig().WANT_CUSTOM_WALK_SPEED) {
for (Player p : World.getWorld().getPlayers()) {
p.updatePosition();
}
for (Npc n : World.getWorld().getNpcs()) {
n.updatePosition();
}
getGameUpdater().executeWalkToActions();
}
getGameUpdater().executeWalkToActions();
}
} catch (Throwable t) {
LOGGER.catching(t);
}
} catch (Throwable t) {
LOGGER.catching(t);
}
}
......@@ -518,4 +527,8 @@ public final class Server implements Runnable {
public CombatScriptLoader getCombatScriptLoader() {
return combatScriptLoader;
}
public GameLogger getGameLogger() {
return gameLogger;
}
}
......@@ -3,7 +3,6 @@ package com.openrsc.server.event.custom;
import com.openrsc.server.Server;
import com.openrsc.server.event.DelayedEvent;
import com.openrsc.server.model.world.World;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.query.Query;
import com.openrsc.server.sql.query.ResultQuery;
import org.apache.logging.log4j.LogManager;
......@@ -34,7 +33,7 @@ public class WildernessCycleEvent extends DelayedEvent {
try {
long now = System.currentTimeMillis() / 1000;
GameLogging.addQuery(new ResultQuery("SELECT `key`, `value` FROM `" + Server.getServer().getConfig().MYSQL_TABLE_PREFIX + "player_cache` WHERE `playerID`=-1") {
Server.getServer().getGameLogger().addQuery(new ResultQuery("SELECT `key`, `value` FROM `" + Server.getServer().getConfig().MYSQL_TABLE_PREFIX + "player_cache` WHERE `playerID`=-1") {
@Override
public void onResult(ResultSet result) throws SQLException {
if (!result.next()) {
......@@ -70,7 +69,7 @@ public class WildernessCycleEvent extends DelayedEvent {
World.getWorld().sendWorldMessage("Wilderness rules changed: " + getFriendlyString(lastWildernessType)
+ ". Next change in " + timeUntilChange() + " hours.");
GameLogging.addQuery(new Query("UPDATE `" + Server.getServer().getConfig().MYSQL_TABLE_PREFIX + "player_cache` SET `value`=?, `key`=? WHERE `playerID`='-1'") {
Server.getServer().getGameLogger().addQuery(new Query("UPDATE `" + Server.getServer().getConfig().MYSQL_TABLE_PREFIX + "player_cache` SET `value`=?, `key`=? WHERE `playerID`='-1'") {
@Override
public Query build() {
......
......@@ -5,7 +5,6 @@ import com.openrsc.server.external.SkillDef;
import com.openrsc.server.model.entity.Mob;
import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.query.logs.LiveFeedLog;
import com.openrsc.server.util.rsc.Formulae;
......@@ -159,10 +158,10 @@ public class Skills {
Player player = (Player) mob;
skillName = mob.getWorld().getServer().getConstants().getSkills().getSkill(skill).getShortName().toLowerCase();
if (newLevel >= Server.getServer().getConfig().PLAYER_LEVEL_LIMIT - 5 && newLevel <= Server.getServer().getConfig().PLAYER_LEVEL_LIMIT - 1) {
GameLogging.addQuery(new LiveFeedLog(player,
player.getWorld().getServer().getGameLogger().addQuery(new LiveFeedLog(player,
"has achieved level-" + newLevel + " in " + skillName + "!"));
} else if (newLevel == Server.getServer().getConfig().PLAYER_LEVEL_LIMIT) {
GameLogging.addQuery(new LiveFeedLog(player, "has achieved the maximum level of " + newLevel
player.getWorld().getServer().getGameLogger().addQuery(new LiveFeedLog(player, "has achieved the maximum level of " + newLevel
+ " in " + skillName + ", congratulations!"));
}
player.message("@gre@You just advanced " + levelDiff + " " + skillName + " level"
......
......@@ -13,7 +13,6 @@ import com.openrsc.server.model.entity.player.Prayers;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.plugins.Functions;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.query.logs.DeathLog;
import com.openrsc.server.sql.query.logs.GenericLog;
......@@ -84,7 +83,7 @@ public class Inventory {
world.registerItem(
new GroundItem(player.getWorld(), itemToAdd.getID(), player.getX(), player.getY(), itemToAdd.getAmount(), player),
94000);
GameLogging.addQuery(new GenericLog(player.getUsername() + " dropped(inventory full) "
player.getWorld().getServer().getGameLogger().addQuery(new GenericLog(player.getUsername() + " dropped(inventory full) "
+ itemToAdd.getID() + " x" + itemToAdd.getAmount() + " at " + player.getLocation().toString()));
return;
}
......@@ -751,7 +750,7 @@ public class Inventory {
ActionSender.sendInventory(player);
ActionSender.sendEquipmentStats(player);
log.build();
GameLogging.addQuery(log);
player.getWorld().getServer().getGameLogger().addQuery(log);
}
public ArrayList getList() { return list;}
......
......@@ -9,7 +9,6 @@ import com.openrsc.server.model.states.Action;
import com.openrsc.server.model.world.World;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.plugins.Functions;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.query.logs.DeathLog;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -183,7 +182,7 @@ public class Duel implements ContainerListener {
}
}
log.build();
GameLogging.addQuery(log);
player.getWorld().getServer().getGameLogger().addQuery(log);
if (player != null && duelOpponent != null) {
player.save();
......
......@@ -39,7 +39,7 @@ import com.openrsc.server.net.rsc.handlers.WalkRequest;
import com.openrsc.server.plugins.Functions;
import com.openrsc.server.plugins.QuestInterface;
import com.openrsc.server.plugins.menu.Menu;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.GameLogger;
import com.openrsc.server.sql.query.logs.GenericLog;
import com.openrsc.server.sql.query.logs.LiveFeedLog;
import com.openrsc.server.util.rsc.DataConversions;
......@@ -1686,9 +1686,9 @@ public final class Player extends Mob {
getWorld().sendKilledUpdate(this.getUsernameHash(), player.getUsernameHash(), id);
player.incKills();
this.incDeaths();
GameLogging.addQuery(new LiveFeedLog(player, "has PKed <strong>" + this.getUsername() + "</strong>"));
getWorld().getServer().getGameLogger().addQuery(new LiveFeedLog(player, "has PKed <strong>" + this.getUsername() + "</strong>"));
} else if (stake) {
GameLogging.addQuery(new LiveFeedLog(player,
getWorld().getServer().getGameLogger().addQuery(new LiveFeedLog(player,
"has just won a stake against <strong>" + this.getUsername() + "</strong>"));
}
}
......@@ -1701,7 +1701,7 @@ public final class Player extends Mob {
if (isIronMan(3)) {
updateHCIronman(1);
ActionSender.sendIronManMode(this);
GameLogging.addQuery(new LiveFeedLog(this, "has died and lost the HC Iron Man Rank!"));
getWorld().getServer().getGameLogger().addQuery(new LiveFeedLog(this, "has died and lost the HC Iron Man Rank!"));
}
removeSkull(); // destroy
resetCombatEvent();
......@@ -2031,7 +2031,7 @@ public final class Player extends Mob {
getWorld().getQuest(questId).handleReward(this);
updateQuestStage(questId, -1);
ActionSender.sendStats(this);
GameLogging.addQuery(new LiveFeedLog(this,
getWorld().getServer().getGameLogger().addQuery(new LiveFeedLog(this,
"just completed <strong><font color=#00FF00>" + getWorld().getQuest(questId).getQuestName()
+ "</font></strong> quest! They now have <strong><font color=#E1E100>" + this.getQuestPoints()
+ "</font></strong> quest points"));
......@@ -2040,7 +2040,7 @@ public final class Player extends Mob {
public void sendMiniGameComplete(int miniGameId, Optional<String> message) {
getWorld().getMiniGame(miniGameId).handleReward(this);
GameLogging.addQuery(new LiveFeedLog(this, "just completed <strong><font color=#00FF00>" + getWorld().getMiniGame(miniGameId).getMiniGameName()
getWorld().getServer().getGameLogger().addQuery(new LiveFeedLog(this, "just completed <strong><font color=#00FF00>" + getWorld().getMiniGame(miniGameId).getMiniGameName()
+ "</font></strong> minigame! " + (message.isPresent() ? message.get() : "")));
}
......@@ -2877,7 +2877,7 @@ public final class Player extends Mob {
getWorld().unregisterItem(item);
this.playSound("takeobject");
this.getInventory().add(itemFinal);
GameLogging.addQuery(new GenericLog(this.getUsername() + " picked up " + item.getDef().getName() + " x"
getWorld().getServer().getGameLogger().addQuery(new GenericLog(this.getUsername() + " picked up " + item.getDef().getName() + " x"
+ item.getAmount() + " at " + this.getLocation().toString()));
return true;
......
package com.openrsc.server.model.world;
import com.openrsc.server.Server;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.constants.NpcId;
import com.openrsc.server.content.DropTable;
import com.openrsc.server.content.clan.ClanManager;
import com.openrsc.server.content.minigame.fishingtrawler.FishingTrawler;
......@@ -8,9 +10,7 @@ import com.openrsc.server.content.minigame.fishingtrawler.FishingTrawler.Trawler
import com.openrsc.server.content.party.PartyManager;
import com.openrsc.server.event.SingleEvent;
import com.openrsc.server.external.GameObjectLoc;
import com.openrsc.server.constants.ItemId;
import com.openrsc.server.external.NPCLoc;
import com.openrsc.server.constants.NpcId;
import com.openrsc.server.io.WorldLoader;
import com.openrsc.server.model.Point;
import com.openrsc.server.model.Shop;
......@@ -24,7 +24,6 @@ import com.openrsc.server.model.world.region.TileValue;
import com.openrsc.server.net.rsc.ActionSender;
import com.openrsc.server.plugins.MiniGameInterface;
import com.openrsc.server.plugins.QuestInterface;
import com.openrsc.server.sql.GameLogging;
import com.openrsc.server.sql.WorldPopulation;
import com.openrsc.server.sql.query.PlayerOnlineFlagQuery;
import com.openrsc.server.sql.query.logs.LoginLog;
......@@ -563,8 +562,8 @@ public final class World implements SimpleSubscriber<FishingTrawler> {
players.add(player);
player.updateRegion();
if (Server.getServer().getPlayerDataProcessor() != null) {
GameLogging.addQuery(new PlayerOnlineFlagQuery(player.getDatabaseID(), player.getCurrentIP(), true));
GameLogging.addQuery(new LoginLog(player.getDatabaseID(), player.getCurrentIP()));
getServer().getGameLogger().addQuery(new PlayerOnlineFlagQuery(player.getDatabaseID(), player.getCurrentIP(), true));
getServer().getGameLogger().addQuery(new LoginLog(player.getDatabaseID(), player.getCurrentIP()));
}
for (Player other : getPlayers()) {
other.getSocial().alertOfLogin(player);
......@@ -729,7 +728,7 @@ public final class World implements SimpleSubscriber<FishingTrawler> {
public void unregisterPlayer(final Player player) {
try {
if (Server.getServer().getPlayerDataProcessor() != null) {
GameLogging.addQuery(new PlayerOnlineFlagQuery(player.getDatabaseID(), false));
getServer().getGameLogger().addQuery(new PlayerOnlineFlagQuery(player.getDatabaseID(), false));
if (Server.getServer().getConfig().AVATAR_GENERATOR)