From f8428fea3e5180a5cd13eebe40bff1eb550200e8 Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Sat, 5 Jun 2021 19:44:09 +0200 Subject: [PATCH] refactor: changed public final variables to getters --- .../marvelous/server/lobby/Lobby.java | 28 ++++++++++++++++--- .../lobby/pipelining/DisconnectSegment.java | 10 +++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/Lobby.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/Lobby.java index ca7fc87..189715f 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/Lobby.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/Lobby.java @@ -18,10 +18,10 @@ import uulm.teamname.marvelous.server.lobbymanager.Participant; import java.util.*; public class Lobby { - public final String gameID; - public final LobbyConnection connection; - public final GameInstance game; - public final Pipeline pipeline; + private final String gameID; + private final LobbyConnection connection; + private final GameInstance game; + private final Pipeline pipeline; private Participant activePlayer; private int badRequests; private PauseSegment pauseSegment; @@ -176,4 +176,24 @@ public class Lobby { public PauseSegment getPauseSegment() { return pauseSegment; } + + public String getGameID() { + return gameID; + } + + public LobbyConnection getConnection() { + return connection; + } + + public GameInstance getGame() { + return game; + } + + public Pipeline getPipeline() { + return pipeline; + } + + public Participant getActivePlayer() { + return activePlayer; + } } diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/DisconnectSegment.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/DisconnectSegment.java index 9a507f9..d4c5602 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/DisconnectSegment.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/pipelining/DisconnectSegment.java @@ -23,14 +23,14 @@ public class DisconnectSegment implements Segment { Logger.trace("DisconnectSegment received {} requests.", packet.size()); if (packet.containsRequestOfType(RequestType.DisconnectRequest)) { Logger.debug("Player of Type {} sent DisconnectRequest", packet.getOrigin().type); - parent.connection.removePlayer(packet.getOrigin()); + parent.getConnection().removePlayer(packet.getOrigin()); if (packet.getOrigin().type != ParticipantType.Spectator) { - if(parent.connection.hasPlayer1()){ - parent.generateWin(parent.connection.getPlayer1()); + if(parent.getConnection().hasPlayer1()){ + parent.generateWin(parent.getConnection().getPlayer1()); } - else if(parent.connection.hasPlayer2()) { - parent.generateWin(parent.connection.getPlayer2()); + else if(parent.getConnection().hasPlayer2()) { + parent.generateWin(parent.getConnection().getPlayer2()); } } packet.clear();