Skip to content

Commit

Permalink
checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
tvd12 committed May 6, 2022
1 parent e868bd5 commit db8f610
Show file tree
Hide file tree
Showing 58 changed files with 213 additions and 214 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

<parent>
<groupId>com.tvd12</groupId>
<artifactId>ezyfox-server</artifactId>
<version>1.0.3</version>
<artifactId>ezyfox</artifactId>
<version>1.0.4</version>
</parent>

<artifactId>game-box</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>

<name>game-box</name>
<url>https://youngmonkeys.org/</url>

<properties>
<ezy.server.version>1.2.2</ezy.server.version>
<ezy.server.version>1.2.3</ezy.server.version>
</properties>

<dependencies>
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/tvd12/gamebox/constant/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ public final class Commands {

public static final String SYNC_POSITION = "s";

private Commands() {
}
private Commands() {}
}
4 changes: 1 addition & 3 deletions src/main/java/com/tvd12/gamebox/constant/IPlayerRole.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

import com.tvd12.ezyfox.constant.EzyConstant;

@SuppressWarnings("AbbreviationAsWordInName")
public interface IPlayerRole extends EzyConstant {
}
public interface IPlayerRole extends EzyConstant {}
4 changes: 1 addition & 3 deletions src/main/java/com/tvd12/gamebox/constant/IPlayerStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

import com.tvd12.ezyfox.constant.EzyConstant;

@SuppressWarnings("AbbreviationAsWordInName")
public interface IPlayerStatus extends EzyConstant {
}
public interface IPlayerStatus extends EzyConstant {}
4 changes: 1 addition & 3 deletions src/main/java/com/tvd12/gamebox/constant/IRoomStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

import com.tvd12.ezyfox.constant.EzyConstant;

@SuppressWarnings("AbbreviationAsWordInName")
public interface IRoomStatus extends EzyConstant {
}
public interface IRoomStatus extends EzyConstant {}
9 changes: 5 additions & 4 deletions src/main/java/com/tvd12/gamebox/constant/PlayerRole.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ public enum PlayerRole implements IPlayerRole {
PLAYER(3),
NPC(4);

@Getter
private final int id;

private static final Map<Integer, PlayerRole> ROLE_BY_ID =
EzyEnums.enumMapInt(PlayerRole.class);
@Getter
private int id;

private PlayerRole(int id) {
PlayerRole(int id) {
this.id = id;
}

public static PlayerRole valueOf(int id) {
return ROLE_BY_ID.getOrDefault(Integer.valueOf(id), NULL);
return ROLE_BY_ID.getOrDefault(id, NULL);
}

@Override
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/tvd12/gamebox/constant/PlayerStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ public enum PlayerStatus implements IPlayerStatus {
PLAYING(2),
SPEAKING(3);

@Getter
private final int id;

private static final Map<Integer, PlayerStatus> STATUS_BY_ID =
EzyEnums.enumMapInt(PlayerStatus.class);
@Getter
private int id;

private PlayerStatus(int id) {
PlayerStatus(int id) {
this.id = id;
}

public static PlayerStatus valueOf(int id) {
return STATUS_BY_ID.getOrDefault(Integer.valueOf(id), NULL);
return STATUS_BY_ID.getOrDefault(id, NULL);
}

@Override
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/tvd12/gamebox/constant/RoomStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ public enum RoomStatus implements IRoomStatus {
FINISHING(4),
FINISHED(5);

@Getter
private final int id;

private static final Map<Integer, RoomStatus> STATUS_BY_ID =
EzyEnums.enumMapInt(RoomStatus.class);
@Getter
private int id;

private RoomStatus(int id) {
RoomStatus(int id) {
this.id = id;
}

public static RoomStatus valueOf(int id) {
return STATUS_BY_ID.get(Integer.valueOf(id));
return STATUS_BY_ID.get(id);
}

@Override
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/tvd12/gamebox/entity/LocatedPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,5 @@ protected Player newProduct() {
public LocatedPlayer build() {
return (LocatedPlayer) super.build();
}

}

}
1 change: 0 additions & 1 deletion src/main/java/com/tvd12/gamebox/entity/LocatedRoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,4 @@ protected LocatedRoom newProduct() {
return new LocatedRoom(this);
}
}

}
15 changes: 9 additions & 6 deletions src/main/java/com/tvd12/gamebox/entity/MMOPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@
import java.util.concurrent.atomic.AtomicBoolean;

@Getter
@SuppressWarnings("AbbreviationAsWordInName")
public class MMOPlayer extends Player {

@Getter(AccessLevel.NONE)
protected final Map<String, MMOPlayer> nearbyPlayers = new ConcurrentHashMap<>();
protected Vec3 position = new Vec3();
protected Vec3 rotation = new Vec3();
@Getter(AccessLevel.NONE)
protected AtomicBoolean stateChanged = new AtomicBoolean(false);
@Setter
protected int clientTimeTick;

@Getter(AccessLevel.NONE)
protected final AtomicBoolean stateChanged
= new AtomicBoolean(false);

@Getter(AccessLevel.NONE)
protected final Map<String, MMOPlayer> nearbyPlayers
= new ConcurrentHashMap<>();

public MMOPlayer(String name) {
super(name);
}
Expand Down Expand Up @@ -84,7 +87,7 @@ public void getNearbyPlayerNames(List<String> buffer) {
}

public List<String> getNearbyPlayerNames() {
return new ArrayList<String>(nearbyPlayers.keySet());
return new ArrayList<>(nearbyPlayers.keySet());
}

public static class Builder extends Player.Builder<Builder> {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/tvd12/gamebox/entity/MMORoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("AbbreviationAsWordInName")
public class MMORoom extends NormalRoom {

@Getter
@Setter
protected MMOPlayer master;
@Getter
protected final double distanceOfInterest;
protected final List<MMOPlayer> playerBuffer;
protected final List<MMORoomUpdatedHandler> roomUpdatedHandlers;
@Getter
@Setter
protected MMOPlayer master;

public MMORoom(Builder builder) {
super(builder);
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/tvd12/gamebox/entity/MMORoomGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

@SuppressWarnings("AbbreviationAsWordInName")
class MMORoomGroup extends EzyLoggable {

private static final AtomicInteger COUNTER = new AtomicInteger();
private volatile boolean active;
private final long timeTickMillis;
private final RoomManager<MMORoom> roomManager;
private volatile boolean active;

private static final AtomicInteger COUNTER
= new AtomicInteger();

protected MMORoomGroup(Builder builder) {
this.timeTickMillis = builder.timeTickMillis;
Expand Down Expand Up @@ -43,6 +44,7 @@ private void loop() {
long end = System.currentTimeMillis();
long timeElapsed = end - start;
if (timeElapsed < timeTickMillis) {
//noinspection BusyWait
Thread.sleep(timeTickMillis - timeElapsed);
}
} catch (Exception e) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/tvd12/gamebox/entity/MMOVirtualWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import java.util.Arrays;

@SuppressWarnings("AbbreviationAsWordInName")
public class MMOVirtualWorld extends EzyLoggable {

private final MMORoomGroup[] roomGroups;
Expand Down Expand Up @@ -89,6 +88,5 @@ public Builder timeTickMillis(int timeTickMillis) {
public MMOVirtualWorld build() {
return new MMOVirtualWorld(this);
}

}
}
5 changes: 1 addition & 4 deletions src/main/java/com/tvd12/gamebox/entity/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,10 @@ public Player build() {
return newProduct();
}

protected void preBuild() {
}
protected void preBuild() {}

protected Player newProduct() {
return new Player(this);
}

}

}
16 changes: 7 additions & 9 deletions src/main/java/com/tvd12/gamebox/entity/Room.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
@Getter
public class Room {

protected static final String NAME_PREFIX = "Room#";
protected final long id;
protected final String name;
@Setter
protected String password;
@Setter
protected IRoomStatus status = RoomStatus.WAITING;

protected static final String NAME_PREFIX = "Room#";

protected Room(Builder<?> builder) {
this.id = builder.id;
this.name = builder.name;
Expand Down Expand Up @@ -46,12 +47,10 @@ public int hashCode() {

@Override
public String toString() {
return new StringBuilder()
.append("(")
.append("name = ").append(name)
.append(", id = ").append(id)
.append(")")
.toString();
return "(" +
"name = " + name +
", id = " + id +
")";
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -83,8 +82,7 @@ public Room build() {
return newProduct();
}

protected void preBuild() {
}
protected void preBuild() {}

protected Room newProduct() {
return new Room(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ public class LocationNotAvailableException extends IllegalArgumentException {
public LocationNotAvailableException(String msg) {
super(msg);
}

}
33 changes: 20 additions & 13 deletions src/main/java/com/tvd12/gamebox/exception/MaxPlayerException.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,27 @@ public MaxPlayerException(String msg) {
super(msg);
}

public MaxPlayerException(String player, int currentPlayerCount, int maxPlayerCount) {
this(new StringBuilder()
.append("can not add new player: ").append(player)
.append(", current player count is: ").append(currentPlayerCount)
.append(" when max player count is: ").append(maxPlayerCount)
.toString());
public MaxPlayerException(
String player,
int currentPlayerCount,
int maxPlayerCount
) {
this(
"can not add new player: " + player +
", current player count is: " + currentPlayerCount +
" when max player count is: " + maxPlayerCount
);
}

public MaxPlayerException(int numberOfPlayer, int currentPlayerCount, int maxPlayerCount) {
this(new StringBuilder()
.append("can not add ").append(numberOfPlayer).append(" new players")
.append(", current player count is: ").append(currentPlayerCount)
.append(" when max player count is: ").append(maxPlayerCount)
.toString());
public MaxPlayerException(
int numberOfPlayer,
int currentPlayerCount,
int maxPlayerCount
) {
this(
"can not add " + numberOfPlayer + " new players" +
", current player count is: " + currentPlayerCount +
" when max player count is: " + maxPlayerCount
);
}

}
33 changes: 20 additions & 13 deletions src/main/java/com/tvd12/gamebox/exception/MaxRoomException.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,27 @@ public MaxRoomException(String msg) {
super(msg);
}

public MaxRoomException(String room, int currentRoomCount, int maxRoomCount) {
this(new StringBuilder()
.append("can not add new room: ").append(room)
.append(", current room count is: ").append(currentRoomCount)
.append(" when max room count is: ").append(maxRoomCount)
.toString());
public MaxRoomException(
String room,
int currentRoomCount,
int maxRoomCount
) {
this(
"can not add new room: " + room +
", current room count is: " + currentRoomCount +
" when max room count is: " + maxRoomCount
);
}

public MaxRoomException(int numberOfRoom, int currentRoomCount, int maxRoomCount) {
this(new StringBuilder()
.append("can not add ").append(numberOfRoom).append(" new rooms")
.append(", current room count is: ").append(currentRoomCount)
.append(" when max room count is: ").append(maxRoomCount)
.toString());
public MaxRoomException(
int numberOfRoom,
int currentRoomCount,
int maxRoomCount
) {
this(
"can not add " + numberOfRoom + " new rooms" +
", current room count is: " + currentRoomCount +
" when max room count is: " + maxRoomCount
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ public class NoSlotException extends RuntimeException {
public NoSlotException(String msg) {
super(msg);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ public class PlayerExistsException extends IllegalArgumentException {
public PlayerExistsException(String username) {
super("player: " + username + " has added");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ public class PlayerNotExistsException extends IllegalArgumentException {
public PlayerNotExistsException(String message) {
super(message);
}

}
Loading

0 comments on commit db8f610

Please sign in to comment.