Code style

This commit is contained in:
Nanit
2021-10-28 21:08:14 +03:00
parent 1c6da4ee0a
commit d170bcbee2
24 changed files with 120 additions and 120 deletions

View File

@@ -13,24 +13,24 @@ public final class Connections {
private final Map<UUID, ClientConnection> connections;
public Connections(){
public Connections() {
connections = new ConcurrentHashMap<>();
}
public Collection<ClientConnection> getAllConnections(){
public Collection<ClientConnection> getAllConnections() {
return Collections.unmodifiableCollection(connections.values());
}
public int getCount(){
public int getCount() {
return connections.size();
}
public void addConnection(ClientConnection connection){
public void addConnection(ClientConnection connection) {
connections.put(connection.getUuid(), connection);
Logger.info("Player %s connected (%s)", connection.getUsername(), connection.getAddress());
}
public void removeConnection(ClientConnection connection){
public void removeConnection(ClientConnection connection) {
connections.remove(connection.getUuid());
Logger.info("Player %s disconnected", connection.getUsername());
}

View File

@@ -30,11 +30,11 @@ public final class LimboServer {
private EventLoopGroup bossGroup;
private EventLoopGroup workerGroup;
public LimboConfig getConfig(){
public LimboConfig getConfig() {
return config;
}
public Connections getConnections(){
public Connections getConnections() {
return connections;
}
@@ -67,10 +67,10 @@ public final class LimboServer {
Logger.info("Server started on %s", config.getAddress());
}
private void startBootstrap(){
private void startBootstrap() {
Class<? extends ServerChannel> channelClass;
if (config.isUseEpoll() && Epoll.isAvailable()){
if (config.isUseEpoll() && Epoll.isAvailable()) {
bossGroup = new EpollEventLoopGroup(config.getBossGroupSize());
workerGroup = new EpollEventLoopGroup(config.getWorkerGroupSize());
channelClass = EpollServerSocketChannel.class;
@@ -91,20 +91,20 @@ public final class LimboServer {
.bind();
}
private void broadcastKeepAlive(){
private void broadcastKeepAlive() {
connections.getAllConnections().forEach(ClientConnection::sendKeepAlive);
}
private void stop(){
if (keepAliveTask != null){
private void stop() {
if (keepAliveTask != null) {
keepAliveTask.cancel(true);
}
if (bossGroup != null){
if (bossGroup != null) {
bossGroup.shutdownGracefully();
}
if (workerGroup != null){
if (workerGroup != null) {
workerGroup.shutdownGracefully();
}
}

View File

@@ -101,13 +101,13 @@ public class BossBar {
try {
bossBar.setColor(Color.valueOf(node.node("color").getString("").toUpperCase()));
} catch (IllegalArgumentException e){
} catch (IllegalArgumentException e) {
throw new SerializationException("Invalid bossbar color");
}
try {
bossBar.setDivision(Division.valueOf(node.node("division").getString("").toUpperCase()));
} catch (IllegalArgumentException e){
} catch (IllegalArgumentException e) {
throw new SerializationException("Invalid bossbar division");
}

View File

@@ -20,15 +20,15 @@ public class InfoForwarding {
return secretKey;
}
public boolean isNone(){
public boolean isNone() {
return type == Type.NONE;
}
public boolean isLegacy(){
public boolean isLegacy() {
return type == Type.LEGACY;
}
public boolean isModern(){
public boolean isModern() {
return type == Type.MODERN;
}
@@ -46,11 +46,11 @@ public class InfoForwarding {
try {
forwarding.type = Type.valueOf(node.node("type").getString("").toUpperCase());
} catch (IllegalArgumentException e){
} catch (IllegalArgumentException e) {
throw new SerializationException("Undefined info forwarding type");
}
if (forwarding.type == Type.MODERN){
if (forwarding.type == Type.MODERN) {
forwarding.secretKey = node.node("secret").getString("").getBytes(StandardCharsets.UTF_8);
}