use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.
the class GameModeFileLoader method loadGameModes.
private void loadGameModes(String[] gameFiles) {
SystemCollections.clearGameModeList();
File gameModeDir = new File(ConfigurationSettings.getSystemsDir(), "gameModes");
int progress = 0;
for (final String gameFile : gameFiles) {
File specGameModeDir = new File(gameModeDir, gameFile);
File miscInfoFile = new File(specGameModeDir, "miscinfo.lst");
final GameMode gm = GameModeFileLoader.loadGameModeMiscInfo(gameFile, miscInfoFile.toURI());
if (gm != null) {
String gmName = gm.getName();
//SettingsHandler.setGame(gmName);
LoadContext context = gm.getModeContext();
loadGameModeInfoFile(gm, new File(specGameModeDir, "level.lst").toURI(), "level");
loadGameModeInfoFile(gm, new File(specGameModeDir, "rules.lst").toURI(), "rules");
// Load equipmentslot.lst
GameModeFileLoader.loadGameModeLstFile(context, eqSlotLoader, gmName, gameFile, "equipmentslots.lst");
// Load paperInfo.lst
GameModeFileLoader.loadGameModeLstFile(context, paperLoader, gmName, gameFile, "paperInfo.lst");
// Load bio files
GameModeFileLoader.loadGameModeLstFile(context, traitLoader, gmName, gameFile, "bio" + File.separator + "traits.lst");
GameModeFileLoader.loadGameModeLstFile(context, locationLoader, gmName, gameFile, "bio" + File.separator + "locations.lst");
// Load load.lst and check for completeness
GameModeFileLoader.loadGameModeLstFile(context, loadInfoLoader, gmName, gameFile, "load.lst");
// Load sizeAdjustment.lst
GameModeFileLoader.loadGameModeLstFile(context, sizeLoader, gmName, gameFile, "sizeAdjustment.lst");
// Load statsandchecks.lst
GameModeFileLoader.loadGameModeLstFile(context, statCheckLoader, gmName, gameFile, "statsandchecks.lst");
// Load equipIcons.lst
GameModeFileLoader.loadGameModeLstFile(context, equipIconLoader, gmName, gameFile, "equipIcons.lst");
GameModeFileLoader.loadGameModeLstFile(context, codeControlLoader, gmName, gameFile, "codeControl.lst");
// Load pointbuymethods.lst
loadPointBuyFile(context, gameFile, gmName);
for (final PointBuyCost pbc : context.getReferenceContext().getConstructedCDOMObjects(PointBuyCost.class)) {
gm.addPointBuyStatCost(pbc);
}
// Load migration.lst
GameModeFileLoader.loadGameModeLstFile(context, migrationLoader, gmName, gameFile, "migration.lst");
GameModeFileLoader.loadGameModeLstFile(context, bioLoader, gmName, gameFile, "bio" + File.separator + "biosettings.lst");
}
try {
GameModeFileLoader.addDefaultWieldCategories(gm.getModeContext());
} catch (final PersistenceLayerException ple) {
Logging.errorPrint("Error Initializing PreParserFactory");
Logging.errorPrint(" " + ple.getMessage(), ple);
throw new UnreachableError();
}
progress++;
setProgress(progress);
}
SystemCollections.sortGameModeList();
}
use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.
the class AssociationKey method buildMap.
private static void buildMap() {
map = new CaseInsensitiveMap<>();
Field[] fields = AssociationKey.class.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
int mod = fields[i].getModifiers();
if (Modifier.isStatic(mod) && Modifier.isFinal(mod) && Modifier.isPublic(mod)) {
try {
Object obj = fields[i].get(null);
if (obj instanceof AssociationKey) {
map.put(fields[i].getName(), (AssociationKey<?>) obj);
}
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new UnreachableError(e);
}
}
}
}
use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.
the class ObjectKey method buildMap.
private static void buildMap() {
map = new CaseInsensitiveMap<>();
Field[] fields = ObjectKey.class.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
int mod = fields[i].getModifiers();
if (java.lang.reflect.Modifier.isStatic(mod) && java.lang.reflect.Modifier.isFinal(mod) && java.lang.reflect.Modifier.isPublic(mod)) {
try {
Object obj = fields[i].get(null);
if (obj instanceof ObjectKey) {
map.put(fields[i].getName(), (ObjectKey<?>) obj);
}
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new UnreachableError(e);
}
}
}
}
use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.
the class InfoPane method setText.
public void setText(String text) {
//This is done so the vertical scroll bar goes back up to the top when the text is changed
EditorKit kit = textPane.getEditorKit();
Document newDoc = kit.createDefaultDocument();
try {
kit.read(new StringReader(text), newDoc, 0);
} catch (IOException | BadLocationException ex) {
throw new UnreachableError(ex);
}
textPane.setDocument(newDoc);
}
use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.
the class TokenFamily method buildMap.
/**
* Actually build the set of Constants, using any "public static final"
* constants within the child (extending) class as initial values in the
* Constant pool.
*/
private static void buildMap() {
typeMap = new TreeMap<>();
Class<TokenFamily> cl = TokenFamily.class;
Field[] fields = cl.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
int mod = fields[i].getModifiers();
if (Modifier.isStatic(mod) && Modifier.isFinal(mod) && Modifier.isPublic(mod)) {
try {
Object o = fields[i].get(null);
if (cl.equals(o.getClass())) {
TokenFamily tObj = cl.cast(o);
if (typeMap.containsKey(tObj.rev)) {
throw new UnreachableError("Attempt to redefine constant value " + tObj.rev + " to " + fields[i].getName() + ", value was " + typeMap.get(tObj.rev));
}
typeMap.put(tObj.rev, tObj);
}
} catch (IllegalArgumentException e) {
throw new UnreachableError("Attempt to fetch field failed: " + e.getMessage());
} catch (IllegalAccessException e) {
throw new UnreachableError("Attempt to fetch field failed for access: " + e.getMessage());
}
}
}
}
Aggregations