getPlayerNames() {
@Override
public boolean containsPlayer(String username) {
- boolean contains = playersByName.containsKey(username);
- return contains;
+ return playersByName.containsKey(username);
}
@Override
@@ -176,19 +174,20 @@ protected void removePlayers0(Collection players) {
@Override
public int getPlayerCount() {
- int count = playersByName.size();
- return count;
+ return playersByName.size();
}
@Override
public boolean available() {
- boolean available = playersByName.size() < maxPlayer;
- return available;
+ return playersByName.size() < maxPlayer;
}
@Override
public Lock getLock(String username) {
- return locks.computeIfAbsent(username, EzyFunctions.NEW_REENTRANT_LOCK_FUNC);
+ return locks.computeIfAbsent(
+ username,
+ EzyFunctions.NEW_REENTRANT_LOCK_FUNC
+ );
}
@Override
@@ -203,8 +202,11 @@ public boolean isEmpty() {
@Override
public int countPlayers(Predicate
tester) {
- int count = (int) playersByName.values().stream().filter(tester).count();
- return count;
+ return (int) playersByName
+ .values()
+ .stream()
+ .filter(tester)
+ .count();
}
@Override
@@ -221,7 +223,7 @@ public void clear() {
protected void unlockAll() {
for (Lock lock : locks.values()) {
- EzyProcessor.processSilently(() -> lock.unlock());
+ EzyProcessor.processSilently(lock::unlock);
}
}
@@ -254,10 +256,8 @@ public final PlayerManager build() {
return newProduct();
}
- protected void preBuild() {
- }
+ protected void preBuild() {}
protected abstract PlayerManager newProduct();
}
-
}
diff --git a/src/main/java/com/tvd12/gamebox/manager/AbstractRoomManager.java b/src/main/java/com/tvd12/gamebox/manager/AbstractRoomManager.java
index de11adf..73d6132 100644
--- a/src/main/java/com/tvd12/gamebox/manager/AbstractRoomManager.java
+++ b/src/main/java/com/tvd12/gamebox/manager/AbstractRoomManager.java
@@ -100,26 +100,22 @@ protected void addRooms0(Iterable rooms, boolean failIfAdded) {
@Override
public boolean containsRoom(long id) {
- boolean contains = roomsById.containsKey(id);
- return contains;
+ return roomsById.containsKey(id);
}
@Override
public boolean containsRoom(String name) {
- boolean contains = roomsByName.containsKey(name);
- return contains;
+ return roomsByName.containsKey(name);
}
@Override
public R getRoom(long id) {
- R room = roomsById.get(id);
- return room;
+ return roomsById.get(id);
}
@Override
public R getRoom(String name) {
- R room = roomsByName.get(name);
- return room;
+ return roomsByName.get(name);
}
@Override
@@ -134,7 +130,7 @@ public R getRoom(Predicate predicate) {
@Override
public List getRoomList() {
- return new ArrayList(roomsByName.values());
+ return new ArrayList<>(roomsByName.values());
}
@Override
@@ -153,8 +149,7 @@ public void getRoomList(List buffer) {
@Override
public int getRoomCount() {
- int count = roomsByName.size();
- return count;
+ return roomsByName.size();
}
@Override
@@ -210,8 +205,7 @@ protected void removeRoom1(R room) {
@Override
public boolean available() {
- boolean answer = roomsById.size() < maxRoom;
- return answer;
+ return roomsById.size() < maxRoom;
}
public void clear() {
diff --git a/src/main/java/com/tvd12/gamebox/manager/DefaultLocatedPlayerManager.java b/src/main/java/com/tvd12/gamebox/manager/DefaultLocatedPlayerManager.java
index 73d318a..722b7cd 100644
--- a/src/main/java/com/tvd12/gamebox/manager/DefaultLocatedPlayerManager.java
+++ b/src/main/java/com/tvd12/gamebox/manager/DefaultLocatedPlayerManager.java
@@ -17,7 +17,8 @@ public class DefaultLocatedPlayerManager
extends EzyLoggable
implements LocatedPlayerManager {
- protected final Map playersByName = newPlayersByNameMap();
+ protected final Map playersByName
+ = newPlayersByNameMap();
protected final NavigableMap playersByLocation
= newPlayersByLocationsMap();
@Getter
@@ -29,8 +30,7 @@ public class DefaultLocatedPlayerManager
@Override
public LocatedPlayer getPlayer(int location) {
- LocatedPlayer player = playersByLocation.get(location);
- return player;
+ return playersByLocation.get(location);
}
@Override
@@ -206,12 +206,10 @@ protected NavigableMap newPlayersByLocationsMap() {
@Override
public String toString() {
- return new StringBuilder()
- .append("(")
- .append("master: ").append(master).append(", ")
- .append("speakinger: ").append(speakinger).append(", ")
- .append("playersByLocation: ").append(playersByLocation)
- .append(")")
- .toString();
+ return "(" +
+ "master: " + master + ", " +
+ "speakinger: " + speakinger + ", " +
+ "playersByLocation: " + playersByLocation +
+ ")";
}
}
diff --git a/src/main/java/com/tvd12/gamebox/manager/DefaultPlayerManager.java b/src/main/java/com/tvd12/gamebox/manager/DefaultPlayerManager.java
index 7813a81..4b3ac36 100644
--- a/src/main/java/com/tvd12/gamebox/manager/DefaultPlayerManager.java
+++ b/src/main/java/com/tvd12/gamebox/manager/DefaultPlayerManager.java
@@ -28,5 +28,4 @@ protected PlayerManager newProduct() {
return new DefaultPlayerManager<>(this);
}
}
-
}
diff --git a/src/main/java/com/tvd12/gamebox/manager/DefaultRoomManager.java b/src/main/java/com/tvd12/gamebox/manager/DefaultRoomManager.java
index 7290259..55b4ce9 100644
--- a/src/main/java/com/tvd12/gamebox/manager/DefaultRoomManager.java
+++ b/src/main/java/com/tvd12/gamebox/manager/DefaultRoomManager.java
@@ -27,7 +27,5 @@ public static class Builder>
public DefaultRoomManager build() {
return new DefaultRoomManager<>(this);
}
-
}
-
}
diff --git a/src/main/java/com/tvd12/gamebox/manager/LocatedPlayerManager.java b/src/main/java/com/tvd12/gamebox/manager/LocatedPlayerManager.java
index 390346c..c7eec25 100644
--- a/src/main/java/com/tvd12/gamebox/manager/LocatedPlayerManager.java
+++ b/src/main/java/com/tvd12/gamebox/manager/LocatedPlayerManager.java
@@ -27,19 +27,19 @@ public interface LocatedPlayerManager {
LocatedPlayer nextOf(LocatedPlayer player, Predicate condition);
default LocatedPlayer nextOf(LocatedPlayer player) {
- return nextOf(player, EzyPredicates.alwayTrue());
+ return nextOf(player, EzyPredicates.alwaysTrue());
}
LocatedPlayer rightOf(LocatedPlayer player, Predicate condition);
default LocatedPlayer rightOf(LocatedPlayer player) {
- return rightOf(player, EzyPredicates.alwayTrue());
+ return rightOf(player, EzyPredicates.alwaysTrue());
}
LocatedPlayer leftOf(LocatedPlayer player, Predicate condition);
default LocatedPlayer leftOf(LocatedPlayer player) {
- return leftOf(player, EzyPredicates.alwayTrue());
+ return leftOf(player, EzyPredicates.alwaysTrue());
}
List getPlayerNames();
diff --git a/src/main/java/com/tvd12/gamebox/manager/PlayerManager.java b/src/main/java/com/tvd12/gamebox/manager/PlayerManager.java
index e4994fb..3a89af4 100644
--- a/src/main/java/com/tvd12/gamebox/manager/PlayerManager.java
+++ b/src/main/java/com/tvd12/gamebox/manager/PlayerManager.java
@@ -204,5 +204,5 @@ default P removePlayer(String username) {
*
* @return empty or not
*/
- public boolean isEmpty();
+ boolean isEmpty();
}
diff --git a/src/main/java/com/tvd12/gamebox/manager/SimplePlayerManager.java b/src/main/java/com/tvd12/gamebox/manager/SimplePlayerManager.java
index 01d930e..aca72e0 100644
--- a/src/main/java/com/tvd12/gamebox/manager/SimplePlayerManager.java
+++ b/src/main/java/com/tvd12/gamebox/manager/SimplePlayerManager.java
@@ -36,5 +36,4 @@ protected PlayerManager newProduct() {
return new SimplePlayerManager<>(this);
}
}
-
}
diff --git a/src/main/java/com/tvd12/gamebox/manager/SimpleRoomManager.java b/src/main/java/com/tvd12/gamebox/manager/SimpleRoomManager.java
index d805711..799a698 100644
--- a/src/main/java/com/tvd12/gamebox/manager/SimpleRoomManager.java
+++ b/src/main/java/com/tvd12/gamebox/manager/SimpleRoomManager.java
@@ -40,7 +40,5 @@ public static class Builder>
public SimpleRoomManager build() {
return new SimpleRoomManager<>(this);
}
-
}
-
}
diff --git a/src/main/java/com/tvd12/gamebox/manager/SynchronizedPlayerManager.java b/src/main/java/com/tvd12/gamebox/manager/SynchronizedPlayerManager.java
index b27ec83..5847834 100644
--- a/src/main/java/com/tvd12/gamebox/manager/SynchronizedPlayerManager.java
+++ b/src/main/java/com/tvd12/gamebox/manager/SynchronizedPlayerManager.java
@@ -201,5 +201,4 @@ protected PlayerManager newProduct() {
return new SynchronizedPlayerManager<>(this);
}
}
-
}
diff --git a/src/main/java/com/tvd12/gamebox/manager/SynchronizedRoomManager.java b/src/main/java/com/tvd12/gamebox/manager/SynchronizedRoomManager.java
index d835b93..d1326c9 100644
--- a/src/main/java/com/tvd12/gamebox/manager/SynchronizedRoomManager.java
+++ b/src/main/java/com/tvd12/gamebox/manager/SynchronizedRoomManager.java
@@ -189,6 +189,5 @@ public static class Builder>
public RoomManager build() {
return new SynchronizedRoomManager<>(this);
}
-
}
}
diff --git a/src/main/java/com/tvd12/gamebox/math/Numbers.java b/src/main/java/com/tvd12/gamebox/math/Numbers.java
index 6a4ea92..9c94382 100644
--- a/src/main/java/com/tvd12/gamebox/math/Numbers.java
+++ b/src/main/java/com/tvd12/gamebox/math/Numbers.java
@@ -32,8 +32,7 @@ public final class Numbers {
*/
private static final int NEGATIVE_ZERO_FLOAT_BITS = Float.floatToRawIntBits(-0.0f);
- private Numbers() {
- }
+ private Numbers() {}
/**
* Returns true if they are equal as defined by
diff --git a/src/main/java/com/tvd12/gamebox/math/Rect.java b/src/main/java/com/tvd12/gamebox/math/Rect.java
index d435d0c..5a6b84f 100644
--- a/src/main/java/com/tvd12/gamebox/math/Rect.java
+++ b/src/main/java/com/tvd12/gamebox/math/Rect.java
@@ -8,8 +8,7 @@ public class Rect {
public float width;
public float height;
- public Rect() {
- }
+ public Rect() {}
public Rect(Rect r) {
this.x = r.x;
@@ -162,15 +161,6 @@ public Rect unionWithRect(Rect rect) {
@Override
public String toString() {
- return new StringBuilder().append("(")
- .append(x)
- .append(", ")
- .append(y)
- .append(" | ")
- .append(width)
- .append(", ")
- .append(height)
- .append(")")
- .toString();
+ return "(" + x + ", " + y + " | " + width + ", " + height + ")";
}
}
diff --git a/src/main/java/com/tvd12/gamebox/math/Vec2.java b/src/main/java/com/tvd12/gamebox/math/Vec2.java
index 4a9328b..d1b642a 100644
--- a/src/main/java/com/tvd12/gamebox/math/Vec2.java
+++ b/src/main/java/com/tvd12/gamebox/math/Vec2.java
@@ -8,13 +8,14 @@
@SuppressWarnings("MemberName")
public class Vec2 {
+ public float x;
+ public float y;
+
public static final Vec2 ZERO = new Vec2();
public static final Vec2 LEFT = new Vec2(-1, 0);
public static final Vec2 UP = new Vec2(0, 1);
public static final Vec2 RIGHT = new Vec2(1, 0);
public static final Vec2 DOWN = new Vec2(0, -1);
- public float x;
- public float y;
public Vec2() {
this(0.0F, 0.0F);
@@ -103,6 +104,7 @@ public float distanceSquare(Vec2 v) {
@Override
public boolean equals(Object obj) {
Vec2 other = (Vec2) obj;
+ //noinspection SuspiciousNameCombination
return Numbers.equals(x, other.x)
&& Numbers.equals(y, other.y);
}
@@ -124,11 +126,6 @@ public EzyArray toArray() {
@Override
public String toString() {
- return new StringBuilder()
- .append("(")
- .append(x).append(", ")
- .append(y)
- .append(")")
- .toString();
+ return "(" + x + ", " + y + ")";
}
}
diff --git a/src/main/java/com/tvd12/gamebox/math/Vec3.java b/src/main/java/com/tvd12/gamebox/math/Vec3.java
index 668ee5a..c0961d7 100644
--- a/src/main/java/com/tvd12/gamebox/math/Vec3.java
+++ b/src/main/java/com/tvd12/gamebox/math/Vec3.java
@@ -7,6 +7,11 @@
@Getter
@SuppressWarnings("MemberName")
public class Vec3 {
+
+ public float x;
+ public float y;
+ public float z;
+
public static final Vec3 ZERO = new Vec3();
public static final Vec3 up = new Vec3(0.0f, 1f, 0.0f);
public static final Vec3 down = new Vec3(0.0f, -1f, 0.0f);
@@ -14,9 +19,6 @@ public class Vec3 {
public static final Vec3 right = new Vec3(1f, 0.0f, 0.0f);
public static final Vec3 forward = new Vec3(0.0f, 0.0f, 1f);
public static final Vec3 backward = new Vec3(0.0f, 0.0f, -1f);
- public float x;
- public float y;
- public float z;
public Vec3() {
this(0.0f, 0.0f, 0.0f);
@@ -105,6 +107,7 @@ public float distanceSquare(Vec3 v) {
@Override
public boolean equals(Object obj) {
Vec3 other = (Vec3) obj;
+ //noinspection SuspiciousNameCombination
return Numbers.equals(x, other.x)
&& Numbers.equals(y, other.y)
&& Numbers.equals(z, other.z);
@@ -128,12 +131,6 @@ public EzyArray toArray() {
@Override
public String toString() {
- return new StringBuilder()
- .append("(")
- .append(x).append(", ")
- .append(y).append(", ")
- .append(z)
- .append(")")
- .toString();
+ return "(" + x + ", " + y + ", " + z + ")";
}
}
diff --git a/src/test/java/com/tvd12/gamebox/entity/MMOIntergrationTest.java b/src/test/java/com/tvd12/gamebox/entity/MMOIntegrationTest.java
similarity index 95%
rename from src/test/java/com/tvd12/gamebox/entity/MMOIntergrationTest.java
rename to src/test/java/com/tvd12/gamebox/entity/MMOIntegrationTest.java
index 85f32f9..2fa6b87 100644
--- a/src/test/java/com/tvd12/gamebox/entity/MMOIntergrationTest.java
+++ b/src/test/java/com/tvd12/gamebox/entity/MMOIntegrationTest.java
@@ -14,7 +14,7 @@
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
-public class MMOIntergrationTest {
+public class MMOIntegrationTest {
private final MMOVirtualWorld world;
private final ExecutorService executorService;
@@ -24,7 +24,7 @@ public class MMOIntergrationTest {
private final AtomicInteger totalPlayers;
private final RoomManager roomManager;
- public MMOIntergrationTest() {
+ public MMOIntegrationTest() {
this.world = MMOVirtualWorld.builder()
.maxRoomCount(1000)
.roomGroupCount(16)
@@ -39,18 +39,19 @@ public MMOIntergrationTest() {
}
public static void main(String[] args) throws Exception {
- new MMOIntergrationTest().test();
+ new MMOIntegrationTest().test();
}
public void test() throws Exception {
long testTime = 5 * 60 * 1000;
long startTime = System.currentTimeMillis();
- long endtime = startTime + testTime;
+ long endTime = startTime + testTime;
while (true) {
long currentTime = System.currentTimeMillis();
- if (currentTime > endtime) {
+ if (currentTime > endTime) {
break;
}
+ //noinspection BusyWait
Thread.sleep(300);
addPlayers();
addPlayerToRooms();
diff --git a/src/test/java/com/tvd12/gamebox/entity/MMORoomTest.java b/src/test/java/com/tvd12/gamebox/entity/MMORoomTest.java
index 2513c9f..683ff04 100644
--- a/src/test/java/com/tvd12/gamebox/entity/MMORoomTest.java
+++ b/src/test/java/com/tvd12/gamebox/entity/MMORoomTest.java
@@ -7,6 +7,7 @@
import org.testng.annotations.Test;
import java.util.Arrays;
+import java.util.Collections;
public class MMORoomTest {
@@ -54,13 +55,29 @@ public void test() {
Asserts.assertEmpty(player1.getNearbyPlayerNames());
Asserts.assertEmpty(player2.getNearbyPlayerNames());
sut.update();
- Asserts.assertEquals(player1.getNearbyPlayerNames(), Arrays.asList(player1.getName()), false);
- Asserts.assertEquals(player2.getNearbyPlayerNames(), Arrays.asList(player2.getName()), false);
+ Asserts.assertEquals(
+ player1.getNearbyPlayerNames(),
+ Collections.singletonList(player1.getName()),
+ false
+ );
+ Asserts.assertEquals(
+ player2.getNearbyPlayerNames(),
+ Collections.singletonList(player2.getName()),
+ false
+ );
player2.setPosition(new Vec3(1, 1, 1));
sut.update();
- Asserts.assertEquals(player1.getNearbyPlayerNames(), Arrays.asList(player1.getName(), player2.getName()), false);
- Asserts.assertEquals(player2.getNearbyPlayerNames(), Arrays.asList(player1.getName(), player2.getName()), false);
+ Asserts.assertEquals(
+ player1.getNearbyPlayerNames(),
+ Arrays.asList(player1.getName(), player2.getName()),
+ false
+ );
+ Asserts.assertEquals(
+ player2.getNearbyPlayerNames(),
+ Arrays.asList(player1.getName(), player2.getName()),
+ false
+ );
}
@Test
@@ -70,7 +87,7 @@ public void buildFailedDueToDistanceOfInterest() {
.playerManager(new SynchronizedPlayerManager<>());
// when
- Throwable e = Asserts.assertThrows(() -> builder.build());
+ Throwable e = Asserts.assertThrows(builder::build);
// then
Asserts.assertEqualsType(e, IllegalArgumentException.class);
diff --git a/src/test/java/com/tvd12/gamebox/entity/PlayerTest.java b/src/test/java/com/tvd12/gamebox/entity/PlayerTest.java
index e2a1189..f2a605e 100644
--- a/src/test/java/com/tvd12/gamebox/entity/PlayerTest.java
+++ b/src/test/java/com/tvd12/gamebox/entity/PlayerTest.java
@@ -24,7 +24,9 @@ public void test() {
Asserts.assertEquals(sut.getRole(), PlayerRole.MASTER);
Asserts.assertEquals(sut.getStatus(), PlayerStatus.PLAYING);
Asserts.assertEquals(sut.getCurrentRoomId(), 1L);
+ //noinspection EqualsWithItself
Asserts.assertTrue(sut.equals(sut));
+ //noinspection ConstantConditions
Asserts.assertFalse(sut.equals(null));
Player me = Player.builder()
diff --git a/src/test/java/com/tvd12/gamebox/entity/RoomTest.java b/src/test/java/com/tvd12/gamebox/entity/RoomTest.java
index 0e269a8..dfdb5f3 100644
--- a/src/test/java/com/tvd12/gamebox/entity/RoomTest.java
+++ b/src/test/java/com/tvd12/gamebox/entity/RoomTest.java
@@ -21,7 +21,9 @@ public void test() {
// then
Asserts.assertEquals(sut.getPassword(), "123456");
Asserts.assertEquals(sut.getStatus(), RoomStatus.FINISHED);
+ //noinspection EqualsWithItself
Asserts.assertTrue(sut.equals(sut));
+ //noinspection ConstantConditions
Asserts.assertFalse(sut.equals(null));
Room me = Room.builder()
diff --git a/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager1Test.java b/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager1Test.java
index 6e061f1..674d5ec 100644
--- a/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager1Test.java
+++ b/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager1Test.java
@@ -40,7 +40,5 @@ public void justOne() {
System.out.println(manager);
Asserts.assertEquals(manager.nextOf(a), null);
-
}
-
}
diff --git a/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager2Test.java b/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager2Test.java
index 1d5f5e7..cc83b22 100644
--- a/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager2Test.java
+++ b/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager2Test.java
@@ -19,7 +19,5 @@ public void test() {
manager.setNewMaster();
System.out.println(manager);
-
}
-
}
diff --git a/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager3Test.java b/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager3Test.java
index 85a68c9..7f3131b 100644
--- a/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager3Test.java
+++ b/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager3Test.java
@@ -33,7 +33,5 @@ public void test() {
System.out.println(manager.nextOf(binh4, p -> p != huongntm2 && p != havm));
System.out.println(manager.nextOf(binh5, p -> p != huongntm2 && p != havm));
System.out.println(manager.nextOf(huongntm3, p -> p != huongntm2 && p != havm));
-
}
-
}
diff --git a/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager4Test.java b/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager4Test.java
index 430b406..74e8b88 100644
--- a/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager4Test.java
+++ b/src/test/java/com/tvd12/gamebox/testing/DefaultLocatedPlayerManager4Test.java
@@ -41,5 +41,4 @@ public void test() {
Asserts.assertEquals(manager.rightOf(huongntm3, p -> p != huongntm2 && p != havm), binh4);
Asserts.assertEquals(manager.rightOf(binh4, p -> p != binh5 && p != havm), huongntm3);
}
-
}
diff --git a/src/test/java/com/tvd12/gamebox/testing/IteratorTest.java b/src/test/java/com/tvd12/gamebox/testing/IteratorTest.java
index 1efee15..302f6f8 100644
--- a/src/test/java/com/tvd12/gamebox/testing/IteratorTest.java
+++ b/src/test/java/com/tvd12/gamebox/testing/IteratorTest.java
@@ -7,5 +7,4 @@ public class IteratorTest {
public static void main(String[] args) {
System.out.println(Lists.newArrayList(1, 2, 3).iterator());
}
-
}
diff --git a/src/test/java/com/tvd12/gamebox/testing/LocatedRoomTest.java b/src/test/java/com/tvd12/gamebox/testing/LocatedRoomTest.java
index cc5a08c..d4efb57 100644
--- a/src/test/java/com/tvd12/gamebox/testing/LocatedRoomTest.java
+++ b/src/test/java/com/tvd12/gamebox/testing/LocatedRoomTest.java
@@ -25,5 +25,4 @@ public void masterTest() {
System.out.println("\n\nnext master is: " + room.getPlayerManager().setNewMaster() + "\n\n");
}
-
}
diff --git a/src/test/java/com/tvd12/gamebox/testing/MMORoomTest.java b/src/test/java/com/tvd12/gamebox/testing/MMORoomTest.java
index 41810ef..a12ec66 100644
--- a/src/test/java/com/tvd12/gamebox/testing/MMORoomTest.java
+++ b/src/test/java/com/tvd12/gamebox/testing/MMORoomTest.java
@@ -120,9 +120,8 @@ public void maxPlayerTest() {
Asserts.assertEquals(MaxPlayerException.class.toString(), e.getClass().toString());
}
- public class A implements MMORoomUpdatedHandler {
+ public static class A implements MMORoomUpdatedHandler {
@Override
- public void onRoomUpdated(MMORoom room, List players) {
- }
+ public void onRoomUpdated(MMORoom room, List players) {}
}
}
diff --git a/src/test/java/com/tvd12/gamebox/testing/SyncPositionRoomUpdatedHandlerTest.java b/src/test/java/com/tvd12/gamebox/testing/SyncPositionRoomUpdatedHandlerTest.java
index cb6d8cc..8e91376 100644
--- a/src/test/java/com/tvd12/gamebox/testing/SyncPositionRoomUpdatedHandlerTest.java
+++ b/src/test/java/com/tvd12/gamebox/testing/SyncPositionRoomUpdatedHandlerTest.java
@@ -85,5 +85,4 @@ public void casePlayerChangeStateTest() {
verify(arrayResponse, times(1)).usernames(nearbyPlayerNameList);
verify(arrayResponse, times(1)).execute();
}
-
}
diff --git a/src/test/java/com/tvd12/gamebox/testing/TestHelper.java b/src/test/java/com/tvd12/gamebox/testing/TestHelper.java
index 2112d53..eccd3b7 100644
--- a/src/test/java/com/tvd12/gamebox/testing/TestHelper.java
+++ b/src/test/java/com/tvd12/gamebox/testing/TestHelper.java
@@ -5,8 +5,7 @@
public class TestHelper {
- private TestHelper() {
- }
+ private TestHelper() {}
public static Vec3 randomVec3() {
return new Vec3(
diff --git a/src/test/java/com/tvd12/gamebox/testing/manager/AbstractRoomManagerTest.java b/src/test/java/com/tvd12/gamebox/testing/manager/AbstractRoomManagerTest.java
index f117423..3e5d5ff 100644
--- a/src/test/java/com/tvd12/gamebox/testing/manager/AbstractRoomManagerTest.java
+++ b/src/test/java/com/tvd12/gamebox/testing/manager/AbstractRoomManagerTest.java
@@ -17,6 +17,5 @@ public void test() {
Asserts.assertEquals(sut.getMaxRoom(), 10000);
}
- private static class InternalRoomManager extends AbstractRoomManager {
- }
+ private static class InternalRoomManager extends AbstractRoomManager {}
}
diff --git a/src/test/java/com/tvd12/gamebox/testing/manager/DefaultRoomManagerTest.java b/src/test/java/com/tvd12/gamebox/testing/manager/DefaultRoomManagerTest.java
index 2adf25a..34e32c2 100644
--- a/src/test/java/com/tvd12/gamebox/testing/manager/DefaultRoomManagerTest.java
+++ b/src/test/java/com/tvd12/gamebox/testing/manager/DefaultRoomManagerTest.java
@@ -6,7 +6,7 @@
import com.tvd12.test.assertion.Asserts;
import org.testng.annotations.Test;
-import java.util.Arrays;
+import java.util.Collections;
public class DefaultRoomManagerTest {
@@ -29,7 +29,7 @@ public void test() {
// when
sut.addRooms(new Room[]{room1});
- sut.addRooms(Arrays.asList(room2));
+ sut.addRooms(Collections.singletonList(room2));
// then
Asserts.assertEquals(sut.getMaxRoom(), 100);
diff --git a/src/test/java/com/tvd12/gamebox/testing/manager/SynchronizedPlayerManagerTest.java b/src/test/java/com/tvd12/gamebox/testing/manager/SynchronizedPlayerManagerTest.java
index da3eaea..219db96 100644
--- a/src/test/java/com/tvd12/gamebox/testing/manager/SynchronizedPlayerManagerTest.java
+++ b/src/test/java/com/tvd12/gamebox/testing/manager/SynchronizedPlayerManagerTest.java
@@ -8,6 +8,7 @@
import org.testng.annotations.Test;
import java.util.Arrays;
+import java.util.Collections;
import java.util.concurrent.locks.Lock;
public class SynchronizedPlayerManagerTest {
@@ -42,9 +43,17 @@ public void test() {
Asserts.assertNull(sut.getPlayer("unknown"));
Asserts.assertEquals(sut.getPlayer("test", () -> null), player1);
Asserts.assertEquals(sut.getFirstPlayer(), player1);
- Asserts.assertEquals(sut.getPlayerList(it -> true), Arrays.asList(player1), false);
+ Asserts.assertEquals(
+ sut.getPlayerList(it -> true),
+ Collections.singletonList(player1),
+ false
+ );
Asserts.assertEmpty(sut.getPlayerList(it -> it.getName().equals("unknown")));
- Asserts.assertEquals(sut.getPlayerNames(), Arrays.asList("test"), false);
+ Asserts.assertEquals(
+ sut.getPlayerNames(),
+ Collections.singletonList("test"),
+ false
+ );
Asserts.assertEquals(sut.removePlayer(player1), player1);
sut.addPlayer(player1, true);
@@ -60,23 +69,29 @@ public void test() {
Asserts.assertNotNull(sut.getLock("test"));
sut.removeLock("test");
- sut.removePlayers(Arrays.asList(player1));
+ sut.removePlayers(Collections.singletonList(player1));
Asserts.assertEquals(sut.getPlayerCount(), 1);
sut.clear();
Asserts.assertNull(sut.getFirstPlayer());
Asserts.assertEquals(sut.getPlayer("unknown", () -> playerx), playerx);
sut.clear();
- sut.addPlayers(Arrays.asList(player1), false);
+ sut.addPlayers(Collections.singletonList(player1), false);
Asserts.assertEquals(sut.getPlayerCount(), 1);
- sut.addPlayers(Arrays.asList(player1), false);
- Throwable e3 = Asserts.assertThrows(() -> sut.addPlayers(Arrays.asList(player1), true));
+ sut.addPlayers(Collections.singletonList(player1), false);
+ Throwable e3 = Asserts.assertThrows(
+ () -> sut.addPlayers(Collections.singletonList(player1), true)
+ );
Asserts.assertEqualsType(e3, PlayerExistsException.class);
Throwable e4 = Asserts.assertThrows(() -> sut.addPlayers(Arrays.asList(player2, playerx), false));
Asserts.assertEqualsType(e4, MaxPlayerException.class);
Asserts.assertEquals(sut.countPlayers(it -> it.getName().equals("test")), 1);
- Asserts.assertEquals(sut.filterPlayers(it -> it.getName().equals("test")), Arrays.asList(player1), false);
+ Asserts.assertEquals(
+ sut.filterPlayers(it -> it.getName().equals("test")),
+ Collections.singletonList(player1),
+ false
+ );
Lock lock = sut.getLock("test");
lock.lock();
diff --git a/src/test/java/com/tvd12/gamebox/testing/manager/SynchronizedRoomManagerTest.java b/src/test/java/com/tvd12/gamebox/testing/manager/SynchronizedRoomManagerTest.java
index 5877ae7..70df52b 100644
--- a/src/test/java/com/tvd12/gamebox/testing/manager/SynchronizedRoomManagerTest.java
+++ b/src/test/java/com/tvd12/gamebox/testing/manager/SynchronizedRoomManagerTest.java
@@ -8,6 +8,7 @@
import org.testng.annotations.Test;
import java.util.Arrays;
+import java.util.Collections;
public class SynchronizedRoomManagerTest {
@@ -44,11 +45,15 @@ public void test() {
Asserts.assertEqualsType(e2, MaxRoomException.class);
sut.clear();
- sut.addRooms(Arrays.asList(room1), false);
- Throwable e3 = Asserts.assertThrows(() -> sut.addRooms(Arrays.asList(room1), true));
+ sut.addRooms(Collections.singletonList(room1), false);
+ Throwable e3 = Asserts.assertThrows(
+ () -> sut.addRooms(Collections.singletonList(room1), true)
+ );
Asserts.assertEqualsType(e3, RoomExistsException.class);
- sut.addRooms(Arrays.asList(room2), true);
- Throwable e4 = Asserts.assertThrows(() -> sut.addRooms(Arrays.asList(roomx), true));
+ sut.addRooms(Collections.singletonList(room2), true);
+ Throwable e4 = Asserts.assertThrows(
+ () -> sut.addRooms(Collections.singletonList(roomx), true)
+ );
Asserts.assertEqualsType(e4, MaxRoomException.class);
Asserts.assertEquals(sut.getRoom("room1"), room1);
@@ -73,7 +78,11 @@ public void test() {
Asserts.assertEquals(sut.getRoom(it -> it.getName().equals("room1")), room1);
Asserts.assertNull(sut.getRoom(it -> it.getName().equals("unknown")));
- Asserts.assertEquals(sut.getRoomList(it -> it.getName().equals("room1")), Arrays.asList(room1), false);
+ Asserts.assertEquals(
+ sut.getRoomList(it -> it.getName().equals("room1")),
+ Collections.singletonList(room1),
+ false
+ );
sut.clear();
sut.addRooms(new LocatedRoom[]{room1}, false);
diff --git a/src/test/java/com/tvd12/gamebox/testing/math/NumbersTest.java b/src/test/java/com/tvd12/gamebox/testing/math/NumbersTest.java
index d366134..34fe3fd 100644
--- a/src/test/java/com/tvd12/gamebox/testing/math/NumbersTest.java
+++ b/src/test/java/com/tvd12/gamebox/testing/math/NumbersTest.java
@@ -28,7 +28,9 @@ public void test() {
Asserts.assertTrue(Numbers.equals(-2147483648.0F, Float.MIN_VALUE, 1325400065));
+ //noinspection divzero
Asserts.assertFalse(Numbers.equals(0.0F / 0.0F, 1.0F, 1));
+ //noinspection divzero
Asserts.assertFalse(Numbers.equals(1.0F, 0.0F / 0.0F, 1));
}
}