Пример #1
0
  public NBTTagCompound writeNBT(NBTTagCompound nbtfactions) {
    nbtfactions.setInteger("Slot", this.id);
    nbtfactions.setString("Title", this.title);
    NBTTagList dialogs = new NBTTagList();
    Iterator var3 = this.dialogs.values().iterator();

    while (var3.hasNext()) {
      Dialog dialog = (Dialog) var3.next();
      dialogs.appendTag(dialog.writeToNBT(new NBTTagCompound()));
    }

    nbtfactions.setTag("Dialogs", dialogs);
    return nbtfactions;
  }
Пример #2
0
 public void readNBT(NBTTagCompound compound) {
   this.id = compound.getInteger("Slot");
   this.title = compound.getString("Title");
   NBTTagList dialogsList = compound.getTagList("Dialogs", 10);
   if (dialogsList != null) {
     for (int ii = 0; ii < dialogsList.tagCount(); ++ii) {
       Dialog dialog = new Dialog();
       dialog.category = this;
       NBTTagCompound comp = dialogsList.getCompoundTagAt(ii);
       dialog.readNBT(comp);
       dialog.id = comp.getInteger("DialogId");
       this.dialogs.put(Integer.valueOf(dialog.id), dialog);
     }
   }
 }
  public void buttonEvent(GuiButton guibutton) {
    int id = guibutton.id;
    if (id == 0) {
      this.save();
      if (this.categorySelection) {
        if (this.category.id < 0) {
          return;
        }

        this.dialog = new Dialog();
        Client.sendData(
            EnumPacketServer.DialogsGet, new Object[] {Integer.valueOf(this.category.id)});
      } else if (!this.categorySelection) {
        this.dialog = new Dialog();
        this.category = new DialogCategory();
        Client.sendData(EnumPacketServer.DialogCategoriesGet, new Object[0]);
      }

      this.categorySelection = !this.categorySelection;
      this.getButton(0).setEnabled(false);
      this.scroll.clear();
      this.data.clear();
    }

    if (id == 1) {
      this.save();

      String name;
      for (name = "New"; this.data.containsKey(name); name = name + "_") {;
      }

      if (this.categorySelection) {
        DialogCategory dialog = new DialogCategory();
        dialog.title = name;
        Client.sendData(
            EnumPacketServer.DialogCategorySave,
            new Object[] {dialog.writeNBT(new NBTTagCompound())});
      } else {
        Dialog dialog1 = new Dialog();
        dialog1.title = name;
        Client.sendData(
            EnumPacketServer.DialogSave,
            new Object[] {
              Integer.valueOf(this.category.id), dialog1.writeToNBT(new NBTTagCompound())
            });
      }
    }

    if (id == 2 && this.data.containsKey(this.scroll.getSelected())) {
      if (this.categorySelection) {
        Client.sendData(
            EnumPacketServer.DialogCategoryRemove,
            new Object[] {Integer.valueOf(this.category.id)});
        this.category = new DialogCategory();
      } else {
        Client.sendData(
            EnumPacketServer.DialogRemove, new Object[] {Integer.valueOf(this.dialog.id)});
        this.dialog = new Dialog();
      }

      this.scroll.clear();
    }

    if (id == 3 && this.dialog.id >= 0) {
      this.setSubGui(new SubGuiNpcTextArea(this.dialog.text));
    }

    if (id == 4 && this.dialog.id >= 0) {
      this.setSubGui(new SubGuiNpcAvailability(this.dialog.availability));
    }

    if (id == 5 && this.dialog.id >= 0) {
      this.setSubGui(new SubGuiNpcFactionOptions(this.dialog.factionOptions));
    }

    if (id == 6 && this.dialog.id >= 0) {
      this.setSubGui(new SubGuiNpcDialogOptions(this.dialog));
    }

    if (id == 7 && this.dialog.id >= 0) {
      NoppesUtil.openGUI(
          super.player, new GuiNPCQuestSelection(super.npc, this, this.dialog.quest));
    }

    if (id == 8 && this.dialog.id >= 0) {
      this.dialog.quest = -1;
      this.initGui();
    }

    if (id == 9 && this.dialog.id >= 0) {
      NoppesUtil.openGUI(
          super.player,
          this.gui = new GuiNpcSoundSelection(super.npc, this, this.getTextField(2).getText()));
    }

    if (id == 10) {
      this.setSubGui(new SubGuiNpcDialogExtra(this.dialog, this));
    }
  }