use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class CommandEditNpcEvent method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp()) {
player.sendMessage("This is an operator only command");
return false;
}
}
if (args.length == 0) {
return false;
}
int npcid = Integer.parseInt(args[0]);
if (args.length == 1) {
try {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(npcid);
if (npc != null) {
npc.sendNPCEvents(sender);
} else {
sender.sendMessage("NPC ID doesnt exist");
}
return true;
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
}
String triggertext = args[1];
if (args.length == 2) {
try {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(npcid);
if (npc != null) {
boolean found = false;
for (ISoliniaNPCEventHandler handler : npc.getEventHandlers()) {
if (handler.getTriggerdata().toUpperCase().equals(triggertext.toUpperCase())) {
found = true;
npc.sendNPCEvent(sender, triggertext);
}
}
if (found == false) {
sender.sendMessage("Trigger event doesnt exist on npc");
}
} else {
sender.sendMessage("NPC ID doesnt exist");
}
return true;
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
}
if (args.length < 4) {
sender.sendMessage("Insufficient arguments: npcid triggertext setting value");
return false;
}
String setting = args[2];
String value = args[3];
// for 'text' based npc settings like trigger texts etc, get the whole thing as a string
if (args.length > 4 && (setting.toLowerCase().equals("chatresponse") || setting.toLowerCase().equals("title") || setting.toLowerCase().equals("randomisedgearsuffix"))) {
value = "";
int current = 0;
for (String entry : args) {
current++;
if (current <= 3)
continue;
value = value + entry + " ";
}
value = value.trim();
}
if (npcid < 1) {
sender.sendMessage("Invalid NPC id");
return false;
}
try {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(npcid);
if (npc != null) {
boolean found = false;
for (ISoliniaNPCEventHandler handler : npc.getEventHandlers()) {
if (handler.getTriggerdata().toUpperCase().equals(triggertext.toUpperCase())) {
found = true;
}
}
if (found == false) {
sender.sendMessage("Trigger event doesnt exist on npc");
return false;
}
} else {
sender.sendMessage("NPC ID doesnt exist");
return false;
}
StateManager.getInstance().getConfigurationManager().editNpcTriggerEvent(npcid, triggertext, setting, value);
sender.sendMessage("Updating setting on NPC Event");
} catch (InvalidNPCEventSettingException ne) {
sender.sendMessage("Invalid NPC Event Setting: " + ne.getMessage());
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
sender.sendMessage(e.getMessage());
}
return true;
}
use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getMaxHP.
@Override
public double getMaxHP() {
if (getNpcid() < 1 && !isPlayer())
return 1;
double statHp = Utils.getStatMaxHP(getClassObj(), getLevel(), getStamina());
double itemHp = getItemHp();
double totalHp = statHp + itemHp;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc == null)
return totalHp;
totalHp += Utils.getTotalEffectTotalHP(this.getBukkitLivingEntity());
if (npc.isBoss()) {
totalHp += (Utils.getBossHPMultiplier() * npc.getLevel());
}
if (npc.isHeroic()) {
totalHp += (Utils.getHeroicHPMultiplier() * npc.getLevel());
}
if (npc.isRaidboss()) {
totalHp += (Utils.getRaidBossHPMultiplier() * npc.getLevel());
}
if (npc.isRaidheroic()) {
totalHp += (Utils.getRaidHeroicHPMultiplier() * npc.getLevel());
}
return totalHp;
}
if (isPlayer()) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
if (solplayer == null)
return totalHp;
totalHp += Utils.getTotalEffectTotalHP(this.getBukkitLivingEntity());
// get AA hp bonus
totalHp += Utils.getTotalAAEffectMaxHp(this.getBukkitLivingEntity());
return totalHp;
}
} catch (CoreStateInitException e) {
return totalHp;
}
return totalHp;
}
use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getWisdom.
@Override
public int getWisdom() {
if (getNpcid() < 1 && !isPlayer())
return 1;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc == null)
return 1;
int stat = npc.getLevel() * 5;
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "WISDOM");
if (stat > getMaxStat("WISDOM"))
stat = getMaxStat("WISDOM");
return stat;
}
if (isPlayer()) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
if (solplayer == null)
return 1;
int stat = 1;
if (solplayer.getRace() != null)
stat += solplayer.getRace().getWisdom();
stat += solplayer.getTotalItemStat("WISDOM");
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "WISDOM");
stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "WISDOM");
if (stat > getMaxStat("WISDOM"))
stat = getMaxStat("WISDOM");
return stat;
}
} catch (CoreStateInitException e) {
return 1;
}
return 1;
}
use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class SoliniaLivingEntity method processInteractionEvent.
@Override
public void processInteractionEvent(LivingEntity triggerentity, InteractionType type, String data) {
if (this.getNpcid() > 0) {
ISoliniaNPC npc;
try {
npc = StateManager.getInstance().getConfigurationManager().getNPC(this.getNpcid());
npc.processInteractionEvent(this, triggerentity, type, data);
} catch (CoreStateInitException e) {
e.printStackTrace();
}
}
}
use of com.solinia.solinia.Interfaces.ISoliniaNPC in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getStamina.
@Override
public int getStamina() {
if (getNpcid() < 1 && !isPlayer())
return 1;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc == null)
return 1;
int stat = npc.getLevel() * 5;
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STAMINA");
if (stat > getMaxStat("STAMINA"))
stat = getMaxStat("STAMINA");
return stat;
}
if (isPlayer()) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
if (solplayer == null)
return 1;
int stat = 1;
if (solplayer.getRace() != null)
stat += solplayer.getRace().getStamina();
stat += solplayer.getTotalItemStat("STAMINA");
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STAMINA");
stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "STAMINA");
if (stat > getMaxStat("STAMINA"))
stat = getMaxStat("STAMINA");
return stat;
}
} catch (CoreStateInitException e) {
return 1;
}
return 1;
}
Aggregations