Added support for varying log levels configurable in the server config (see log_level in default.conf)

Error logs now properly print to stderr when possible
Colour-coded logs
Addressed a scenario in which outgoing packet writes could get hung up
Fixed interface incorrect definition message on server startup
This commit is contained in:
Ceikry
2023-03-01 08:01:14 +00:00
committed by Ryan
parent e1faa64af7
commit 88a2f354b4
171 changed files with 723 additions and 475 deletions
@@ -11,9 +11,12 @@ import core.game.node.entity.player.Player;
import core.game.node.scenery.Scenery;
import core.plugin.Initializable;
import core.plugin.Plugin;
import core.tools.Log;
import core.tools.SystemLogger;
import core.plugin.ClassScanner;
import static core.api.ContentAPIKt.log;
/**
* The build option handling plugin.
* @author Emperor
@@ -63,8 +66,8 @@ public final class BuildOptionPlugin extends OptionHandler {
}
Hotspot hotspot = player.getHouseManager().getHotspot(object);
if (hotspot == null || !isBuildable(player, object, hotspot)) {
System.out.println(hotspot == null);
SystemLogger.logErr(this.getClass(), "Construction (building): " + hotspot + " : " + object + " chunkX = " + object.getLocation().getChunkX() + ", chunkY = " + object.getLocation().getChunkY());
log(this.getClass(), Log.ERR, "Construction (building): " + hotspot + " : " + object + " chunkX = " + object.getLocation().getChunkX() + ", chunkY = " + object.getLocation().getChunkY());
return true;
}
@@ -16,12 +16,15 @@ import core.game.world.update.flag.context.Animation;
import core.net.packet.PacketRepository;
import core.net.packet.context.ContainerContext;
import core.net.packet.out.ContainerPacket;
import core.tools.Log;
import org.jetbrains.annotations.NotNull;
import core.tools.SystemLogger;
import java.util.ArrayList;
import java.util.Arrays;
import static core.api.ContentAPIKt.log;
/**
* Utility class for building.
* @author Emperor
@@ -135,7 +138,7 @@ public final class BuildingUtils {
player.getPacketDispatch().sendString("Level " + decoration.getLevel(), 396, 140 + menuIndex);
//player.getPacketDispatch().sendItemZoomOnInterface(items[i].protocol(), 50000, 396, 49 + i);
}
System.out.println(c261Value);
player.getConfigManager().set(261, c261Value);
PacketRepository.send(ContainerPacket.class, new ContainerContext(player, 396, 132, 8, items, false));
}
@@ -287,7 +290,7 @@ public final class BuildingUtils {
}
}
} else {
SystemLogger.logErr(BuildingUtils.class, "Couldn't find stairs! " + plane);
log(BuildingUtils.class, Log.ERR, "Couldn't find stairs! " + plane);
}
}
}
@@ -407,7 +410,7 @@ public final class BuildingUtils {
}
}
} else {
SystemLogger.logErr(BuildingUtils.class, "Couldn't find stairs! " + plane);
log(BuildingUtils.class, Log.ERR, "Couldn't find stairs! " + plane);
}
}
}
@@ -549,7 +552,7 @@ public final class BuildingUtils {
}
}
//(0=east, 1=south, 2=west, 3=north).
// System.out.println("Roof information: index=" + index + ", exit count=" + count + "; array=" + Arrays.toString(exits));
if (count == 4) {
room = Room.create(player, RoomProperties.ROOF_4_EXIT);
}
@@ -10,8 +10,11 @@ import core.game.node.entity.skill.Skills;
import core.game.node.scenery.Scenery;
import core.plugin.Initializable;
import core.plugin.Plugin;
import core.tools.Log;
import core.tools.SystemLogger;
import static core.api.ContentAPIKt.log;
/**
* Handles the creating of a decoration object.
* @author Emperor
@@ -38,12 +41,12 @@ public final class ConstructionInterface extends ComponentPlugin {
Hotspot hotspot = player.getAttribute("con:hotspot");
Scenery object = player.getAttribute("con:hsobject");
if (hotspot == null || object == null) {
SystemLogger.logErr(this.getClass(), "Failed building decoration " + hotspot + " : " + object);
log(this.getClass(), Log.ERR, "Failed building decoration " + hotspot + " : " + object);
break;
}
slot = ((slot % 2 != 0) ? 4 : 0) + (slot >> 1);
if (slot >= hotspot.getHotspot().getDecorations().length) {
SystemLogger.logErr(this.getClass(), "Failed building decoration " + slot + "/" + hotspot.getHotspot().getDecorations().length);
log(this.getClass(), Log.ERR, "Failed building decoration " + slot + "/" + hotspot.getHotspot().getDecorations().length);
break;
}
boolean debug = player.isStaff();
@@ -104,7 +107,7 @@ public final class ConstructionInterface extends ComponentPlugin {
break;
case 402:
int index = button - 160;
SystemLogger.logErr(this.getClass(), "BuildRoom Interface Index: " + index);
log(this.getClass(), Log.FINE, "BuildRoom Interface Index: " + index);
if (index > -1 && index < RoomProperties.values().length) {
player.getDialogueInterpreter().open("con:room", RoomProperties.values()[index]);
return true;
@@ -17,6 +17,7 @@ import core.game.world.map.build.DynamicRegion;
import core.game.world.map.zone.ZoneBorders;
import core.game.world.map.zone.ZoneBuilder;
import core.game.world.update.flag.context.Animation;
import core.tools.Log;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.simple.JSONArray;
@@ -27,6 +28,7 @@ import core.game.world.GameWorld;
import java.awt.*;
import java.nio.ByteBuffer;
import static core.api.ContentAPIKt.log;
import static core.api.regionspec.RegionSpecificationKt.fillWith;
import static core.api.regionspec.RegionSpecificationKt.using;
@@ -323,7 +325,7 @@ public final class HouseManager {
*/
public Location getEnterLocation() {
if (houseRegion == null) {
SystemLogger.logErr(this.getClass(), "House wasn't constructed yet!");
log(this.getClass(), Log.ERR, "House wasn't constructed yet!");
return null;
}
for (int x = 0; x < 8; x++) {