removed displaying of the message box from the logger

master
Stefan Dollase 2016-11-21 02:47:05 +01:00
parent da8c8e3913
commit 33f6a5b4b8
9 changed files with 59 additions and 28 deletions

View File

@ -11,6 +11,7 @@ import amidst.fragment.Fragment;
import amidst.fragment.FragmentGraph;
import amidst.gui.main.viewer.FragmentGraphToScreenTranslator;
import amidst.logging.AmidstLogger;
import amidst.logging.AmidstMessageBox;
import amidst.mojangapi.world.Dimension;
import amidst.mojangapi.world.biome.Biome;
import amidst.mojangapi.world.biome.UnknownBiomeIndexException;
@ -74,7 +75,9 @@ public class CursorInformationWidget extends TextWidget {
try {
return Biome.getByIndex(biome).getName();
} catch (UnknownBiomeIndexException e) {
AmidstLogger.error(e.getMessage());
String message = e.getMessage();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
e.printStackTrace();
return UNKNOWN_BIOME_NAME;
}

View File

@ -9,6 +9,7 @@ import amidst.documentation.AmidstThread;
import amidst.documentation.CalledOnlyBy;
import amidst.documentation.NotThreadSafe;
import amidst.logging.AmidstLogger;
import amidst.logging.AmidstMessageBox;
import amidst.mojangapi.MojangApi;
import amidst.mojangapi.file.directory.ProfileDirectory;
import amidst.mojangapi.file.directory.VersionDirectory;
@ -88,15 +89,17 @@ public class LocalProfileComponent extends ProfileComponent {
String possibleModProfiles = ".*(optifine|forge).*";
if (Pattern.matches(possibleModProfiles, getVersionName().toLowerCase(Locale.ENGLISH))) {
AmidstLogger.error(
"Amidst does not support modded Minecraft profiles! Please select or create an unmodded Minecraft profile via the Minecraft Launcher.");
AmidstLogger.error("Amidst does not support modded Minecraft profiles! Please select or create an unmodded Minecraft profile via the Minecraft Launcher.");
AmidstMessageBox.displayError("Error", "Amidst does not support modded Minecraft profiles! Please select or create an unmodded Minecraft profile via the Minecraft Launcher.");
return false;
}
mojangApi.set(getProfileName(), profileDirectory, versionDirectory);
return true;
} catch (LocalMinecraftInterfaceCreationException e) {
AmidstLogger.error(e.getMessage());
String message = e.getMessage();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
e.printStackTrace();
return false;
}

View File

@ -18,6 +18,7 @@ import amidst.documentation.AmidstThread;
import amidst.documentation.CalledOnlyBy;
import amidst.documentation.NotThreadSafe;
import amidst.logging.AmidstLogger;
import amidst.logging.AmidstMessageBox;
import amidst.mojangapi.MojangApi;
import amidst.mojangapi.file.MojangApiParsingException;
import amidst.mojangapi.file.json.launcherprofiles.LauncherProfileJson;
@ -155,6 +156,7 @@ public class ProfileSelectWindow {
@CalledOnlyBy(AmidstThread.EDT)
private void scanAndLoadProfilesFailed(Exception e) {
AmidstLogger.error("Error reading launcher_profiles.json");
AmidstMessageBox.displayError("Error", "Error reading launcher_profiles.json");
e.printStackTrace();
profileSelectPanel.setEmptyMessage("Failed loading");
}

View File

@ -18,8 +18,6 @@ public class AmidstLogger {
private static final InMemoryLogger IN_MEMORY_LOGGER = new InMemoryLogger();
private static final Object LOG_LOCK = new Object();
private static final boolean IS_USING_ALERTS = true;
private static final boolean IS_SHOWING_DEBUG = true;
private static final Map<String, Logger> LOGGER = createLoggerMap();
@ -43,11 +41,9 @@ public class AmidstLogger {
}
public static void debug(String message) {
if (IS_SHOWING_DEBUG) {
synchronized (LOG_LOCK) {
for (Logger listener : LOGGER.values()) {
listener.log(DEBUG_TAG, message);
}
synchronized (LOG_LOCK) {
for (Logger listener : LOGGER.values()) {
listener.log(DEBUG_TAG, message);
}
}
}
@ -74,9 +70,6 @@ public class AmidstLogger {
public static void error(String message) {
synchronized (LOG_LOCK) {
if (IS_USING_ALERTS) {
AmidstMessageBox.displayError("Error", message);
}
for (Logger listener : LOGGER.values()) {
listener.log(ERROR_TAG, message);
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import amidst.documentation.Immutable;
import amidst.logging.AmidstLogger;
import amidst.logging.AmidstMessageBox;
import amidst.mojangapi.minecraftinterface.local.SymbolicNames;
@Immutable
@ -51,8 +52,9 @@ public enum WorldType {
if (result != null) {
return result;
} else {
AmidstLogger.error(
"Unable to find World Type: " + nameOrSymbolicFieldName + ". Falling back to default world type.");
String message = "Unable to find World Type: " + nameOrSymbolicFieldName + ". Falling back to default world type.";
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
return DEFAULT;
}
}

View File

@ -2,6 +2,7 @@ package amidst.mojangapi.world.icon.type;
import amidst.documentation.ThreadSafe;
import amidst.logging.AmidstLogger;
import amidst.logging.AmidstMessageBox;
import amidst.mojangapi.minecraftinterface.MinecraftInterfaceException;
import amidst.mojangapi.world.biome.Biome;
import amidst.mojangapi.world.biome.UnknownBiomeIndexException;
@ -28,15 +29,21 @@ public class TempleWorldIconTypeProvider implements WorldIconTypeProvider<Void>
} else if (biome == Biome.icePlains || biome == Biome.coldTaiga) {
return DefaultWorldIconTypes.IGLOO;
} else {
AmidstLogger.error("No known structure for this biome type: " + biome.getName());
String message = "No known structure for this biome type: " + biome.getName();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
return null;
}
} catch (UnknownBiomeIndexException e) {
AmidstLogger.error(e.getMessage());
String message = e.getMessage();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
e.printStackTrace();
return null;
} catch (MinecraftInterfaceException e) {
AmidstLogger.error(e.getMessage());
String message = e.getMessage();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
e.printStackTrace();
return null;
}

View File

@ -5,6 +5,7 @@ import java.util.Random;
import amidst.documentation.ThreadSafe;
import amidst.logging.AmidstLogger;
import amidst.logging.AmidstMessageBox;
import amidst.mojangapi.minecraftinterface.MinecraftInterface;
import amidst.mojangapi.minecraftinterface.MinecraftInterfaceException;
import amidst.mojangapi.world.biome.Biome;
@ -30,7 +31,9 @@ public class BiomeDataOracle {
try {
copyToResult(result, width, height, getBiomeData(left, top, width, height, useQuarterResolution));
} catch (MinecraftInterfaceException e) {
AmidstLogger.error(e.getMessage());
String message = e.getMessage();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
e.printStackTrace();
}
}
@ -56,11 +59,15 @@ public class BiomeDataOracle {
try {
return validBiomes.contains(getBiomeAt(x, y));
} catch (UnknownBiomeIndexException e) {
AmidstLogger.error(e.getMessage());
String message = e.getMessage();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
e.printStackTrace();
return false;
} catch (MinecraftInterfaceException e) {
AmidstLogger.error(e.getMessage());
String message = e.getMessage();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
e.printStackTrace();
return false;
}
@ -86,11 +93,15 @@ public class BiomeDataOracle {
}
return true;
} catch (UnknownBiomeIndexException e) {
AmidstLogger.error(e.getMessage());
String message = e.getMessage();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
e.printStackTrace();
return false;
} catch (MinecraftInterfaceException e) {
AmidstLogger.error(e.getMessage());
String message = e.getMessage();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
e.printStackTrace();
return false;
}
@ -126,11 +137,15 @@ public class BiomeDataOracle {
}
return result;
} catch (UnknownBiomeIndexException e) {
AmidstLogger.error(e.getMessage());
String message = e.getMessage();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
e.printStackTrace();
return null;
} catch (MinecraftInterfaceException e) {
AmidstLogger.error(e.getMessage());
String message = e.getMessage();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
e.printStackTrace();
return null;
}

View File

@ -2,6 +2,7 @@ package amidst.settings.biomeprofile;
import amidst.documentation.ThreadSafe;
import amidst.logging.AmidstLogger;
import amidst.logging.AmidstMessageBox;
import amidst.mojangapi.world.biome.BiomeColor;
import amidst.mojangapi.world.biome.UnknownBiomeIndexException;
@ -17,7 +18,9 @@ public class BiomeProfileSelection {
try {
return getBiomeColor(index);
} catch (UnknownBiomeIndexException e) {
AmidstLogger.error(e.getMessage());
String message = e.getMessage();
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
e.printStackTrace();
return BiomeColor.unknown();
}

View File

@ -8,6 +8,7 @@ import java.util.function.Function;
import amidst.documentation.GsonConstructor;
import amidst.documentation.Immutable;
import amidst.logging.AmidstLogger;
import amidst.logging.AmidstMessageBox;
import amidst.mojangapi.mocking.FragmentCornerWalker;
import amidst.mojangapi.world.World;
import amidst.mojangapi.world.coordinates.CoordinatesInWorld;
@ -38,7 +39,9 @@ public class CoordinatesCollectionJson {
corner -> producer.produce(corner, consumer, additionalDataFactory.apply(corner)));
SortedSet<CoordinatesInWorld> coordinates = createSortedSet(consumer.get());
if (coordinates.size() < minimalNumberOfCoordinates) {
AmidstLogger.error("not enough coordinates for '" + name + "'");
String message = "not enough coordinates for '" + name + "'";
AmidstLogger.error(message);
AmidstMessageBox.displayError("Error", message);
}
return new CoordinatesCollectionJson(coordinates);
}