Skip to content

Commit 9ab4f68

Browse files
committed
cleanup code and update dependencies
1 parent acf8228 commit 9ab4f68

File tree

9 files changed

+99
-99
lines changed

9 files changed

+99
-99
lines changed

pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13-
<jmh.version>1.21</jmh.version>
13+
<jmh.version>1.23</jmh.version>
1414
</properties>
1515

1616
<build>
@@ -31,7 +31,7 @@
3131
<plugin>
3232
<groupId>org.apache.maven.plugins</groupId>
3333
<artifactId>maven-assembly-plugin</artifactId>
34-
<version>3.1.1</version>
34+
<version>3.2.0</version>
3535
<configuration>
3636
<descriptorRefs>
3737
<descriptorRef>jar-with-dependencies</descriptorRef>
@@ -101,37 +101,37 @@
101101
<dependency>
102102
<groupId>net.java.dev.jna</groupId>
103103
<artifactId>jna</artifactId>
104-
<version>5.4.0</version>
104+
<version>5.5.0</version>
105105
</dependency>
106106

107107
<!-- https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform -->
108108
<dependency>
109109
<groupId>net.java.dev.jna</groupId>
110110
<artifactId>jna-platform</artifactId>
111-
<version>5.4.0</version>
111+
<version>5.5.0</version>
112112
</dependency>
113113

114114
<!-- https://mvnrepository.com/artifact/junit/junit -->
115115
<dependency>
116116
<groupId>junit</groupId>
117117
<artifactId>junit</artifactId>
118-
<version>4.12</version>
118+
<version>4.13</version>
119119
<scope>test</scope>
120120
</dependency>
121121

122122
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
123123
<dependency>
124124
<groupId>org.mockito</groupId>
125125
<artifactId>mockito-core</artifactId>
126-
<version>3.1.0</version>
126+
<version>3.2.4</version>
127127
<scope>test</scope>
128128
</dependency>
129129

130130
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
131131
<dependency>
132132
<groupId>org.assertj</groupId>
133133
<artifactId>assertj-core</artifactId>
134-
<version>3.13.2</version>
134+
<version>3.15.0</version>
135135
<scope>test</scope>
136136
</dependency>
137137

src/main/java/bwapi/Client.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ boolean connect() {
128128
return false;
129129
}
130130

131-
GameTable gameTable = null;
131+
GameTable gameTable;
132132
try {
133133
gameTable = new GameTable(gameTableFileHandle);
134134
}

src/main/java/bwapi/CommandTemp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ enum EventType {
1616
Finish
1717
}
1818

19-
UnitCommand command;
19+
final UnitCommand command;
2020
EventType eventType = EventType.Resource;
2121
Player player = null;
22-
Game game;
22+
final Game game;
2323

2424
CommandTemp(final UnitCommand command, Game game) {
2525
this.command = command;

src/main/java/bwapi/GameTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class GameTable {
2727
static final int MAX_GAME_INSTANCES = 8;
2828
static final int SIZE = MAX_GAME_INSTANCES * GameInstance.SIZE;
2929

30-
GameInstance[] gameInstances;
30+
final GameInstance[] gameInstances;
3131

3232
GameTable(final ByteBuffer gameTableFileHandle) {
3333
gameInstances = new GameInstance[MAX_GAME_INSTANCES];

src/main/java/bwapi/PlayerSelf.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import java.util.stream.IntStream;
44

55
class PlayerSelf {
6-
IntegerCache minerals = new IntegerCache();
7-
IntegerCache gas = new IntegerCache();
8-
IntegerCache[] supplyUsed = new IntegerCache[3];
6+
final IntegerCache minerals = new IntegerCache();
7+
final IntegerCache gas = new IntegerCache();
8+
final IntegerCache[] supplyUsed = new IntegerCache[3];
99

10-
BooleanCache[] isResearching = new BooleanCache[TechType.idToEnum.length];
11-
BooleanCache[] isUpgrading = new BooleanCache[UpgradeType.idToEnum.length];
10+
final BooleanCache[] isResearching = new BooleanCache[TechType.idToEnum.length];
11+
final BooleanCache[] isUpgrading = new BooleanCache[UpgradeType.idToEnum.length];
1212

1313
PlayerSelf() {
1414
IntStream.range(0, supplyUsed.length).forEach(i -> supplyUsed[i] = new IntegerCache());

src/main/java/bwapi/Point.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package bwapi;
22

3-
public abstract class Point<T extends Point> implements Comparable<Point> {
3+
public abstract class Point<T extends Point<T>> implements Comparable<Point<T>> {
44
static final int TILE_WALK_FACTOR = 4; // 32 / 8
55

66
public final int x;

src/main/java/bwapi/UnitFilter.java

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public interface UnitFilter extends Predicate<Unit> {
88
UnitFilter CanAttack = u -> u.getType().canAttack();
99
UnitFilter CanMove = u -> u.getType().canMove();
1010
UnitFilter IsFlyer = u -> u.getType().isFlyer();
11-
UnitFilter IsFlying = u -> u.isFlying();
11+
UnitFilter IsFlying = Unit::isFlying;
1212
UnitFilter RegeneratesHP = u -> u.getType().regeneratesHP();
1313
UnitFilter IsSpellcaster = u -> u.getType().isSpellcaster();
1414
UnitFilter HasPermanentCloak = u -> u.getType().hasPermanentCloak();
@@ -280,54 +280,54 @@ static UnitFilter GetBottom(Predicate<Integer> c) {
280280
return u -> c.test(u.getBottom());
281281
}
282282

283-
UnitFilter Exists = u -> u.exists();
284-
UnitFilter IsAttacking = u -> u.isAttacking();
285-
UnitFilter IsBeingConstructed = u -> u.isBeingConstructed();
286-
UnitFilter IsBeingGathered = u -> u.isBeingGathered();
287-
UnitFilter IsBeingHealed = u -> u.isBeingHealed();
288-
UnitFilter IsBlind = u -> u.isBlind();
289-
UnitFilter IsBraking = u -> u.isBraking();
290-
UnitFilter IsBurrowed = u -> u.isBurrowed();
291-
UnitFilter IsCarryingGas = u -> u.isCarryingGas();
292-
UnitFilter IsCarryingMinerals = u -> u.isCarryingMinerals();
283+
UnitFilter Exists = Unit::exists;
284+
UnitFilter IsAttacking = Unit::isAttacking;
285+
UnitFilter IsBeingConstructed = Unit::isBeingConstructed;
286+
UnitFilter IsBeingGathered = Unit::isBeingGathered;
287+
UnitFilter IsBeingHealed = Unit::isBeingHealed;
288+
UnitFilter IsBlind = Unit::isBlind;
289+
UnitFilter IsBraking = Unit::isBraking;
290+
UnitFilter IsBurrowed = Unit::isBurrowed;
291+
UnitFilter IsCarryingGas = Unit::isCarryingGas;
292+
UnitFilter IsCarryingMinerals = Unit::isCarryingMinerals;
293293
UnitFilter IsCarryingSomething = u -> u.isCarryingMinerals() || u.isCarryingGas();
294-
UnitFilter IsCloaked = u -> u.isCloaked();
295-
UnitFilter IsCompleted = u -> u.isCompleted();
296-
UnitFilter IsConstructing = u -> u.isConstructing();
297-
UnitFilter IsDefenseMatrixed = u -> u.isDefenseMatrixed();
298-
UnitFilter IsDetected = u -> u.isDetected();
299-
UnitFilter IsEnsnared = u -> u.isEnsnared();
300-
UnitFilter IsFollowing = u -> u.isFollowing();
301-
UnitFilter IsGatheringGas = u -> u.isGatheringGas();
302-
UnitFilter IsGatheringMinerals = u -> u.isGatheringMinerals();
303-
UnitFilter IsHallucination = u -> u.isHallucination();
304-
UnitFilter IsHoldingPosition = u -> u.isHoldingPosition();
305-
UnitFilter IsIdle = u -> u.isIdle();
306-
UnitFilter IsInterruptible = u -> u.isInterruptible();
307-
UnitFilter IsInvincible = u -> u.isInvincible();
308-
UnitFilter IsIrradiated = u -> u.isIrradiated();
309-
UnitFilter IsLifted = u -> u.isLifted();
310-
UnitFilter IsLoaded = u -> u.isLoaded();
311-
UnitFilter IsLockedDown = u -> u.isLockedDown();
312-
UnitFilter IsMaelstrommed = u -> u.isMaelstrommed();
313-
UnitFilter IsMorphing = u -> u.isMorphing();
314-
UnitFilter IsMoving = u -> u.isMoving();
315-
UnitFilter IsParasited = u -> u.isParasited();
316-
UnitFilter IsPatrolling = u -> u.isPatrolling();
317-
UnitFilter IsPlagued = u -> u.isPlagued();
318-
UnitFilter IsRepairing = u -> u.isRepairing();
319-
UnitFilter IsResearching = u -> u.isResearching();
320-
UnitFilter IsSieged = u -> u.isSieged();
321-
UnitFilter IsStartingAttack = u -> u.isStartingAttack();
322-
UnitFilter IsStasised = u -> u.isStasised();
323-
UnitFilter IsStimmed = u -> u.isStimmed();
324-
UnitFilter IsStuck = u -> u.isStuck();
325-
UnitFilter IsTraining = u -> u.isTraining();
326-
UnitFilter IsUnderAttack = u -> u.isUnderAttack();
327-
UnitFilter IsUnderDarkSwarm = u -> u.isUnderDarkSwarm();
328-
UnitFilter IsUnderDisruptionWeb = u -> u.isUnderDisruptionWeb();
329-
UnitFilter IsUnderStorm = u -> u.isUnderStorm();
330-
UnitFilter IsPowered = u -> u.isPowered();
331-
UnitFilter IsVisible = u -> u.isVisible();
294+
UnitFilter IsCloaked = Unit::isCloaked;
295+
UnitFilter IsCompleted = Unit::isCompleted;
296+
UnitFilter IsConstructing = Unit::isConstructing;
297+
UnitFilter IsDefenseMatrixed = Unit::isDefenseMatrixed;
298+
UnitFilter IsDetected = Unit::isDetected;
299+
UnitFilter IsEnsnared = Unit::isEnsnared;
300+
UnitFilter IsFollowing = Unit::isFollowing;
301+
UnitFilter IsGatheringGas = Unit::isGatheringGas;
302+
UnitFilter IsGatheringMinerals = Unit::isGatheringMinerals;
303+
UnitFilter IsHallucination = Unit::isHallucination;
304+
UnitFilter IsHoldingPosition = Unit::isHoldingPosition;
305+
UnitFilter IsIdle = Unit::isIdle;
306+
UnitFilter IsInterruptible = Unit::isInterruptible;
307+
UnitFilter IsInvincible = Unit::isInvincible;
308+
UnitFilter IsIrradiated = Unit::isIrradiated;
309+
UnitFilter IsLifted = Unit::isLifted;
310+
UnitFilter IsLoaded = Unit::isLoaded;
311+
UnitFilter IsLockedDown = Unit::isLockedDown;
312+
UnitFilter IsMaelstrommed = Unit::isMaelstrommed;
313+
UnitFilter IsMorphing = Unit::isMorphing;
314+
UnitFilter IsMoving = Unit::isMoving;
315+
UnitFilter IsParasited = Unit::isParasited;
316+
UnitFilter IsPatrolling = Unit::isPatrolling;
317+
UnitFilter IsPlagued = Unit::isPlagued;
318+
UnitFilter IsRepairing = Unit::isRepairing;
319+
UnitFilter IsResearching = Unit::isResearching;
320+
UnitFilter IsSieged = Unit::isSieged;
321+
UnitFilter IsStartingAttack = Unit::isStartingAttack;
322+
UnitFilter IsStasised = Unit::isStasised;
323+
UnitFilter IsStimmed = Unit::isStimmed;
324+
UnitFilter IsStuck = Unit::isStuck;
325+
UnitFilter IsTraining = Unit::isTraining;
326+
UnitFilter IsUnderAttack = Unit::isUnderAttack;
327+
UnitFilter IsUnderDarkSwarm = Unit::isUnderDarkSwarm;
328+
UnitFilter IsUnderDisruptionWeb = Unit::isUnderDisruptionWeb;
329+
UnitFilter IsUnderStorm = Unit::isUnderStorm;
330+
UnitFilter IsPowered = Unit::isPowered;
331+
UnitFilter IsVisible = Unit::isVisible;
332332
}
333333

src/main/java/bwapi/UnitSelf.java

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,40 @@
33
import java.util.stream.IntStream;
44

55
class UnitSelf {
6-
OrderCache order = new OrderCache();
7-
IntegerCache targetPositionX = new IntegerCache();
8-
IntegerCache targetPositionY = new IntegerCache();
9-
IntegerCache orderTargetPositionX = new IntegerCache();
10-
IntegerCache orderTargetPositionY = new IntegerCache();
11-
IntegerCache target = new IntegerCache();
12-
BooleanCache isConstructing = new BooleanCache();
13-
BooleanCache isIdle = new BooleanCache();
14-
UnitTypeCache buildType = new UnitTypeCache();
15-
OrderCache secondaryOrder = new OrderCache();
16-
IntegerCache remainingBuildTime = new IntegerCache();
17-
IntegerCache buildUnit = new IntegerCache();
18-
UnitTypeCache type = new UnitTypeCache();
19-
BooleanCache isMorphing = new BooleanCache();
20-
BooleanCache isCompleted = new BooleanCache();
21-
IntegerCache remainingResearchTime = new IntegerCache();
22-
TechTypeCache tech = new TechTypeCache();
23-
BooleanCache isTraining = new BooleanCache();
24-
IntegerCache remainingTrainTime = new IntegerCache();
25-
UpgradeTypeCache upgrade = new UpgradeTypeCache();
26-
IntegerCache remainingUpgradeTime = new IntegerCache();
27-
BooleanCache isMoving = new BooleanCache();
28-
BooleanCache isGathering = new BooleanCache();
29-
IntegerCache rallyPositionX = new IntegerCache();
30-
IntegerCache rallyPositionY = new IntegerCache();
31-
IntegerCache rallyUnit = new IntegerCache();
32-
IntegerCache stimTimer = new IntegerCache();
33-
IntegerCache orderTarget = new IntegerCache();
6+
final OrderCache order = new OrderCache();
7+
final IntegerCache targetPositionX = new IntegerCache();
8+
final IntegerCache targetPositionY = new IntegerCache();
9+
final IntegerCache orderTargetPositionX = new IntegerCache();
10+
final IntegerCache orderTargetPositionY = new IntegerCache();
11+
final IntegerCache target = new IntegerCache();
12+
final BooleanCache isConstructing = new BooleanCache();
13+
final BooleanCache isIdle = new BooleanCache();
14+
final UnitTypeCache buildType = new UnitTypeCache();
15+
final OrderCache secondaryOrder = new OrderCache();
16+
final IntegerCache remainingBuildTime = new IntegerCache();
17+
final IntegerCache buildUnit = new IntegerCache();
18+
final UnitTypeCache type = new UnitTypeCache();
19+
final BooleanCache isMorphing = new BooleanCache();
20+
final BooleanCache isCompleted = new BooleanCache();
21+
final IntegerCache remainingResearchTime = new IntegerCache();
22+
final TechTypeCache tech = new TechTypeCache();
23+
final BooleanCache isTraining = new BooleanCache();
24+
final IntegerCache remainingTrainTime = new IntegerCache();
25+
final UpgradeTypeCache upgrade = new UpgradeTypeCache();
26+
final IntegerCache remainingUpgradeTime = new IntegerCache();
27+
final BooleanCache isMoving = new BooleanCache();
28+
final BooleanCache isGathering = new BooleanCache();
29+
final IntegerCache rallyPositionX = new IntegerCache();
30+
final IntegerCache rallyPositionY = new IntegerCache();
31+
final IntegerCache rallyUnit = new IntegerCache();
32+
final IntegerCache stimTimer = new IntegerCache();
33+
final IntegerCache orderTarget = new IntegerCache();
3434

35-
UnitTypeCache[] trainingQueue = new UnitTypeCache[5];
35+
final UnitTypeCache[] trainingQueue = new UnitTypeCache[5];
3636

37-
IntegerCache hitPoints = new IntegerCache();
38-
IntegerCache trainingQueueCount = new IntegerCache();
39-
IntegerCache energy = new IntegerCache();
37+
final IntegerCache hitPoints = new IntegerCache();
38+
final IntegerCache trainingQueueCount = new IntegerCache();
39+
final IntegerCache energy = new IntegerCache();
4040

4141

4242
UnitSelf() {

src/main/java/bwem/BWEM.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* By default BWEM throws when an invalid state is encountered.
2424
* But if you know what you are doing, you can skip these throws by setting
2525
* {@link #setFailOnError} to `false`.
26-
* These errors will then be outputted to {@link System.err}, but this can also be changed
26+
* These errors will then be outputted to `System.err`, but this can also be changed
2727
* with {@link #setFailOutputStream} (if you set it to `null` the errors will be completely ignored).
2828
*/
2929
public final class BWEM {

0 commit comments

Comments
 (0)