Search in sources :

Example 1 with SoliniaDisguiseCreationException

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

the class SoliniaDisguiseFactory method Create.

public static SoliniaDisguise Create(String disguiseName, String disguiseType) throws CoreStateInitException, SoliniaDisguiseCreationException {
    if (StateManager.getInstance().getConfigurationManager().getDisguise(disguiseName.toUpperCase()) != null)
        throw new SoliniaDisguiseCreationException("Disguise already exists: " + StateManager.getInstance().getConfigurationManager().getDisguise(disguiseName.toUpperCase()).getDisguiseName());
    SoliniaDisguise d = new SoliniaDisguise();
    d.setId(StateManager.getInstance().getConfigurationManager().getNextDisguiseId());
    d.setDisguiseName(disguiseName.toUpperCase());
    d.setDisguiseType(disguiseType.toUpperCase());
    StateManager.getInstance().getConfigurationManager().addDisguise(d);
    return d;
}
Also used : SoliniaDisguiseCreationException(com.solinia.solinia.Exceptions.SoliniaDisguiseCreationException) SoliniaDisguise(com.solinia.solinia.Models.SoliniaDisguise)

Example 2 with SoliniaDisguiseCreationException

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

the class CommandCreateDisguise 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.isOp() && !sender.hasPermission("solinia.createdisguise")) {
        sender.sendMessage("You do not have permission to access this command");
        return false;
    }
    if (args.length < 2) {
        sender.sendMessage("Insufficient arguments: name disguisetype");
        return false;
    }
    String name = args[0].toUpperCase();
    String disguisetype = args[1].toUpperCase();
    if (name.equals("")) {
        sender.sendMessage("Name of disguise cannot be null");
        return false;
    }
    if (disguisetype.equals("")) {
        sender.sendMessage("Type of disguise cannot be null");
        return false;
    }
    try {
        SoliniaDisguise existing = StateManager.getInstance().getConfigurationManager().getDisguise(name);
        if (existing != null) {
            sender.sendMessage("A disguise already exists with this name");
            return false;
        }
        SoliniaDisguise disguise = SoliniaDisguiseFactory.Create(name, disguisetype);
        sender.sendMessage("Created Disguise: " + disguise.getId());
    } catch (CoreStateInitException | SoliniaDisguiseCreationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        sender.sendMessage(e.getMessage());
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) SoliniaDisguiseCreationException(com.solinia.solinia.Exceptions.SoliniaDisguiseCreationException) CommandSender(org.bukkit.command.CommandSender) SoliniaDisguise(com.solinia.solinia.Models.SoliniaDisguise)

Aggregations

SoliniaDisguiseCreationException (com.solinia.solinia.Exceptions.SoliniaDisguiseCreationException)2 SoliniaDisguise (com.solinia.solinia.Models.SoliniaDisguise)2 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)1 CommandSender (org.bukkit.command.CommandSender)1 Player (org.bukkit.entity.Player)1