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