Diamond Economy

Diamond Economy

2M Downloads

Server Crashing

BITS-US opened this issue ยท 6 comments

commented

[13:54:45] [Server thread/ERROR]: Encountered an unexpected exception
java.lang.NullPointerException: Cannot invoke "String.indexOf(int)" because "$$0" is null
at net.minecraft.class_2960.method_60935(class_2960.java:94) ~[server-intermediary.jar:?]
at net.minecraft.class_2960.method_12829(class_2960.java:65) ~[server-intermediary.jar:?]
at com.gmail.sneakdevs.diamondeconomy.CurrencyType.(CurrencyType.java:30) ~[diamondeconomy-1.6.0+1.21.jar:?]
at com.gmail.sneakdevs.diamondeconomy.sql.SQLiteDatabaseManager.getCurrency(SQLiteDatabaseManager.java:457) ~[diamondeconomy-1.6.0+1.21.jar:?]
at com.gmail.sneakdevs.diamondeconomy.DiamondUtils.createCurrencyList(DiamondUtils.java:106) ~[diamondeconomy-1.6.0+1.21.jar:?]
at com.gmail.sneakdevs.diamondeconomy.DiamondEconomy.initServer(DiamondEconomy.java:31) ~[diamondeconomy-1.6.0+1.21.jar:?]
at net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents.lambda$static$0(ServerLifecycleEvents.java:38) ~[fabric-lifecycle-events-v1-2.3.1+6c1df36019-f08a967dd320d5f1.jar:?]
at net.minecraft.server.MinecraftServer.handler$zkg000$fabric-lifecycle-events-v1$beforeSetupServer(MinecraftServer.java:4138) ~[server-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:664) ~[server-intermediary.jar:?]
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:281) ~[server-intermediary.jar:?]
at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]

2024-09-12-2.log
crash-2024-09-12_13.51.41-server.txt

commented

could you post the config you're using

commented

I am having the same issue on my server.

With the default config, I tested the mods @BITS-US had installed. I found that the BanHammer mod causes the server to crash. (There may be more, I didn't test all of them).

On my server, I use the Husk Homes mod, and this also causes the server to crash.

I am on 1.21.1

BanHammer Log

[13:31:50] [main/INFO]: SpongePowered MIXIN Subsystem Version=0.8.7 Source=file:/C:/Users/ticataco/Downloads/libraries/net/fabricmc/sponge-mixin/0.15.3+mixin.0.8.7/sponge-mixin-0.15.3+mixin.0.8.7.jar Service=Knot/Fabric Env=SERVER
[13:31:50] [main/INFO]: Compatibility level set to JAVA_17
[13:31:51] [main/INFO]: Initializing MixinExtras via com.llamalad7.mixinextras.service.MixinExtrasServiceImpl(version=0.4.1).
[13:31:58] [main/INFO]: Environment: Environment[sessionHost=https://sessionserver.mojang.com, servicesHost=https://api.minecraftservices.com, name=PROD]
[13:31:59] [main/INFO]: Loaded 1290 recipes
[13:31:59] [main/INFO]: Loaded 1399 advancements
[13:32:00] [main/INFO]: Applied 0 biome modifications to 0 of 64 new biomes in 1.636 ms
[13:32:00] [Server thread/INFO]: BanHammer connected successfully to SQLite database!
[13:32:00] [Server thread/ERROR]: Encountered an unexpected exception
java.lang.NullPointerException: Cannot invoke "String.indexOf(int)" because "$$0" is null
at knot/net.minecraft.class_2960.method_60935(class_2960.java:94) ~[server-intermediary.jar:?]
at knot/net.minecraft.class_2960.method_12829(class_2960.java:65) ~[server-intermediary.jar:?]
at knot/com.gmail.sneakdevs.diamondeconomy.CurrencyType.(CurrencyType.java:30) ~[diamondeconomy-1.6.0+1.21.jar:?]
at knot/com.gmail.sneakdevs.diamondeconomy.sql.SQLiteDatabaseManager.getCurrency(SQLiteDatabaseManager.java:457) ~[diamondeconomy-1.6.0+1.21.jar:?]
at knot/com.gmail.sneakdevs.diamondeconomy.DiamondUtils.createCurrencyList(DiamondUtils.java:106) ~[diamondeconomy-1.6.0+1.21.jar:?]
at knot/com.gmail.sneakdevs.diamondeconomy.DiamondEconomy.initServer(DiamondEconomy.java:31) ~[diamondeconomy-1.6.0+1.21.jar:?]
at knot/net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents.lambda$static$0(ServerLifecycleEvents.java:38) ~[fabric-lifecycle-events-v1-2.3.1+6c1df36019-a0320f6814921fbf.jar:?]
at knot/net.minecraft.server.MinecraftServer.handler$zej000$fabric-lifecycle-events-v1$beforeSetupServer(MinecraftServer.java:2638) ~[server-intermediary.jar:?]
at knot/net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:664) ~[server-intermediary.jar:?]
at knot/net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:281) ~[server-intermediary.jar:?]
at java.base/java.lang.Thread.run(Thread.java:1570) [?:?]
[13:32:00] [Server thread/ERROR]: This crash report has been saved to: C:\Users\ticataco\Downloads\crash-reports\crash-2024-10-12_13.32.00-server.txt
[13:32:00] [Server thread/INFO]: Stopping server
[13:32:00] [Server thread/INFO]: Saving worlds
[13:32:00] [Server thread/ERROR]: Exception stopping the server
java.lang.NullPointerException: Cannot invoke "net.minecraft.class_3218.method_8621()" because "$$5" is null
at knot/net.minecraft.server.MinecraftServer.method_3723(MinecraftServer.java:561) ~[server-intermediary.jar:?]
at knot/net.minecraft.server.MinecraftServer.method_3782(MinecraftServer.java:620) ~[server-intermediary.jar:?]
at knot/net.minecraft.class_3176.method_3782(class_3176.java:561) ~[server-intermediary.jar:?]
at knot/net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:735) ~[server-intermediary.jar:?]
at knot/net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:281) ~[server-intermediary.jar:?]
at java.base/java.lang.Thread.run(Thread.java:1570) [?:?]

Husk Homes Log

[13:47:01] [main/INFO]: SpongePowered MIXIN Subsystem Version=0.8.7 Source=file:/C:/Users/ticataco/Downloads/libraries/net/fabricmc/sponge-mixin/0.15.3+mixin.0.8.7/sponge-mixin-0.15.3+mixin.0.8.7.jar Service=Knot/Fabric Env=SERVER
[13:47:01] [main/INFO]: Compatibility level set to JAVA_17
[13:47:02] [main/INFO]: Initializing MixinExtras via com.llamalad7.mixinextras.service.MixinExtrasServiceImpl(version=0.4.1).
[13:47:08] [main/INFO]: Initializing plugin config & locale files...
[13:47:09] [main/INFO]: Successfully initialized plugin config & locale files
[13:47:09] [main/INFO]: Initializing commands...
[13:47:09] [main/INFO]: Successfully initialized commands
[13:47:09] [main/INFO]: Environment: Environment[sessionHost=https://sessionserver.mojang.com, servicesHost=https://api.minecraftservices.com, name=PROD]
[13:47:10] [main/INFO]: Loaded 1290 recipes
[13:47:11] [main/INFO]: Loaded 1399 advancements
[13:47:11] [main/INFO]: Applied 0 biome modifications to 0 of 64 new biomes in 1.749 ms
[13:47:12] [Server thread/ERROR]: Encountered an unexpected exception
java.lang.NullPointerException: Cannot invoke "String.indexOf(int)" because "$$0" is null
at knot/net.minecraft.class_2960.method_60935(class_2960.java:94) ~[server-intermediary.jar:?]
at knot/net.minecraft.class_2960.method_12829(class_2960.java:65) ~[server-intermediary.jar:?]
at knot/com.gmail.sneakdevs.diamondeconomy.CurrencyType.(CurrencyType.java:30) ~[diamondeconomy-1.6.0+1.21.jar:?]
at knot/com.gmail.sneakdevs.diamondeconomy.sql.SQLiteDatabaseManager.getCurrency(SQLiteDatabaseManager.java:457) ~[diamondeconomy-1.6.0+1.21.jar:?]
at knot/com.gmail.sneakdevs.diamondeconomy.DiamondUtils.createCurrencyList(DiamondUtils.java:106) ~[diamondeconomy-1.6.0+1.21.jar:?]
at knot/com.gmail.sneakdevs.diamondeconomy.DiamondEconomy.initServer(DiamondEconomy.java:31) ~[diamondeconomy-1.6.0+1.21.jar:?]
at knot/net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents.lambda$static$0(ServerLifecycleEvents.java:38) ~[fabric-lifecycle-events-v1-2.3.1+6c1df36019-a0320f6814921fbf.jar:?]
at knot/net.minecraft.server.MinecraftServer.handler$zfa000$fabric-lifecycle-events-v1$beforeSetupServer(MinecraftServer.java:3138) ~[server-intermediary.jar:?]
at knot/net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:664) ~[server-intermediary.jar:?]
at knot/net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:281) ~[server-intermediary.jar:?]
at java.base/java.lang.Thread.run(Thread.java:1570) [?:?]
[13:47:12] [Server thread/ERROR]: This crash report has been saved to: C:\Users\ticataco\Downloads\crash-reports\crash-2024-10-12_13.47.12-server.txt
[13:47:12] [Server thread/INFO]: Stopping server
[13:47:12] [Server thread/INFO]: Saving worlds
[13:47:12] [Server thread/ERROR]: Exception stopping the server
java.lang.NullPointerException: Cannot invoke "net.minecraft.class_3218.method_8621()" because "$$5" is null
at knot/net.minecraft.server.MinecraftServer.method_3723(MinecraftServer.java:561) ~[server-intermediary.jar:?]
at knot/net.minecraft.server.MinecraftServer.method_3782(MinecraftServer.java:620) ~[server-intermediary.jar:?]
at knot/net.minecraft.class_3176.method_3782(class_3176.java:561) ~[server-intermediary.jar:?]
at knot/net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:735) ~[server-intermediary.jar:?]
at knot/net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:281) ~[server-intermediary.jar:?]
at java.base/java.lang.Thread.run(Thread.java:1570) [?:?]

commented

@IAmSneak I may have found a solution.

I've never used Java or SQLite before so there may be a better way to patch this bug. If so, this may be a good temporary patch before you can get time to hunt that down.

What I found was in the getCurrency function in SQLiteDatabaseManager.java. For some reason, this bug only occurs when using other mods that utilize an SQLite database. When this happens, the SQLite database outputs a seconds row with a null "item" value. This causes the CurrencyType function to raise an error. I propose that a simple if statement is added to the getCurrency functions like shown below.

if (item == null) {
return null;
}
return new CurrencyType(item, sellValue, buyValue, inCurrencyList, canBuy, canSell);

This will prevent these null values from being passed to the CurrencyType function, and fixes the server crashing.

commented

that would most likely fix the crash but it wouldnt fix the actual issue. I imagine I'm using a weird version of SQL and I'll prolly take a look at how other mods use it

commented

I hope I'm not being too annoying with these messages, but could the issue be that the value of rs.next() is not being checked? If rs.next() returns false, then there are no more rows, so the function could be returned right there.

In the getCurrency() function, this if statement inside the for loop could be added to check if the row is valid before it is operated on.

for (int j = -1; j < i; j++) {
    if (!rs.next()) {
        return null;
    }
}

I tested this on my server and it fixed the crash.

commented

this was fixed btw