mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 15:56:10 +00:00
Profile Sync Quest Data Crash Fix
This commit is contained in:
1 parent
5cf9b26a2e
commit
15749c8ad7
10 files changed
+179
-8
No files matched your search
@@ -7,7 +7,9 @@ import kamkeel.npcs.controllers.data.profile.Profile;
|
||||
import kamkeel.npcs.controllers.data.profile.ProfileInfoEntry;
|
||||
import kamkeel.npcs.controllers.data.profile.ProfileOperation;
|
||||
import kamkeel.npcs.controllers.data.profile.Slot;
|
||||
import kamkeel.npcs.network.packets.data.ProfileSharedQuestPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
@@ -453,6 +455,9 @@ public class ProfileController implements IProfileHandler {
|
||||
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(profile.player);
|
||||
verifySlotQuests(profile.player);
|
||||
save(profile.player, profile);
|
||||
if (profile.player instanceof EntityPlayerMP) {
|
||||
ProfileSharedQuestPacket.sendToPlayer((EntityPlayerMP) profile.player);
|
||||
}
|
||||
|
||||
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(profile.player);
|
||||
EventHooks.onProfileCreate(handler, scriptPlayer, profile, newSlotId, true);
|
||||
@@ -524,6 +529,9 @@ public class ProfileController implements IProfileHandler {
|
||||
saveSlotData(profile.player, profile, prevSlot);
|
||||
loadSlotData(profile.player, profile, newSlotId);
|
||||
syncSharedQuestsToPlayer(profile.player);
|
||||
if (profile.player instanceof EntityPlayerMP) {
|
||||
ProfileSharedQuestPacket.sendToPlayer((EntityPlayerMP) profile.player);
|
||||
}
|
||||
|
||||
EventHooks.onProfileChange(handler, scriptPlayer, profile, newSlotId, prevSlot, true);
|
||||
} else {
|
||||
@@ -901,5 +909,8 @@ public class ProfileController implements IProfileHandler {
|
||||
profile.sharedQuestTimestamps.put(questId, completeTime);
|
||||
}
|
||||
save(player, profile);
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
ProfileSharedQuestPacket.sendToPlayer((EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumSyncAction;
|
||||
import kamkeel.npcs.network.enums.EnumSyncType;
|
||||
import kamkeel.npcs.network.packets.data.LoginPacket;
|
||||
import kamkeel.npcs.network.packets.data.ProfileSharedQuestPacket;
|
||||
import kamkeel.npcs.network.packets.data.ability.AbilityCooldownSyncPacket;
|
||||
import kamkeel.npcs.network.packets.data.ability.AbilityHotbarSyncPacket;
|
||||
import kamkeel.npcs.network.packets.data.ability.PlayerAbilitySyncPacket;
|
||||
@@ -184,6 +185,7 @@ public class SyncController {
|
||||
DBCAddon.instance.syncPlayer(player);
|
||||
syncPlayerData(player, false);
|
||||
PartyInfoPacket.sendPartyData(player);
|
||||
ProfileSharedQuestPacket.sendToPlayer(player);
|
||||
|
||||
// Sync skin overlays after full handshake to ensure the client is ready.
|
||||
// Overlays are not part of getSyncNBTFull(), and packets sent during
|
||||
|
||||
@@ -586,6 +586,7 @@ public class PacketHandler {
|
||||
DATA_PACKET.registerPacket(new UpdateAnimationsPacket());
|
||||
DATA_PACKET.registerPacket(new VillagerListPacket());
|
||||
DATA_PACKET.registerPacket(new PlayerDataInfoPacket());
|
||||
DATA_PACKET.registerPacket(new ProfileSharedQuestPacket());
|
||||
|
||||
// Data | GUI Packets
|
||||
DATA_PACKET.registerPacket(new GuiClosePacket());
|
||||
|
||||
@@ -67,6 +67,9 @@ public enum EnumDataPacket {
|
||||
ABILITY_HOTBAR_SYNC,
|
||||
ABILITY_COOLDOWN_SYNC,
|
||||
|
||||
// Profile System
|
||||
PROFILE_SHARED_QUEST,
|
||||
|
||||
// Auction System
|
||||
AUCTION_DATA,
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package kamkeel.npcs.network.packets.data;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumDataPacket;
|
||||
import kamkeel.npcs.util.ByteBufUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.ProfileClientConfig;
|
||||
import noppes.npcs.controllers.ProfileConfigSync;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class ProfileSharedQuestPacket extends AbstractPacket {
|
||||
public static final String packetName = "Data|ProfileSharedQuest";
|
||||
|
||||
private NBTTagCompound compound;
|
||||
|
||||
public ProfileSharedQuestPacket() {
|
||||
}
|
||||
|
||||
public ProfileSharedQuestPacket(NBTTagCompound compound) {
|
||||
this.compound = compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumDataPacket.PROFILE_SHARED_QUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.DATA_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
ByteBufUtils.writeNBT(out, this.compound);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
NBTTagCompound nbt = ByteBufUtils.readNBT(in);
|
||||
ProfileClientConfig.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
public static void sendToPlayer(EntityPlayerMP player) {
|
||||
NBTTagCompound compound = ProfileConfigSync.writeToNBT(player);
|
||||
PacketHandler.Instance.sendToPlayer(new ProfileSharedQuestPacket(compound), player);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user