use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class ItemStackAdapter method generateWeaponAbilityLoreText.
private static Collection<String> generateWeaponAbilityLoreText(ISoliniaItem soliniaItem) {
List<String> loreTxt = new ArrayList<String>();
ISoliniaSpell spell;
try {
spell = StateManager.getInstance().getConfigurationManager().getSpell(soliniaItem.getWeaponabilityid());
loreTxt.add(ChatColor.WHITE + "Chance to Proc on Hit: " + ChatColor.YELLOW + spell.getName() + ChatColor.RESET);
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return loreTxt;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class ItemStackAdapter method generateSpellLoreText.
private static List<String> generateSpellLoreText(ISoliniaItem soliniaItem) {
List<String> loreTxt = new ArrayList<String>();
ISoliniaSpell spell;
try {
spell = StateManager.getInstance().getConfigurationManager().getSpell(soliniaItem.getAbilityid());
if (spell.getEffectid1() != 254 && !Utils.getSpellEffectType(spell.getEffectid1()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid1()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue1() == 0) && !Utils.getSpellEffectType(spell.getEffectid1()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue1() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid1()).name() + ChatColor.RESET);
}
if (spell.getEffectid2() != 254 && !Utils.getSpellEffectType(spell.getEffectid2()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid2()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue2() == 0) && !Utils.getSpellEffectType(spell.getEffectid2()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue2() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid2()).name() + ChatColor.RESET);
}
if (spell.getEffectid3() != 254 && !Utils.getSpellEffectType(spell.getEffectid3()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid3()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue3() == 0) && !Utils.getSpellEffectType(spell.getEffectid3()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue3() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid3()).name() + ChatColor.RESET);
}
if (spell.getEffectid4() != 254 && !Utils.getSpellEffectType(spell.getEffectid4()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid4()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue4() == 0) && !Utils.getSpellEffectType(spell.getEffectid4()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue4() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid4()).name() + ChatColor.RESET);
}
if (spell.getEffectid5() != 254 && !Utils.getSpellEffectType(spell.getEffectid5()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid5()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue5() == 0) && !Utils.getSpellEffectType(spell.getEffectid5()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue5() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid5()).name() + ChatColor.RESET);
}
if (spell.getEffectid6() != 254 && !Utils.getSpellEffectType(spell.getEffectid6()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid6()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue6() == 0) && !Utils.getSpellEffectType(spell.getEffectid6()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue6() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid6()).name() + ChatColor.RESET);
}
if (spell.getEffectid7() != 254 && !Utils.getSpellEffectType(spell.getEffectid7()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid7()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue7() == 0) && !Utils.getSpellEffectType(spell.getEffectid7()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue7() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid7()).name() + ChatColor.RESET);
}
if (spell.getEffectid8() != 254 && !Utils.getSpellEffectType(spell.getEffectid8()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid8()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue8() == 0) && !Utils.getSpellEffectType(spell.getEffectid8()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue8() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid8()).name() + ChatColor.RESET);
}
if (spell.getEffectid9() != 254 && !Utils.getSpellEffectType(spell.getEffectid9()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid9()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue9() == 0) && !Utils.getSpellEffectType(spell.getEffectid9()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue9() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid9()).name() + ChatColor.RESET);
}
if (spell.getEffectid10() != 254 && !Utils.getSpellEffectType(spell.getEffectid10()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid10()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue10() == 0) && !Utils.getSpellEffectType(spell.getEffectid10()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue10() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid10()).name() + ChatColor.RESET);
}
if (spell.getEffectid11() != 254 && !Utils.getSpellEffectType(spell.getEffectid11()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid11()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue11() == 0) && !Utils.getSpellEffectType(spell.getEffectid11()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue11() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid11()).name() + ChatColor.RESET);
}
if (spell.getEffectid12() != 254 && !Utils.getSpellEffectType(spell.getEffectid12()).name().contains("LIMIT_") && !(Utils.getSpellEffectType(spell.getEffectid12()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue12() == 0) && !Utils.getSpellEffectType(spell.getEffectid12()).name().contains("StackingCommand_")) {
String pos = "+";
if (spell.getEffectBaseValue12() < 0)
pos = "-";
loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + Utils.getSpellEffectType(spell.getEffectid12()).name() + ChatColor.RESET);
}
loreTxt.add(ChatColor.WHITE + "Mana/Power: " + ChatColor.YELLOW + spell.getMana() + ChatColor.RESET);
loreTxt.add(ChatColor.WHITE + "Spell Skill: " + ChatColor.YELLOW + Utils.getSkillType(spell.getSkill()).name().toUpperCase() + ChatColor.RESET);
loreTxt.add(ChatColor.WHITE + "Range: " + ChatColor.YELLOW + spell.getRange() + ChatColor.RESET);
if (spell.isAASpell()) {
loreTxt.add(ChatColor.WHITE + "This spell is an AA spell" + ChatColor.RESET);
}
if (spell.isBuffSpell() && spell.getBuffduration() > 0) {
loreTxt.add(ChatColor.WHITE + "Buff Duration: " + ChatColor.YELLOW + (spell.getBuffduration() * 6) + " seconds" + ChatColor.RESET);
}
loreTxt.add(ChatColor.WHITE + "Target Type: " + ChatColor.YELLOW + Utils.getSpellTargetType(spell.getTargettype()).name() + ChatColor.RESET);
String classesBuilder = "";
List<SoliniaSpellClass> allowedSpellClasses = spell.getAllowedClasses();
int rowcount = 0;
for (SoliniaSpellClass spellclass : allowedSpellClasses) {
if (StateManager.getInstance().getConfigurationManager().getClassObj(spellclass.getClassname().toUpperCase()) == null)
continue;
classesBuilder += ChatColor.WHITE + spellclass.getClassname() + " (" + ChatColor.YELLOW + spellclass.getMinlevel() + ChatColor.WHITE + ") " + ChatColor.RESET;
rowcount++;
if (rowcount > 2) {
loreTxt.add(classesBuilder);
classesBuilder = "";
}
}
// If we never reached 2 classes on a row, handle the overspill here
if (!classesBuilder.equals(""))
loreTxt.add(classesBuilder);
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return loreTxt;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class ItemStackAdapter method generateConsumableAbilityLoreText.
private static Collection<String> generateConsumableAbilityLoreText(ISoliniaItem soliniaItem) {
List<String> loreTxt = new ArrayList<String>();
ISoliniaSpell spell;
String consumable = "";
if (soliniaItem.isConsumable()) {
consumable += "Consumable ";
}
try {
spell = StateManager.getInstance().getConfigurationManager().getSpell(soliniaItem.getAbilityid());
if (spell.getEffectid1() != 254 && !Utils.getSpellEffectType(spell.getEffectid1()).name().contains("LIMIT_"))
loreTxt.add(ChatColor.WHITE + consumable + "Ability: " + ChatColor.YELLOW + Utils.getSpellEffectType(spell.getEffectid1()).name() + "(" + spell.getEffectBaseValue1() + ")" + ChatColor.RESET);
if (spell.getEffectid2() != 254 && !Utils.getSpellEffectType(spell.getEffectid2()).name().contains("LIMIT_"))
loreTxt.add(ChatColor.WHITE + consumable + "Ability: " + ChatColor.YELLOW + Utils.getSpellEffectType(spell.getEffectid2()).name() + "(" + spell.getEffectBaseValue2() + ")" + ChatColor.RESET);
if (spell.getEffectid3() != 254 && !Utils.getSpellEffectType(spell.getEffectid3()).name().contains("LIMIT_"))
loreTxt.add(ChatColor.WHITE + consumable + "Ability: " + ChatColor.YELLOW + Utils.getSpellEffectType(spell.getEffectid3()).name() + "(" + spell.getEffectBaseValue3() + ")" + ChatColor.RESET);
if (spell.getEffectid4() != 254 && !Utils.getSpellEffectType(spell.getEffectid4()).name().contains("LIMIT_"))
loreTxt.add(ChatColor.WHITE + consumable + "Ability: " + ChatColor.YELLOW + Utils.getSpellEffectType(spell.getEffectid4()).name() + "(" + spell.getEffectBaseValue4() + ")" + ChatColor.RESET);
if (spell.getEffectid5() != 254 && !Utils.getSpellEffectType(spell.getEffectid5()).name().contains("LIMIT_"))
loreTxt.add(ChatColor.WHITE + consumable + "Ability: " + ChatColor.YELLOW + Utils.getSpellEffectType(spell.getEffectid5()).name() + "(" + spell.getEffectBaseValue5() + ")" + ChatColor.RESET);
if (spell.getEffectid6() != 254 && !Utils.getSpellEffectType(spell.getEffectid6()).name().contains("LIMIT_"))
loreTxt.add(ChatColor.WHITE + consumable + "Ability: " + ChatColor.YELLOW + Utils.getSpellEffectType(spell.getEffectid6()).name() + "(" + spell.getEffectBaseValue6() + ")" + ChatColor.RESET);
if (spell.getEffectid7() != 254 && !Utils.getSpellEffectType(spell.getEffectid7()).name().contains("LIMIT_"))
loreTxt.add(ChatColor.WHITE + consumable + "Ability: " + ChatColor.YELLOW + Utils.getSpellEffectType(spell.getEffectid7()).name() + "(" + spell.getEffectBaseValue7() + ")" + ChatColor.RESET);
if (spell.getEffectid8() != 254 && !Utils.getSpellEffectType(spell.getEffectid8()).name().contains("LIMIT_"))
loreTxt.add(ChatColor.WHITE + consumable + "Ability: " + ChatColor.YELLOW + Utils.getSpellEffectType(spell.getEffectid8()).name() + "(" + spell.getEffectBaseValue8() + ")" + ChatColor.RESET);
if (spell.getEffectid9() != 254 && !Utils.getSpellEffectType(spell.getEffectid9()).name().contains("LIMIT_"))
loreTxt.add(ChatColor.WHITE + consumable + "Ability: " + ChatColor.YELLOW + Utils.getSpellEffectType(spell.getEffectid9()).name() + "(" + spell.getEffectBaseValue9() + ")" + ChatColor.RESET);
if (spell.getEffectid10() != 254 && !Utils.getSpellEffectType(spell.getEffectid10()).name().contains("LIMIT_"))
loreTxt.add(ChatColor.WHITE + consumable + "Ability: " + ChatColor.YELLOW + Utils.getSpellEffectType(spell.getEffectid10()).name() + "(" + spell.getEffectBaseValue10() + ")" + ChatColor.RESET);
if (spell.getEffectid11() != 254 && !Utils.getSpellEffectType(spell.getEffectid11()).name().contains("LIMIT_"))
loreTxt.add(ChatColor.WHITE + consumable + "Ability: " + ChatColor.YELLOW + Utils.getSpellEffectType(spell.getEffectid11()).name() + "(" + spell.getEffectBaseValue11() + ")" + ChatColor.RESET);
if (spell.getEffectid12() != 254 && !Utils.getSpellEffectType(spell.getEffectid12()).name().contains("LIMIT_"))
loreTxt.add(ChatColor.WHITE + consumable + "Ability: " + ChatColor.YELLOW + Utils.getSpellEffectType(spell.getEffectid12()).name() + "(" + spell.getEffectBaseValue12() + ")" + ChatColor.RESET);
if (spell.isBuffSpell() && spell.getBuffduration() > 0) {
loreTxt.add(ChatColor.WHITE + consumable + "Buff Duration: " + ChatColor.YELLOW + (spell.getBuffduration() * 6) + " seconds" + ChatColor.RESET);
}
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return loreTxt;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class CommandCharacter method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
if (args.length == 0) {
player.sendMessage("Your Characters: ");
String main = "ALT";
if (solplayer.isMain()) {
main = "MAIN";
}
player.sendMessage("- " + ChatColor.LIGHT_PURPLE + solplayer.getFullNameWithTitle() + ChatColor.RESET + " " + main + " - " + ChatColor.GREEN + "ACTIVE" + ChatColor.RESET);
for (ISoliniaPlayer character : StateManager.getInstance().getPlayerManager().getCharactersByPlayerUUID(player.getUniqueId())) {
if (character.getCharacterId().equals(solplayer.getCharacterId()))
continue;
if (character.isMain()) {
main = "MAIN";
} else {
main = "ALT";
}
TextComponent tc = new TextComponent();
tc.setText("- " + ChatColor.LIGHT_PURPLE + character.getFullNameWithTitle() + ChatColor.RESET + " " + main + " - ");
String details = ChatColor.GOLD + character.getFullNameWithTitle() + " Level: " + character.getLevel() + ChatColor.RESET;
TextComponent tc2 = new TextComponent();
String changetext = "/character load " + character.getCharacterId().toString();
if (StateManager.getInstance().getPlayerManager().getPlayerLastChangeChar(player.getUniqueId()) != null) {
tc2.setText(ChatColor.RED + "Already changed this session" + ChatColor.RESET);
} else {
tc2.setText(ChatColor.AQUA + "[Click to Switch]" + ChatColor.RESET);
tc2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, changetext));
}
tc.addExtra(tc2);
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(details).create()));
sender.spigot().sendMessage(tc);
}
player.sendMessage("Note, new characters may not be visible for up to 15 minutes");
player.sendMessage("Use '/character new' to create a new character");
} else {
switch(args[0].toUpperCase()) {
case "NEW":
if (StateManager.getInstance().getPlayerManager().getPlayerLastChangeChar(player.getUniqueId()) != null) {
player.sendMessage("You can only change your character once per server session. Please wait for the next 4 hourly restart");
return true;
}
ISoliniaPlayer newPlayer = StateManager.getInstance().getPlayerManager().createNewPlayerAlt(plugin, player);
if (newPlayer != null) {
player.sendMessage("Your character has been stored and a new character created");
player.sendMessage("Please check you have not dropped any items due to your character change");
} else {
player.sendMessage("Problem creating your new character");
}
break;
case "LOAD":
if (args.length < 2) {
player.sendMessage("You must provide the character UUID");
return true;
}
if (StateManager.getInstance().getPlayerManager().getPlayerLastChangeChar(player.getUniqueId()) != null) {
player.sendMessage("You can only change your character once per server session. Please wait for the next 4 hourly restart");
return true;
}
UUID characterUUID = UUID.fromString(args[1]);
ISoliniaPlayer loadedPlayer = StateManager.getInstance().getPlayerManager().loadPlayerAlt(plugin, player, characterUUID);
if (loadedPlayer != null) {
player.sendMessage("Your character has been stored and your new character loaded");
player.sendMessage("Please check you have not dropped any items due to your character change");
} else {
player.sendMessage("Problem loading requested character");
}
break;
default:
player.sendMessage("Unknown character subcommand");
break;
}
}
} catch (CoreStateInitException e) {
}
return true;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class CommandConvertMerchantToLootDrop method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender)) {
sender.sendMessage("This is a Player/Console only command");
return false;
}
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp() && !player.hasPermission("solinia.convertmerchanttolootdrop")) {
player.sendMessage("You do not have permission to access this command");
return false;
}
}
if (args.length < 5) {
sender.sendMessage("args: merchantid newlootdropname count always chance");
return true;
}
int merchant = Integer.parseInt(args[0]);
String name = args[1].toUpperCase();
int count = Integer.parseInt(args[2]);
boolean always = Boolean.parseBoolean(args[3]);
int chance = Integer.parseInt(args[4]);
if (name.length() > 25) {
sender.sendMessage("Lootdrop name cannot be longer than 25 characters");
return true;
}
try {
if (StateManager.getInstance().getConfigurationManager().getNPCMerchant(merchant) == null) {
sender.sendMessage("Cannot find merchantid");
return true;
}
if (StateManager.getInstance().getConfigurationManager().getLootDrop(name.toUpperCase()) != null) {
sender.sendMessage("Lootdrop name already in use");
return true;
}
SoliniaLootFactory.CreateLootDropFromMerchant(StateManager.getInstance().getConfigurationManager().getNPCMerchant(merchant), name, count, always, chance, sender.isOp());
sender.sendMessage("LootDrop Created: " + StateManager.getInstance().getConfigurationManager().getLootDrop(name.toUpperCase()).getId());
return true;
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
return false;
}
Aggregations