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;
}
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;
}
Aggregations