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;
}
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);
}
}
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));
}
}
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]);
}
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);
}
}
Aggregations