use of com.solinia.solinia.Interfaces.ISoliniaClass in project solinia3-core by mixxit.
the class CommandAddRaceClass 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 racename = args[0];
String classname = args[1];
try {
ISoliniaRace race = StateManager.getInstance().getConfigurationManager().getRace(racename);
ISoliniaClass classobj = StateManager.getInstance().getConfigurationManager().getClassObj(classname);
if (race == null) {
sender.sendMessage("Race does not exist");
return false;
}
if (classobj == null) {
sender.sendMessage("Class does not exist");
return false;
}
if (classobj.getValidRaces() != null)
if (classobj.getValidRaces().contains(race.getId())) {
sender.sendMessage("Race already contains class");
return false;
}
StateManager.getInstance().getConfigurationManager().addRaceClass(race.getId(), classobj.getId());
sender.sendMessage("* Race class combination added");
return true;
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
Aggregations