Skip to content

Commit

Permalink
Update to 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNavaStar committed Jun 18, 2022
1 parent 95d04de commit 81f4fe8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 26 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

include(modImplementation("com.github.MrNavaStar:SQLib:${project.sqlib_version}"))
include(modImplementation('com.github.P03W:Microconfig:2.0.4'))
include(modImplementation("com.github.P03W:Microconfig:${project.microconfig_version}"))
}

processResources {
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx4G
# Fabric Properties

# check these on https://fabricmc.net/develop/
minecraft_version=1.18.1
yarn_mappings=1.18.1+build.22
loader_version=0.13.3
minecraft_version=1.19
yarn_mappings=1.19+build.2
loader_version=0.14.7

# Mod Properties
mod_version=v2.2.0
mod_version=v2.3.0
maven_group=mrnavastar
archives_base_name=invsync

# Dependencies
fabric_version=0.46.6+1.18
sqlib_version=v1.2.1
cloth_version=6.0.42
fabric_version=0.55.3+1.19
sqlib_version=v1.3.1
microconfig_version=2.2.1
42 changes: 25 additions & 17 deletions src/main/java/mrnavastar/invsync/InvSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import mrnavastar.sqlib.api.databases.MySQLDatabase;
import mrnavastar.sqlib.api.databases.SQLiteDatabase;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.minecraft.server.MinecraftServer;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;

Expand All @@ -20,6 +22,7 @@ public class InvSync implements ModInitializer {
public static Table playerData;
public static Settings settings;
private static Database database;
private static MinecraftServer server;

@Override
public void onInitialize() {
Expand All @@ -38,28 +41,33 @@ public void onInitialize() {
validConfig = true;
}

if (validConfig) {
playerData = database.createTable("PlayerData");
ServerLifecycleEvents.SERVER_STARTING.register(s -> server = s);

ServerPlayConnectionEvents.JOIN.register((handler, s, server) -> {
try {
TimeUnit.SECONDS.sleep(1); //Maybe we can find a less shit solution in the future
playerData.beginTransaction();
Converter.updatePlayerData(handler.getPlayer());
playerData.endTransaction();
} catch (InterruptedException e) {
e.printStackTrace();
}
});
if (!validConfig) {
log(Level.INFO, "Halting initialization! You need to change some settings in the InvSync config");
server.stop(true);
}

playerData = database.createTable("PlayerData");

ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
ServerPlayConnectionEvents.JOIN.register((handler, s, server) -> {
try {
TimeUnit.SECONDS.sleep(1); //Maybe we can find a less shit solution in the future
playerData.beginTransaction();
Converter.savePlayerData(handler.getPlayer());
Converter.updatePlayerData(handler.getPlayer());
playerData.endTransaction();
});
} catch (InterruptedException e) {
e.printStackTrace();
}
});

ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
playerData.beginTransaction();
Converter.savePlayerData(handler.getPlayer());
playerData.endTransaction();
});

log(Level.INFO, "Complete!");
} else log(Level.INFO, "Halting initialization! You need to change some settings in the InvSync config");
log(Level.INFO, "Complete!");
}

public static void log(Level level, String message) {
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
],
"depends": {
"fabricloader": ">=0.12.12",
"fabric": "*"
"fabric": "*",
"minecraft": [
"1.19.x"
]
}
}

0 comments on commit 81f4fe8

Please sign in to comment.