Search in sources :

Example 1 with SoliniaClassCreationException

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

the class SoliniaClassFactory method CreateClass.

public static ISoliniaClass CreateClass(String classname, boolean adminonly) throws CoreStateInitException, SoliniaClassCreationException {
    if (StateManager.getInstance().getConfigurationManager().getClassObj(classname.toUpperCase()) != null)
        throw new SoliniaClassCreationException("Class already exists");
    SoliniaClass classObj = new SoliniaClass();
    classObj.setId(StateManager.getInstance().getConfigurationManager().getNextClassId());
    classObj.setName(classname.toUpperCase());
    classObj.setAdmin(adminonly);
    StateManager.getInstance().getConfigurationManager().addClass(classObj);
    return classObj;
}
Also used : SoliniaClassCreationException(com.solinia.solinia.Exceptions.SoliniaClassCreationException) SoliniaClass(com.solinia.solinia.Models.SoliniaClass) ISoliniaClass(com.solinia.solinia.Interfaces.ISoliniaClass)

Example 2 with SoliniaClassCreationException

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

the class CommandAddClass method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender)) {
        sender.sendMessage("This is a Player/Console only command");
        return false;
    }
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp()) {
            player.sendMessage("This is an operator only command");
            return true;
        }
    }
    if (args.length < 2)
        return false;
    String classname = args[0];
    boolean adminonly = Boolean.parseBoolean(args[1]);
    try {
        SoliniaClassFactory.CreateClass(classname, adminonly);
        sender.sendMessage("* Class created");
    } catch (CoreStateInitException | SoliniaClassCreationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        sender.sendMessage("Error: " + e.getMessage());
        return true;
    }
    return true;
}
Also used : SoliniaClassCreationException(com.solinia.solinia.Exceptions.SoliniaClassCreationException) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

Aggregations

SoliniaClassCreationException (com.solinia.solinia.Exceptions.SoliniaClassCreationException)2 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)1 ISoliniaClass (com.solinia.solinia.Interfaces.ISoliniaClass)1 SoliniaClass (com.solinia.solinia.Models.SoliniaClass)1 CommandSender (org.bukkit.command.CommandSender)1 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)1 Player (org.bukkit.entity.Player)1