Search in sources :

Example 6 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.

the class CommandQuests method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player))
        return false;
    try {
        Player player = (Player) sender;
        ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
        player.sendMessage("Aquired Quest Flags:");
        String flags = "";
        for (String questFlag : solplayer.getPlayerQuestFlags()) {
            flags += questFlag.toUpperCase() + " ";
        }
        if (flags.length() > 32767) {
            flags = flags.substring(0, 32760) + "...";
        }
        player.sendMessage(flags.trim());
        player.sendMessage("Active Quests:");
        for (PlayerQuest playerQuest : solplayer.getPlayerQuests()) {
            player.sendMessage(playerQuest.getQuest().getName() + " Complete: " + playerQuest.isComplete());
        }
    } catch (CoreStateInitException e) {
    }
    return true;
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) PlayerQuest(com.solinia.solinia.Models.PlayerQuest) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 7 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.

the class CommandSetChannel method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (args.length == 0) {
            player.sendMessage("Insufficient arguments [OOC,LOCAL]");
            return false;
        }
        if (!args[0].toUpperCase().equals("OOC") && !args[0].toUpperCase().equals("LOCAL")) {
            player.sendMessage("Insufficient arguments [OOC,LOCAL]");
            return false;
        }
        try {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
            solplayer.setCurrentChannel(args[0].toUpperCase());
            player.sendMessage("* Channel set to " + args[0].toUpperCase());
            return true;
        } catch (CoreStateInitException e) {
            sender.sendMessage(e.getMessage());
        }
    }
    return false;
}
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 8 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.

the class CommandSetClass method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player))
        return false;
    try {
        String prolist = "";
        String prolistunformatted = "";
        List<ISoliniaClass> pros = new ArrayList<ISoliniaClass>();
        List<ISoliniaClass> rawpros = StateManager.getInstance().getConfigurationManager().getClasses();
        if ((sender instanceof ConsoleCommandSender || sender instanceof DiscordDefaultChannelCommandSender || sender instanceof DiscordAdminChannelCommandSender)) {
            String tmplist = "";
            for (ISoliniaClass pro : rawpros) {
                tmplist = prolist + " " + ChatColor.LIGHT_PURPLE + pro.getName().toUpperCase() + ChatColor.RESET + "(A:" + pro.isAdmin() + ")";
            }
            sender.sendMessage(tmplist);
            return true;
        }
        Player player = (Player) sender;
        try {
            ISoliniaPlayer soliniaplayer = SoliniaPlayerAdapter.Adapt(player);
            if (soliniaplayer.hasChosenRace() == false) {
                SendProfessionFull(sender, rawpros);
                sender.sendMessage("You cannot pick a profession until you set your race with /setrace");
                return true;
            }
            if (soliniaplayer.hasChosenClass() == true) {
                SendProfessionFull(sender, rawpros);
                sender.sendMessage("You cannot pick a profession as you have already chosen one");
                return true;
            }
            for (ISoliniaClass pro : rawpros) {
                if (!pro.isAdmin() && StateManager.getInstance().getConfigurationManager().isValidRaceClass(soliniaplayer.getRaceId(), pro.getId())) {
                    prolist = prolist + " " + ChatColor.LIGHT_PURPLE + pro.getName().toUpperCase() + ChatColor.RESET;
                    prolistunformatted = prolistunformatted + " " + pro.getName().toUpperCase();
                    pros.add(pro);
                }
            }
            if (args.length == 0) {
                SendProfessionList(sender, rawpros, prolistunformatted);
                sender.sendMessage("Insufficient arguments Valid Professions are: [" + prolist + "]");
                if (soliniaplayer != null) {
                    ISoliniaClass profession = StateManager.getInstance().getConfigurationManager().getClassObj(soliniaplayer.getClassId());
                    if (profession != null)
                        sender.sendMessage("Your current profession is: " + profession.getName());
                    else
                        sender.sendMessage("Your current profession is: UNKNOWN");
                }
                return false;
            }
            String profession = args[0].toUpperCase();
            boolean found = false;
            ISoliniaClass solprofession = null;
            for (ISoliniaClass allowedprofession : pros) {
                if (allowedprofession.getName().equals(profession)) {
                    solprofession = allowedprofession;
                    found = true;
                }
            }
            if (found == false) {
                SendProfessionList(sender, rawpros, prolistunformatted);
                return false;
            }
            if (!StateManager.getInstance().getConfigurationManager().isValidRaceClass(soliniaplayer.getRaceId(), solprofession.getId())) {
                SendProfessionList(sender, rawpros, prolistunformatted);
                sender.sendMessage("That is not a valid Race / Profession");
                return true;
            }
            soliniaplayer.setClassId(solprofession.getId());
            soliniaplayer.setChosenClass(true);
            sender.sendMessage("* Profession set to " + profession);
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
            solplayer.updateMaxHp();
            return true;
        } catch (CoreStateInitException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } catch (CoreStateInitException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        sender.sendMessage(e1.getMessage());
        return false;
    }
    return true;
}
Also used : ISoliniaClass(com.solinia.solinia.Interfaces.ISoliniaClass) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) DiscordAdminChannelCommandSender(com.solinia.solinia.Providers.DiscordAdminChannelCommandSender) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList) DiscordDefaultChannelCommandSender(com.solinia.solinia.Providers.DiscordDefaultChannelCommandSender) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

Example 9 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.

the class CommandNPCGive 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 < 1) {
            player.sendMessage("Invalid syntax missing <itemid>");
            return true;
        }
        if (solplayer.getInteraction() == null) {
            player.sendMessage(ChatColor.GRAY + "* You are not currently interacting with an NPC");
            return true;
        }
        Entity entity = Bukkit.getEntity(solplayer.getInteraction());
        if (entity == null) {
            player.sendMessage(ChatColor.GRAY + "* The npc you are trying to interact with appears to no longer be available");
            return true;
        }
        if (!(entity instanceof LivingEntity)) {
            player.sendMessage(ChatColor.GRAY + "* The npc you are trying to interact with appears to no longer be living");
            return true;
        }
        ISoliniaLivingEntity solentity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) entity);
        if (solentity.getNpcid() < 1) {
            player.sendMessage(ChatColor.GRAY + "* You are not currently interacting with an NPC");
            return true;
        }
        ISoliniaNPC solnpc = StateManager.getInstance().getConfigurationManager().getNPC(solentity.getNpcid());
        int itemid = Integer.parseInt(args[0]);
        if (itemid < 1) {
            player.sendMessage("ItemID must be greater than 0");
            return true;
        }
        ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemid);
        if (Utils.getPlayerTotalCountOfItemId(player, itemid) < 1) {
            player.sendMessage("Sorry but you do not have the quantity you are trying to give");
            return true;
        }
        // Check if the npc actually wants to receive this item
        boolean npcWantsItem = false;
        for (ISoliniaNPCEventHandler eventHandler : solnpc.getEventHandlers()) {
            if (!eventHandler.getInteractiontype().equals(InteractionType.ITEM))
                continue;
            System.out.println("Comparing item id: " + item.getId() + " to triggerdata " + eventHandler.getTriggerdata());
            if (Integer.parseInt(eventHandler.getTriggerdata()) != item.getId())
                continue;
            if (eventHandler.getChatresponse() != null && !eventHandler.getChatresponse().equals("")) {
                System.out.println("Checking if player meets requirements to hand in item");
                if (!eventHandler.playerMeetsRequirements(player)) {
                    player.sendMessage(ChatColor.GRAY + "[Hint] You do not meet the requirements to hand this quest item in. Either you are missing a quest step or have already completed this step");
                    continue;
                }
                System.out.println("NPC wants the item");
                npcWantsItem = true;
                String response = eventHandler.getChatresponse();
                solentity.say(solnpc.replaceChatWordsWithHints(response), player);
                eventHandler.awardPlayer((Player) player);
                Utils.removeItemsFromInventory(player, itemid, 1);
            }
        }
        if (npcWantsItem == false) {
            player.sendMessage(ChatColor.GRAY + "* This being does not want this item at this time");
        }
        return true;
    } catch (CoreStateInitException e) {
        player.sendMessage(e.getMessage());
    }
    return true;
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) ISoliniaNPCEventHandler(com.solinia.solinia.Interfaces.ISoliniaNPCEventHandler) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaNPC(com.solinia.solinia.Interfaces.ISoliniaNPC) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 10 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.

the class CommandSetTitle 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 (args.length == 0) {
                player.sendMessage("Available titles:");
                for (String title : solplayer.getAvailableTitles()) {
                    TextComponent tc = new TextComponent();
                    tc.setText("- " + title);
                    TextComponent tc2 = new TextComponent();
                    tc2.setText(ChatColor.GRAY + "Click here to set this title" + ChatColor.RESET);
                    tc2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/settitle " + title));
                    tc.addExtra(tc2);
                    sender.spigot().sendMessage(tc);
                }
                player.sendMessage("/settitle none to remove your current title");
                return true;
            }
            String targetTitle = args[0];
            if (args.length > 0) {
                targetTitle = "";
                int current = 0;
                for (String entry : args) {
                    current++;
                    targetTitle = targetTitle + entry + " ";
                }
                targetTitle = targetTitle.trim();
            }
            if (!targetTitle.equals("none")) {
                boolean found = false;
                for (String title : solplayer.getAvailableTitles()) {
                    if (targetTitle.toUpperCase().equals(title.toUpperCase())) {
                        targetTitle = title;
                        found = true;
                        break;
                    }
                }
                if (found == false) {
                    player.sendMessage("You do not have this title");
                    return true;
                }
                solplayer.setTitle(targetTitle);
            } else {
                solplayer.setTitle("");
            }
            System.out.println("* [" + player.getName() + "] Title set to: " + "'" + solplayer.getTitle() + "'");
            player.sendMessage("* Title set to: '" + solplayer.getTitle() + "'");
        } catch (CoreStateInitException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            player.sendMessage(e.getMessage());
        }
    }
    return true;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) 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