Skip to content

Commit 98beb62

Browse files
flTobiNicholasBatesNZ
authored andcommitted
Checkstyle: Fix missing bracing of if-statements
1 parent 32a9cc4 commit 98beb62

File tree

7 files changed

+42
-29
lines changed

7 files changed

+42
-29
lines changed

engine/src/main/java/org/destinationsol/assets/AssetHelper.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,24 @@ public void init(ModuleEnvironment environment) {
5353
assetTypeManager = new ModuleAwareAssetTypeManagerImpl();
5454

5555
assetTypeManager.createAssetType(OggSound.class, OggSound::new, "sounds");
56-
((AssetFileDataProducer)assetTypeManager.getAssetType(OggSound.class).get().getProducers().get(0)).addAssetFormat(new OggSoundFileFormat());
56+
((AssetFileDataProducer) assetTypeManager.getAssetType(OggSound.class).get().getProducers().get(0)).addAssetFormat(new OggSoundFileFormat());
5757

5858
assetTypeManager.createAssetType(OggMusic.class, OggMusic::new, "music");
59-
((AssetFileDataProducer)assetTypeManager.getAssetType(OggMusic.class).get().getProducers().get(0)).addAssetFormat(new OggMusicFileFormat());
59+
((AssetFileDataProducer) assetTypeManager.getAssetType(OggMusic.class).get().getProducers().get(0)).addAssetFormat(new OggMusicFileFormat());
6060

6161
assetTypeManager.createAssetType(Font.class, Font::new, "fonts");
62-
((AssetFileDataProducer)assetTypeManager.getAssetType(Font.class).get().getProducers().get(0)).addAssetFormat(new FontFileFormat());
62+
((AssetFileDataProducer) assetTypeManager.getAssetType(Font.class).get().getProducers().get(0)).addAssetFormat(new FontFileFormat());
6363

6464
assetTypeManager.createAssetType(Emitter.class, Emitter::new, "emitters");
65-
((AssetFileDataProducer)assetTypeManager.getAssetType(Emitter.class).get().getProducers().get(0)).addAssetFormat(new EmitterFileFormat());
65+
((AssetFileDataProducer) assetTypeManager.getAssetType(Emitter.class).get().getProducers().get(0)).addAssetFormat(new EmitterFileFormat());
6666

6767
assetTypeManager.createAssetType(Json.class, Json::new, "collisionMeshes", "ships", "items", "configs", "grounds", "mazes", "asteroids", "schemas");
6868
AssetFileDataProducer dataProducer = (AssetFileDataProducer) assetTypeManager.getAssetType(Json.class).get().getProducers().get(0);
6969
dataProducer.addAssetFormat(new JsonFileFormat());
7070
dataProducer.addDeltaFormat(new JsonDeltaFileFormat());
7171

7272
assetTypeManager.createAssetType(DSTexture.class, DSTexture::new, "textures", "ships", "items", "grounds", "mazes", "asteroids", "fonts");
73-
((AssetFileDataProducer)assetTypeManager.getAssetType(DSTexture.class).get().getProducers().get(0)).addAssetFormat(new DSTextureFileFormat());
73+
((AssetFileDataProducer) assetTypeManager.getAssetType(DSTexture.class).get().getProducers().get(0)).addAssetFormat(new DSTextureFileFormat());
7474

7575
assetTypeManager.switchEnvironment(environment);
7676
}
@@ -113,8 +113,9 @@ public String resolveToPath(List<AssetDataFile> assetDataFiles) {
113113
}
114114
}
115115
}
116-
if (!validPath)
116+
if (!validPath) {
117117
continue;
118+
}
118119

119120
StringBuilder path = new StringBuilder();
120121

engine/src/main/java/org/destinationsol/game/Hero.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ public void setSolShip(SolShip hero, SolGame solGame) {
7979
}
8080
GameOptions options = solGame.getSolApplication().getOptions();
8181
//Satisfying unit tests
82-
if (hero.getHull() != null)
82+
if (hero.getHull() != null) {
8383
solGame.getSolApplication().getMusicManager().registerModuleMusic(hero.getHull().getHullConfig().getInternalName().split(":")[0], options);
84+
}
8485
solGame.getSolApplication().getMusicManager().playMusic(OggMusicManager.GAME_MUSIC_SET, options);
8586
}
8687

engine/src/main/java/org/destinationsol/game/planet/DecoConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
1919
import com.badlogic.gdx.math.Vector2;
20-
import org.json.JSONObject;
2120
import org.destinationsol.assets.Assets;
2221
import org.destinationsol.common.SolMath;
22+
import org.json.JSONObject;
2323

2424
import java.util.ArrayList;
2525
import java.util.List;
@@ -45,8 +45,9 @@ static List<DecoConfig> load(JSONObject planetConfig) {
4545
ArrayList<DecoConfig> res = new ArrayList<>();
4646
JSONObject decorations = planetConfig.getJSONObject("decorations");
4747
for (String s : decorations.keySet()) {
48-
if (!(decorations.get(s) instanceof JSONObject))
48+
if (!(decorations.get(s) instanceof JSONObject)) {
4949
continue;
50+
}
5051
JSONObject deco = decorations.getJSONObject(s);
5152
float density = (float) deco.getDouble("density");
5253
float szMin = (float) deco.getDouble("szMin");

engine/src/main/java/org/destinationsol/game/planet/SysConfigs.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
*/
1616
package org.destinationsol.game.planet;
1717

18-
import org.destinationsol.assets.json.Validator;
19-
import org.json.JSONObject;
2018
import org.destinationsol.assets.Assets;
2119
import org.destinationsol.assets.json.Json;
20+
import org.destinationsol.assets.json.Validator;
2221
import org.destinationsol.common.SolRandom;
2322
import org.destinationsol.files.HullConfigManager;
2423
import org.destinationsol.game.ShipConfig;
2524
import org.destinationsol.game.chunk.SpaceEnvConfig;
2625
import org.destinationsol.game.item.ItemManager;
2726
import org.destinationsol.game.item.TradeConfig;
28-
import org.terasology.gestalt.assets.ResourceUrn;
27+
import org.json.JSONObject;
28+
import org.terasology.assets.ResourceUrn;
2929

3030
import java.util.ArrayList;
3131
import java.util.HashMap;
@@ -52,8 +52,9 @@ private void load(String configName, HullConfigManager hullConfigs, boolean belt
5252
JSONObject rootNode = Validator.getValidatedJSON("engine:" + configName, "engine:schemaSystemsConfig");
5353

5454
for (String s : rootNode.keySet()) {
55-
if (!(rootNode.get(s) instanceof JSONObject))
55+
if (!(rootNode.get(s) instanceof JSONObject)) {
5656
continue;
57+
}
5758
JSONObject node = rootNode.getJSONObject(s);
5859
String name = s;
5960

@@ -72,8 +73,9 @@ private void load(String configName, HullConfigManager hullConfigs, boolean belt
7273
rootNode = Validator.getValidatedJSON(configUrn.toString(), "engine:schemaSystemsConfig");
7374

7475
for (String s : rootNode.keySet()) {
75-
if (!(rootNode.get(s) instanceof JSONObject))
76+
if (!(rootNode.get(s) instanceof JSONObject)) {
7677
continue;
78+
}
7779
JSONObject node = rootNode.getJSONObject(s);
7880
String name = s;
7981

engine/src/main/java/org/destinationsol/game/projectile/ProjectileConfigs.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818
import com.badlogic.gdx.graphics.g2d.Animation;
1919
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
2020
import com.badlogic.gdx.math.Vector2;
21-
import org.destinationsol.assets.json.Validator;
22-
import org.json.JSONObject;
2321
import org.destinationsol.assets.Assets;
2422
import org.destinationsol.assets.audio.OggSound;
2523
import org.destinationsol.assets.audio.OggSoundManager;
2624
import org.destinationsol.assets.json.Json;
25+
import org.destinationsol.assets.json.Validator;
2726
import org.destinationsol.common.SolMath;
2827
import org.destinationsol.game.DmgType;
2928
import org.destinationsol.game.GameColors;
3029
import org.destinationsol.game.drawables.SpriteInfo;
3130
import org.destinationsol.game.particle.EffectConfig;
3231
import org.destinationsol.game.particle.EffectTypes;
33-
import org.terasology.gestalt.assets.ResourceUrn;
32+
import org.json.JSONObject;
33+
import org.terasology.assets.ResourceUrn;
3434

3535
import java.util.HashMap;
3636
import java.util.Map;
@@ -49,8 +49,9 @@ public ProjectileConfigs(OggSoundManager soundManager, EffectTypes effectTypes,
4949
JSONObject rootNode = Validator.getValidatedJSON(configUrn.toString(), "engine:schemaProjectileConfig");
5050

5151
for (String s : rootNode.keySet()) {
52-
if (!(rootNode.get(s) instanceof JSONObject))
52+
if (!(rootNode.get(s) instanceof JSONObject)) {
5353
continue;
54+
}
5455
JSONObject node = rootNode.getJSONObject(s);
5556
String name = s;
5657
String texName = node.getString("tex");

engine/src/main/java/org/destinationsol/game/screens/WarnDrawer.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public WarnDrawer(String text, Color backgroundColor) {
5252
backgroundOriginA = backgroundColor.a;
5353
textColor = new Color(SolColor.WHITE);
5454
// create the 3 rectangles where notifications can appear
55-
for(int i=0; i<3; i++) {
55+
for (int i = 0; i < 3; i++) {
5656
rectangles.add(createRectangle(i));
5757
}
5858
}
@@ -70,24 +70,29 @@ public void update(SolGame game) {
7070
protected abstract boolean shouldWarn(SolGame game);
7171

7272
public void draw(UiDrawer uiDrawer, int drawIndex) {
73-
if(drawIndex >= rectangles.size()) return;
73+
if (drawIndex >= rectangles.size()) {
74+
return;
75+
}
7476
uiDrawer.draw(rectangles.get(drawIndex), backgroundColor);
7577
}
7678

7779
public void drawText(UiDrawer uiDrawer, int drawIndex) {
78-
if(drawIndex >= rectangles.size()) return;
80+
if (drawIndex >= rectangles.size()) {
81+
return;
82+
}
7983
Rectangle warningRectangle = rectangles.get(drawIndex);
8084
uiDrawer.drawString(text, warningRectangle.x + warningRectangle.width / 2.f, warningRectangle.y + warningRectangle.height / 2.f, FontSize.MENU, true, textColor);
8185
}
8286

8387
/**
8488
* Create background rectangle by calculating bounds
89+
*
8590
* @param drawIndex where the rectangle starts on the screen
8691
*/
8792
private Rectangle createRectangle(int drawIndex) {
8893
float x;
8994
float y = 0.05f;
90-
switch(drawIndex) {
95+
switch (drawIndex) {
9196
case 1: // left of center
9297
x = 0.18f * displayDimensions.getRatio();
9398
break;

engine/src/main/java/org/destinationsol/util/FramerateLimiter.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class FramerateLimiter {
44
protected static long variableYieldTime;
5-
protected static long lastTime;
5+
protected static long lastTime;
66

77
/**
88
* SOURCE: http://forum.lwjgl.org/index.php?topic=5653.0
@@ -13,11 +13,13 @@ public class FramerateLimiter {
1313
* @author kappa (On the LWJGL Forums)
1414
*/
1515
public static void synchronizeFPS(int fps) {
16-
if (fps <= 0) return;
16+
if (fps <= 0) {
17+
return;
18+
}
1719

1820
long sleepTime = 1000000000 / fps; // nanoseconds to sleep this frame
1921
// yieldTime + remainder micro & nano seconds if smaller than sleepTime
20-
long yieldTime = Math.min(sleepTime, variableYieldTime + sleepTime % (1000*1000));
22+
long yieldTime = Math.min(sleepTime, variableYieldTime + sleepTime % (1000 * 1000));
2123
long overSleep = 0; // time the sync goes over by
2224

2325
try {
@@ -26,7 +28,7 @@ public static void synchronizeFPS(int fps) {
2628

2729
if (t < sleepTime - yieldTime) {
2830
Thread.sleep(1);
29-
}else if (t < sleepTime) {
31+
} else if (t < sleepTime) {
3032
// burn the last few CPU cycles to ensure accuracy
3133
Thread.yield();
3234
} else {
@@ -42,10 +44,10 @@ public static void synchronizeFPS(int fps) {
4244
// auto tune the time sync should yield
4345
if (overSleep > variableYieldTime) {
4446
// increase by 200 microseconds (1/5 a ms)
45-
variableYieldTime = Math.min(variableYieldTime + 200*1000, sleepTime);
46-
} else if (overSleep < variableYieldTime - 200*1000) {
47+
variableYieldTime = Math.min(variableYieldTime + 200 * 1000, sleepTime);
48+
} else if (overSleep < variableYieldTime - 200 * 1000) {
4749
// decrease by 2 microseconds
48-
variableYieldTime = Math.max(variableYieldTime - 2*1000, 0);
50+
variableYieldTime = Math.max(variableYieldTime - 2 * 1000, 0);
4951
}
5052
}
5153
}

0 commit comments

Comments
 (0)