Search in sources :

Example 1 with InvalidPacketException

use of com.solinia.solinia.Exceptions.InvalidPacketException in project solinia3-core by mixxit.

the class PacketMobVitals method fromPacketData.

public void fromPacketData(String data) throws InvalidPacketException {
    if (data == null)
        throw new InvalidPacketException("Packet data is empty");
    if (!data.contains("^"))
        throw new InvalidPacketException("Packet data is wrong format");
    String[] dataArray = data.split("\\^", -1);
    if (dataArray.length < 5)
        throw new InvalidPacketException("Packet data missing elements");
    int partyMember = Integer.parseInt(dataArray[0]);
    float healthPercent = Float.parseFloat(dataArray[1]);
    float manaPercent = Float.parseFloat(dataArray[2]);
    int entityId = 0;
    try {
        entityId = Integer.parseInt(dataArray[3]);
    } catch (Exception e) {
    // not valid UUID (ie null
    }
    String name = dataArray[4];
    int level = Integer.parseInt(dataArray[5]);
    int xp = Integer.parseInt(dataArray[6]);
    this.partyMember = partyMember;
    this.healthPercent = healthPercent;
    this.manaPercent = manaPercent;
    this.entityId = entityId;
    this.name = name;
    this.level = level;
    this.xp = xp;
}
Also used : InvalidPacketException(com.solinia.solinia.Exceptions.InvalidPacketException) InvalidPacketException(com.solinia.solinia.Exceptions.InvalidPacketException)

Example 2 with InvalidPacketException

use of com.solinia.solinia.Exceptions.InvalidPacketException in project solinia3-core by mixxit.

the class PacketOpenSpellbook method fromPacketData.

public void fromPacketData(String data) throws InvalidPacketException {
    if (data == null)
        throw new InvalidPacketException("Packet data is empty");
    String[] dataArray = data.split("\\^");
    if (dataArray.length < 1)
        throw new InvalidPacketException("Packet data missing elements");
    int spellbookPage = Integer.parseInt(dataArray[0]);
    // now pages
    this.spellbookPage = new SpellbookPage();
    this.spellbookPage.PageNo = spellbookPage;
    for (int i = 1; i < dataArray.length; i++) {
        String[] spellArray = dataArray[i].split("\\|", -1);
        int slotNo = Integer.parseInt(spellArray[0]);
        int Id = Integer.parseInt(spellArray[1]);
        int Icon = Integer.parseInt(spellArray[2]);
        int NewIcon = Integer.parseInt(spellArray[3]);
        int MemIcon = Integer.parseInt(spellArray[4]);
        String Name = spellArray[5];
        int Level = Integer.parseInt(spellArray[6]);
        String slotDescription = "";
        if (dataArray[i].split("\\|", -1).length > 7)
            slotDescription = spellArray[7];
        this.spellbookPage.setSpellSlot(slotNo, Id, Icon, NewIcon, MemIcon, Name, Level, slotDescription);
    }
}
Also used : InvalidPacketException(com.solinia.solinia.Exceptions.InvalidPacketException)

Example 3 with InvalidPacketException

use of com.solinia.solinia.Exceptions.InvalidPacketException in project solinia3-core by mixxit.

the class PacketEffects method fromPacketData.

public void fromPacketData(String data) throws InvalidPacketException {
    if (data == null)
        throw new InvalidPacketException("Packet data is empty");
    // now pages
    this.effects = new Effects();
    if (data.equals(""))
        return;
    String[] dataArray = data.split("\\^", -1);
    for (int i = 0; i < dataArray.length; i++) {
        String[] effectArray = dataArray[i].split("\\|", -1);
        int SpellId = Integer.parseInt(effectArray[0]);
        int Icon = Integer.parseInt(effectArray[1]);
        int NewIcon = Integer.parseInt(effectArray[2]);
        int MemIcon = Integer.parseInt(effectArray[3]);
        String Name = effectArray[4];
        int TicksLeft = Integer.parseInt(effectArray[5]);
        this.effects.effectSlots.put(SpellId, new EffectSlot(SpellId, Icon, MemIcon, NewIcon, Name, TicksLeft));
    }
}
Also used : InvalidPacketException(com.solinia.solinia.Exceptions.InvalidPacketException)

Example 4 with InvalidPacketException

use of com.solinia.solinia.Exceptions.InvalidPacketException in project solinia3-core by mixxit.

the class PacketEquipSlots method fromPacketData.

public void fromPacketData(String data) throws InvalidPacketException {
    if (data == null)
        throw new InvalidPacketException("Packet data is empty");
    // now pages
    this.equipSlots = new EquipSlots();
    if (data.equals(""))
        return;
    String[] dataArray = data.split("\\^", -1);
    if (dataArray.length < 11)
        throw new InvalidPacketException("Packet data missing elements");
    this.equipSlots.setSlotByIndex(0, dataArray[0]);
    this.equipSlots.setSlotByIndex(1, dataArray[1]);
    this.equipSlots.setSlotByIndex(2, dataArray[2]);
    this.equipSlots.setSlotByIndex(3, dataArray[3]);
    this.equipSlots.setSlotByIndex(4, dataArray[4]);
    this.equipSlots.setSlotByIndex(5, dataArray[5]);
    this.equipSlots.setSlotByIndex(6, dataArray[6]);
    this.equipSlots.setSlotByIndex(7, dataArray[7]);
    this.equipSlots.setSlotByIndex(8, dataArray[8]);
    this.equipSlots.setSlotByIndex(9, dataArray[9]);
    this.equipSlots.setSlotByIndex(10, dataArray[10]);
    this.equipSlots.setSlotByIndex(11, dataArray[11]);
}
Also used : InvalidPacketException(com.solinia.solinia.Exceptions.InvalidPacketException)

Example 5 with InvalidPacketException

use of com.solinia.solinia.Exceptions.InvalidPacketException in project solinia3-core by mixxit.

the class PacketMemorisedSpells method fromPacketData.

public void fromPacketData(String data) throws InvalidPacketException {
    if (data == null)
        throw new InvalidPacketException("Packet data is empty");
    // now pages
    this.memorisedSpells = new MemorisedSpells();
    if (data.equals(""))
        return;
    String[] dataArray = data.split("\\^", -1);
    for (int i = 0; i < dataArray.length; i++) {
        String[] spellArray = dataArray[i].split("\\|", -1);
        int slotNo = Integer.parseInt(spellArray[0]);
        int Id = Integer.parseInt(spellArray[1]);
        int Icon = Integer.parseInt(spellArray[2]);
        int NewIcon = Integer.parseInt(spellArray[3]);
        int MemIcon = Integer.parseInt(spellArray[4]);
        String Name = spellArray[5];
        int Level = Integer.parseInt(spellArray[6]);
        this.memorisedSpells.setSlot(slotNo, Id, Icon, NewIcon, MemIcon, Name, Level);
    }
}
Also used : InvalidPacketException(com.solinia.solinia.Exceptions.InvalidPacketException)

Aggregations

InvalidPacketException (com.solinia.solinia.Exceptions.InvalidPacketException)31 Test (org.junit.Test)21 PacketMobVitals (com.solinia.solinia.Models.PacketMobVitals)4 PacketOpenSpellbook (com.solinia.solinia.Models.PacketOpenSpellbook)4 PacketCastingPercent (com.solinia.solinia.Models.PacketCastingPercent)3 PacketEffects (com.solinia.solinia.Models.PacketEffects)2 PacketEquipSlots (com.solinia.solinia.Models.PacketEquipSlots)2 PacketMemorisedSpells (com.solinia.solinia.Models.PacketMemorisedSpells)2 PacketOpenCharacterCreation (com.solinia.solinia.Models.PacketOpenCharacterCreation)2 PacketTrackingChoices (com.solinia.solinia.Models.PacketTrackingChoices)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 EffectSlot (com.solinia.solinia.Models.EffectSlot)1 EquipSlots (com.solinia.solinia.Models.EquipSlots)1 MemorisedSpells (com.solinia.solinia.Models.MemorisedSpells)1 RaceChoice (com.solinia.solinia.Models.RaceChoice)1 SpellbookPage (com.solinia.solinia.Models.SpellbookPage)1