forked from MagicBane/Server
null pointer evasion
This commit is contained in:
@@ -123,7 +123,7 @@ public class LootManager {
|
|||||||
//iterate the booty tables and add items to mob inventory
|
//iterate the booty tables and add items to mob inventory
|
||||||
MobLoot toAdd = getGenTableItem(bse.lootTable, mob);
|
MobLoot toAdd = getGenTableItem(bse.lootTable, mob);
|
||||||
if (toAdd != null) {
|
if (toAdd != null) {
|
||||||
if(toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix().isEmpty() == true){
|
if(toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix()!= null && toAdd.getSuffix().isEmpty() == true){
|
||||||
toAdd.setIsID(true);
|
toAdd.setIsID(true);
|
||||||
}
|
}
|
||||||
mob.getCharItemManager().addItemToInventory(toAdd);
|
mob.getCharItemManager().addItemToInventory(toAdd);
|
||||||
@@ -133,7 +133,7 @@ public class LootManager {
|
|||||||
int lootTableID = bse.lootTable + 1;
|
int lootTableID = bse.lootTable + 1;
|
||||||
MobLoot toAddHZ = getGenTableItem(lootTableID, mob);
|
MobLoot toAddHZ = getGenTableItem(lootTableID, mob);
|
||||||
if (toAddHZ != null)
|
if (toAddHZ != null)
|
||||||
if(toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix().isEmpty() == true){
|
if(toAdd.getPrefix() != null && toAdd.getPrefix().isEmpty() == true && toAdd.getSuffix()!= null && toAdd.getSuffix().isEmpty() == true){
|
||||||
toAdd.setIsID(true);
|
toAdd.setIsID(true);
|
||||||
}
|
}
|
||||||
mob.getCharItemManager().addItemToInventory(toAddHZ);
|
mob.getCharItemManager().addItemToInventory(toAddHZ);
|
||||||
@@ -169,6 +169,7 @@ public class LootManager {
|
|||||||
|
|
||||||
|
|
||||||
public static MobLoot getGenTableItem(int genTableID, Mob mob) {
|
public static MobLoot getGenTableItem(int genTableID, Mob mob) {
|
||||||
|
try {
|
||||||
if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) {
|
if (genTableID == 0 || mob == null || generalItemTables.containsKey(genTableID) == false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -199,7 +200,7 @@ public class LootManager {
|
|||||||
if (outItem.getItemBase().isGlass() == false) {
|
if (outItem.getItemBase().isGlass() == false) {
|
||||||
int prefixChanceRoll = ThreadLocalRandom.current().nextInt(101);
|
int prefixChanceRoll = ThreadLocalRandom.current().nextInt(101);
|
||||||
double prefixChance = 2.057 * mob.level - 28.67;
|
double prefixChance = 2.057 * mob.level - 28.67;
|
||||||
if(prefixChanceRoll < prefixChance) {
|
if (prefixChanceRoll < prefixChance) {
|
||||||
ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable);
|
ModTypeTable prefixTable = modTypeTables.get(selectedRow.pModTable);
|
||||||
|
|
||||||
int prefixroll = ThreadLocalRandom.current().nextInt(101);
|
int prefixroll = ThreadLocalRandom.current().nextInt(101);
|
||||||
@@ -214,7 +215,7 @@ public class LootManager {
|
|||||||
}
|
}
|
||||||
int suffixChanceRoll = ThreadLocalRandom.current().nextInt(101);
|
int suffixChanceRoll = ThreadLocalRandom.current().nextInt(101);
|
||||||
double suffixChance = 2.057 * mob.level - 28.67;
|
double suffixChance = 2.057 * mob.level - 28.67;
|
||||||
if(suffixChanceRoll < suffixChance) {
|
if (suffixChanceRoll < suffixChance) {
|
||||||
int suffixroll = ThreadLocalRandom.current().nextInt(101);
|
int suffixroll = ThreadLocalRandom.current().nextInt(101);
|
||||||
ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable);
|
ModTypeTable suffixTable = modTypeTables.get(selectedRow.sModTable);
|
||||||
if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) {
|
if (modTables.get(suffixTable.getRowForRange(suffixroll).modTableID) != null) {
|
||||||
@@ -229,6 +230,9 @@ public class LootManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return outItem;
|
return outItem;
|
||||||
|
}catch(Exception e){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private static int TableRoll(int mobLevel){
|
private static int TableRoll(int mobLevel){
|
||||||
int max = (int)(4.882 * mobLevel + 121.0);
|
int max = (int)(4.882 * mobLevel + 121.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user