diff --git a/src/main/java/vip/fubuki/playersync/sync/ModsSupport.java b/src/main/java/vip/fubuki/playersync/sync/ModsSupport.java index fea94a3..7b7f4a7 100644 --- a/src/main/java/vip/fubuki/playersync/sync/ModsSupport.java +++ b/src/main/java/vip/fubuki/playersync/sync/ModsSupport.java @@ -41,18 +41,12 @@ public class ModsSupport { StoreCurios(player,true); } } - if(ModList.get().isLoaded("sophisticatedbackpacks")) { - //TODO sophisticatedbackpacks support - } } public void onPlayerLeave(Player player) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException { if (ModList.get().isLoaded("curios")) { StoreCurios(player, false); } - if(ModList.get().isLoaded("sophisticatedbackpacks")) { - //TODO sophisticatedbackpacks support - } } public void StoreCurios(Player player,boolean init) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException { diff --git a/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java b/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java index cfc53e9..60068b1 100644 --- a/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java +++ b/src/main/java/vip/fubuki/playersync/sync/VanillaSync.java @@ -4,8 +4,6 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.client.Minecraft; import net.minecraft.nbt.*; import net.minecraft.network.chat.Component; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.dedicated.DedicatedServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; @@ -13,10 +11,10 @@ import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; +import vip.fubuki.playersync.PlayerSync; import vip.fubuki.playersync.config.JdbcConfig; import vip.fubuki.playersync.util.JDBCsetUp; import vip.fubuki.playersync.util.LocalJsonUtil; @@ -32,7 +30,7 @@ import java.util.*; public class VanillaSync { @SubscribeEvent - public void OnPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException, CommandSyntaxException { + public static void OnPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException, IOException, CommandSyntaxException { String player_uuid = event.getEntity().getUUID().toString(); ResultSet resultSet=JDBCsetUp.executeQuery("SELECT online FROM player_data WHERE uuid='"+player_uuid+"'"); ServerPlayer serverPlayer = (ServerPlayer) event.getEntity(); @@ -80,7 +78,7 @@ public class VanillaSync { serverPlayer.addEffect(mobEffectInstance); } //Advancements - File gameDir = Minecraft.getInstance().gameDirectory; + File gameDir = serverPlayer.getServer().getServerDirectory(); if(Dist.CLIENT.isDedicatedServer()){ File advancements = new File(gameDir, JdbcConfig.SYNC_WORLD.get().get(0)+"/advancements"+"/"+player_uuid+".json"); if (!advancements.exists()) { @@ -159,11 +157,11 @@ public class VanillaSync { //Advancements //File root = serverPlayer.getServer().getServerDirectory(); File advancements = null; + File gameDir = Objects.requireNonNull(player.getServer()).getServerDirectory(); if(isServer){ - File gameDir = player.getServer().getServerDirectory(); advancements = new File(gameDir, JdbcConfig.SYNC_WORLD.get().get(0)+"/advancements"+"/"+player_uuid+".json"); }else{ - File gameDir = Minecraft.getInstance().gameDirectory; +// File gameDir = Minecraft.getInstance().gameDirectory; File[] files=ScanAdvancementsFile(player_uuid, gameDir); //Get LastModified long latestModifiedDate = 0;