Search in sources :

Example 26 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class CommandSkillCheck method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        Player player = (Player) sender;
        try {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
            if (solplayer == null) {
                player.sendMessage("Failed to emote, player does not exist");
                return false;
            }
            List<String> skills = new ArrayList<String>();
            skills.add("athletics");
            skills.add("acrobatics");
            skills.add("sleightofhand");
            skills.add("stealth");
            skills.add("arcana");
            skills.add("history");
            skills.add("investigation");
            skills.add("nature");
            skills.add("religion");
            skills.add("animalhandling");
            skills.add("insight");
            skills.add("medicine");
            skills.add("perception");
            skills.add("survival");
            skills.add("deception");
            skills.add("intimidation");
            skills.add("performance");
            skills.add("persuasion");
            String skill = "perception";
            if (args.length == 0) {
                player.sendMessage("Insufficient arguments, must provide skill from this list: " + String.join(",", skills));
                return false;
            } else {
                skill = args[0].toLowerCase();
                if (!skills.contains(skill)) {
                    player.sendMessage("Invalid argument [" + skill + "], must provide skill from this list: " + String.join(", ", skills));
                    return false;
                }
            }
            String message = ChatColor.AQUA + " * " + solplayer.getFullName() + " makes a skill check for " + skill + ". They roll: " + Utils.RandomBetween(0, 20) + "/20" + ChatColor.RESET;
            solplayer.emote(message);
        } catch (CoreStateInitException e) {
            player.sendMessage(e.getMessage());
        }
    }
    return true;
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 27 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class CommandToggleAA method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        Player player = (Player) sender;
        try {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
            if (solplayer == null) {
                player.sendMessage("Failed to toggle AA, player does not exist");
                return false;
            }
            if (solplayer.getLevel() >= 20) {
                if (solplayer.getAapct() > 0) {
                    player.sendMessage("* All of your experience will now go to normal experience");
                    solplayer.setAapct(0);
                } else {
                    player.sendMessage("* All of your experience will now go to AA experience");
                    solplayer.setAapct(100);
                }
            } else {
                player.sendMessage("You must be minimum level 20 to enable AA experience");
            }
        } catch (CoreStateInitException e) {
            e.printStackTrace();
        }
    }
    return true;
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 28 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException 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;
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) SoliniaPlayerSkill(com.solinia.solinia.Models.SoliniaPlayerSkill) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 29 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class CommandSpecialise method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player)) {
        return false;
    }
    Player player = (Player) sender;
    if (args.length < 1) {
        player.sendMessage("Insufficient arguments (<skillname>)");
        return false;
    }
    String skillName = args[0].toUpperCase();
    List<String> validSpecialisationSkills = Utils.getSpecialisationSkills();
    if (!validSpecialisationSkills.contains(skillName)) {
        player.sendMessage("You can only specialise in spell school skills");
        return false;
    }
    try {
        ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
        if (solplayer == null) {
            player.sendMessage("Failed to emote, player does not exist");
            return false;
        }
        if (solplayer.getClassObj() == null) {
            player.sendMessage("Your class cannot specialise");
            return false;
        }
        if (solplayer.getClassObj().getSpecialiselevel() < 1) {
            player.sendMessage("Your class cannot specialise");
            return false;
        }
        if (solplayer.getClassObj().getSpecialiselevel() > solplayer.getLevel()) {
            player.sendMessage("You cannot specialise until level: " + solplayer.getLevel());
            return false;
        }
        if (!solplayer.getSpecialisation().equals("")) {
            player.sendMessage("You have already chosen your specialisation: " + solplayer.getSpecialisation());
            return false;
        }
        solplayer.setSpecialisation(skillName);
        player.sendMessage("Specialisation Set to: " + solplayer.getSpecialisation());
        return true;
    } catch (CoreStateInitException e) {
        player.sendMessage(e.getMessage());
    }
    return true;
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 30 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class CommandSwearFealty method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player)) {
        return false;
    }
    if (args.length < 1)
        return false;
    if (Bukkit.getPlayer(args[0]) == null) {
        sender.sendMessage("Cannot find player");
        return true;
    }
    try {
        Player fealtyTo = Bukkit.getPlayer(args[0]);
        ISoliniaPlayer sourcePlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
        ISoliniaPlayer fealtyPlayer = SoliniaPlayerAdapter.Adapt(fealtyTo);
        if (!sourcePlayer.isMain()) {
            sender.sendMessage("You must be your main character to swear fealty");
            return true;
        }
        if (!fealtyPlayer.isMain()) {
            sender.sendMessage("You can only swear fealty to a main character");
            return true;
        }
        if (sourcePlayer.getRaceId() < 1 || fealtyPlayer.getRaceId() < 1) {
            sender.sendMessage("You and your target must both have a race set");
            return true;
        }
        if (sourcePlayer.getRaceId() != fealtyPlayer.getRaceId()) {
            sender.sendMessage("You can only swear fealty to a player of the same race");
            return true;
        } else {
            sourcePlayer.setFealty(fealtyTo.getUniqueId());
        }
        return true;
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        sender.sendMessage(e.getMessage());
        return true;
    }
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Aggregations

CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)216 Player (org.bukkit.entity.Player)114 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)99 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)43 CommandSender (org.bukkit.command.CommandSender)42 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)41 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)36 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)36 LivingEntity (org.bukkit.entity.LivingEntity)32 ArrayList (java.util.ArrayList)31 Entity (org.bukkit.entity.Entity)21 ItemStack (org.bukkit.inventory.ItemStack)20 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)17 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)16 EventHandler (org.bukkit.event.EventHandler)16 Timestamp (java.sql.Timestamp)13 TextComponent (net.md_5.bungee.api.chat.TextComponent)12 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)11 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)11 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)10