mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 07:17:27 +00:00
Large Packet Commit
This commit is contained in:
1 parent
b15d64bd09
commit
f2c34699b1
41 files changed
+446
-432
No files matched your search
@@ -449,249 +449,13 @@ public class PacketHandlerServer{
|
||||
}
|
||||
|
||||
private void wandPackets(EnumPacketServer type, ByteBuf buffer, EntityPlayerMP player, EntityNPCInterface npc) throws IOException{
|
||||
if(type == EnumPacketServer.BanksGet){
|
||||
NoppesUtilServer.sendBankDataAll(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.BankGet){
|
||||
Bank bank = BankController.getInstance().getBank(buffer.readInt());
|
||||
NoppesUtilServer.sendBank(player,bank);
|
||||
}
|
||||
else if(type == EnumPacketServer.BankSave){
|
||||
Bank bank = new Bank();
|
||||
bank.readEntityFromNBT(ByteBufUtils.readNBT(buffer));
|
||||
BankController.getInstance().saveBank(bank);
|
||||
NoppesUtilServer.sendBankDataAll(player);
|
||||
NoppesUtilServer.sendBank(player,bank);
|
||||
}
|
||||
else if(type == EnumPacketServer.BankRemove){
|
||||
BankController.getInstance().removeBank(buffer.readInt());
|
||||
NoppesUtilServer.sendBankDataAll(player);
|
||||
NoppesUtilServer.sendBank(player,new Bank());
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteMainMenu){
|
||||
Entity entity = player.worldObj.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) entity);
|
||||
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
|
||||
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), ((EntityNPCInterface)entity).display.getName(), entity.posX, entity.posY, entity.posZ, entity.worldObj.getWorldInfo().getWorldName()));
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteGlobalMenu){
|
||||
NoppesUtilServer.sendOpenGui(player, EnumGuiType.GlobalRemote, null);
|
||||
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
|
||||
LogWriter.script(String.format("[%s] (Player) %s OPEN GLOBAL MENU", "WAND", player.getCommandSenderName()));
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteDelete){
|
||||
Entity entity = player.worldObj.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
npc = (EntityNPCInterface) entity;
|
||||
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
|
||||
LogWriter.script(String.format("[%s] (Player) %s DELETE NPC %s (%s, %s, %s) [%s]", "WAND", player.getCommandSenderName(), npc.display.getName(), (int)npc.posX, (int)npc.posY, (int)npc.posZ, npc.worldObj.getWorldInfo().getWorldName()));
|
||||
}
|
||||
npc.delete();
|
||||
NoppesUtilServer.deleteNpc(npc,player);
|
||||
NoppesUtilServer.sendNearbyNpcs(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteNpcsGet){
|
||||
NoppesUtilServer.sendNearbyNpcs(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteFreeze){
|
||||
CustomNpcs.FreezeNPCs = !CustomNpcs.FreezeNPCs;
|
||||
ScrollSelectedPacket.setSelectedList(player, CustomNpcs.FreezeNPCs?"Unfreeze NPCs":"Freeze NPCs");
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteFreezeGet){
|
||||
ScrollSelectedPacket.setSelectedList(player, CustomNpcs.FreezeNPCs?"Unfreeze NPCs":"Freeze NPCs");
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteReset){
|
||||
Entity entity = player.worldObj.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
npc = (EntityNPCInterface) entity;
|
||||
npc.reset();
|
||||
}
|
||||
else if(type == EnumPacketServer.RemoteTpToNpc){
|
||||
Entity entity = player.worldObj.getEntityByID(buffer.readInt());
|
||||
if(entity == null || !(entity instanceof EntityNPCInterface))
|
||||
return;
|
||||
npc = (EntityNPCInterface) entity;
|
||||
player.playerNetServerHandler.setPlayerLocation(npc.posX, npc.posY, npc.posZ, 0, 0);
|
||||
}
|
||||
else if(type == EnumPacketServer.Gui){
|
||||
EnumGuiType gui = EnumGuiType.values()[buffer.readInt()];
|
||||
int i = buffer.readInt();
|
||||
int j = buffer.readInt();
|
||||
int k = buffer.readInt();
|
||||
NoppesUtilServer.sendOpenGui(player, gui, npc, i, j, k);
|
||||
}
|
||||
else if(type == EnumPacketServer.RecipesGet){
|
||||
NoppesUtilServer.sendRecipeData(player,buffer.readInt());
|
||||
}
|
||||
else if(type == EnumPacketServer.RecipeGet){
|
||||
RecipeCarpentry recipe = RecipeController.Instance.getRecipe(buffer.readInt());
|
||||
NoppesUtilServer.setRecipeGui(player,recipe);
|
||||
}
|
||||
else if(type == EnumPacketServer.RecipeRemove){
|
||||
RecipeCarpentry recipe = RecipeController.Instance.delete(buffer.readInt());
|
||||
NoppesUtilServer.sendRecipeData(player, recipe.isGlobal?3:4);
|
||||
NoppesUtilServer.setRecipeGui(player,new RecipeCarpentry(""));
|
||||
}
|
||||
else if(type == EnumPacketServer.RecipeSave){
|
||||
RecipeCarpentry recipe = RecipeController.Instance.saveRecipe(ByteBufUtils.readNBT(buffer));
|
||||
NoppesUtilServer.sendRecipeData(player, recipe.isGlobal?3:4);
|
||||
NoppesUtilServer.setRecipeGui(player,recipe);
|
||||
}
|
||||
else if(type == EnumPacketServer.NaturalSpawnGetAll){
|
||||
ScrollDataPacket.sendScrollData(player, SpawnController.Instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.NaturalSpawnGet){
|
||||
SpawnData spawn = SpawnController.Instance.getSpawnData(buffer.readInt());
|
||||
if(spawn != null){
|
||||
GuiDataPacket.sendGuiData(player, spawn.writeNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.NaturalSpawnSave){
|
||||
SpawnData data = new SpawnData();
|
||||
data.readNBT(ByteBufUtils.readNBT(buffer));
|
||||
SpawnController.Instance.saveSpawnData(data);
|
||||
|
||||
ScrollDataPacket.sendScrollData(player, SpawnController.Instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.NaturalSpawnRemove){
|
||||
SpawnController.Instance.removeSpawnData(buffer.readInt());
|
||||
ScrollDataPacket.sendScrollData(player, SpawnController.Instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogCategorySave){
|
||||
DialogCategory category = new DialogCategory();
|
||||
category.readNBT(ByteBufUtils.readNBT(buffer));
|
||||
DialogController.Instance.saveCategory(category);
|
||||
ScrollDataPacket.sendScrollData(player, DialogController.Instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogCategoryRemove){
|
||||
DialogController.Instance.removeCategory(buffer.readInt());
|
||||
ScrollDataPacket.sendScrollData(player, DialogController.Instance.getScroll());
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogCategoryGet){
|
||||
DialogCategory category = DialogController.Instance.categories.get(buffer.readInt());
|
||||
if(category != null){
|
||||
NBTTagCompound comp = category.writeNBT(new NBTTagCompound());
|
||||
comp.removeTag("Dialogs");
|
||||
GuiDataPacket.sendGuiData(player, comp);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogSave){
|
||||
int category = buffer.readInt();
|
||||
Dialog dialog = new Dialog();
|
||||
dialog.readNBT(ByteBufUtils.readNBT(buffer));
|
||||
boolean sendGroup = buffer.readBoolean();
|
||||
DialogController.Instance.saveDialog(category,dialog);
|
||||
if(dialog.category != null){
|
||||
if(sendGroup){
|
||||
NoppesUtilServer.sendDialogGroup(player,dialog.category);
|
||||
}
|
||||
else {
|
||||
NoppesUtilServer.sendDialogData(player,dialog.category);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestOpenGui){
|
||||
if(type == EnumPacketServer.QuestOpenGui){
|
||||
Quest quest = new Quest();
|
||||
int gui = buffer.readInt();
|
||||
quest.readNBT(ByteBufUtils.readNBT(buffer));
|
||||
NoppesUtilServer.setEditingQuest(player,quest);
|
||||
player.openGui(CustomNpcs.instance, gui , player.worldObj, 0, 0, 0);
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogRemove){
|
||||
int diagId = buffer.readInt();
|
||||
boolean sendGroup = buffer.readBoolean();
|
||||
Dialog dialog = DialogController.Instance.dialogs.get(diagId);
|
||||
if(dialog != null && dialog.category != null){
|
||||
DialogController.Instance.removeDialog(dialog);
|
||||
if(sendGroup){
|
||||
NoppesUtilServer.sendDialogGroup(player,dialog.category);
|
||||
}
|
||||
else {
|
||||
NoppesUtilServer.sendDialogData(player,dialog.category);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogNpcGet){
|
||||
NoppesUtilServer.sendNpcDialogs(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogNpcSet){
|
||||
int slot = buffer.readInt();
|
||||
int dialog = buffer.readInt();
|
||||
DialogOption option = NoppesUtilServer.setNpcDialog(slot,dialog,player);
|
||||
if(option != null && option.hasDialog()){
|
||||
NBTTagCompound compound = option.writeNBT();
|
||||
compound.setInteger("Position", slot);
|
||||
GuiDataPacket.sendGuiData(player, compound);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.DialogNpcRemove){
|
||||
npc.dialogs.remove(buffer.readInt());
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestCategoryGet){
|
||||
QuestCategory category = QuestController.Instance.categories.get(buffer.readInt());
|
||||
if(category != null){
|
||||
NBTTagCompound comp = category.writeNBT(new NBTTagCompound());
|
||||
comp.removeTag("Dialogs");
|
||||
GuiDataPacket.sendGuiData(player, comp);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestCategorySave){
|
||||
QuestCategory category = new QuestCategory();
|
||||
category.readNBT(ByteBufUtils.readNBT(buffer));
|
||||
QuestController.Instance.saveCategory(category);
|
||||
NoppesUtilServer.sendQuestCategoryData(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestCategoryRemove){
|
||||
QuestController.Instance.removeCategory(buffer.readInt());
|
||||
NoppesUtilServer.sendQuestCategoryData(player);
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestSave){
|
||||
int category = buffer.readInt();
|
||||
Quest quest = new Quest();
|
||||
quest.readNBT(ByteBufUtils.readNBT(buffer));
|
||||
boolean sendGroup = buffer.readBoolean();
|
||||
QuestController.Instance.saveQuest(category, quest);
|
||||
if(quest.category != null){
|
||||
if(sendGroup){
|
||||
NoppesUtilServer.sendQuestGroup(player, quest.category);
|
||||
}
|
||||
else {
|
||||
NoppesUtilServer.sendQuestData(player, quest.category);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestDialogGetTitle){
|
||||
Dialog quest = DialogController.Instance.dialogs.get(buffer.readInt());
|
||||
Dialog quest2 = DialogController.Instance.dialogs.get(buffer.readInt());
|
||||
Dialog quest3 = DialogController.Instance.dialogs.get(buffer.readInt());
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
if(quest != null)
|
||||
compound.setString("1", quest.title);
|
||||
if(quest2 != null)
|
||||
compound.setString("2", quest2.title);
|
||||
if(quest3 != null)
|
||||
compound.setString("3", quest3.title);
|
||||
GuiDataPacket.sendGuiData(player, compound);
|
||||
}
|
||||
else if(type == EnumPacketServer.QuestRemove){
|
||||
Quest quest = QuestController.Instance.quests.get(buffer.readInt());
|
||||
boolean sendGroup = buffer.readBoolean();
|
||||
if(quest != null){
|
||||
QuestController.Instance.removeQuest(quest);
|
||||
if(sendGroup){
|
||||
NoppesUtilServer.sendQuestGroup(player,quest.category);
|
||||
}
|
||||
else {
|
||||
NoppesUtilServer.sendQuestData(player,quest.category);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketServer.TransportCategoriesGet){
|
||||
NoppesUtilServer.sendTransportCategoryData(player);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user