Skip to content

Commit

Permalink
Made the rewrite work on with proxy servers
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNavaStar committed Sep 2, 2021
1 parent 26e128c commit e813159
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 122 deletions.
118 changes: 118 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# User-specific stuff
.idea/

*.iml
*.ipr
*.iws

# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

.gradle
build/

# Ignore Gradle GUI config
gradle-app.setting

# Cache of project
.gradletasknamecache

**/build/

# Common working directory
/run/

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ archives_base_name=invsync
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.39.2+1.17
sqlib_version=v1.0.0
sqlib_version=v1.1.0
cloth_version=5.0.38
37 changes: 18 additions & 19 deletions src/main/java/mrnavastar/invsync/Invsync.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer;
import mrnavastar.invsync.api.events.PlayerJoinCallback;
import mrnavastar.invsync.api.events.PlayerLeaveCallback;
import mrnavastar.invsync.util.Converter;
import mrnavastar.invsync.util.Settings;
import mrnavastar.sqlib.api.SqlTypes;
import mrnavastar.sqlib.api.Table;
import mrnavastar.sqlib.util.Database;
import net.fabricmc.api.ModInitializer;
import net.minecraft.util.ActionResult;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.concurrent.TimeUnit;

public class Invsync implements ModInitializer {

Expand Down Expand Up @@ -51,29 +50,29 @@ public void onInitialize() {
Database.init();
playerData = new Table(MODID + "PlayerData");

PlayerJoinCallback.EVENT.register((player, server) -> {
Converter.updatePlayerData(player);
return ActionResult.PASS;
ServerPlayConnectionEvents.JOIN.register((handler, sender, 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();
}
});

PlayerLeaveCallback.EVENT.register((player, server) -> {
Converter.savePlayerData(player);
return ActionResult.PASS;
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 InvSync.toml.");
}

//Stuff for console logging
public static final Logger LOGGER = LogManager.getLogger();

public static void log(Level level, String message) {
log(level, message, (Object) null);
}

public static void log(Level level, String message, Object ... fields){
LOGGER.log(level, "[" + MODID + "] " + message, fields);
public static void log(Level level, String message){
LogManager.getLogger().log(level, "[" + MODID + "] " + message);
}
}

This file was deleted.

This file was deleted.

23 changes: 0 additions & 23 deletions src/main/java/mrnavastar/invsync/api/mixin/PlayerManagerMixin.java

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/main/java/mrnavastar/invsync/util/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public static void updatePlayerData(PlayerEntity player) {
}
}
}

}
}

Expand Down
6 changes: 1 addition & 5 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
"authors": [],
"contact": {},
"license": "MIT",
"icon": "assets/invsync/icon.png",
"environment": "*",
"entrypoints": {
"client": [
"mrnavastar.invsync.client.InvsyncClient"
],
"main": [
"mrnavastar.invsync.Invsync"
]
Expand All @@ -23,6 +19,6 @@
"depends": {
"fabricloader": ">=0.11.6",
"fabric": "*",
"minecraft": "1.17.1"
"minecraft": "1.17.x"
}
}
4 changes: 0 additions & 4 deletions src/main/resources/invsync.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"package": "mrnavastar.invsync.api.mixin",
"compatibilityLevel": "JAVA_16",
"mixins": [
"PlayerManagerMixin",
"ServerPlayNetworkHandlerMixin"
],
"client": [
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit e813159

Please sign in to comment.