Skip to content

Commit

Permalink
Reformat code #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjabrain1 committed Sep 5, 2024
1 parent e2b24a8 commit 84b099b
Show file tree
Hide file tree
Showing 25 changed files with 47 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/main/java/ninjabrainbot/event/ObservableField.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void set(T value) {
/**
* Sets the value and notifies subscribers even if the value was the same as the previous value.
*/
public void setAndAlwaysNotifySubscribers(T value){
public void setAndAlwaysNotifySubscribers(T value) {
data = value;
for (Consumer<T> subscriber : subscribers) {
subscriber.accept(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public CustomCheckbox(boolean ticked) {
addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean ticked = (boolean) ((JCheckBox) e.getSource()).isSelected();
boolean ticked = ((JCheckBox) e.getSource()).isSelected();
onChanged(ticked);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@ public void setFont(Font font) {
@Override
public void setBounds(int x, int y, int width, int height) {
super.setBounds(x, y, width, height);
int w = width - 2 * 0 - height;
int w = width - height;
int y0 = -1;
if (!errorsEnabled) {
if (this.x != null)
this.x.setBounds(0, y0, w / 3, height);
if (this.z != null)
this.z.setBounds(0 + w / 3, y0, w / 3, height);
this.z.setBounds(w / 3, y0, w / 3, height);
if (this.alpha != null)
this.alpha.setBounds(0 + 2 * w / 3, y0, w / 3, height);
this.alpha.setBounds(2 * w / 3, y0, w / 3, height);
} else {
if (this.x != null)
this.x.setBounds(0, y0, w / 4, height);
if (this.z != null)
this.z.setBounds(0 + w / 4, y0, w / 4, height);
this.z.setBounds(w / 4, y0, w / 4, height);
if (this.alpha != null)
this.alpha.setBounds(0 + 2 * w / 4, y0, w / 4, height);
this.alpha.setBounds(2 * w / 4, y0, w / 4, height);
if (this.error != null)
this.error.setBounds(0 + 3 * w / 4, y0, w / 4, height);
this.error.setBounds(3 * w / 4, y0, w / 4, height);
}
error.setVisible(errorsEnabled);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ private String formatStrongholdCoords(ChunkPrediction chunkPrediction, Stronghol
return "<html>" + I18n.get("chunk_blocks", getFormattedCoords(chunk.x, chunk.z), distance) + "</html>";
}

private String getFormattedCoords(int x, int z){
if (preferences.colorCodeNegativeCoords.get()){
private String getFormattedCoords(int x, int z) {
if (preferences.colorCodeNegativeCoords.get()) {
String xColor = x < 0 ? styleManager.currentTheme.COLOR_NEGATIVE.hex() : styleManager.currentTheme.TEXT_COLOR_SLIGHTLY_WEAK.hex();
String zColor = z < 0 ? styleManager.currentTheme.COLOR_NEGATIVE.hex() : styleManager.currentTheme.TEXT_COLOR_SLIGHTLY_WEAK.hex();
return String.format(Locale.US, "(<font color='%s'>%d</font>, <font color='%s'>%d</font>)", xColor, x, zColor, z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ private String formatStrongholdCoords(Chunk chunk, StrongholdDisplayType strongh
return getFormattedCoords(chunk.x, chunk.z);
}

private String getFormattedCoords(int x, int z){
if (preferences.colorCodeNegativeCoords.get()){
private String getFormattedCoords(int x, int z) {
if (preferences.colorCodeNegativeCoords.get()) {
String xColor = x < 0 ? styleManager.currentTheme.COLOR_NEGATIVE.hex() : styleManager.currentTheme.TEXT_COLOR_SLIGHTLY_WEAK.hex();
String zColor = z < 0 ? styleManager.currentTheme.COLOR_NEGATIVE.hex() : styleManager.currentTheme.TEXT_COLOR_SLIGHTLY_WEAK.hex();
return String.format(Locale.US, "<html>(<font color='%s'>%d</font>, <font color='%s'>%d</font>)</html>", xColor, x, zColor, z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class AngleAdjustmentOptionsPanel extends JPanel {

private final ThemedLabel tallResExplanation;
private final FloatPreferencePanel resolutionHeight;
private final FloatPreferencePanel resolutionHeight;
private final DoublePreferencePanel customAdjustmentAmount;

public AngleAdjustmentOptionsPanel(StyleManager styleManager, NinjabrainBotPreferences preferences, DisposeHandler disposeHandler) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public BoatMeasurementOptionsPanel(StyleManager styleManager, NinjabrainBotPrefe
column1.setOpaque(false);
add(column1);

CheckboxPanel enableBoatMeasurementsCheckbox = new CheckboxPanel(styleManager, I18n.get("settings.use_precise_angle"), preferences.usePreciseAngle);
CheckboxPanel enableBoatMeasurementsCheckbox = new CheckboxPanel(styleManager, I18n.get("settings.use_precise_angle"), preferences.usePreciseAngle);
column1.add(enableBoatMeasurementsCheckbox);

sensitivityManual = new FloatPreferencePanel(styleManager, I18n.get("settings.sensitivityManual"), preferences.sensitivityManual);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class CustomTheme extends Theme {

private ArrayList<ConfigurableColor> configurableColors;
private final ArrayList<ConfigurableColor> configurableColors;

private final ObservableField<String> themeString = new ObservableField<String>();

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ninjabrainbot/io/KeyConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

public class KeyConverter extends SwingKeyAdapter {

public int convertNativeKeyCodeToKeyCode(int nativeKeyCode){
NativeKeyEvent nativeKeyEvent = new NativeKeyEvent(0, 0, 0, nativeKeyCode, (char)0);
public int convertNativeKeyCodeToKeyCode(int nativeKeyCode) {
NativeKeyEvent nativeKeyEvent = new NativeKeyEvent(0, 0, 0, nativeKeyCode, (char) 0);
return getJavaKeyEvent(nativeKeyEvent).getKeyCode();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ private void updateHttpServerStatus() {
if (httpServer == null)
startHttpServer(52533);
} else {
if (httpServer != null)
if (httpServer != null)
stopHttpServer();
}
}

private void startHttpServer(int port){
private void startHttpServer(int port) {
error = null;
try {
httpServer = HttpServer.create(new InetSocketAddress(port), 0);
Expand All @@ -62,7 +62,7 @@ private void startHttpServer(int port){
Logger.log("HTTP server started on port " + port);
}

private void stopHttpServer(){
private void stopHttpServer() {
apiV1HttpHandler.dispose();
apiV1HttpHandler = null;
httpServer.stop(0);
Expand All @@ -75,7 +75,7 @@ public void dispose() {
if (httpServer != null) {
httpServer.stop(0);
}
if (apiV1HttpHandler != null){
if (apiV1HttpHandler != null) {
apiV1HttpHandler.dispose();
}
disposeHandler.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ public abstract class ActiveInstanceProviderFactory {

public static IActiveInstanceProvider createPlatformSpecificActiveInstanceProvider() {
try {
switch (Platform.getOSType()) {
case Platform.WINDOWS:
return new WindowsActiveInstanceListener();
default:
return new UnsupportedOSActiveInstanceProvider();
if (Platform.getOSType() == Platform.WINDOWS) {
return new WindowsActiveInstanceListener();
}
return new UnsupportedOSActiveInstanceProvider();
} catch (IOException exception) {
Logger.log("Cannot monitor active Minecraft instance.");
Logger.log(exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ public NinjabrainBotPreferences(IPreferenceSource source) {
Assert.isTrue(settingsVersion.get() >= 2); // Do >= to allow users to downgrade to an earlier version, in case newer version has issues
}

private void upgradeSettings_From_0_To_1(){
for (HotkeyPreference hotkeyPreference : HotkeyPreference.hotkeys){
private void upgradeSettings_From_0_To_1() {
for (HotkeyPreference hotkeyPreference : HotkeyPreference.hotkeys) {
if (hotkeyPreference.getCode() == -1)
continue;
int nativeKeyCode = KeyConverter.convertKeyCodeToNativeKeyCode(hotkeyPreference.getCode());
Expand All @@ -170,10 +170,10 @@ private void upgradeSettings_From_0_To_1(){
settingsVersion.set(1);
}

private void upgradeSettings_From_1_To_2(){
if (!Platform.isLinux()){
private void upgradeSettings_From_1_To_2() {
if (!Platform.isLinux()) {
KeyConverter keyConverter = new KeyConverter();
for (HotkeyPreference hotkeyPreference : HotkeyPreference.hotkeys){
for (HotkeyPreference hotkeyPreference : HotkeyPreference.hotkeys) {
if (hotkeyPreference.getCode() == -1)
continue;
int keyCode = keyConverter.convertNativeKeyCodeToKeyCode(hotkeyPreference.getCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private StructureType getAllAdvancementStructureTypeFromPlayerPosition(IDetailed
if (preferences.oneDotTwentyPlusAA.get()) {
if (t.yInPlayerDimension() <= 30 && t.isInOverworld())
return StructureType.DeepDark;

if (t.yInPlayerDimension() > 160 && t.isInOverworld())
return StructureType.CityQuery;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class AddEnderEyeThrowAction implements IAction {
public AddEnderEyeThrowAction(IDataState dataState, IEnderEyeThrow throwToAdd) {
this.dataState = dataState;
this.throwToAdd = throwToAdd;
}
}

@Override
public void execute() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public ChangeLastAngleAction(IListComponent<IEnderEyeThrow> throwList, IObservab
this.throwList = throwList;
this.locked = locked;
this.preferences = preferences;
this.correctionIncrements = correctionIncrements;
}
this.correctionIncrements = correctionIncrements;
}

@Override
public void execute() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

public enum BlindEvaluation {

EXCELLENT, HIGHROLL_GOOD, HIGHROLL_OKAY, BAD_BUT_IN_RING, BAD, NOT_IN_RING;
EXCELLENT, HIGHROLL_GOOD, HIGHROLL_OKAY, BAD_BUT_IN_RING, BAD, NOT_IN_RING

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public BlindResult(double x, double z, double highrollProbability, double highro
}

public Pair<Float, String> evaluation() {
switch (evaluationEnum){
switch (evaluationEnum) {
case EXCELLENT:
return EXCELLENT;
case HIGHROLL_GOOD:
Expand All @@ -58,7 +58,7 @@ public Pair<Float, String> evaluation() {
return NOT_IN_RING;
}

private BlindEvaluation getBlindEvaluation(){
private BlindEvaluation getBlindEvaluation() {
if (Ring.get(Math.sqrt(x * x + z * z) / 2.0) == null)
return BlindEvaluation.NOT_IN_RING;
if (highrollProbability / optHighrollProb < 0.01) // prevents divine from showing "Excellent" when not in a sector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ private void onNewLimitedPlayerPositionInputted(ILimitedPlayerPosition playerPos

if (isBoatThrowCalibrator) {
add(new BoatEnderEyeThrow(playerPosition, preferences, 0), changeAngleAction);
}
else {
} else {
add(new ManualEnderEyeThrow(playerPosition, preferences.crosshairCorrection.get()), changeAngleAction);
}
} catch (InterruptedException e) {
Expand All @@ -102,8 +101,7 @@ private void onNewDetailedPlayerPositionInputted(IDetailedPlayerPosition playerP
try {
if (isBoatThrowCalibrator) {
add(new BoatEnderEyeThrow(playerPosition, preferences, 0), null);
}
else {
} else {
add(new NormalEnderEyeThrow(playerPosition, preferences.crosshairCorrection.get()), null);
}
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public double zInNether() {
return zInOverworld() / 8.0;
}

public int xInNetherForDisplay(){
public int xInNetherForDisplay() {
return (int) Math.floor(x / 8.0);
}

public int zInNetherForDisplay(){
public int zInNetherForDisplay() {
return (int) Math.floor(z / 8.0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static F3CData tryParseF3CString(String string) {
try {
String world = substrings[2];
MCDimension dimension = getMCDimension(world);

double x = Double.parseDouble(substrings[6]);
double y = Double.parseDouble(substrings[7]);
double z = Double.parseDouble(substrings[8]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static F3IData tryParseF3IString(String string) {
return null;
try {
int x = Integer.parseInt(substrings[1]);
int y = Integer.parseInt(substrings[2]);
int y = Integer.parseInt(substrings[2]);
int z = Integer.parseInt(substrings[3]);
return new F3IData(x, y, z);
} catch (NullPointerException | NumberFormatException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package ninjabrainbot.model.datastate.endereye;

public enum MCDimension {
OVERWORLD, NETHER, END;
OVERWORLD, NETHER, END
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void updateConditionalProbability(Chunk chunk, IEnderEyeThrow t) {
chunk.weight *= Math.exp(-delta * delta / (2 * s * s));
}

private double getVarianceFromPositionImprecision(double distance2){
private double getVarianceFromPositionImprecision(double distance2) {
// Assume the error is uniformly distributed for simplicity
double maxLateralError = 0.005 * Math.sqrt(2) * 180 / Math.PI;
return maxLateralError * maxLateralError / distance2 / 6; // Variance for uniform distribution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ private IAction getActionForInputtedPlayerPosition(IDetailedPlayerPosition playe

if (preferences.usePreciseAngle.get() && dataState.boatDataState().reducingModulo360().get())
return new ReduceBoatAngleMod360Action(dataState.boatDataState(), playerPosition.horizontalAngle(), preferences.sensitivityAutomatic.get());

if (dataState.allAdvancementsDataState().allAdvancementsModeEnabled().get())
return new TryAddAllAdvancementsStructureAction(dataState, playerPosition, preferences);

if (!playerPosition.isInOverworld())
return null;

if (playerPosition.lookingBelowHorizon())
return null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void oneEyeBoatCalculatedTravelEyeSpies_doogilePositionImprecision(String
testBuilder.setClipboard(enderEyeF3c);
testBuilder.inputSubpixelCorrections(subpixelCorrections);

for (Chunk chunk : testBuilder.dataState.calculatorResult().get().getTopChunks()){
for (Chunk chunk : testBuilder.dataState.calculatorResult().get().getTopChunks()) {
double error = chunk.getAngleError(McVersion.PRE_119, testBuilder.dataState.getThrowList().get(0));
System.out.println("Chunk: (" + chunk.x + ", " + chunk.z + "), Certainty: " + chunk.weight + ", Error: " + error);
}
Expand Down

0 comments on commit 84b099b

Please sign in to comment.