mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 16:39:49 +00:00
General get packet
This commit is contained in:
1 parent
021989aa79
commit
c5329a1c63
11 files changed
+129
-34
No files matched your search
@@ -348,6 +348,8 @@ public class PacketHandler {
|
||||
|
||||
PLAYER_PACKET.registerPacket(new BankActionPacket());
|
||||
|
||||
PLAYER_PACKET.registerPacket(new CheckPlayerValue());
|
||||
|
||||
PLAYER_PACKET.registerPacket(new MailActionPacket());
|
||||
PLAYER_PACKET.registerPacket(new MailActionPacket.MailSendPacket());
|
||||
|
||||
|
||||
@@ -5,16 +5,13 @@ public enum EnumPlayerPacket {
|
||||
Transport,
|
||||
BankAction,
|
||||
Dialog, // TODO
|
||||
QuestLog, // TODO
|
||||
TrackedQuest, // TODO
|
||||
CheckQuestCompletion, // TODO
|
||||
FactionsGet, // TODO
|
||||
GetPlayerValue,
|
||||
MailBoxAction,
|
||||
MailSend,
|
||||
SaveSign, // TODO
|
||||
SaveBook, // TODO
|
||||
Companion, // TODO: OpenInv, TalentExp
|
||||
RoleGet, // TODO
|
||||
GetRole, // TODO
|
||||
InputDevice,
|
||||
ScreenSize
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package kamkeel.npcs.network.packets.player;
|
||||
|
||||
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.EnumPlayerPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import noppes.npcs.NoppesUtilPlayer;
|
||||
import noppes.npcs.controllers.PartyController;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.PlayerFactionData;
|
||||
import noppes.npcs.controllers.data.PlayerQuestData;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class CheckPlayerValue extends AbstractPacket {
|
||||
public static final String packetName = "Player|CheckPlayerVal";
|
||||
|
||||
private Type type;
|
||||
|
||||
public CheckPlayerValue() {
|
||||
}
|
||||
|
||||
public CheckPlayerValue(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumPlayerPacket.GetPlayerValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.PLAYER_PACKET;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(type.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP) player;
|
||||
Type type = Type.values()[in.readInt()];
|
||||
switch (type) {
|
||||
case Faction:
|
||||
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(playerMP).factionData;
|
||||
GuiDataPacket.sendGuiData(playerMP, data.getPlayerGuiData());
|
||||
break;
|
||||
case QuestLog:
|
||||
NoppesUtilPlayer.sendQuestLogData(playerMP);
|
||||
break;
|
||||
case TrackedQuest:
|
||||
NoppesUtilPlayer.sendTrackedQuest(playerMP);
|
||||
break;
|
||||
case CheckQuestCompletion:
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(playerMP);
|
||||
PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(playerMP).questData;
|
||||
Party playerParty = playerData.getPlayerParty();
|
||||
if(playerParty != null)
|
||||
PartyController.Instance().checkQuestCompletion(playerParty, null);
|
||||
|
||||
questData.checkQuestCompletion(playerData, null);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
Faction,
|
||||
QuestLog,
|
||||
TrackedQuest,
|
||||
CheckQuestCompletion
|
||||
}
|
||||
}
|
||||
@@ -185,25 +185,25 @@ public class PacketHandlerPlayer{
|
||||
return;
|
||||
NoppesUtilPlayer.dialogSelected(buffer.readInt(), buffer.readInt(), player, npc);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.CheckQuestCompletion){
|
||||
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
Party playerParty = playerData.getPlayerParty();
|
||||
if(playerParty != null)
|
||||
PartyController.Instance().checkQuestCompletion(playerParty, null);
|
||||
|
||||
questData.checkQuestCompletion(playerData, null);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.QuestLog){
|
||||
NoppesUtilPlayer.sendQuestLogData(player);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.TrackedQuest){
|
||||
NoppesUtilPlayer.sendTrackedQuest(player);
|
||||
}
|
||||
else if(type == EnumPlayerPacket.FactionsGet){
|
||||
PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
|
||||
GuiDataPacket.sendGuiData(player, data.getPlayerGuiData());
|
||||
}
|
||||
// else if(type == EnumPlayerPacket.CheckQuestCompletion){
|
||||
// PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
|
||||
// PlayerQuestData questData = PlayerDataController.Instance.getPlayerData(player).questData;
|
||||
// Party playerParty = playerData.getPlayerParty();
|
||||
// if(playerParty != null)
|
||||
// PartyController.Instance().checkQuestCompletion(playerParty, null);
|
||||
//
|
||||
// questData.checkQuestCompletion(playerData, null);
|
||||
// }
|
||||
// else if(type == EnumPlayerPacket.QuestLog){
|
||||
// NoppesUtilPlayer.sendQuestLogData(player);
|
||||
// }
|
||||
// else if(type == EnumPlayerPacket.TrackedQuest){
|
||||
// NoppesUtilPlayer.sendTrackedQuest(player);
|
||||
// }
|
||||
// else if(type == EnumPlayerPacket.FactionsGet){
|
||||
// PlayerFactionData data = PlayerDataController.Instance.getPlayerData(player).factionData;
|
||||
// GuiDataPacket.sendGuiData(player, data.getPlayerGuiData());
|
||||
// }
|
||||
// else if(type == EnumPlayerPacket.MailGet){
|
||||
// PlayerMailData data = PlayerDataController.Instance.getPlayerData(player).mailData;
|
||||
// GuiDataPacket.sendGuiData(player, data.saveNBTData(new NBTTagCompound()));
|
||||
|
||||
@@ -7,6 +7,7 @@ import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||
import kamkeel.npcs.addon.client.DBCClient;
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
|
||||
import kamkeel.npcs.network.packets.player.InputDevicePacket;
|
||||
import kamkeel.npcs.network.packets.player.ScreenSizePacket;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -49,7 +50,7 @@ public class ClientTickHandler{
|
||||
}
|
||||
if(mc.thePlayer != null && mc.thePlayer.openContainer instanceof ContainerPlayer){
|
||||
if(otherContainer){
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.CheckQuestCompletion);
|
||||
PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.CheckQuestCompletion));
|
||||
otherContainer = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.client.gui.player;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -644,7 +646,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose
|
||||
}
|
||||
private void closed(){
|
||||
grabMouse(false);
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.CheckQuestCompletion);
|
||||
PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.CheckQuestCompletion));
|
||||
}
|
||||
|
||||
public void save() {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.client.gui.player.inventory;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -35,7 +37,7 @@ public class GuiFaction extends GuiCNPCInventory implements IGuiData {
|
||||
ySize = 180;
|
||||
this.drawDefaultBackground = false;
|
||||
title = "";
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.FactionsGet);
|
||||
PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.Faction));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package noppes.npcs.client.gui.player.inventory;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.data.large.PartyDataPacket;
|
||||
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
|
||||
import kamkeel.npcs.network.packets.request.party.*;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
@@ -54,7 +55,7 @@ public class GuiParty extends GuiCNPCInventory implements ITextfieldListener,ICu
|
||||
xSize = 280;
|
||||
ySize = 180;
|
||||
drawDefaultBackground = false;
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.TrackedQuest);
|
||||
PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.TrackedQuest));
|
||||
PacketClient.sendClient(new PartyInfoPacket());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package noppes.npcs.client.gui.player.inventory;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -35,7 +37,7 @@ public class GuiProfiles extends GuiCNPCInventory implements IGuiData {
|
||||
ySize = 180;
|
||||
this.drawDefaultBackground = false;
|
||||
title = "";
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.FactionsGet);
|
||||
PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.Faction));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.client.gui.player.inventory;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
|
||||
import kamkeel.npcs.network.packets.request.party.PartyLogToServerPacket;
|
||||
import kamkeel.npcs.network.packets.request.party.PartySetQuestPacket;
|
||||
import kamkeel.npcs.network.packets.request.quest.QuestLogToServerPacket;
|
||||
@@ -51,7 +52,7 @@ public class GuiQuestLog extends GuiCNPCInventory implements ICustomScrollListen
|
||||
xSize = 280;
|
||||
ySize = 180;
|
||||
drawDefaultBackground = false;
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.QuestLog);
|
||||
PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.QuestLog));
|
||||
}
|
||||
public void initGui(){
|
||||
super.initGui();
|
||||
|
||||
@@ -8,11 +8,11 @@ public enum EnumPlayerPacket {
|
||||
// BankUnlock,
|
||||
// BankUpgrade,
|
||||
Dialog,
|
||||
QuestLog,
|
||||
TrackedQuest,
|
||||
CheckQuestCompletion,
|
||||
// QuestLog,
|
||||
// TrackedQuest,
|
||||
// CheckQuestCompletion,
|
||||
// BankSlotOpen,
|
||||
FactionsGet,
|
||||
// FactionsGet,
|
||||
// MailGet,
|
||||
// MailDelete,
|
||||
// MailSend,
|
||||
|
||||
Reference in new issue
Block a user