Search in sources :

Example 6 with CoreStateInitException

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

the class CommandCreateQuest method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp()) {
            player.sendMessage("This is an operator only command");
            return false;
        }
    }
    if (args.length < 1) {
        sender.sendMessage("Insufficient arguments: name");
        return false;
    }
    String questname = args[0];
    if (questname.equals("")) {
        sender.sendMessage("Invalid quest name");
        return false;
    }
    try {
        for (ISoliniaQuest quest : StateManager.getInstance().getConfigurationManager().getQuests()) {
            if (quest.getName().toUpperCase().equals(questname.toUpperCase())) {
                sender.sendMessage("That quest already exists");
                return false;
            }
        }
        SoliniaQuest quest = new SoliniaQuest();
        quest.setId(StateManager.getInstance().getConfigurationManager().getNextQuestId());
        quest.setName(questname);
        StateManager.getInstance().getConfigurationManager().addQuest(quest);
        sender.sendMessage("Quest created! [" + quest.getId() + "]");
    } catch (CoreStateInitException e) {
        sender.sendMessage(e.getMessage());
    }
    return true;
}
Also used : ISoliniaQuest(com.solinia.solinia.Interfaces.ISoliniaQuest) Player(org.bukkit.entity.Player) ISoliniaQuest(com.solinia.solinia.Interfaces.ISoliniaQuest) SoliniaQuest(com.solinia.solinia.Models.SoliniaQuest) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

Example 7 with CoreStateInitException

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

the class CommandEditFaction method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp() && !player.hasPermission("solinia.editfaction")) {
            player.sendMessage("You do not have permission to access this command");
            return false;
        }
    }
    if (args.length == 0) {
        return false;
    }
    int factionid = Integer.parseInt(args[0]);
    if (args.length == 1) {
        try {
            ISoliniaFaction solfaction = StateManager.getInstance().getConfigurationManager().getFaction(factionid);
            if (solfaction != null) {
                solfaction.sendFactionSettingsToSender(sender);
            } else {
                sender.sendMessage("FACTION ID doesnt exist");
            }
            return true;
        } catch (CoreStateInitException e) {
            sender.sendMessage(e.getMessage());
        }
    }
    if (args.length < 3) {
        sender.sendMessage("Insufficient arguments: factionid setting value");
        return false;
    }
    String setting = args[1];
    String value = args[2];
    // a string
    if (args.length > 3 && (setting.toLowerCase().contains("description") || setting.toLowerCase().contains("factionentry") || setting.toLowerCase().contains("allygrants") || setting.toLowerCase().contains("title"))) {
        value = "";
        int current = 0;
        for (String entry : args) {
            current++;
            if (current <= 2)
                continue;
            value = value + entry + " ";
        }
        value = value.trim();
    }
    if (factionid < 1) {
        sender.sendMessage("Invalid faction id");
        return false;
    }
    try {
        if (StateManager.getInstance().getConfigurationManager().getFaction(factionid) == null) {
            sender.sendMessage("Cannot locate faction id: " + factionid);
            return false;
        }
        if (StateManager.getInstance().getConfigurationManager().getFaction(factionid).isOperatorCreated() && !sender.isOp()) {
            sender.sendMessage("This faction was op created and you are not an op. Only ops can faction op items");
            return false;
        }
        StateManager.getInstance().getConfigurationManager().editFaction(factionid, setting, value);
        sender.sendMessage("Updating setting on faction");
    } catch (InvalidFactionSettingException ne) {
        sender.sendMessage("Invalid faction setting: " + ne.getMessage());
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        sender.sendMessage(e.getMessage());
    } catch (NumberFormatException e) {
        // TODO Auto-generated catch block
        sender.sendMessage(e.getMessage());
    } catch (IOException e) {
        // TODO Auto-generated catch block
        sender.sendMessage(e.getMessage());
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) ISoliniaFaction(com.solinia.solinia.Interfaces.ISoliniaFaction) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) InvalidFactionSettingException(com.solinia.solinia.Exceptions.InvalidFactionSettingException) IOException(java.io.IOException)

Example 8 with CoreStateInitException

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

the class CommandEditClass method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp()) {
            player.sendMessage("This is an operator only command");
            return false;
        }
    }
    if (args.length == 0) {
        return false;
    }
    int classid = Integer.parseInt(args[0]);
    if (args.length == 1) {
        try {
            ISoliniaClass solclass = StateManager.getInstance().getConfigurationManager().getClassObj(classid);
            if (solclass != null) {
                solclass.sendClassSettingsToSender(sender);
            } else {
                sender.sendMessage("CLASS ID doesnt exist");
            }
            return true;
        } catch (CoreStateInitException e) {
            sender.sendMessage(e.getMessage());
        }
    }
    if (args.length < 3) {
        sender.sendMessage("Insufficient arguments: classid setting value");
        return false;
    }
    String setting = args[1];
    String value = args[2];
    // a string
    if (args.length > 3 && (setting.toLowerCase().contains("text") || setting.toLowerCase().contains("description") || setting.toLowerCase().contains("title"))) {
        value = "";
        int current = 0;
        for (String entry : args) {
            current++;
            if (current <= 2)
                continue;
            value = value + entry + " ";
        }
        value = value.trim();
    }
    if (classid < 1) {
        sender.sendMessage("Invalid class id");
        return false;
    }
    try {
        if (StateManager.getInstance().getConfigurationManager().getClassObj(classid) == null) {
            sender.sendMessage("Cannot locate class id: " + classid);
            return false;
        }
        StateManager.getInstance().getConfigurationManager().editClass(classid, setting, value);
        sender.sendMessage("Updating setting on class");
    } catch (InvalidClassSettingException ne) {
        sender.sendMessage("Invalid class setting: " + ne.getMessage());
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        sender.sendMessage(e.getMessage());
    }
    return true;
}
Also used : ISoliniaClass(com.solinia.solinia.Interfaces.ISoliniaClass) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) InvalidClassSettingException(com.solinia.solinia.Exceptions.InvalidClassSettingException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

Example 9 with CoreStateInitException

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

the class CommandCreateLootDrop method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp() && !player.hasPermission("solinia.createlootdrop")) {
            player.sendMessage("You do not have permission to access this command");
            return false;
        }
    }
    if (args.length < 1) {
        sender.sendMessage("Insufficient arguments: name");
        return false;
    }
    String lootdropname = "";
    int count = 0;
    for (String entry : args) {
        lootdropname += entry;
        count++;
    }
    if (lootdropname.equals("")) {
        sender.sendMessage("Blank name not allowed when creating lootdrop");
        return false;
    }
    lootdropname = lootdropname.replace(" ", "_").toUpperCase();
    if (lootdropname.length() > 25) {
        sender.sendMessage("Lootdrop name cannot be longer than 25 characters");
        return true;
    }
    try {
        if (StateManager.getInstance().getConfigurationManager().getLootDrop(lootdropname) != null) {
            sender.sendMessage("LootDrop already exists with the same name");
            return true;
        }
        SoliniaLootFactory.CreateLootDrop(lootdropname, sender.isOp());
        sender.sendMessage("LootDrop created as " + StateManager.getInstance().getConfigurationManager().getLootDrop(lootdropname).getId());
    } catch (CoreStateInitException e) {
        sender.sendMessage(e.getMessage());
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

Example 10 with CoreStateInitException

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

the class CommandCreateMerchantList method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp()) {
            player.sendMessage("This is an operator only command");
            return false;
        }
    }
    if (args.length < 1) {
        sender.sendMessage("Insufficient arguments: name");
        return false;
    }
    String merchantlistname = "";
    for (String entry : args) {
        merchantlistname += entry;
    }
    if (merchantlistname.equals("")) {
        sender.sendMessage("Blank name not allowed when creating merchant list");
        return false;
    }
    merchantlistname.replace(" ", "_");
    try {
        if (StateManager.getInstance().getConfigurationManager().getNPCMerchant(merchantlistname.toUpperCase()) != null) {
            sender.sendMessage("MerchantList already exists with the same name");
            return true;
        }
        SoliniaNPCMerchantFactory.CreateNPCMerchant(merchantlistname);
        sender.sendMessage("MerchantList created");
    } catch (CoreStateInitException e) {
        sender.sendMessage(e.getMessage());
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

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