use of com.solinia.solinia.Interfaces.ISoliniaFaction in project solinia3-core by mixxit.
the class SoliniaFaction method editSetting.
@Override
public void editSetting(String setting, String value) throws InvalidFactionSettingException, NumberFormatException, CoreStateInitException, java.io.IOException {
switch(setting.toLowerCase()) {
case "name":
if (value.equals(""))
throw new InvalidFactionSettingException("Name is empty");
if (value.length() > 25)
throw new InvalidFactionSettingException("Name is longer than 25 characters");
setName(value);
break;
case "base":
if (Integer.parseInt(value) < -1500 || Integer.parseInt(value) > 1500)
throw new InvalidFactionSettingException("Bounds are -1500 to 1500");
setBase(Integer.parseInt(value));
break;
case "allygrantstitle":
setAllyGrantsTitle(value);
break;
case "scowlsgrantstitle":
setScowlsGrantsTitle(value);
break;
case "factionentry":
String[] data = value.split(" ");
if (data.length < 2)
throw new InvalidFactionSettingException("Missing factionid and base value to set factionstanding (ie -1500 > 1500)");
int factionId = Integer.parseInt(data[0]);
ISoliniaFaction faction = StateManager.getInstance().getConfigurationManager().getFaction(factionId);
if (faction == null)
throw new InvalidFactionSettingException("Faction doesnt exist");
if (Integer.parseInt(data[1]) < -1500 || Integer.parseInt(data[1]) > 1500)
throw new InvalidFactionSettingException("Bounds are -1500 to 1500");
setFactionEntry(faction.getId(), Integer.parseInt(data[1]));
break;
default:
throw new InvalidFactionSettingException("Invalid SpawnGroup setting. Valid Options are: name, base, factionentry");
}
}
use of com.solinia.solinia.Interfaces.ISoliniaFaction in project solinia3-core by mixxit.
the class SoliniaFactionFactory method CreateFaction.
public static ISoliniaFaction CreateFaction(String factionname, int base, boolean operatorCreated) throws CoreStateInitException {
SoliniaFaction faction = new SoliniaFaction();
faction.setId(StateManager.getInstance().getConfigurationManager().getNextFactionId());
faction.setName(factionname);
faction.setBase(base);
faction.setOperatorCreated(operatorCreated);
return StateManager.getInstance().getConfigurationManager().addFaction(faction);
}
use of com.solinia.solinia.Interfaces.ISoliniaFaction 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.ISoliniaFaction in project solinia3-core by mixxit.
the class SoliniaLivingEntity method doCheckForEnemies.
@Override
public void doCheckForEnemies() {
if (isPlayer())
return;
if (this.getNpcid() < 1)
return;
if (getBukkitLivingEntity().isDead())
return;
if (!(getBukkitLivingEntity() instanceof Creature))
return;
if (((Creature) getBukkitLivingEntity()).getTarget() != null)
return;
try {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(this.getNpcid());
if (npc.getFactionid() == 0)
return;
ISoliniaFaction faction = StateManager.getInstance().getConfigurationManager().getFaction(npc.getFactionid());
if (faction.getName().equals("NEUTRAL") || faction.getName().equals("KOS"))
return;
for (Entity entity : getBukkitLivingEntity().getNearbyEntities(10, 10, 10)) {
if (!(entity instanceof Player))
continue;
if (entity.isDead())
continue;
Player player = (Player) entity;
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(player);
PlayerFactionEntry factionEntry = solPlayer.getFactionEntry(npc.getFactionid());
if (factionEntry != null) {
switch(Utils.getFactionStandingType(factionEntry.getFactionId(), factionEntry.getValue())) {
case FACTION_THREATENLY:
case FACTION_SCOWLS:
if (Utils.isEntityInLineOfSight(player, getBukkitLivingEntity())) {
((Creature) getBukkitLivingEntity()).setTarget(player);
return;
} else {
continue;
}
default:
break;
}
}
}
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.solinia.solinia.Interfaces.ISoliniaFaction in project solinia3-core by mixxit.
the class ConfigurationManager method editFaction.
@Override
public void editFaction(int factionid, String setting, String value) throws NumberFormatException, InvalidFactionSettingException, CoreStateInitException, IOException {
ISoliniaFaction faction = getFaction(factionid);
faction.editSetting(setting, value);
}
Aggregations