Search in sources :

Example 11 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer 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 12 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer 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 13 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer 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 14 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer 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 15 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer 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

ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)89 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)85 Player (org.bukkit.entity.Player)57 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)16 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)13 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)12 EventHandler (org.bukkit.event.EventHandler)11 LivingEntity (org.bukkit.entity.LivingEntity)10 ArrayList (java.util.ArrayList)9 UUID (java.util.UUID)9 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)8 TextComponent (net.md_5.bungee.api.chat.TextComponent)8 ItemStack (org.bukkit.inventory.ItemStack)8 CommandSender (org.bukkit.command.CommandSender)5 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)5 Entity (org.bukkit.entity.Entity)5 Timestamp (java.sql.Timestamp)4 LocalDateTime (java.time.LocalDateTime)4 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)4 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)4