Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ServerModel to return 'PlayerName' instead of String #5335

Merged
merged 1 commit into from Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -41,6 +41,7 @@
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.filechooser.FileFilter;
import org.triplea.domain.data.PlayerName;
import org.triplea.game.ApplicationContext;
import org.triplea.java.Interruptibles;
import org.triplea.lobby.common.GameDescription;
Expand Down Expand Up @@ -251,7 +252,7 @@ public static void hostGame(
}

/** Spawns a new process to join a network game. */
public static void joinGame(final GameDescription description, final String playerName) {
public static void joinGame(final GameDescription description, final PlayerName playerName) {
final GameDescription.GameStatus status = description.getStatus();
if (GameDescription.GameStatus.LAUNCHING == status) {
return;
Expand All @@ -264,7 +265,7 @@ public static void joinGame(final GameDescription description, final String play
commands.add(prefix + TRIPLEA_PORT + "=" + description.getHostedBy().getPort());
commands.add(
prefix + TRIPLEA_HOST + "=" + description.getHostedBy().getAddress().getHostAddress());
commands.add(prefix + TRIPLEA_NAME + "=" + playerName);
commands.add(prefix + TRIPLEA_NAME + "=" + playerName.getValue());
commands.add(Services.loadAny(ApplicationContext.class).getMainClass().getName());
ProcessRunnerUtil.exec(commands);
}
Expand Down
Expand Up @@ -61,6 +61,7 @@
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import lombok.extern.java.Log;
import org.triplea.domain.data.PlayerName;
import org.triplea.game.chat.ChatModel;
import org.triplea.game.server.HeadlessGameServer;
import org.triplea.game.startup.ServerSetupModel;
Expand Down Expand Up @@ -335,7 +336,7 @@ private Optional<ServerConnectionProps> getServerProps() {
.password(System.getProperty(SERVER_PASSWORD))
.build());
}
final String playerName = ClientSetting.playerName.getValueOrThrow();
final PlayerName playerName = PlayerName.of(ClientSetting.playerName.getValueOrThrow());
final Interruptibles.Result<ServerOptions> optionsResult =
Interruptibles.awaitResult(
() ->
Expand Down
Expand Up @@ -15,6 +15,7 @@
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import org.triplea.domain.data.PlayerName;
import org.triplea.swing.IntTextField;
import org.triplea.swing.SwingAction;

Expand All @@ -31,15 +32,15 @@ public class ServerOptions extends JDialog {

public ServerOptions(
final Component owner,
final String defaultName,
final PlayerName defaultName,
final int defaultPort,
final boolean showComment) {
super(owner == null ? null : JOptionPane.getFrameForComponent(owner), "Server options", true);
this.showComment = showComment;
initComponents();
layoutComponents();
setupActions();
nameField.setText(defaultName);
nameField.setText(defaultName.getValue());
portField.setValue(defaultPort);
setWidgetActivation();
pack();
Expand Down
Expand Up @@ -3,6 +3,7 @@
import games.strategy.net.IMessenger;
import games.strategy.net.Messengers;
import lombok.Getter;
import org.triplea.domain.data.PlayerName;
import org.triplea.http.client.lobby.HttpLobbyClient;
import org.triplea.lobby.common.IModeratorController;

Expand Down Expand Up @@ -35,8 +36,8 @@ public boolean isPasswordChangeRequired() {
}

/** Returns the assigned name of the current player connected to the lobby. */
public String getPlayerName() {
return messengers.getLocalNode().getName();
public PlayerName getPlayerName() {
return messengers.getLocalNode().getPlayerName();
}

public IModeratorController getModeratorController() {
Expand Down