mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 00:39:40 +00:00
Bunch more Get Packets
This commit is contained in:
1 parent
57e41412dd
commit
f950ba0a22
12 files changed
+265
-56
No files matched your search
@@ -137,10 +137,13 @@ public class PacketHandler {
|
||||
REQUEST_PACKET.registerPacket(new DialogCategorySavePacket());
|
||||
REQUEST_PACKET.registerPacket(new DialogCategoryRemovePacket());
|
||||
REQUEST_PACKET.registerPacket(new DialogCategoryGetPacket());
|
||||
REQUEST_PACKET.registerPacket(new DialogCategoriesGetPacket());
|
||||
|
||||
// Dialog Packets
|
||||
REQUEST_PACKET.registerPacket(new DialogSavePacket());
|
||||
REQUEST_PACKET.registerPacket(new DialogRemovePacket());
|
||||
REQUEST_PACKET.registerPacket(new DialogsGetPacket());
|
||||
REQUEST_PACKET.registerPacket(new DialogGetPacket());
|
||||
|
||||
REQUEST_PACKET.registerPacket(new DialogNpcGetPacket());
|
||||
REQUEST_PACKET.registerPacket(new DialogNpcSetPacket());
|
||||
@@ -166,6 +169,7 @@ public class PacketHandler {
|
||||
|
||||
// Tag Packets
|
||||
REQUEST_PACKET.registerPacket(new TagsGetPacket());
|
||||
REQUEST_PACKET.registerPacket(new TagGetPacket());
|
||||
REQUEST_PACKET.registerPacket(new TagsNpcGetPacket());
|
||||
REQUEST_PACKET.registerPacket(new TagSetPacket());
|
||||
REQUEST_PACKET.registerPacket(new TagSavePacket());
|
||||
|
||||
@@ -31,7 +31,6 @@ public enum EnumRequestPacket {
|
||||
DialogNpcGet,
|
||||
DialogCategorySave,
|
||||
DialogCategoriesGet,
|
||||
DialogsGetFromDialog,
|
||||
DialogCategoryRemove,
|
||||
DialogCategoryGet,
|
||||
DialogSave,
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package kamkeel.npcs.network.packets.request.dialog;
|
||||
|
||||
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.PacketUtil;
|
||||
import kamkeel.npcs.network.enums.EnumItemPacketType;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.ScrollDataPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.data.DialogCategory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class DialogCategoriesGetPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|DialogCategoriesGet";
|
||||
|
||||
public DialogCategoriesGetPacket() {}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.DialogCategoriesGet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.REQUEST_PACKET;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK))
|
||||
return;
|
||||
|
||||
ScrollDataPacket.sendScrollData((EntityPlayerMP) player, DialogController.Instance.getScroll());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package kamkeel.npcs.network.packets.request.dialog;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.*;
|
||||
import kamkeel.npcs.network.enums.EnumItemPacketType;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
import noppes.npcs.controllers.QuestController;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
import noppes.npcs.controllers.data.Quest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class DialogGetPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|DialogGet";
|
||||
|
||||
private int dialogID;
|
||||
|
||||
public DialogGetPacket() {}
|
||||
|
||||
public DialogGetPacket(int dialogID) {
|
||||
this.dialogID = dialogID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.DialogGet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.REQUEST_PACKET;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(this.dialogID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK))
|
||||
return;
|
||||
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(in.readInt());
|
||||
if(dialog != null){
|
||||
NBTTagCompound compound = dialog.writeToNBT(new NBTTagCompound());
|
||||
Quest quest = QuestController.Instance.quests.get(dialog.quest);
|
||||
if(quest != null)
|
||||
compound.setString("DialogQuestName", quest.title);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
|
||||
}
|
||||
}
|
||||
|
||||
public static void getDialog(int id){
|
||||
PacketClient.sendClient(new DialogGetPacket(id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package kamkeel.npcs.network.packets.request.dialog;
|
||||
|
||||
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.PacketUtil;
|
||||
import kamkeel.npcs.network.enums.EnumItemPacketType;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.controllers.DialogController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class DialogsGetPacket extends AbstractPacket {
|
||||
public static String packetName = "Request|DialogsGet";
|
||||
|
||||
private int categoryID;
|
||||
private boolean sendGroup;
|
||||
|
||||
public DialogsGetPacket() {}
|
||||
|
||||
public DialogsGetPacket(int categoryID, boolean send) {
|
||||
this.categoryID = categoryID;
|
||||
this.sendGroup = send;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.DialogsGet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.REQUEST_PACKET;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(this.categoryID);
|
||||
out.writeBoolean(this.sendGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
|
||||
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK))
|
||||
return;
|
||||
|
||||
int catID = in.readInt();
|
||||
boolean sendGroup = in.readBoolean();
|
||||
if(sendGroup){
|
||||
NoppesUtilServer.sendDialogGroup((EntityPlayerMP) player,DialogController.Instance.categories.get(catID));
|
||||
}
|
||||
else {
|
||||
NoppesUtilServer.sendDialogData((EntityPlayerMP) player,DialogController.Instance.categories.get(catID));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package kamkeel.npcs.network.packets.request.tags;
|
||||
|
||||
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.PacketUtil;
|
||||
import kamkeel.npcs.network.enums.EnumItemPacketType;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.controllers.TagController;
|
||||
import noppes.npcs.controllers.data.Tag;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public final class TagGetPacket extends AbstractPacket {
|
||||
public static final String packetName = "Request|TagGet";
|
||||
|
||||
private int tagID;
|
||||
|
||||
public TagGetPacket() {}
|
||||
|
||||
public TagGetPacket(int tagID) {
|
||||
this.tagID = tagID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getType() {
|
||||
return EnumRequestPacket.TagGet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketChannel getChannel() {
|
||||
return PacketHandler.REQUEST_PACKET;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void sendData(ByteBuf out) throws IOException {
|
||||
out.writeInt(tagID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!PacketUtil.verifyItemPacket(player, EnumItemPacketType.WAND, EnumItemPacketType.CLONER))
|
||||
return;
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
Tag tag = TagController.getInstance().get(in.readInt());
|
||||
tag.writeNBT(compound);
|
||||
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -72,9 +72,7 @@ public class PacketHandlerServer{
|
||||
warn(player, "tried to use custom npcs without a tool in hand, probably a hacker");
|
||||
else {
|
||||
if (item != null) {
|
||||
if (item.getItem() == CustomItems.wand)
|
||||
wandPackets(type, in, player, npc);
|
||||
else if (item.getItem() == CustomItems.moving)
|
||||
if (item.getItem() == CustomItems.moving)
|
||||
movingPackets(type, in, player, npc);
|
||||
else if (item.getItem() == CustomItems.mount)
|
||||
mountPackets(type, in, player);
|
||||
@@ -365,26 +363,7 @@ public class PacketHandlerServer{
|
||||
}
|
||||
|
||||
private void blockPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException {
|
||||
if(type == EnumPacketServer.DialogCategoriesGet){
|
||||
ScrollDataPacket.sendScrollData(player, DialogController.Instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogsGetFromDialog){
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(buffer.readInt());
|
||||
if(dialog == null)
|
||||
return;
|
||||
NoppesUtilServer.sendDialogData(player,dialog.category);
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogsGet){
|
||||
int catID = buffer.readInt();
|
||||
boolean sendGroup = buffer.readBoolean();
|
||||
if(sendGroup){
|
||||
NoppesUtilServer.sendDialogGroup(player,DialogController.Instance.categories.get(catID));
|
||||
}
|
||||
else {
|
||||
NoppesUtilServer.sendDialogData(player,DialogController.Instance.categories.get(catID));
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestsGetFromQuest){
|
||||
if(type == EnumPacketServer.QuestsGetFromQuest){
|
||||
Quest quest = QuestController.Instance.quests.get(buffer.readInt());
|
||||
if(quest == null)
|
||||
return;
|
||||
@@ -406,16 +385,6 @@ public class PacketHandlerServer{
|
||||
else if(type == EnumPacketServer.FactionsGet){
|
||||
NoppesUtilServer.sendFactionDataAll(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogGet){
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(buffer.readInt());
|
||||
if(dialog != null){
|
||||
NBTTagCompound compound = dialog.writeToNBT(new NBTTagCompound());
|
||||
Quest quest = QuestController.Instance.quests.get(dialog.quest);
|
||||
if(quest != null)
|
||||
compound.setString("DialogQuestName", quest.title);
|
||||
GuiDataPacket.sendGuiData(player, compound);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestGet){
|
||||
Quest quest = QuestController.Instance.quests.get(buffer.readInt());
|
||||
if(quest != null){
|
||||
@@ -431,17 +400,8 @@ public class PacketHandlerServer{
|
||||
faction.writeNBT(compound);
|
||||
GuiDataPacket.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.TagGet){
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
Tag tag = TagController.getInstance().get(buffer.readInt());
|
||||
tag.writeNBT(compound);
|
||||
GuiDataPacket.sendGuiData(player, compound);
|
||||
}
|
||||
}
|
||||
|
||||
private void wandPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws IOException{
|
||||
blockPackets(type, buffer, player);
|
||||
}
|
||||
private void mountPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player) throws IOException{
|
||||
if(type == EnumPacketServer.SpawnRider){
|
||||
Entity entity = EntityList.createEntityFromNBT(ByteBufUtils.readNBT(buffer), player.worldObj);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.dialog.DialogGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
@@ -66,16 +67,16 @@ public class SubGuiNpcAvailabilityDialog extends SubGuiInterface implements GuiS
|
||||
getButton(13).setDisplayText("availability.selectdialog");
|
||||
|
||||
if(availabitily.dialogId >= 0){
|
||||
Client.sendData(EnumPacketServer.DialogGet, availabitily.dialogId);
|
||||
DialogGetPacket.getDialog(availabitily.dialogId);
|
||||
}
|
||||
if(availabitily.dialog2Id >= 0){
|
||||
Client.sendData(EnumPacketServer.DialogGet, availabitily.dialog2Id);
|
||||
DialogGetPacket.getDialog(availabitily.dialog2Id);
|
||||
}
|
||||
if(availabitily.dialog3Id >= 0){
|
||||
Client.sendData(EnumPacketServer.DialogGet, availabitily.dialog3Id);
|
||||
DialogGetPacket.getDialog(availabitily.dialog3Id);
|
||||
}
|
||||
if(availabitily.dialog4Id >= 0){
|
||||
Client.sendData(EnumPacketServer.DialogGet, availabitily.dialog4Id);
|
||||
DialogGetPacket.getDialog(availabitily.dialog4Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package noppes.npcs.client.gui;
|
||||
|
||||
import kamkeel.npcs.network.packets.request.dialog.DialogGetPacket;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.Client;
|
||||
@@ -44,7 +45,7 @@ public class SubGuiNpcDialogOption extends SubGuiInterface implements IGuiData,
|
||||
if(option.optionType == EnumOptionType.DialogOption){
|
||||
this.addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 84, "availability.selectdialog"));
|
||||
if(option.dialogId >= 0)
|
||||
Client.sendData(EnumPacketServer.DialogGet, option.dialogId);
|
||||
DialogGetPacket.getDialog(option.dialogId);
|
||||
}
|
||||
if(option.optionType == EnumOptionType.CommandBlock){
|
||||
this.addTextField(new GuiNpcTextField(4, this, this.fontRendererObj, guiLeft + 4, guiTop + 84, 248, 20, option.command));
|
||||
|
||||
@@ -43,7 +43,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
public GuiNPCManageDialogs(EntityNPCInterface npc)
|
||||
{
|
||||
super(npc);
|
||||
Client.sendData(EnumPacketServer.DialogCategoriesGet);
|
||||
PacketClient.sendClient(new DialogCategoriesGetPacket());
|
||||
}
|
||||
|
||||
public void initGui()
|
||||
@@ -278,7 +278,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
else {
|
||||
category.readNBT(compound);
|
||||
setPrevCatName(category.title);
|
||||
Client.sendData(EnumPacketServer.DialogsGet, category.id, true);
|
||||
PacketClient.sendClient(new DialogsGetPacket(category.id, true));
|
||||
resetDiagList();
|
||||
}
|
||||
initGui();
|
||||
@@ -354,7 +354,7 @@ public class GuiNPCManageDialogs extends GuiNPCInterface2 implements IScrollGrou
|
||||
String selected = dialogScroll.getSelected();
|
||||
if(!selected.equals(prevDialogName) || override){
|
||||
dialog = new Dialog();
|
||||
Client.sendData(EnumPacketServer.DialogGet, dialogData.get(selected));
|
||||
DialogGetPacket.getDialog(dialogData.get(selected));
|
||||
setPrevDialogName(selected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package noppes.npcs.client.gui.global;
|
||||
|
||||
import kamkeel.npcs.network.PacketClient;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagsGetPacket;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagRemovePacket;
|
||||
import kamkeel.npcs.network.packets.request.tags.TagSavePacket;
|
||||
@@ -158,7 +159,7 @@ public class GuiNPCManageTags extends GuiNPCInterface2 implements IScrollData,IC
|
||||
{
|
||||
save();
|
||||
selected = scrollTags.getSelected();
|
||||
Client.sendData(EnumPacketServer.TagGet, data.get(selected));
|
||||
PacketClient.sendClient(new TagGetPacket(data.get(selected)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,15 +37,11 @@ public enum EnumPacketServer {
|
||||
EventScriptDataSave(CustomNpcsPermissions.SCRIPT_NPC, true),
|
||||
EventScriptDataGet(true),
|
||||
|
||||
DialogCategoriesGet,
|
||||
DialogsGetFromDialog,
|
||||
DialogsGet,
|
||||
DialogGet,
|
||||
DialogRemove(CustomNpcsPermissions.GLOBAL_DIALOG),
|
||||
|
||||
FactionsGet,
|
||||
FactionGet,
|
||||
TagGet,
|
||||
QuestCategoriesGet,
|
||||
QuestsGetFromQuest, QuestsGet,
|
||||
MerchantUpdate(CustomNpcsPermissions.EDIT_VILLAGER),
|
||||
|
||||
Reference in new issue
Block a user