use of com.solinia.solinia.Interfaces.ISoliniaRace in project solinia3-core by mixxit.
the class JsonRaceRepository method reload.
@Override
public void reload() {
List<ISoliniaRace> file = new ArrayList<ISoliniaRace>();
try {
Gson gson = new Gson();
BufferedReader br = new BufferedReader(new FileReader(filePath));
file = gson.fromJson(br, new TypeToken<List<SoliniaRace>>() {
}.getType());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
races.clear();
for (ISoliniaRace race : file) {
races.put(race.getId(), race);
}
System.out.println("Reloaded " + races.size() + " races");
}
use of com.solinia.solinia.Interfaces.ISoliniaRace in project solinia3-core by mixxit.
the class CommandAddRace 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 < 9)
return false;
String racename = args[0];
int strength = Integer.parseInt(args[1]);
int stamina = Integer.parseInt(args[2]);
int agility = Integer.parseInt(args[3]);
int dexterity = Integer.parseInt(args[4]);
int wisdom = Integer.parseInt(args[5]);
int intelligence = Integer.parseInt(args[6]);
int charisma = Integer.parseInt(args[7]);
boolean adminonly = Boolean.parseBoolean(args[8]);
try {
ISoliniaRace race = SoliniaRaceFactory.CreateRace(racename, strength, stamina, agility, dexterity, wisdom, intelligence, charisma, adminonly);
sender.sendMessage("* Race created [" + race.getId() + "]");
} catch (CoreStateInitException | SoliniaRaceCreationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
sender.sendMessage("Error: " + e.getMessage());
return true;
}
return true;
}
use of com.solinia.solinia.Interfaces.ISoliniaRace 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