fix server bug.
This commit is contained in:
parent
0437374dee
commit
029789ccd1
|
|
@ -41,18 +41,12 @@ public class ModsSupport {
|
||||||
StoreCurios(player,true);
|
StoreCurios(player,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ModList.get().isLoaded("sophisticatedbackpacks")) {
|
|
||||||
//TODO sophisticatedbackpacks support
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerLeave(Player player) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
|
public void onPlayerLeave(Player player) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
if (ModList.get().isLoaded("curios")) {
|
if (ModList.get().isLoaded("curios")) {
|
||||||
StoreCurios(player, false);
|
StoreCurios(player, false);
|
||||||
}
|
}
|
||||||
if(ModList.get().isLoaded("sophisticatedbackpacks")) {
|
|
||||||
//TODO sophisticatedbackpacks support
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StoreCurios(Player player,boolean init) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
|
public void StoreCurios(Player player,boolean init) throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.nbt.*;
|
import net.minecraft.nbt.*;
|
||||||
import net.minecraft.network.chat.Component;
|
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.server.level.ServerPlayer;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
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.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
|
import vip.fubuki.playersync.PlayerSync;
|
||||||
import vip.fubuki.playersync.config.JdbcConfig;
|
import vip.fubuki.playersync.config.JdbcConfig;
|
||||||
import vip.fubuki.playersync.util.JDBCsetUp;
|
import vip.fubuki.playersync.util.JDBCsetUp;
|
||||||
import vip.fubuki.playersync.util.LocalJsonUtil;
|
import vip.fubuki.playersync.util.LocalJsonUtil;
|
||||||
|
|
@ -32,7 +30,7 @@ import java.util.*;
|
||||||
public class VanillaSync {
|
public class VanillaSync {
|
||||||
|
|
||||||
@SubscribeEvent
|
@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();
|
String player_uuid = event.getEntity().getUUID().toString();
|
||||||
ResultSet resultSet=JDBCsetUp.executeQuery("SELECT online FROM player_data WHERE uuid='"+player_uuid+"'");
|
ResultSet resultSet=JDBCsetUp.executeQuery("SELECT online FROM player_data WHERE uuid='"+player_uuid+"'");
|
||||||
ServerPlayer serverPlayer = (ServerPlayer) event.getEntity();
|
ServerPlayer serverPlayer = (ServerPlayer) event.getEntity();
|
||||||
|
|
@ -80,7 +78,7 @@ public class VanillaSync {
|
||||||
serverPlayer.addEffect(mobEffectInstance);
|
serverPlayer.addEffect(mobEffectInstance);
|
||||||
}
|
}
|
||||||
//Advancements
|
//Advancements
|
||||||
File gameDir = Minecraft.getInstance().gameDirectory;
|
File gameDir = serverPlayer.getServer().getServerDirectory();
|
||||||
if(Dist.CLIENT.isDedicatedServer()){
|
if(Dist.CLIENT.isDedicatedServer()){
|
||||||
File advancements = new File(gameDir, JdbcConfig.SYNC_WORLD.get().get(0)+"/advancements"+"/"+player_uuid+".json");
|
File advancements = new File(gameDir, JdbcConfig.SYNC_WORLD.get().get(0)+"/advancements"+"/"+player_uuid+".json");
|
||||||
if (!advancements.exists()) {
|
if (!advancements.exists()) {
|
||||||
|
|
@ -159,11 +157,11 @@ public class VanillaSync {
|
||||||
//Advancements
|
//Advancements
|
||||||
//File root = serverPlayer.getServer().getServerDirectory();
|
//File root = serverPlayer.getServer().getServerDirectory();
|
||||||
File advancements = null;
|
File advancements = null;
|
||||||
|
File gameDir = Objects.requireNonNull(player.getServer()).getServerDirectory();
|
||||||
if(isServer){
|
if(isServer){
|
||||||
File gameDir = player.getServer().getServerDirectory();
|
|
||||||
advancements = new File(gameDir, JdbcConfig.SYNC_WORLD.get().get(0)+"/advancements"+"/"+player_uuid+".json");
|
advancements = new File(gameDir, JdbcConfig.SYNC_WORLD.get().get(0)+"/advancements"+"/"+player_uuid+".json");
|
||||||
}else{
|
}else{
|
||||||
File gameDir = Minecraft.getInstance().gameDirectory;
|
// File gameDir = Minecraft.getInstance().gameDirectory;
|
||||||
File[] files=ScanAdvancementsFile(player_uuid, gameDir);
|
File[] files=ScanAdvancementsFile(player_uuid, gameDir);
|
||||||
//Get LastModified
|
//Get LastModified
|
||||||
long latestModifiedDate = 0;
|
long latestModifiedDate = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user