use of com.solinia.solinia.Models.SoliniaPlayerSkill in project solinia3-core by mixxit.
the class CommandSetLanguage method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
try {
ISoliniaPlayer soliniaplayer = SoliniaPlayerAdapter.Adapt(player);
if (soliniaplayer.getRace() == null) {
player.sendMessage("You cannot set your language until you /setrace");
return true;
}
if (args.length == 0) {
// always has 100% skill on own race
player.sendMessage(ChatColor.GRAY + "Native Languages: ");
player.sendMessage(ChatColor.BLUE + soliniaplayer.getRace().getName() + ": " + 100);
player.sendMessage(ChatColor.GRAY + "See /skills for other languages you have learned");
player.sendMessage(ChatColor.GRAY + "To set your language use /language languagename");
return false;
}
String language = args[0].toUpperCase();
if (soliniaplayer.getLanguage().equals(language)) {
player.sendMessage("That is already your current tongue.");
return false;
}
if (language.equals(soliniaplayer.getRace().getName())) {
soliniaplayer.setLanguage(language);
player.sendMessage("* You will now speak in " + language);
return true;
}
SoliniaPlayerSkill soliniaskill = soliniaplayer.getSkill(language);
if (soliniaskill != null && soliniaskill.getValue() >= 100) {
soliniaplayer.setLanguage(language);
player.sendMessage("* You will now speak in " + language);
return true;
}
player.sendMessage("Language change failed. Default for you is /language " + soliniaplayer.getRace().getName() + " or any other language you have mastered to 100 in /skills");
return false;
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return true;
}
use of com.solinia.solinia.Models.SoliniaPlayerSkill in project solinia3-core by mixxit.
the class PlayerRegenTickTimer method getPlayerMeditatingManaBonus.
private int getPlayerMeditatingManaBonus(ISoliniaPlayer solplayer) {
int manaregen = 0;
if (solplayer.isMeditating()) {
SoliniaPlayerSkill meditationskill = solplayer.getSkill("MEDITATION");
int bonusmana = 3 + (meditationskill.getValue() / 15);
manaregen += bonusmana;
// apply meditation skill increase
Random r = new Random();
int randomInt = r.nextInt(100) + 1;
if (randomInt > 90) {
int currentvalue = 0;
SoliniaPlayerSkill skill = solplayer.getSkill("MEDITATION");
if (skill != null) {
currentvalue = skill.getValue();
}
if ((currentvalue + 1) <= solplayer.getSkillCap("MEDITATION")) {
solplayer.setSkill("MEDITATION", currentvalue + 1);
}
}
}
return manaregen;
}
use of com.solinia.solinia.Models.SoliniaPlayerSkill in project solinia3-core by mixxit.
the class CommandCraft method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
ItemStack primaryItem = player.getInventory().getItemInMainHand();
if (primaryItem.getType().equals(Material.AIR)) {
player.sendMessage(ChatColor.GRAY + "Empty item in primary hand. You must hold the item you want to use in your crafting recipe");
return false;
}
ItemStack secondaryItem = player.getInventory().getItemInOffHand();
if (secondaryItem.getType().equals(Material.AIR)) {
player.sendMessage(ChatColor.GRAY + "Empty item in offhand. You must hold the item you want to use in your crafting recipe");
return false;
}
if (primaryItem.getAmount() > 1) {
player.sendMessage(ChatColor.GRAY + "Stack size in primary hand is too high (max 1)");
return false;
}
if (secondaryItem.getAmount() > 1) {
player.sendMessage(ChatColor.GRAY + "Stack size in secondary hand is too high (max 1)");
return false;
}
if (!Utils.IsSoliniaItem(primaryItem)) {
player.sendMessage("You can only create a new item from solinia items, not minecraft items");
return true;
}
if (!Utils.IsSoliniaItem(secondaryItem)) {
player.sendMessage("You can only create a new item from solinia items, not minecraft items");
return true;
}
try {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(player);
ISoliniaItem primarysolItem = SoliniaItemAdapter.Adapt(primaryItem);
ISoliniaItem secondarysolItem = SoliniaItemAdapter.Adapt(secondaryItem);
List<SoliniaCraft> craft = StateManager.getInstance().getConfigurationManager().getCrafts(primarysolItem.getId(), secondarysolItem.getId());
if (craft.size() < 1) {
player.sendMessage("You do not seem to know how to make anything with these items");
return true;
}
int createCount = 0;
for (SoliniaCraft craftEntry : craft) {
if (craftEntry.getClassId() > 0) {
if (solPlayer.getClassObj() == null) {
player.sendMessage("You do not seem to know how to make anything with these items");
continue;
}
if (solPlayer.getClassObj().getId() != craftEntry.getClassId()) {
player.sendMessage("You do not seem to know how to make anything with these items");
continue;
}
}
if (craftEntry.getSkilltype() != SkillType.None) {
if (craftEntry.getMinSkill() > 0) {
SoliniaPlayerSkill skill = solPlayer.getSkill(craftEntry.getSkilltype().name().toUpperCase());
if (skill == null) {
player.sendMessage("You do not seem to know how to make anything with these items");
continue;
}
if (skill.getValue() < craftEntry.getMinSkill()) {
player.sendMessage("You do not seem to know how to make anything with these items");
continue;
}
}
}
ISoliniaItem outputItem = StateManager.getInstance().getConfigurationManager().getItem(craftEntry.getOutputItem());
if (outputItem != null) {
player.getWorld().dropItemNaturally(player.getLocation(), outputItem.asItemStack());
player.sendMessage("You fashion the items together to make something new!");
createCount++;
if (craftEntry.getSkilltype() != SkillType.None) {
solPlayer.tryIncreaseSkill(craftEntry.getSkilltype().name().toUpperCase(), 1);
}
}
}
if (createCount > 0) {
player.getInventory().setItemInMainHand(null);
player.getInventory().setItemInOffHand(null);
player.updateInventory();
}
} catch (CoreStateInitException e) {
} catch (SoliniaItemException e) {
player.sendMessage("Item no longer exists");
}
return true;
}
Aggregations