formatting

* organized imports
* removed unnecessary @formatter:off comments
* formatted the code using the new code formatter with new preferences
master
Stefan Dollase 2016-11-20 22:07:14 +01:00
parent e81b1d5076
commit 1832a7c6b5
85 changed files with 497 additions and 453 deletions

View File

@ -42,11 +42,9 @@ public class Amidst {
private static void parseCommandLineArgumentsAndRun(String[] args) {
CommandLineParameters parameters = new CommandLineParameters();
AmidstMetaData metadata = createMetadata();
CmdLineParser parser = new CmdLineParser(parameters, ParserProperties
.defaults()
.withShowDefaults(false)
.withUsageWidth(120)
.withOptionSorter(null));
CmdLineParser parser = new CmdLineParser(
parameters,
ParserProperties.defaults().withShowDefaults(false).withUsageWidth(120).withOptionSorter(null));
try {
parser.parseArgument(args);
run(parameters, metadata, parser);
@ -174,12 +172,11 @@ public class Amidst {
} catch (DotMinecraftDirectoryNotFoundException e) {
Log.w(e.getMessage());
e.printStackTrace();
JOptionPane
.showMessageDialog(
null,
"Amidst is not able to find your '.minecraft' directory, but it requires a working Minecraft installation.",
"Please install Minecraft",
JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(
null,
"Amidst is not able to find your '.minecraft' directory, but it requires a working Minecraft installation.",
"Please install Minecraft",
JOptionPane.ERROR_MESSAGE);
} catch (Exception e) {
handleCrash(e, Thread.currentThread());
}

View File

@ -34,7 +34,8 @@ public class Application {
@CalledOnlyBy(AmidstThread.EDT)
public Application(CommandLineParameters parameters, AmidstMetaData metadata, AmidstSettings settings)
throws DotMinecraftDirectoryNotFoundException, LocalMinecraftInterfaceCreationException {
throws DotMinecraftDirectoryNotFoundException,
LocalMinecraftInterfaceCreationException {
this.parameters = parameters;
this.metadata = metadata;
this.settings = settings;
@ -45,11 +46,12 @@ public class Application {
}
@CalledOnlyBy(AmidstThread.EDT)
private MojangApi createMojangApi() throws DotMinecraftDirectoryNotFoundException,
private MojangApi createMojangApi()
throws DotMinecraftDirectoryNotFoundException,
LocalMinecraftInterfaceCreationException {
return new MojangApiBuilder(new WorldBuilder(
new PlayerInformationCacheImpl(),
SeedHistoryLogger.from(parameters.seedHistoryFile)), parameters).construct();
return new MojangApiBuilder(
new WorldBuilder(new PlayerInformationCacheImpl(), SeedHistoryLogger.from(parameters.seedHistoryFile)),
parameters).construct();
}
@CalledOnlyBy(AmidstThread.EDT)
@ -89,25 +91,22 @@ public class Application {
@CalledOnlyBy(AmidstThread.EDT)
public void displayMainWindow() {
setMainWindow(new MainWindow(
this,
metadata,
settings,
mojangApi,
biomeProfileDirectory,
viewerFacadeBuilder,
threadMaster));
setMainWindow(
new MainWindow(
this,
metadata,
settings,
mojangApi,
biomeProfileDirectory,
viewerFacadeBuilder,
threadMaster));
setProfileSelectWindow(null);
}
@CalledOnlyBy(AmidstThread.EDT)
public void displayProfileSelectWindow() {
setProfileSelectWindow(new ProfileSelectWindow(
this,
metadata,
threadMaster.getWorkerExecutor(),
mojangApi,
settings));
setProfileSelectWindow(
new ProfileSelectWindow(this, metadata, threadMaster.getWorkerExecutor(), mojangApi, settings));
setMainWindow(null);
}

View File

@ -26,8 +26,11 @@ public enum Classes {
public static Map<String, SymbolicClass> createSymbolicClassMap(
File jarFile,
URLClassLoader classLoader,
ClassTranslator translator) throws FileNotFoundException, JarFileParsingException,
SymbolicClassGraphCreationException, ClassNotFoundException {
ClassTranslator translator)
throws FileNotFoundException,
JarFileParsingException,
SymbolicClassGraphCreationException,
ClassNotFoundException {
Log.i("Reading " + jarFile.getName());
List<RealClass> realClasses = RealClasses.fromJarFile(jarFile);
Log.i("Jar load complete.");
@ -42,7 +45,8 @@ public enum Classes {
}
public static Map<SymbolicClassDeclaration, Integer> countMatches(File jarFile, ClassTranslator translator)
throws FileNotFoundException, JarFileParsingException {
throws FileNotFoundException,
JarFileParsingException {
Log.i("Checking " + jarFile.getName());
List<RealClass> realClasses = RealClasses.fromJarFile(jarFile);
Map<SymbolicClassDeclaration, List<RealClass>> map = translator.translateToAllMatching(realClasses);
@ -56,8 +60,10 @@ public enum Classes {
for (RealClass realClass : entry.getValue()) {
builder.append(", ").append(realClass.getRealClassName());
}
Log.w(entry.getKey().getSymbolicClassName() + " has multiple matching classes: "
+ builder.toString().substring(2));
Log
.w(
entry.getKey().getSymbolicClassName() + " has multiple matching classes: "
+ builder.toString().substring(2));
}
}
return result;

View File

@ -16,14 +16,15 @@ import amidst.documentation.Immutable;
public enum RealClasses {
;
private static final int MAXIMUM_CLASS_BYTES = 16*1024;
private static final int MAXIMUM_CLASS_BYTES = 16 * 1024;
private static final RealClassBuilder REAL_CLASS_BUILDER = new RealClassBuilder();
public static List<RealClass> fromJarFile(File jarFile) throws FileNotFoundException, JarFileParsingException {
return readRealClassesFromJarFile(jarFile);
}
private static List<RealClass> readRealClassesFromJarFile(File jarFile) throws JarFileParsingException,
private static List<RealClass> readRealClassesFromJarFile(File jarFile)
throws JarFileParsingException,
FileNotFoundException {
if (!jarFile.exists()) {
throw new FileNotFoundException("Attempted to load jar file at: " + jarFile + " but it does not exist.");
@ -49,7 +50,8 @@ public enum RealClasses {
return result;
}
private static RealClass readJarFileEntry(ZipFile zipFile, ZipEntry entry) throws IOException,
private static RealClass readJarFileEntry(ZipFile zipFile, ZipEntry entry)
throws IOException,
RealClassCreationException {
String realClassName = getFileNameWithoutExtension(entry.getName(), "class");
if (!entry.isDirectory() && realClassName != null) {
@ -59,7 +61,8 @@ public enum RealClasses {
}
}
private static RealClass readRealClass(String realClassName, BufferedInputStream stream) throws IOException,
private static RealClass readRealClass(String realClassName, BufferedInputStream stream)
throws IOException,
RealClassCreationException {
try (BufferedInputStream theStream = stream) {
// TODO: Double check that this filter won't mess anything up.

View File

@ -59,22 +59,30 @@ public class SymbolicClass {
return fieldsBySymbolicName.get(symbolicName) != null;
}
public SymbolicObject callConstructor(String symbolicName, Object... parameters) throws InstantiationException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException {
public SymbolicObject callConstructor(String symbolicName, Object... parameters)
throws InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException {
return constructorsBySymbolicName.get(symbolicName).call(parameters);
}
public Object callMethod(String symbolicName, SymbolicObject symbolicObject, Object... parameters)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
throws IllegalAccessException,
IllegalArgumentException,
InvocationTargetException {
return methodsBySymbolicName.get(symbolicName).call(symbolicObject, parameters);
}
public Object callStaticMethod(String symbolicName, Object... parameters) throws IllegalAccessException,
IllegalArgumentException, InvocationTargetException {
public Object callStaticMethod(String symbolicName, Object... parameters)
throws IllegalAccessException,
IllegalArgumentException,
InvocationTargetException {
return methodsBySymbolicName.get(symbolicName).callStatic(parameters);
}
public Object getFieldValue(String symbolicName, SymbolicObject symbolicObject) throws IllegalArgumentException,
public Object getFieldValue(String symbolicName, SymbolicObject symbolicObject)
throws IllegalArgumentException,
IllegalAccessException {
return fieldsBySymbolicName.get(symbolicName).getValue(symbolicObject);
}

View File

@ -94,14 +94,16 @@ public class SymbolicClassBuilder {
}
private SymbolicConstructor createConstructor(SymbolicConstructorDeclaration declaration)
throws ClassNotFoundException, NoSuchMethodException {
throws ClassNotFoundException,
NoSuchMethodException {
String symbolicName = declaration.getSymbolicName();
Class<?>[] parameterClasses = getParameterClasses(declaration.getParameters().getDeclarations());
Constructor<?> constructor = getConstructor(product.getClazz(), parameterClasses);
return new SymbolicConstructor(product, symbolicName, constructor);
}
private SymbolicMethod createMethod(SymbolicMethodDeclaration declaration) throws ClassNotFoundException,
private SymbolicMethod createMethod(SymbolicMethodDeclaration declaration)
throws ClassNotFoundException,
NoSuchMethodException {
String symbolicName = declaration.getSymbolicName();
String realName = declaration.getRealName();
@ -125,7 +127,8 @@ public class SymbolicClassBuilder {
return result;
}
private Method getMethod(Class<?> clazz, String realName, Class<?>[] parameterClasses) throws NoSuchMethodException {
private Method getMethod(Class<?> clazz, String realName, Class<?>[] parameterClasses)
throws NoSuchMethodException {
Method result = clazz.getDeclaredMethod(realName, parameterClasses);
result.setAccessible(true);
return result;

View File

@ -17,13 +17,19 @@ public class SymbolicConstructor {
this.constructor = constructor;
}
public SymbolicObject call(Object... parameters) throws InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException {
public SymbolicObject call(Object... parameters)
throws InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException {
return new SymbolicObject(parent, newInstance(parameters));
}
private Object newInstance(Object... parameters) throws InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException {
private Object newInstance(Object... parameters)
throws InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException {
return constructor.newInstance(parameters);
}

View File

@ -34,18 +34,24 @@ public class SymbolicMethod {
return realName;
}
public Object call(SymbolicObject symbolicObject, Object... parameters) throws IllegalAccessException,
IllegalArgumentException, InvocationTargetException {
public Object call(SymbolicObject symbolicObject, Object... parameters)
throws IllegalAccessException,
IllegalArgumentException,
InvocationTargetException {
return callFromObject(symbolicObject.getObject(), parameters);
}
public Object callStatic(Object... parameters) throws IllegalAccessException, IllegalArgumentException,
public Object callStatic(Object... parameters)
throws IllegalAccessException,
IllegalArgumentException,
InvocationTargetException {
return callFromObject(null, parameters);
}
private Object callFromObject(Object object, Object... parameters) throws IllegalAccessException,
IllegalArgumentException, InvocationTargetException {
private Object callFromObject(Object object, Object... parameters)
throws IllegalAccessException,
IllegalArgumentException,
InvocationTargetException {
Object value = invoke(object, parameters);
if (isReturnTypeSymbolicClass()) {
return new SymbolicObject(returnType, value);
@ -53,7 +59,9 @@ public class SymbolicMethod {
return value;
}
private Object invoke(Object object, Object... parameters) throws IllegalAccessException, IllegalArgumentException,
private Object invoke(Object object, Object... parameters)
throws IllegalAccessException,
IllegalArgumentException,
InvocationTargetException {
return method.invoke(object, parameters);
}

View File

@ -34,8 +34,10 @@ public class SymbolicObject {
return type.hasField(symbolicName);
}
public Object callMethod(String symbolicName, Object... parameters) throws IllegalAccessException,
IllegalArgumentException, InvocationTargetException {
public Object callMethod(String symbolicName, Object... parameters)
throws IllegalAccessException,
IllegalArgumentException,
InvocationTargetException {
return type.callMethod(symbolicName, this, parameters);
}

View File

@ -60,8 +60,8 @@ public class SymbolicClassDeclaration {
if (isOptional) {
Log.i("Missing class " + symbolicClassName);
} else {
throw new ClassNotFoundException("cannot find a real class matching the symbolic class "
+ symbolicClassName);
throw new ClassNotFoundException(
"cannot find a real class matching the symbolic class " + symbolicClassName);
}
}

View File

@ -64,11 +64,15 @@ public class CTBuilder {
});
}
public SymbolicParameterDeclarationListBuilder<SCDBuilder> requiredMethod(String symbolicName, String realName) {
public SymbolicParameterDeclarationListBuilder<SCDBuilder> requiredMethod(
String symbolicName,
String realName) {
return method(symbolicName, realName, false);
}
public SymbolicParameterDeclarationListBuilder<SCDBuilder> optionalMethod(String symbolicName, String realName) {
public SymbolicParameterDeclarationListBuilder<SCDBuilder> optionalMethod(
String symbolicName,
String realName) {
return method(symbolicName, realName, true);
}
@ -115,7 +119,7 @@ public class CTBuilder {
this.detector = detector;
return this;
}
public SCDBuilder thenDeclareRequired(String symbolicClassName) {
return thenDeclare(symbolicClassName, false);
}
@ -125,7 +129,7 @@ public class CTBuilder {
}
private SCDBuilder thenDeclare(String symbolicClassName, boolean isOptional) {
if(detector == null)
if (detector == null)
throw new IllegalStateException("can't declare a symbolic class without calling ifDetect before");
CTBuilder.this.declarationBuilder.init(symbolicClassName, isOptional);
return CTBuilder.this.declarationBuilder;

View File

@ -36,8 +36,10 @@ public class FragmentCache {
@CalledOnlyBy(AmidstThread.EDT)
public synchronized void increaseSize() {
Log.i("increasing fragment cache size from " + cache.size() + " to "
+ (cache.size() + NEW_FRAGMENTS_PER_REQUEST));
Log
.i(
"increasing fragment cache size from " + cache.size() + " to "
+ (cache.size() + NEW_FRAGMENTS_PER_REQUEST));
requestNewFragments();
Log.i("fragment cache size increased to " + cache.size());
}

View File

@ -47,12 +47,8 @@ public class FragmentGraph implements Iterable<FragmentGraphItem> {
public void adjust(int newLeft, int newAbove, int newRight, int newBelow) {
fragmentsPerRow = fragmentsPerRow + newLeft + newRight;
fragmentsPerColumn = fragmentsPerColumn + newAbove + newBelow;
topLeftFragment.replaceWithValue(f -> f.adjustRowsAndColumns(
newAbove,
newBelow,
newLeft,
newRight,
fragmentManager));
topLeftFragment
.replaceWithValue(f -> f.adjustRowsAndColumns(newAbove, newBelow, newLeft, newRight, fragmentManager));
}
@CalledOnlyBy(AmidstThread.EDT)

View File

@ -30,7 +30,6 @@ public class TheEndColorProvider implements ColorProvider {
public int getColorAt(Dimension dimension, Fragment fragment, long cornerX, long cornerY, int x, int y) {
long xAsQuarter = cornerX + x;
long yAsQuarter = cornerY + y;
// @formatter:off
return getColorAt(
(int) (xAsQuarter << 2),
(int) (yAsQuarter << 2),
@ -39,7 +38,6 @@ public class TheEndColorProvider implements ColorProvider {
(int) (x % TEXTURES_WIDTH),
(int) (y % TEXTURES_HEIGHT),
fragment.getEndIslands());
// @formatter:on
}
private int getColorAt(

View File

@ -50,14 +50,12 @@ public class LayerBuilder {
* This also defines the construction order.
*/
private Iterable<FragmentConstructor> createConstructors() {
// @formatter:off
return Collections.unmodifiableList(Arrays.asList(
new BiomeDataConstructor(Resolution.QUARTER),
new EndIslandsConstructor(),
new ImageConstructor( Resolution.QUARTER, LayerIds.BACKGROUND),
new ImageConstructor( Resolution.CHUNK, LayerIds.SLIME)
));
// @formatter:on
return Collections.unmodifiableList(
Arrays.asList(
new BiomeDataConstructor(Resolution.QUARTER),
new EndIslandsConstructor(),
new ImageConstructor(Resolution.QUARTER, LayerIds.BACKGROUND),
new ImageConstructor(Resolution.CHUNK, LayerIds.SLIME)));
}
public Iterable<FragmentConstructor> getConstructors() {
@ -75,13 +73,13 @@ public class LayerBuilder {
WorldIconSelection worldIconSelection,
Zoom zoom,
Graphics2DAccelerationCounter accelerationCounter) {
// @formatter:off
List<LayerDeclaration> declarations = createDeclarations(settings, world.getVersionFeatures());
return new LayerManager(
declarations,
new LayerLoader(createLoaders(declarations, world, biomeSelection, settings), LayerIds.NUMBER_OF_LAYERS),
new LayerLoader(
createLoaders(declarations, world, biomeSelection, settings),
LayerIds.NUMBER_OF_LAYERS),
createDrawers(declarations, zoom, worldIconSelection, accelerationCounter));
// @formatter:on
}
private List<LayerDeclaration> createDeclarations(AmidstSettings settings, VersionFeatures versionFeatures) {

View File

@ -19,8 +19,7 @@ public class LayerDeclaration {
private volatile boolean isVisible;
/**
* @param dimension
* Can be null to enable for all dimensions.
* @param dimension Can be null to enable for all dimensions.
*/
public LayerDeclaration(
int layerId,

View File

@ -20,7 +20,10 @@ public class LayerManager {
private final LayerLoader layerLoader;
private final Iterable<FragmentDrawer> drawers;
public LayerManager(List<LayerDeclaration> declarations, LayerLoader layerLoader, Iterable<FragmentDrawer> drawers) {
public LayerManager(
List<LayerDeclaration> declarations,
LayerLoader layerLoader,
Iterable<FragmentDrawer> drawers) {
this.declarations = declarations;
this.layerLoader = layerLoader;
this.drawers = drawers;

View File

@ -13,10 +13,10 @@ import javax.swing.JTextField;
import javax.swing.ScrollPaneConstants;
import javax.swing.border.LineBorder;
import net.miginfocom.swing.MigLayout;
import amidst.documentation.AmidstThread;
import amidst.documentation.CalledOnlyBy;
import amidst.documentation.NotThreadSafe;
import net.miginfocom.swing.MigLayout;
@NotThreadSafe
public enum CrashWindow {

View File

@ -15,9 +15,9 @@ import javax.swing.border.LineBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import net.miginfocom.swing.MigLayout;
import amidst.AmidstMetaData;
import amidst.documentation.Immutable;
import net.miginfocom.swing.MigLayout;
@Immutable
public class LicenseWindow {

View File

@ -129,10 +129,8 @@ public class Actions {
public void goToStronghold() {
ViewerFacade viewerFacade = this.viewerFacade.get();
if (viewerFacade != null) {
WorldIcon stronghold = mainWindow.askForOptions(
"Go to",
"Select Stronghold:",
viewerFacade.getStrongholdWorldIcons());
WorldIcon stronghold = mainWindow
.askForOptions("Go to", "Select Stronghold:", viewerFacade.getStrongholdWorldIcons());
if (stronghold != null) {
viewerFacade.centerOn(stronghold);
}
@ -214,15 +212,16 @@ public class Actions {
if (file != null) {
file = appendPNGFileExtensionIfNecessary(file);
if (file.exists() && !file.isFile()) {
mainWindow
.displayError("Unable to write capture image, because the target exists but is not a file: "
mainWindow.displayError(
"Unable to write capture image, because the target exists but is not a file: "
+ file.getAbsolutePath());
} else if (!canWriteToFile(file)) {
mainWindow.displayError("Unable to write capture image, because you have no writing permissions: "
+ file.getAbsolutePath());
} else if (!file.exists()
|| mainWindow.askToConfirm("Replace file?", "File already exists. Do you want to replace it?\n"
+ file.getAbsolutePath() + "")) {
mainWindow.displayError(
"Unable to write capture image, because you have no writing permissions: "
+ file.getAbsolutePath());
} else if (!file.exists() || mainWindow.askToConfirm(
"Replace file?",
"File already exists. Do you want to replace it?\n" + file.getAbsolutePath() + "")) {
saveImageToFile(image, file);
}
}
@ -251,9 +250,11 @@ public class Actions {
@CalledOnlyBy(AmidstThread.EDT)
public void about() {
mainWindow.displayMessage("About", "Amidst - Advanced Minecraft Interfacing and Data/Structure Tracking\n\n"
+ "Author: Skidoodle aka skiphs\n" + "Mail: toolbox4minecraft+amidst@gmail.com\n"
+ "Project Page: https://github.com/toolbox4minecraft/amidst");
mainWindow.displayMessage(
"About",
"Amidst - Advanced Minecraft Interfacing and Data/Structure Tracking\n\n"
+ "Author: Skidoodle aka skiphs\n" + "Mail: toolbox4minecraft+amidst@gmail.com\n"
+ "Project Page: https://github.com/toolbox4minecraft/amidst");
}
@CalledOnlyBy(AmidstThread.EDT)
@ -285,10 +286,8 @@ public class Actions {
ViewerFacade viewerFacade = this.viewerFacade.get();
if (viewerFacade != null) {
if (viewerFacade.canSavePlayerLocations()) {
new MovePlayerPopupMenu(this, viewerFacade.getMovablePlayerList(), targetCoordinates).show(
component,
x,
y);
new MovePlayerPopupMenu(this, viewerFacade.getMovablePlayerList(), targetCoordinates)
.show(component, x, y);
}
}
}

View File

@ -86,10 +86,11 @@ public class MainWindow {
@CalledOnlyBy(AmidstThread.EDT)
private JFrame createFrame() {
JFrame frame = new JFrame();
frame.setTitle(createVersionString(
mojangApi.getVersionId(),
mojangApi.getRecognisedVersionName(),
mojangApi.getProfileName()));
frame.setTitle(
createVersionString(
mojangApi.getVersionId(),
mojangApi.getRecognisedVersionName(),
mojangApi.getProfileName()));
frame.setSize(1000, 800);
frame.setIconImages(metadata.getIcons());
return frame;
@ -122,10 +123,10 @@ public class MainWindow {
@CalledOnlyBy(AmidstThread.EDT)
private SeedSearcherWindow createSeedSearcherWindow() {
return new SeedSearcherWindow(metadata, this, new SeedSearcher(
return new SeedSearcherWindow(
metadata,
this,
mojangApi,
threadMaster.getWorkerExecutor()));
new SeedSearcher(this, mojangApi, threadMaster.getWorkerExecutor()));
}
@CalledOnlyBy(AmidstThread.EDT)
@ -316,7 +317,8 @@ public class MainWindow {
@CalledOnlyBy(AmidstThread.EDT)
public boolean askToConfirm(String title, String message) {
return JOptionPane.showConfirmDialog(frame, message, title, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
return JOptionPane
.showConfirmDialog(frame, message, title, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
}
@CalledOnlyBy(AmidstThread.EDT)
@ -333,14 +335,8 @@ public class MainWindow {
@SuppressWarnings("unchecked")
public <T> T askForOptions(String title, String message, List<T> choices) {
Object[] choicesArray = choices.toArray();
return (T) JOptionPane.showInputDialog(
frame,
message,
title,
JOptionPane.PLAIN_MESSAGE,
null,
choicesArray,
choicesArray[0]);
return (T) JOptionPane
.showInputDialog(frame, message, title, JOptionPane.PLAIN_MESSAGE, null, choicesArray, choicesArray[0]);
}
@CalledOnlyBy(AmidstThread.EDT)

View File

@ -14,10 +14,10 @@ import javax.swing.event.AncestorListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import net.miginfocom.swing.MigLayout;
import amidst.documentation.NotThreadSafe;
import amidst.mojangapi.world.WorldSeed;
import amidst.mojangapi.world.WorldSeed.WorldSeedType;
import net.miginfocom.swing.MigLayout;
@NotThreadSafe
public class SeedPrompt {

View File

@ -3,14 +3,14 @@ package amidst.gui.main;
import java.io.IOException;
import java.io.Reader;
import amidst.documentation.Immutable;
import amidst.documentation.NotNull;
import amidst.mojangapi.file.URIUtils;
import com.google.gson.Gson;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import amidst.documentation.Immutable;
import amidst.documentation.NotNull;
import amidst.mojangapi.file.URIUtils;
@Immutable
public enum UpdateInformationRetriever {
;

View File

@ -28,31 +28,39 @@ public class UpdatePrompt {
WorkerExecutor workerExecutor,
MainWindow mainWindow,
boolean silent) {
// @formatter:off
if (mainWindow != null) {
if (silent) {
return new UpdatePrompt(currentVersion, workerExecutor,
NOOP_CONSUMER, NOOP,
message -> mainWindow.askToConfirm(TITLE, message));
return new UpdatePrompt(
currentVersion,
workerExecutor,
NOOP_CONSUMER,
NOOP,
message -> mainWindow.askToConfirm(TITLE, message));
} else {
return new UpdatePrompt(currentVersion, workerExecutor,
return new UpdatePrompt(
currentVersion,
workerExecutor,
exception -> mainWindow.displayException(exception),
() -> mainWindow.displayMessage(TITLE, NO_UPDATES_AVAILABLE),
message -> mainWindow.askToConfirm(TITLE, message));
() -> mainWindow.displayMessage(TITLE, NO_UPDATES_AVAILABLE),
message -> mainWindow.askToConfirm(TITLE, message));
}
} else {
if (silent) {
return new UpdatePrompt(currentVersion, workerExecutor,
NOOP_CONSUMER, NOOP,
message -> askToConfirmDirectly(message));
return new UpdatePrompt(
currentVersion,
workerExecutor,
NOOP_CONSUMER,
NOOP,
message -> askToConfirmDirectly(message));
} else {
return new UpdatePrompt(currentVersion, workerExecutor,
return new UpdatePrompt(
currentVersion,
workerExecutor,
exception -> displayExceptionDirectly(exception),
() -> displayMessageDirectly(NO_UPDATES_AVAILABLE),
message -> askToConfirmDirectly(message));
() -> displayMessageDirectly(NO_UPDATES_AVAILABLE),
message -> askToConfirmDirectly(message));
}
}
// @formatter:on
}
@CalledOnlyBy(AmidstThread.EDT)

View File

@ -84,11 +84,9 @@ public class Drawer {
this.drawers = drawers;
this.dimensionSetting = dimensionSetting;
this.accelerationCounter = accelerationCounter;
this.voidTexturePaint = new TexturePaint(VOID_TEXTURE, new Rectangle(
0,
0,
VOID_TEXTURE.getWidth(),
VOID_TEXTURE.getHeight()));
this.voidTexturePaint = new TexturePaint(
VOID_TEXTURE,
new Rectangle(0, 0, VOID_TEXTURE.getWidth(), VOID_TEXTURE.getHeight()));
}
@CalledOnlyBy(AmidstThread.EDT)

View File

@ -44,18 +44,12 @@ public class ViewerFacadeBuilder {
Graphics2DAccelerationCounter accelerationCounter = new Graphics2DAccelerationCounter();
Movement movement = new Movement(settings.smoothScrolling);
WorldIconSelection worldIconSelection = new WorldIconSelection();
LayerManager layerManager = layerBuilder.create(
settings,
world,
biomeSelection,
worldIconSelection,
zoom,
accelerationCounter);
LayerManager layerManager = layerBuilder
.create(settings, world, biomeSelection, worldIconSelection, zoom, accelerationCounter);
FragmentGraph graph = new FragmentGraph(layerManager.getDeclarations(), fragmentManager);
FragmentGraphToScreenTranslator translator = new FragmentGraphToScreenTranslator(graph, zoom);
FragmentQueueProcessor fragmentQueueProcessor = fragmentManager.createQueueProcessor(
layerManager,
settings.dimension);
FragmentQueueProcessor fragmentQueueProcessor = fragmentManager
.createQueueProcessor(layerManager, settings.dimension);
LayerReloader layerReloader = layerManager.createLayerReloader(world);
WorldExporterFactory worldExporterFactory = new WorldExporterFactory(workerExecutor, world);
WidgetBuilder widgetBuilder = new WidgetBuilder(
@ -80,13 +74,9 @@ public class ViewerFacadeBuilder {
layerManager.getDrawers(),
settings.dimension,
accelerationCounter);
Viewer viewer = new Viewer(new ViewerMouseListener(
new WidgetManager(widgets),
graph,
translator,
zoom,
movement,
actions), drawer);
Viewer viewer = new Viewer(
new ViewerMouseListener(new WidgetManager(widgets), graph, translator, zoom, movement, actions),
drawer);
return new ViewerFacade(
world,
graph,

View File

@ -113,9 +113,8 @@ public class ViewerMouseListener implements MouseListener, MouseWheelListener {
@CalledOnlyBy(AmidstThread.EDT)
private void doMouseClicked(Point mousePosition) {
actions.selectWorldIcon(graph.getClosestWorldIcon(
translator.screenToWorld(mousePosition),
zoom.screenToWorld(50)));
actions.selectWorldIcon(
graph.getClosestWorldIcon(translator.screenToWorld(mousePosition), zoom.screenToWorld(50)));
}
@CalledOnlyBy(AmidstThread.EDT)

View File

@ -137,7 +137,8 @@ public class BiomeWidget extends Widget {
float listHeight = biomeListHeight;
if (scrollbarGrabbed) {
if (mousePosition != null) {
biomeListYOffset = (int) ((listHeight / boxHeight) * (-scrollbarYOnGrab - (mousePosition.y - mouseYOnGrab)));
biomeListYOffset = (int) ((listHeight / boxHeight)
* (-scrollbarYOnGrab - (mousePosition.y - mouseYOnGrab)));
updateBiomeListYOffset();
} else {
scrollbarGrabbed = false;
@ -264,9 +265,8 @@ public class BiomeWidget extends Widget {
return false;
}
if (isInBoundsOfInnerBox(mouseX, mouseY)) {
biomeListYOffset = Math.min(
0,
Math.max(-biomeListHeight + innerBox.height, biomeListYOffset - notches * 35));
biomeListYOffset = Math
.min(0, Math.max(-biomeListHeight + innerBox.height, biomeListYOffset - notches * 35));
}
return true;
}

View File

@ -38,7 +38,6 @@ public class DebugWidget extends TextWidget {
if (isVisibleSetting.get()) {
int columns = graph.getFragmentsPerRow();
int rows = graph.getFragmentsPerColumn();
// @formatter:off
return Arrays.asList(
"Fragment Manager:",
"Cache Size: " + fragmentManager.getCacheSize(),
@ -48,9 +47,7 @@ public class DebugWidget extends TextWidget {
"",
"Viewer:",
"Size: " + columns + "x" + rows + " [" + (columns * rows) + "]",
String.format("Acceleration: %1$.1f%%", accelerationCounter.getAcceleratedPercentage())
);
// @formatter:on
String.format("Acceleration: %1$.1f%%", accelerationCounter.getAcceleratedPercentage()));
} else {
return null;
}

View File

@ -21,8 +21,7 @@ public class WidgetManager {
@CalledOnlyBy(AmidstThread.EDT)
public boolean mouseWheelMoved(Point mousePosition, int notches) {
for (Widget widget : widgets) {
if (widget.isVisible()
&& widget.isInBounds(mousePosition)
if (widget.isVisible() && widget.isInBounds(mousePosition)
&& widget.onMouseWheelMoved(
widget.translateXToWidgetCoordinates(mousePosition),
widget.translateYToWidgetCoordinates(mousePosition),
@ -36,8 +35,7 @@ public class WidgetManager {
@CalledOnlyBy(AmidstThread.EDT)
public boolean mouseClicked(Point mousePosition) {
for (Widget widget : widgets) {
if (widget.isVisible()
&& widget.isInBounds(mousePosition)
if (widget.isVisible() && widget.isInBounds(mousePosition)
&& widget.onClick(
widget.translateXToWidgetCoordinates(mousePosition),
widget.translateYToWidgetCoordinates(mousePosition))) {
@ -50,8 +48,7 @@ public class WidgetManager {
@CalledOnlyBy(AmidstThread.EDT)
public boolean mousePressed(Point mousePosition) {
for (Widget widget : widgets) {
if (widget.isVisible()
&& widget.isInBounds(mousePosition)
if (widget.isVisible() && widget.isInBounds(mousePosition)
&& widget.onMousePressed(
widget.translateXToWidgetCoordinates(mousePosition),
widget.translateYToWidgetCoordinates(mousePosition))) {

View File

@ -82,11 +82,16 @@ public class LocalProfileComponent extends ProfileComponent {
private boolean tryLoad() {
// TODO: Replace with proper handling for modded profiles.
try {
Log.i("using minecraft launcher profile '" + getProfileName() + "' with versionId '" + getVersionName() + "'");
Log
.i(
"using minecraft launcher profile '" + getProfileName() + "' with versionId '"
+ getVersionName() + "'");
String possibleModProfiles = ".*(optifine|forge).*";
if (Pattern.matches(possibleModProfiles, getVersionName().toLowerCase(Locale.ENGLISH))) {
Log.e("Amidst does not support modded Minecraft profiles! Please select or create an unmodded Minecraft profile via the Minecraft Launcher.");
Log
.e(
"Amidst does not support modded Minecraft profiles! Please select or create an unmodded Minecraft profile via the Minecraft Launcher.");
return false;
}

View File

@ -17,11 +17,11 @@ import java.util.List;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
import amidst.documentation.AmidstThread;
import amidst.documentation.CalledOnlyBy;
import amidst.documentation.NotThreadSafe;
import amidst.settings.Setting;
import net.miginfocom.swing.MigLayout;
@NotThreadSafe
public class ProfileSelectPanel {

View File

@ -11,7 +11,6 @@ import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import net.miginfocom.swing.MigLayout;
import amidst.AmidstMetaData;
import amidst.AmidstSettings;
import amidst.Application;
@ -24,6 +23,7 @@ import amidst.mojangapi.file.MojangApiParsingException;
import amidst.mojangapi.file.json.launcherprofiles.LauncherProfileJson;
import amidst.mojangapi.file.json.launcherprofiles.LauncherProfilesJson;
import amidst.threading.WorkerExecutor;
import net.miginfocom.swing.MigLayout;
@NotThreadSafe
public class ProfileSelectWindow {

View File

@ -77,7 +77,8 @@ public class SeedSearcher {
@CalledOnlyBy(AmidstThread.WORKER)
private void doSearch(ProgressReporter<WorldSeed> reporter, SeedSearcherConfiguration configuration)
throws IllegalStateException, MinecraftInterfaceException {
throws IllegalStateException,
MinecraftInterfaceException {
do {
doSearchOne(reporter, configuration);
} while (configuration.isSearchContinuously() && !isStopRequested);

View File

@ -13,7 +13,6 @@ import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import javax.swing.border.LineBorder;
import net.miginfocom.swing.MigLayout;
import amidst.AmidstMetaData;
import amidst.documentation.AmidstThread;
import amidst.documentation.CalledOnlyBy;
@ -23,6 +22,7 @@ import amidst.mojangapi.file.json.filter.WorldFilterJson_MatchAll;
import amidst.mojangapi.world.WorldSeed;
import amidst.mojangapi.world.WorldType;
import amidst.mojangapi.world.filter.WorldFilter;
import net.miginfocom.swing.MigLayout;
@NotThreadSafe
public class SeedSearcherWindow {

View File

@ -123,7 +123,8 @@ public class MojangApi {
* one world at a time. Creating a new world will break all previously
* created world objects.
*/
public World createWorldFromSeed(WorldSeed worldSeed, WorldType worldType) throws IllegalStateException,
public World createWorldFromSeed(WorldSeed worldSeed, WorldType worldType)
throws IllegalStateException,
MinecraftInterfaceException {
MinecraftInterface minecraftInterface = this.minecraftInterface;
if (minecraftInterface != null) {
@ -138,8 +139,12 @@ public class MojangApi {
* one world at a time. Creating a new world will break all previously
* created world objects.
*/
public World createWorldFromSaveGame(File file) throws FileNotFoundException, IOException, IllegalStateException,
MinecraftInterfaceException, MojangApiParsingException {
public World createWorldFromSaveGame(File file)
throws FileNotFoundException,
IOException,
IllegalStateException,
MinecraftInterfaceException,
MojangApiParsingException {
MinecraftInterface minecraftInterface = this.minecraftInterface;
if (minecraftInterface != null) {
return worldBuilder.fromSaveGame(minecraftInterface, SaveDirectory.from(file));

View File

@ -24,15 +24,19 @@ public class MojangApiBuilder {
}
@NotNull
public MojangApi construct() throws DotMinecraftDirectoryNotFoundException,
public MojangApi construct()
throws DotMinecraftDirectoryNotFoundException,
LocalMinecraftInterfaceCreationException {
DotMinecraftDirectory dotMinecraftDirectory = createDotMinecraftDirectory();
if (dotMinecraftDirectory.isValid()) {
Log.i("using '.minecraft' directory at: '" + dotMinecraftDirectory.getRoot() + "', libraries: '"
+ dotMinecraftDirectory.getLibraries() + "'");
Log
.i(
"using '.minecraft' directory at: '" + dotMinecraftDirectory.getRoot() + "', libraries: '"
+ dotMinecraftDirectory.getLibraries() + "'");
} else {
throw new DotMinecraftDirectoryNotFoundException("invalid '.minecraft' directory at: '"
+ dotMinecraftDirectory.getRoot() + "', libraries: '" + dotMinecraftDirectory.getLibraries() + "'");
throw new DotMinecraftDirectoryNotFoundException(
"invalid '.minecraft' directory at: '" + dotMinecraftDirectory.getRoot() + "', libraries: '"
+ dotMinecraftDirectory.getLibraries() + "'");
}
MojangApi result = new MojangApi(worldBuilder, dotMinecraftDirectory);
result.set(null, null, createVersionDirectory(result));
@ -55,12 +59,18 @@ public class MojangApiBuilder {
File json = new File(parameters.minecraftJsonFile);
VersionDirectory result = mojangApi.createVersionDirectory(jar, json);
if (result.isValid()) {
Log.i("using minecraft version directory. versionId: '" + result.getVersionId() + "', jar file: '"
+ result.getJar() + "', json file: '" + result.getJson() + "'");
Log
.i(
"using minecraft version directory. versionId: '" + result.getVersionId()
+ "', jar file: '" + result.getJar() + "', json file: '" + result.getJson()
+ "'");
return result;
} else {
Log.w("invalid minecraft version directory. versionId: '" + result.getVersionId() + "', jar file: '"
+ result.getJar() + "', json file: '" + result.getJson() + "'");
Log
.w(
"invalid minecraft version directory. versionId: '" + result.getVersionId()
+ "', jar file: '" + result.getJar() + "', json file: '" + result.getJson()
+ "'");
}
}
return null;

View File

@ -18,8 +18,10 @@ public enum DotMinecraftDirectoryFinder {
if (result.isDirectory()) {
return result;
} else {
Log.w("Unable to set Minecraft directory to: " + result
+ " as that location does not exist or is not a folder.");
Log
.w(
"Unable to set Minecraft directory to: " + result
+ " as that location does not exist or is not a folder.");
}
}
return getMinecraftDirectory();

View File

@ -6,6 +6,10 @@ import java.io.IOException;
import java.io.Reader;
import java.net.URL;
import com.google.gson.Gson;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import amidst.ResourceLoader;
import amidst.documentation.Immutable;
import amidst.documentation.NotNull;
@ -18,10 +22,6 @@ import amidst.mojangapi.file.json.player.SimplePlayerJson;
import amidst.mojangapi.file.json.version.VersionJson;
import amidst.mojangapi.file.json.versionlist.VersionListJson;
import com.google.gson.Gson;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
/**
* This is a utility class used to read JSON data. Please use this class only to
* read JSON data provided by Mojang, because it throws a
@ -89,7 +89,8 @@ public enum JsonReader {
}
@NotNull
public static LauncherProfilesJson readLauncherProfilesFrom(File file) throws MojangApiParsingException,
public static LauncherProfilesJson readLauncherProfilesFrom(File file)
throws MojangApiParsingException,
IOException {
return read(URIUtils.newReader(file), LauncherProfilesJson.class);
}
@ -116,7 +117,8 @@ public enum JsonReader {
}
@NotNull
public static SimplePlayerJson readSimplePlayerFromPlayerName(String playerName) throws IOException,
public static SimplePlayerJson readSimplePlayerFromPlayerName(String playerName)
throws IOException,
MojangApiParsingException {
return read(URIUtils.newReader(PLAYERNAME_TO_UUID + playerName), SimplePlayerJson.class);
}

View File

@ -1,12 +1,11 @@
package amidst.mojangapi.file.json;
import amidst.documentation.Immutable;
import com.google.gson.annotations.SerializedName;
import amidst.documentation.Immutable;
@Immutable
public enum ReleaseType {
// @formatter:off
@SerializedName("snapshot")
SNAPSHOT("snapshot", "S"),
@SerializedName("release")
@ -15,7 +14,6 @@ public enum ReleaseType {
OLD_BETA("old_beta", "B"),
@SerializedName("old_alpha")
OLD_ALPHA("old_alpha", "A");
// @formatter:on
private final String name;
private final String typeChar;

View File

@ -6,15 +6,15 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import amidst.documentation.GsonConstructor;
import amidst.documentation.Immutable;
import amidst.logging.Log;
import amidst.mojangapi.world.filter.WorldFilter;
import amidst.mojangapi.world.filter.WorldFilter_MatchAll;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
@Immutable
public class WorldFilterJson_MatchAll {
public static Optional<WorldFilterJson_MatchAll> from(String queryString) {

View File

@ -55,8 +55,8 @@ public class LauncherProfileJson {
if (result.isValid()) {
return result;
} else {
throw new FileNotFoundException("cannot find valid profile directory for launcher profile '" + name
+ "': " + gameDir);
throw new FileNotFoundException(
"cannot find valid profile directory for launcher profile '" + name + "': " + gameDir);
}
} else {
return new ProfileDirectory(mojangApi.getDotMinecraftDirectory().getRoot());

View File

@ -21,7 +21,9 @@ public class VersionListJson {
return versions;
}
public VersionDirectory tryFindFirstValidVersionDirectory(List<ReleaseType> allowedReleaseTypes, MojangApi mojangApi) {
public VersionDirectory tryFindFirstValidVersionDirectory(
List<ReleaseType> allowedReleaseTypes,
MojangApi mojangApi) {
for (VersionListEntryJson version : versions) {
if (allowedReleaseTypes.contains(version.getType())) {
VersionDirectory versionDirectory = version.createVersionDirectory(mojangApi);

View File

@ -43,8 +43,8 @@ public enum NBTUtils {
if (value instanceof Number) {
return ((Number) value).longValue();
} else {
throw new IllegalArgumentException("cannot read long value from the class '" + tag.getClass().getName()
+ "'");
throw new IllegalArgumentException(
"cannot read long value from the class '" + tag.getClass().getName() + "'");
}
}
}

View File

@ -44,13 +44,11 @@ public enum PlayerLocationLoader {
private static PlayerCoordinates readPlayerCoordinates(CompoundTag tag) {
int dimensionId = getTagDimension(tag).getValue();
List<Tag> posList = getTagPos(tag).getValue();
// @formatter:off
return PlayerCoordinates.fromNBTFile(
(long) (double) (Double) posList.get(0).getValue(),
(long) (double) (Double) posList.get(1).getValue(),
(long) (double) (Double) posList.get(2).getValue(),
dimensionId);
// @formatter:on
}
private static IntTag getTagDimension(CompoundTag tag) {

View File

@ -88,7 +88,9 @@ public enum PlayerLocationSaver {
return new CompoundTag(NBTTagKeys.TAG_KEY_DATA, modifiedPlayerMap);
}
private static Map<String, Tag> modifyPositionInPlayerMap(Map<String, Tag> playerMap, PlayerCoordinates coordinates) {
private static Map<String, Tag> modifyPositionInPlayerMap(
Map<String, Tag> playerMap,
PlayerCoordinates coordinates) {
Map<String, Tag> result = new HashMap<String, Tag>(playerMap);
ListTag posTag = (ListTag) playerMap.get(NBTTagKeys.TAG_KEY_POS);
ListTag modifiedPosTag = modifyPositionInPosTag(posTag, coordinates);

View File

@ -32,8 +32,8 @@ public class PlayerdataPlayerNbt extends PlayerNbt {
@Override
public PlayerCoordinates readCoordinates() throws IOException, MojangApiParsingException {
return PlayerLocationLoader.readFromPlayerFile(NBTUtils.readTagFromFile(saveDirectory
.getPlayerdataFile(playerUUID)));
return PlayerLocationLoader
.readFromPlayerFile(NBTUtils.readTagFromFile(saveDirectory.getPlayerdataFile(playerUUID)));
}
@Override

View File

@ -32,8 +32,8 @@ public class PlayersPlayerNbt extends PlayerNbt {
@Override
public PlayerCoordinates readCoordinates() throws IOException, MojangApiParsingException {
return PlayerLocationLoader.readFromPlayerFile(NBTUtils.readTagFromFile(saveDirectory
.getPlayersFile(playerName)));
return PlayerLocationLoader
.readFromPlayerFile(NBTUtils.readTagFromFile(saveDirectory.getPlayersFile(playerName)));
}
@Override

View File

@ -15,12 +15,11 @@ import amidst.mojangapi.world.WorldType;
@ThreadSafe
public interface MinecraftInterface {
/**
* @param useQuarterResolution
* Minecraft calculates biomes at quarter-resolution, then
* noisily interpolates the biome-map up to 1:1 resolution when
* needed, set useQuarterResolutionMap to true to read from the
* quarter-resolution map, or false to read values that have been
* interpolated up to full resolution.
* @param useQuarterResolution Minecraft calculates biomes at
* quarter-resolution, then noisily interpolates the biome-map up
* to 1:1 resolution when needed, set useQuarterResolutionMap to
* true to read from the quarter-resolution map, or false to read
* values that have been interpolated up to full resolution.
*
* When useQuarterResolution is true, the x, y, width, and height
* paramaters must all correspond to a quarter of the Minecraft

View File

@ -187,8 +187,10 @@ public enum RecognisedVersion {
}
private static void logFound(RecognisedVersion recognisedVersion) {
Log.i("Recognised Minecraft Version " + recognisedVersion.name + " with the magic string \""
+ recognisedVersion.magicString + "\".");
Log
.i(
"Recognised Minecraft Version " + recognisedVersion.name + " with the magic string \""
+ recognisedVersion.magicString + "\".");
}
public static boolean isNewerOrEqualTo(RecognisedVersion version1, RecognisedVersion version2) {
@ -222,8 +224,9 @@ public enum RecognisedVersion {
for (RecognisedVersion recognisedVersion : RecognisedVersion.values()) {
if (result.containsKey(recognisedVersion.getName())) {
RecognisedVersion colliding = result.get(recognisedVersion.getName());
throw new RuntimeException("name collision for the recognised versions " + recognisedVersion.getName()
+ " and " + colliding.getName());
throw new RuntimeException(
"name collision for the recognised versions " + recognisedVersion.getName() + " and "
+ colliding.getName());
} else {
result.put(recognisedVersion.getName(), recognisedVersion);
}
@ -236,8 +239,9 @@ public enum RecognisedVersion {
for (RecognisedVersion recognisedVersion : RecognisedVersion.values()) {
if (result.containsKey(recognisedVersion.getMagicString())) {
RecognisedVersion colliding = result.get(recognisedVersion.getMagicString());
throw new RuntimeException("magic string collision for the recognised versions "
+ recognisedVersion.getName() + " and " + colliding.getName());
throw new RuntimeException(
"magic string collision for the recognised versions " + recognisedVersion.getName() + " and "
+ colliding.getName());
} else {
result.put(recognisedVersion.getMagicString(), recognisedVersion);
}

View File

@ -79,7 +79,6 @@ public enum DefaultClassTranslator {
.requiredMethod(SymbolicNames.METHOD_GEN_OPTIONS_FACTORY_JSON_TO_FACTORY, "a").real("String").end()
.construct();
}
// @formatter:on
private int[] createIntCacheWildcardBytes() {
return new int[] { 0x11, 0x01, 0x00, 0xB3, 0x00, WILDCARD, 0xBB, 0x00, WILDCARD, 0x59, 0xB7, 0x00, WILDCARD,
@ -87,4 +86,5 @@ public enum DefaultClassTranslator {
0x00, WILDCARD, 0x59, 0xB7, 0x00, WILDCARD, 0xB3, 0x00, WILDCARD, 0xBB, 0x00, WILDCARD, 0x59, 0xB7,
0x00, WILDCARD, 0xB3, 0x00, WILDCARD, 0xB1 };
}
// @formatter:on
}

View File

@ -51,13 +51,13 @@ public class LocalMinecraftInterface implements MinecraftInterface {
this.recognisedVersion = recognisedVersion;
}
// @formatter:off
@Override
public synchronized int[] getBiomeData(int x, int y, int width, int height, boolean useQuarterResolution)
throws MinecraftInterfaceException {
try {
intCacheClass.callStaticMethod(SymbolicNames.METHOD_INT_CACHE_RESET_INT_CACHE);
return (int[]) getBiomeGenerator(useQuarterResolution).callMethod(SymbolicNames.METHOD_GEN_LAYER_GET_INTS, x, y, width, height);
return (int[]) getBiomeGenerator(useQuarterResolution)
.callMethod(SymbolicNames.METHOD_GEN_LAYER_GET_INTS, x, y, width, height);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new MinecraftInterfaceException("unable to get biome data", e);
}
@ -90,37 +90,51 @@ public class LocalMinecraftInterface implements MinecraftInterface {
* Minecraft 1.8 and higher require block initialization to be called before
* creating a biome generator.
*/
private void initializeBlock()
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
private void initializeBlock() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
if (blockInitClass != null) {
blockInitClass.callStaticMethod(SymbolicNames.METHOD_BLOCK_INIT_INITIALIZE);
}
}
private Object[] getGenLayers(long seed, WorldType worldType, String generatorOptions)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
throws IllegalAccessException,
IllegalArgumentException,
InvocationTargetException {
if (worldTypeClass == null) {
return (Object[]) genLayerClass.callStaticMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_1, seed);
return (Object[]) genLayerClass
.callStaticMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_1, seed);
} else if (genLayerClass.hasMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_4)) {
return (Object[]) genLayerClass.callStaticMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_4, seed, getWorldType(worldType).getObject(), getGeneratorOptions(generatorOptions).getObject());
return (Object[]) genLayerClass.callStaticMethod(
SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_4,
seed,
getWorldType(worldType).getObject(),
getGeneratorOptions(generatorOptions).getObject());
} else if (genLayerClass.hasMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_3)) {
return (Object[]) genLayerClass.callStaticMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_3, seed, getWorldType(worldType).getObject(), generatorOptions);
return (Object[]) genLayerClass.callStaticMethod(
SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_3,
seed,
getWorldType(worldType).getObject(),
generatorOptions);
} else {
return (Object[]) genLayerClass.callStaticMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_2, seed, getWorldType(worldType).getObject());
return (Object[]) genLayerClass.callStaticMethod(
SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_2,
seed,
getWorldType(worldType).getObject());
}
}
private SymbolicObject getGeneratorOptions(String generatorOptions)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
SymbolicObject factory = (SymbolicObject) genOptionsFactoryClass.callStaticMethod(SymbolicNames.METHOD_GEN_OPTIONS_FACTORY_JSON_TO_FACTORY, generatorOptions);
throws IllegalAccessException,
IllegalArgumentException,
InvocationTargetException {
SymbolicObject factory = (SymbolicObject) genOptionsFactoryClass
.callStaticMethod(SymbolicNames.METHOD_GEN_OPTIONS_FACTORY_JSON_TO_FACTORY, generatorOptions);
return (SymbolicObject) factory.callMethod(SymbolicNames.METHOD_GEN_OPTIONS_FACTORY_BUILD);
}
private SymbolicObject getWorldType(WorldType worldType)
throws IllegalArgumentException, IllegalAccessException {
private SymbolicObject getWorldType(WorldType worldType) throws IllegalArgumentException, IllegalAccessException {
return (SymbolicObject) worldTypeClass.getStaticFieldValue(worldType.getSymbolicFieldName());
}
// @formatter:on
@Override
public RecognisedVersion getRecognisedVersion() {

View File

@ -26,14 +26,13 @@ public class LocalMinecraftInterfaceBuilder {
}
@NotNull
public MinecraftInterface create(VersionDirectory versionDirectory) throws LocalMinecraftInterfaceCreationException {
public MinecraftInterface create(VersionDirectory versionDirectory)
throws LocalMinecraftInterfaceCreationException {
try {
URLClassLoader classLoader = versionDirectory.createClassLoader();
RecognisedVersion recognisedVersion = RecognisedVersion.from(classLoader);
Map<String, SymbolicClass> symbolicClassMap = Classes.createSymbolicClassMap(
versionDirectory.getJar(),
classLoader,
translator);
Map<String, SymbolicClass> symbolicClassMap = Classes
.createSymbolicClassMap(versionDirectory.getJar(), classLoader, translator);
Log.i("Minecraft load complete.");
return new LocalMinecraftInterface(
symbolicClassMap.get(SymbolicNames.CLASS_INT_CACHE),
@ -42,7 +41,11 @@ public class LocalMinecraftInterfaceBuilder {
symbolicClassMap.get(SymbolicNames.CLASS_WORLD_TYPE),
symbolicClassMap.get(SymbolicNames.CLASS_GEN_OPTIONS_FACTORY),
recognisedVersion);
} catch (MalformedURLException | ClassNotFoundException | FileNotFoundException | JarFileParsingException
} catch (
MalformedURLException
| ClassNotFoundException
| FileNotFoundException
| JarFileParsingException
| SymbolicClassGraphCreationException e) {
throw new LocalMinecraftInterfaceCreationException("unable to create local minecraft interface", e);
}

View File

@ -69,12 +69,16 @@ public class WorldBuilder {
MovablePlayerList.dummy(),
versionFeatures,
biomeDataOracle,
new HeuristicWorldSpawnOracle(worldSeed.getLong(), biomeDataOracle, versionFeatures
.getValidBiomesForStructure_Spawn()));
new HeuristicWorldSpawnOracle(
worldSeed.getLong(),
biomeDataOracle,
versionFeatures.getValidBiomesForStructure_Spawn()));
}
public World fromSaveGame(MinecraftInterface minecraftInterface, SaveDirectory saveDirectory) throws IOException,
MinecraftInterfaceException, MojangApiParsingException {
public World fromSaveGame(MinecraftInterface minecraftInterface, SaveDirectory saveDirectory)
throws IOException,
MinecraftInterfaceException,
MojangApiParsingException {
VersionFeatures versionFeatures = DefaultVersionFeatures.create(minecraftInterface.getRecognisedVersion());
LevelDatNbt levelDat = saveDirectory.createLevelDat();
MovablePlayerList movablePlayerList = new MovablePlayerList(
@ -102,7 +106,6 @@ public class WorldBuilder {
VersionFeatures versionFeatures,
BiomeDataOracle biomeDataOracle,
WorldSpawnOracle worldSpawnOracle) throws MinecraftInterfaceException {
// @formatter:off
RecognisedVersion recognisedVersion = minecraftInterface.getRecognisedVersion();
seedHistoryLogger.log(recognisedVersion, worldSeed);
long seed = worldSeed.getLong();
@ -115,55 +118,65 @@ public class WorldBuilder {
recognisedVersion,
versionFeatures,
biomeDataOracle,
EndIslandOracle.from( seed),
new SlimeChunkOracle( seed),
EndIslandOracle.from(seed),
new SlimeChunkOracle(seed),
new SpawnProducer(worldSpawnOracle),
versionFeatures.getStrongholdProducerFactory().apply(seed, biomeDataOracle, versionFeatures.getValidBiomesAtMiddleOfChunk_Stronghold()),
versionFeatures.getStrongholdProducerFactory().apply(
seed,
biomeDataOracle,
versionFeatures.getValidBiomesAtMiddleOfChunk_Stronghold()),
new PlayerProducer(movablePlayerList),
new StructureProducer<Void>(
Resolution.CHUNK,
4,
new VillageLocationChecker(seed, biomeDataOracle, versionFeatures.getValidBiomesForStructure_Village()),
new VillageLocationChecker(
seed,
biomeDataOracle,
versionFeatures.getValidBiomesForStructure_Village()),
new ImmutableWorldIconTypeProvider(DefaultWorldIconTypes.VILLAGE),
Dimension.OVERWORLD,
false
), new StructureProducer<Void>(
false),
new StructureProducer<Void>(
Resolution.CHUNK,
8,
new TempleLocationChecker(seed, biomeDataOracle, versionFeatures.getValidBiomesAtMiddleOfChunk_Temple()),
new TempleLocationChecker(
seed,
biomeDataOracle,
versionFeatures.getValidBiomesAtMiddleOfChunk_Temple()),
new TempleWorldIconTypeProvider(biomeDataOracle),
Dimension.OVERWORLD,
false
), new StructureProducer<Void>(
false),
new StructureProducer<Void>(
Resolution.CHUNK,
8,
versionFeatures.getMineshaftAlgorithmFactory().apply(seed),
new ImmutableWorldIconTypeProvider(DefaultWorldIconTypes.MINESHAFT),
Dimension.OVERWORLD,
false
), new StructureProducer<Void>(
false),
new StructureProducer<Void>(
Resolution.CHUNK,
8,
versionFeatures.getOceanMonumentLocationCheckerFactory().apply(seed, biomeDataOracle, versionFeatures.getValidBiomesAtMiddleOfChunk_OceanMonument(), versionFeatures.getValidBiomesForStructure_OceanMonument()),
versionFeatures.getOceanMonumentLocationCheckerFactory().apply(
seed,
biomeDataOracle,
versionFeatures.getValidBiomesAtMiddleOfChunk_OceanMonument(),
versionFeatures.getValidBiomesForStructure_OceanMonument()),
new ImmutableWorldIconTypeProvider(DefaultWorldIconTypes.OCEAN_MONUMENT),
Dimension.OVERWORLD,
false
), new StructureProducer<Void>(
false),
new StructureProducer<Void>(
Resolution.NETHER_CHUNK,
88,
new NetherFortressAlgorithm(seed),
new ImmutableWorldIconTypeProvider(DefaultWorldIconTypes.NETHER_FORTRESS),
Dimension.NETHER,
false
), new StructureProducer<List<EndIsland>>(
false),
new StructureProducer<List<EndIsland>>(
Resolution.CHUNK,
8,
new EndCityLocationChecker(seed),
new EndCityWorldIconTypeProvider(),
Dimension.END,
false
)
);
// @formatter:on
false));
}
}

View File

@ -19,26 +19,20 @@ public enum WorldType {
public static final String PROMPT_EACH_TIME = "Prompt each time";
// @formatter:off
private static final WorldType[] SELECTABLE_WORLD_TYPES_ARRAY = new WorldType[] {
WorldType.DEFAULT,
WorldType.FLAT,
WorldType.LARGE_BIOMES,
WorldType.AMPLIFIED
};
// @formatter:on
WorldType.AMPLIFIED };
private static final List<WorldType> SELECTABLE_WORLD_TYPES = Arrays.asList(SELECTABLE_WORLD_TYPES_ARRAY);
// @formatter:off
private static final String[] WORLD_TYPE_SETTING_AVAILABLE_VALUES = new String[] {
PROMPT_EACH_TIME,
WorldType.DEFAULT.getName(),
WorldType.FLAT.getName(),
WorldType.LARGE_BIOMES.getName(),
WorldType.AMPLIFIED.getName()
};
// @formatter:on
WorldType.AMPLIFIED.getName() };
public static List<WorldType> getSelectable() {
return SELECTABLE_WORLD_TYPES;

View File

@ -9,17 +9,14 @@ public class EndCityLocationChecker extends AllValidLocationChecker {
private static final boolean USE_TWO_VALUES_FOR_UPDATE = true;
public EndCityLocationChecker(long seed) {
// @formatter:off
super(new StructureAlgorithm(
super(
new StructureAlgorithm(
seed,
MAGIC_NUMBER_FOR_SEED_1,
MAGIC_NUMBER_FOR_SEED_2,
MAGIC_NUMBER_FOR_SEED_3,
MAX_DISTANCE_BETWEEN_SCATTERED_FEATURES,
MIN_DISTANCE_BETWEEN_SCATTERED_FEATURES,
USE_TWO_VALUES_FOR_UPDATE
)
);
// @formatter:on
USE_TWO_VALUES_FOR_UPDATE));
}
}

View File

@ -59,25 +59,16 @@ public class OceanMonumentLocationChecker_Fixed extends AllValidLocationChecker
BiomeDataOracle biomeDataOracle,
List<Biome> validBiomesAtMiddleOfChunk,
List<Biome> validBiomesForStructure) {
// @formatter:off
super(new StructureAlgorithm(
super(
new StructureAlgorithm(
seed,
MAGIC_NUMBER_FOR_SEED_1,
MAGIC_NUMBER_FOR_SEED_2,
MAGIC_NUMBER_FOR_SEED_3,
MAX_DISTANCE_BETWEEN_SCATTERED_FEATURES,
MIN_DISTANCE_BETWEEN_SCATTERED_FEATURES,
USE_TWO_VALUES_FOR_UPDATE
), new StructureBiomeLocationChecker(
biomeDataOracle,
STRUCTURE_CENTER_SIZE,
validBiomesAtMiddleOfChunk
), new StructureBiomeLocationChecker(
biomeDataOracle,
STRUCTURE_SIZE,
validBiomesForStructure
)
);
// @formatter:on
USE_TWO_VALUES_FOR_UPDATE),
new StructureBiomeLocationChecker(biomeDataOracle, STRUCTURE_CENTER_SIZE, validBiomesAtMiddleOfChunk),
new StructureBiomeLocationChecker(biomeDataOracle, STRUCTURE_SIZE, validBiomesForStructure));
}
}

View File

@ -21,24 +21,16 @@ public class OceanMonumentLocationChecker_Original extends AllValidLocationCheck
BiomeDataOracle biomeDataOracle,
List<Biome> validBiomesAtMiddleOfChunk,
List<Biome> validBiomesForStructure) {
// @formatter:off
super(new StructureAlgorithm(
super(
new StructureAlgorithm(
seed,
MAGIC_NUMBER_FOR_SEED_1,
MAGIC_NUMBER_FOR_SEED_2,
MAGIC_NUMBER_FOR_SEED_3,
MAX_DISTANCE_BETWEEN_SCATTERED_FEATURES,
MIN_DISTANCE_BETWEEN_SCATTERED_FEATURES,
USE_TWO_VALUES_FOR_UPDATE
), new BiomeLocationChecker(
biomeDataOracle,
validBiomesAtMiddleOfChunk
), new StructureBiomeLocationChecker(
biomeDataOracle,
STRUCTURE_SIZE,
validBiomesForStructure
)
);
// @formatter:on
USE_TWO_VALUES_FOR_UPDATE),
new BiomeLocationChecker(biomeDataOracle, validBiomesAtMiddleOfChunk),
new StructureBiomeLocationChecker(biomeDataOracle, STRUCTURE_SIZE, validBiomesForStructure));
}
}

View File

@ -66,8 +66,8 @@ public class StructureAlgorithm implements LocationChecker {
private int updateValue(Random random, int value) {
value *= maxDistanceBetweenScatteredFeatures;
if (useTwoValuesForUpdate) {
value += (random.nextInt(distanceBetweenScatteredFeaturesRange) + random
.nextInt(distanceBetweenScatteredFeaturesRange)) / 2;
value += (random.nextInt(distanceBetweenScatteredFeaturesRange)
+ random.nextInt(distanceBetweenScatteredFeaturesRange)) / 2;
} else {
value += random.nextInt(distanceBetweenScatteredFeaturesRange);
}

View File

@ -16,20 +16,15 @@ public class TempleLocationChecker extends AllValidLocationChecker {
private static final boolean USE_TWO_VALUES_FOR_UPDATE = false;
public TempleLocationChecker(long seed, BiomeDataOracle biomeDataOracle, List<Biome> validBiomesAtMiddleOfChunk) {
// @formatter:off
super(new StructureAlgorithm(
super(
new StructureAlgorithm(
seed,
MAGIC_NUMBER_FOR_SEED_1,
MAGIC_NUMBER_FOR_SEED_2,
MAGIC_NUMBER_FOR_SEED_3,
MAX_DISTANCE_BETWEEN_SCATTERED_FEATURES,
MIN_DISTANCE_BETWEEN_SCATTERED_FEATURES,
USE_TWO_VALUES_FOR_UPDATE
), new BiomeLocationChecker(
biomeDataOracle,
validBiomesAtMiddleOfChunk
)
);
// @formatter:on
USE_TWO_VALUES_FOR_UPDATE),
new BiomeLocationChecker(biomeDataOracle, validBiomesAtMiddleOfChunk));
}
}

View File

@ -17,24 +17,16 @@ public class VillageLocationChecker extends AllValidLocationChecker {
private static final int STRUCTURE_SIZE = 0;
public VillageLocationChecker(long seed, BiomeDataOracle biomeDataOracle, List<Biome> validBiomesForStructure) {
// @formatter:off
super(new StructureAlgorithm(
super(
new StructureAlgorithm(
seed,
MAGIC_NUMBER_FOR_SEED_1,
MAGIC_NUMBER_FOR_SEED_2,
MAGIC_NUMBER_FOR_SEED_3,
MAX_DISTANCE_BETWEEN_SCATTERED_FEATURES,
MIN_DISTANCE_BETWEEN_SCATTERED_FEATURES,
USE_TWO_VALUES_FOR_UPDATE
), new StructureBiomeLocationChecker(
biomeDataOracle,
STRUCTURE_SIZE,
validBiomesForStructure
), new VillageAlgorithm(
biomeDataOracle,
validBiomesForStructure
)
);
// @formatter:on
USE_TWO_VALUES_FOR_UPDATE),
new StructureBiomeLocationChecker(biomeDataOracle, STRUCTURE_SIZE, validBiomesForStructure),
new VillageAlgorithm(biomeDataOracle, validBiomesForStructure));
}
}

View File

@ -22,12 +22,13 @@ public class PlayerProducer extends CachedWorldIconProducer {
List<WorldIcon> result = new LinkedList<WorldIcon>();
for (Player player : movablePlayerList) {
PlayerCoordinates coordinates = player.getPlayerCoordinates();
result.add(new WorldIcon(
coordinates.getCoordinatesInWorld(),
player.getPlayerName(),
player.getHead(),
coordinates.getDimension(),
true));
result.add(
new WorldIcon(
coordinates.getCoordinatesInWorld(),
player.getPlayerName(),
player.getHead(),
coordinates.getDimension(),
true));
}
return result;
}

View File

@ -38,8 +38,8 @@ public class StrongholdProducer_128Algorithm extends StrongholdProducer_Buggy128
@Override
protected double getNextValue_distance(int currentRing, Random random) {
return (4.0 * DISTANCE_IN_CHUNKS) + (6.0 * currentRing * DISTANCE_IN_CHUNKS) + (random.nextDouble() - 0.5)
* (DISTANCE_IN_CHUNKS * 2.5);
return (4.0 * DISTANCE_IN_CHUNKS) + (6.0 * currentRing * DISTANCE_IN_CHUNKS)
+ (random.nextDouble() - 0.5) * (DISTANCE_IN_CHUNKS * 2.5);
}
@Override

View File

@ -48,8 +48,11 @@ public abstract class StrongholdProducer_Base extends CachedWorldIconProducer {
// begin placing strongholds on the next ring.
ring = getNextValue_ring(ring);
currentRingStructureCount = getNextValue_currentRingStructureCount(currentRingStructureCount);
structuresPerRing = getNextValue_structuresPerRing(structuresPerRing, ring, getTotalStructureCount()
- i, random);
structuresPerRing = getNextValue_structuresPerRing(
structuresPerRing,
ring,
getTotalStructureCount() - i,
random);
angle = getNextValue_startAngle(angle, random);
}
}

View File

@ -59,12 +59,13 @@ public class StructureProducer<T> extends WorldIconProducer<T> {
DefaultWorldIconTypes worldIconType = provider.get(x, y, additionalData);
if (worldIconType != null) {
CoordinatesInWorld coordinates = createCoordinates(corner, xRelativeToFragment, yRelativeToFragment);
consumer.accept(new WorldIcon(
coordinates,
worldIconType.getLabel(),
worldIconType.getImage(),
dimension,
displayDimension));
consumer.accept(
new WorldIcon(
coordinates,
worldIconType.getLabel(),
worldIconType.getImage(),
dimension,
displayDimension));
}
}
}

View File

@ -146,7 +146,8 @@ public class BiomeDataOracle {
return coordinate * 16 + 8;
}
public Biome getBiomeAtMiddleOfChunk(int chunkX, int chunkY) throws UnknownBiomeIndexException,
public Biome getBiomeAtMiddleOfChunk(int chunkX, int chunkY)
throws UnknownBiomeIndexException,
MinecraftInterfaceException {
return getBiomeAt(getMiddleOfChunk(chunkX), getMiddleOfChunk(chunkY));
}
@ -161,7 +162,8 @@ public class BiomeDataOracle {
return Biome.getByIndex(biomeData[0]);
}
private int[] getQuarterResolutionBiomeData(int x, int y, int width, int height) throws MinecraftInterfaceException {
private int[] getQuarterResolutionBiomeData(int x, int y, int width, int height)
throws MinecraftInterfaceException {
return getBiomeData(x, y, width, height, true);
}

View File

@ -69,13 +69,12 @@ public class EndIslandOracle {
}
public List<EndIsland> getAt(CoordinatesInWorld corner) {
// @formatter:off
int steps = Resolution.CHUNK.getStepsPerFragment();
return findSurroundingIslands(
(int) corner.getXAs(Resolution.CHUNK),
(int) corner.getYAs(Resolution.CHUNK),
steps, steps);
// @formatter:on
steps,
steps);
}
/**

View File

@ -43,8 +43,10 @@ public class Player {
if (saveLocation()) {
return true;
} else {
Log.w("skipping to save player location, because the backup file cannot be created for player: "
+ getPlayerName());
Log
.w(
"skipping to save player location, because the backup file cannot be created for player: "
+ getPlayerName());
return false;
}
} catch (MojangApiParsingException e) {

View File

@ -25,7 +25,6 @@ public enum DefaultVersionFeatures {
INSTANCE;
public static VersionFeatures create(RecognisedVersion version) {
// @formatter:off
return new VersionFeatures(
INSTANCE.enabledLayers.getValue(version),
INSTANCE.validBiomesForStructure_Spawn.getValue(version),
@ -36,9 +35,7 @@ public enum DefaultVersionFeatures {
INSTANCE.mineshaftAlgorithmFactory.getValue(version),
INSTANCE.oceanMonumentLocationCheckerFactory.getValue(version),
INSTANCE.validBiomesAtMiddleOfChunk_OceanMonument.getValue(version),
INSTANCE.validBiomesForStructure_OceanMonument.getValue(version)
);
// @formatter:on
INSTANCE.validBiomesForStructure_OceanMonument.getValue(version));
}
private final VersionFeature<List<Integer>> enabledLayers;

View File

@ -15,35 +15,29 @@ public enum Settings {
}
public static Setting<String> createString(Preferences preferences, String key, @NotNull String defaultValue) {
// @formatter:off
return new SettingBase<String>(defaultValue,
return new SettingBase<String>(
defaultValue,
value -> preferences.get(key, value),
value -> preferences.put(key, value));
// @formatter:on
}
public static Setting<Boolean> createBoolean(Preferences preferences, String key, boolean defaultValue) {
// @formatter:off
return new SettingBase<Boolean>(defaultValue,
return new SettingBase<Boolean>(
defaultValue,
value -> preferences.getBoolean(key, value),
value -> preferences.putBoolean(key, value));
// @formatter:on
}
public static Setting<Dimension> createDimension(Preferences preferences, String key, Dimension defaultValue) {
// @formatter:off
return new SettingBase<Dimension>(defaultValue,
return new SettingBase<Dimension>(
defaultValue,
value -> Dimension.from(preferences.getInt(key, value.getId())),
value -> preferences.putInt(key, value.getId()));
// @formatter:on
}
public static <T> Setting<T> createDummy(T defaultValue) {
// @formatter:off
return new SettingBase<T>(defaultValue,
value -> value,
value -> {});
// @formatter:on
return new SettingBase<T>(defaultValue, value -> value, value -> {
});
}
public static <T> Setting<T> createDummyWithListener(T defaultValue, Runnable listener) {

View File

@ -5,13 +5,13 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import amidst.documentation.Immutable;
import amidst.logging.Log;
import com.google.gson.Gson;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import amidst.documentation.Immutable;
import amidst.logging.Log;
@Immutable
public class BiomeProfileDirectory {
public static BiomeProfileDirectory create(String root) {

View File

@ -102,7 +102,10 @@ public class WorkerExecutor {
});
}
public <R, P> void run(ProgressReportingWorkerWithResult<R, P> main, Consumer<P> onProgress, Consumer<R> onFinished) {
public <R, P> void run(
ProgressReportingWorkerWithResult<R, P> main,
Consumer<P> onProgress,
Consumer<R> onFinished) {
runInWorker(() -> {
R output = main.run(progressReporter(onProgress));
runInEDT(() -> onFinished.accept(output));

View File

@ -9,10 +9,8 @@ public enum FileExtensionChecker {
/**
* Checks whether the given filename has the given file extension.
*
* @param filename
* The filename
* @param extension
* The expected file extension without the leading "."
* @param filename The filename
* @param extension The expected file extension without the leading "."
*/
public static boolean hasFileExtension(String filename, String extension) {
return filename.toLowerCase().endsWith("." + extension);

View File

@ -94,16 +94,17 @@ public class GenerateRecognisedVersionList {
private void printMessages() {
System.out.println();
System.out.println("If any version are listed in the error section, this might be due to missing libraries.\n"
+ "Start the given minecraft version with the launcher.\n"
+ "This should download the missing libraries. Afterwards, try again.");
System.out.println(
"If any version are listed in the error section, this might be due to missing libraries.\n"
+ "Start the given minecraft version with the launcher.\n"
+ "This should download the missing libraries. Afterwards, try again.");
System.out.println();
System.out
.println("When copying the magic string from this output, make sure to escape all special characters.");
System.out.println();
System.out.println("Versions without a match are probably removed from the launcher.");
System.out.println();
System.out
.println("You might have to reorder the output, e.g. when a security fix for an old version came out, after the snapshots for the next version started.");
System.out.println(
"You might have to reorder the output, e.g. when a security fix for an old version came out, after the snapshots for the next version started.");
}
}

View File

@ -1,11 +1,11 @@
package amidst.devtools;
import amidst.AmidstVersion;
import amidst.gui.main.UpdateInformationJson;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import amidst.AmidstVersion;
import amidst.gui.main.UpdateInformationJson;
public class GenerateUpdateInformationJson {
private static final String DOWNLOAD_URL = "https://github.com/toolbox4minecraft/amidst/releases";
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
@ -21,7 +21,11 @@ public class GenerateUpdateInformationJson {
throw new RuntimeException(
"Update information documents can only be created for stable releases (not a pre-release).");
}
UpdateInformationJson json = new UpdateInformationJson(version.getMajor(), version.getMinor(), "", DOWNLOAD_URL);
UpdateInformationJson json = new UpdateInformationJson(
version.getMajor(),
version.getMinor(),
"",
DOWNLOAD_URL);
System.out.println(GSON.toJson(json));
}
}

View File

@ -28,8 +28,9 @@ public class RecognisedVersionEnumBuilder {
public void addKnown(RecognisedVersion recognisedVersion) {
if (recognisedVersion.isKnown()) {
builders
.put(recognisedVersion.getMagicString(), RecognisedVersionEnumEntryBuilder.known(recognisedVersion));
builders.put(
recognisedVersion.getMagicString(),
RecognisedVersionEnumEntryBuilder.known(recognisedVersion));
}
}

View File

@ -43,7 +43,8 @@ public class FakeMinecraftInterface implements MinecraftInterface {
}
@Override
public void createWorld(long seed, WorldType worldType, String generatorOptions) throws MinecraftInterfaceException {
public void createWorld(long seed, WorldType worldType, String generatorOptions)
throws MinecraftInterfaceException {
if (worldMetadataJson.getSeed() == seed && worldMetadataJson.getWorldType().equals(worldType)
&& generatorOptions.isEmpty()) {
isWorldCreated = true;

View File

@ -31,10 +31,8 @@ public class FakeWorldBuilder {
public World createRealWorld(TestWorldDeclaration worldDeclaration, MinecraftInterface realMinecraftInterface)
throws MinecraftInterfaceException {
return builder.fromSeed(
realMinecraftInterface,
worldDeclaration.getWorldSeed(),
worldDeclaration.getWorldType());
return builder
.fromSeed(realMinecraftInterface, worldDeclaration.getWorldSeed(), worldDeclaration.getWorldType());
}
public World createFakeWorld(TestWorldDirectory worldDeclaration) throws MinecraftInterfaceException {

View File

@ -42,11 +42,8 @@ public class TestWorldBuilder {
realMinecraftInterface,
builder);
World realWorld = worldBuilder.createRealWorld(worldDeclaration, minecraftInterface);
return directoryDeclaration.create(
worldDeclaration,
realWorld,
builder.createQuarterBiomeData(),
builder.createFullBiomeData());
return directoryDeclaration
.create(worldDeclaration, realWorld, builder.createQuarterBiomeData(), builder.createFullBiomeData());
}
public TestWorld createTestWorld(TestWorldDirectory directory) throws MinecraftInterfaceException {

View File

@ -23,7 +23,9 @@ public enum TestWorldCache {
}
public static void createAndPut(TestWorldDeclaration declaration, MinecraftInterface realMinecraftInterface)
throws MinecraftInterfaceException, FileNotFoundException, IOException {
throws MinecraftInterfaceException,
FileNotFoundException,
IOException {
INSTANCE.doCreateAndPut(declaration, realMinecraftInterface);
}
@ -33,11 +35,14 @@ public enum TestWorldCache {
private final ConcurrentHashMap<TestWorldDeclaration, TestWorld> cache = new ConcurrentHashMap<TestWorldDeclaration, TestWorld>();
public void doCreateAndPut(TestWorldDeclaration declaration, MinecraftInterface realMinecraftInterface)
throws MinecraftInterfaceException, FileNotFoundException, IOException {
throws MinecraftInterfaceException,
FileNotFoundException,
IOException {
writer.write(declaration, builder.createDirectory(declaration, realMinecraftInterface));
}
public TestWorld createIfNecessaryAndGet(TestWorldDeclaration declaration) throws IOException,
public TestWorld createIfNecessaryAndGet(TestWorldDeclaration declaration)
throws IOException,
MinecraftInterfaceException {
TestWorld result = cache.get(declaration);
if (result != null) {

View File

@ -13,11 +13,11 @@ import amidst.mojangapi.world.WorldType;
@Immutable
public enum TestWorldDeclaration {
// @formatter:off
/**
* Not all worlds will have data in all entries. However, we should ensure
* that the behavior is kept like this.
*/
// @formatter:off
WORLD1(RecognisedVersion._1_8_9, "amidst-test-seed", WorldType.DEFAULT,
TestWorldEntryNames.ALL
),

View File

@ -22,25 +22,22 @@ public class TestWorldEntryNames {
public static final String LIKELY_END_CITY = "likely-end-city";
public static final String POSSIBLE_END_CITY = "possible-end-city";
// @formatter:off
public static final String[] ALL = {
TestWorldEntryNames.METADATA,
TestWorldEntryNames.QUARTER_RESOLUTION_BIOME_DATA,
TestWorldEntryNames.FULL_RESOLUTION_BIOME_DATA,
TestWorldEntryNames.END_ISLANDS,
TestWorldEntryNames.SLIME_CHUNKS,
TestWorldEntryNames.SPAWN,
TestWorldEntryNames.STRONGHOLDS,
TestWorldEntryNames.VILLAGES,
TestWorldEntryNames.WITCH_HUTS,
TestWorldEntryNames.JUNGLE_TEMPLES,
TestWorldEntryNames.DESERT_TEMPLES,
TestWorldEntryNames.IGLOOS,
TestWorldEntryNames.MINESHAFTS,
TestWorldEntryNames.OCEAN_MONUMENTS,
TestWorldEntryNames.NETHER_FORTRESSES,
TestWorldEntryNames.LIKELY_END_CITY,
TestWorldEntryNames.POSSIBLE_END_CITY
};
// @formatter:on
TestWorldEntryNames.METADATA,
TestWorldEntryNames.QUARTER_RESOLUTION_BIOME_DATA,
TestWorldEntryNames.FULL_RESOLUTION_BIOME_DATA,
TestWorldEntryNames.END_ISLANDS,
TestWorldEntryNames.SLIME_CHUNKS,
TestWorldEntryNames.SPAWN,
TestWorldEntryNames.STRONGHOLDS,
TestWorldEntryNames.VILLAGES,
TestWorldEntryNames.WITCH_HUTS,
TestWorldEntryNames.JUNGLE_TEMPLES,
TestWorldEntryNames.DESERT_TEMPLES,
TestWorldEntryNames.IGLOOS,
TestWorldEntryNames.MINESHAFTS,
TestWorldEntryNames.OCEAN_MONUMENTS,
TestWorldEntryNames.NETHER_FORTRESSES,
TestWorldEntryNames.LIKELY_END_CITY,
TestWorldEntryNames.POSSIBLE_END_CITY };
}

View File

@ -27,13 +27,15 @@ public class TestWorldDirectoryWriter {
}
public void write(TestWorldDeclaration worldDeclaration, TestWorldDirectory directory)
throws FileNotFoundException, IOException {
throws FileNotFoundException,
IOException {
worldDeclaration.createDirectoryIfNecessary();
writeAll(worldDeclaration, directory.getData());
}
private void writeAll(TestWorldDeclaration worldDeclaration, Map<String, Object> data)
throws FileNotFoundException, IOException {
throws FileNotFoundException,
IOException {
for (TestWorldEntryDeclaration<?> entryDeclaration : directoryDeclaration.getEntryDeclarations()) {
if (worldDeclaration.isSupported(entryDeclaration.getName())) {
writeEntry(data, worldDeclaration, entryDeclaration);

View File

@ -8,6 +8,9 @@ import java.io.OutputStreamWriter;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import amidst.documentation.Immutable;
import amidst.mojangapi.world.testworld.storage.json.BiomeDataJson;
import amidst.mojangapi.world.testworld.storage.json.CoordinatesCollectionJson;
@ -15,9 +18,6 @@ import amidst.mojangapi.world.testworld.storage.json.EndIslandsJson;
import amidst.mojangapi.world.testworld.storage.json.SlimeChunksJson;
import amidst.mojangapi.world.testworld.storage.json.WorldMetadataJson;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@Immutable
public enum TestWorldEntrySerializer {
;

View File

@ -9,7 +9,10 @@ import amidst.mojangapi.world.WorldType;
@Immutable
public class WorldMetadataJson {
public static WorldMetadataJson from(World world) {
return new WorldMetadataJson(world.getRecognisedVersion(), world.getWorldSeed().getLong(), world.getWorldType());
return new WorldMetadataJson(
world.getRecognisedVersion(),
world.getWorldSeed().getLong(),
world.getWorldType());
}
private volatile RecognisedVersion recognisedVersion;