use of com.solinia.solinia.Interfaces.ISoliniaLootTable in project solinia3-core by mixxit.
the class SoliniaNPC method editSetting.
@Override
public void editSetting(String setting, String value) throws InvalidNpcSettingException, NumberFormatException, CoreStateInitException, java.io.IOException {
switch(setting.toLowerCase()) {
case "name":
if (value.equals(""))
throw new InvalidNpcSettingException("Name is empty");
if (value.length() > 25)
throw new InvalidNpcSettingException("Name is longer than 25 characters");
setName(value);
break;
case "mctype":
setMctype(value);
break;
case "level":
setLevel(Integer.parseInt(value));
break;
case "factionid":
if (Integer.parseInt(value) == 0) {
setFactionid(Integer.parseInt(value));
break;
}
ISoliniaFaction faction = StateManager.getInstance().getConfigurationManager().getFaction(Integer.parseInt(value));
if (faction == null)
throw new InvalidNpcSettingException("Faction ID does not exist");
setFactionid(Integer.parseInt(value));
break;
case "usedisguise":
setUsedisguise(Boolean.parseBoolean(value));
break;
case "disguisetype":
setDisguisetype(value);
break;
case "headitem":
setHeaditem(value);
break;
case "chestitem":
setChestitem(value);
break;
case "legsitem":
setLegsitem(value);
break;
case "feetitem":
setFeetitem(value);
break;
case "handitem":
setHanditem(value);
break;
case "offhanditem":
setOffhanditem(value);
break;
case "clearitems":
setHeaditem(null);
setChestitem(null);
setLegsitem(null);
setFeetitem(null);
setHanditem(null);
setOffhanditem(null);
case "boss":
setBoss(Boolean.parseBoolean(value));
break;
case "heroic":
setHeroic(Boolean.parseBoolean(value));
break;
case "raidboss":
setRaidboss(Boolean.parseBoolean(value));
break;
case "raidheroic":
setRaidheroic(Boolean.parseBoolean(value));
break;
case "burning":
setBurning(Boolean.parseBoolean(value));
break;
case "invisible":
setInvisible(Boolean.parseBoolean(value));
break;
case "customhead":
setCustomhead(Boolean.parseBoolean(value));
break;
case "customheaddata":
// fetches custom head texture by a player name
setCustomheaddata(Utils.getTextureFromName(value));
break;
case "customheaddatafromnpc":
int npcid = Integer.parseInt(value);
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(npcid);
if (npc == null)
throw new InvalidNpcSettingException("NPCID does not exist");
// fetches custom head texture by existing npc
setCustomheaddata(npc.getCustomheaddata());
break;
case "deathgrantstitle":
// fetches custom head texture by a player name
setDeathGrantsTitle(value);
break;
case "merchantid":
if (Integer.parseInt(value) == 0) {
setMerchantid(Integer.parseInt(value));
break;
}
if (StateManager.getInstance().getConfigurationManager().getNPCMerchant(Integer.parseInt(value)) == null)
throw new InvalidNpcSettingException("MerchantID does not exist");
setMerchantid(Integer.parseInt(value));
break;
case "upsidedown":
setUpsidedown(Boolean.parseBoolean(value));
break;
case "loottableid":
if (Integer.parseInt(value) == 0) {
setLoottableid(0);
break;
}
ISoliniaLootTable loottable = StateManager.getInstance().getConfigurationManager().getLootTable(Integer.parseInt(value));
if (loottable == null)
throw new InvalidNpcSettingException("Loottable ID does not exist");
setLoottableid(Integer.parseInt(value));
break;
case "raceid":
setRaceid(Integer.parseInt(value));
break;
case "classid":
setClassid(Integer.parseInt(value));
break;
case "randomspawn":
setRandomSpawn(Boolean.parseBoolean(value));
break;
case "killtriggertext":
setKillTriggerText(value);
break;
case "ac":
setAC(Integer.parseInt(value));
case "randomchattriggertext":
setRandomchatTriggerText(value);
break;
case "guard":
setGuard(Boolean.parseBoolean(value));
break;
case "pet":
setPet(Boolean.parseBoolean(value));
break;
case "roamer":
setRoamer(Boolean.parseBoolean(value));
break;
case "undead":
setUndead(Boolean.parseBoolean(value));
break;
case "animal":
setAnimal(Boolean.parseBoolean(value));
break;
case "summoner":
setSummoner(Boolean.parseBoolean(value));
break;
case "disablespawners":
disableAllSpawners(Boolean.parseBoolean(value));
break;
case "accuracyrating":
setAccuracyRating(Integer.parseInt(value));
break;
case "avoidancerating":
setAvoidanceRating(Integer.parseInt(value));
break;
case "speaksalllanguages":
setSpeaksAllLanguages(Boolean.parseBoolean(value));
break;
default:
throw new InvalidNpcSettingException("Invalid NPC setting. Valid Options are: name,mctype,health,damage,factionid,usedisguise,disguisetype,headitem,chestitem,legsitem,feetitem,handitem,offhanditem,boss,burning,invisible,customhead,customheaddata,merchantid,upsidedown,loottableid,randomspawn,killtriggertext,randomchattriggertext,guard,roamer,undead,customheaddatafromnpc,summoner,disablespawners,animal,speaksalllanguages");
}
}
use of com.solinia.solinia.Interfaces.ISoliniaLootTable in project solinia3-core by mixxit.
the class SoliniaLivingEntity method dropLoot.
@Override
public void dropLoot() {
if (isPlayer())
return;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc.getLoottableid() == 0)
return;
ISoliniaLootTable table = StateManager.getInstance().getConfigurationManager().getLootTable(npc.getLoottableid());
List<ISoliniaLootDropEntry> absoluteitems = new ArrayList<ISoliniaLootDropEntry>();
List<ISoliniaLootDropEntry> rollitems = new ArrayList<ISoliniaLootDropEntry>();
for (ISoliniaLootTableEntry entry : StateManager.getInstance().getConfigurationManager().getLootTable(table.getId()).getEntries()) {
ISoliniaLootDrop droptable = StateManager.getInstance().getConfigurationManager().getLootDrop(entry.getLootdropid());
for (ISoliniaLootDropEntry dropentry : StateManager.getInstance().getConfigurationManager().getLootDrop(droptable.getId()).getEntries()) {
if (dropentry.isAlways() == true) {
absoluteitems.add(dropentry);
continue;
}
rollitems.add(dropentry);
}
}
if (absoluteitems.size() == 0 && rollitems.size() == 0)
return;
int dropcount = StateManager.getInstance().getWorldPerkDropCountModifier();
Random r = new Random();
int randomInt = r.nextInt(100) + 1;
if (rollitems.size() > 0) {
// Based on the chance attempt to drop this item
for (int i = 0; i < dropcount; i++) {
ISoliniaLootDropEntry droptableentry = rollitems.get(new Random().nextInt(rollitems.size()));
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(droptableentry.getItemid());
randomInt = r.nextInt(100) + 1;
// Handle unique item checking also
if (item.isArtifact() == true && item.isArtifactFound() == true)
continue;
if (randomInt <= droptableentry.getChance()) {
// Handle unique item setting also
if (item.isArtifact() == true && item.isArtifactFound() == false)
item.setArtifactFound(true);
getBukkitLivingEntity().getLocation().getWorld().dropItem(getBukkitLivingEntity().getLocation(), item.asItemStack());
}
}
}
// Always drop these items
if (absoluteitems.size() > 0) {
for (int i = 0; i < absoluteitems.size(); i++) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(absoluteitems.get(i).getItemid());
for (int c = 0; c < absoluteitems.get(i).getCount(); c++) {
// Handle unique item checking also
if (item.isArtifact() == true && item.isArtifactFound() == true)
continue;
getBukkitLivingEntity().getLocation().getWorld().dropItem(getBukkitLivingEntity().getLocation(), item.asItemStack());
// Handle unique item setting also
if (item.isArtifact() == true && item.isArtifactFound() == false)
item.setArtifactFound(true);
}
}
}
} else {
/*
* This is no longer needed now we have loot drops int itemDropMinimum = 95; if
* (Utils.RandomChance(itemDropMinimum)) { if (getBukkitLivingEntity()
* instanceof Monster)
* getBukkitLivingEntity().getWorld().dropItem(this.getBukkitLivingEntity().
* getLocation(),SoliniaItemFactory.GenerateRandomLoot().asItemStack()); }
*/
}
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations