use of games.strategy.engine.lobby.server.IModeratorController in project triplea by triplea-game.
the class LobbyMenu method addBanMacAddressMenu.
private void addBanMacAddressMenu(final JMenu parentMenu) {
final JMenuItem item = new JMenuItem("Ban Hashed Mac Address");
item.addActionListener(e -> {
final String mac = JOptionPane.showInputDialog(null, "Enter the hashed Mac Address that you want to ban from the lobby.\r\n\r\n" + "Hashed Mac Addresses should be entered in this format: $1$MH$345ntXD4G3AKpAeHZdaGe3", "");
if (mac == null || mac.length() < 1) {
return;
}
if (!MacFinder.isValidHashedMacAddress(mac)) {
JOptionPane.showMessageDialog(lobbyFrame, "The hashed Mac Address you entered is invalid.", "Invalid Hashed Mac", JOptionPane.ERROR_MESSAGE);
return;
}
TimespanDialog.prompt(lobbyFrame, "Select Timespan", "Please consult other admins before banning longer than 1 day.", date -> {
final IModeratorController controller = (IModeratorController) lobbyFrame.getLobbyClient().getMessengers().getRemoteMessenger().getRemote(ModeratorController.getModeratorControllerName());
controller.banMac(newDummyNode("__unknown__"), mac, date);
});
});
item.setEnabled(true);
parentMenu.add(item);
}
use of games.strategy.engine.lobby.server.IModeratorController in project triplea by triplea-game.
the class LobbyFrame method createAdminActions.
private List<Action> createAdminActions(final INode clickedOn) {
if (!client.isAdmin()) {
return Collections.emptyList();
}
if (clickedOn.equals(client.getMessenger().getLocalNode())) {
return Collections.emptyList();
}
final IModeratorController controller = (IModeratorController) client.getRemoteMessenger().getRemote(ModeratorController.getModeratorControllerName());
final List<Action> actions = new ArrayList<>();
actions.add(SwingAction.of("Boot " + clickedOn.getName(), e -> {
if (!confirm("Boot " + clickedOn.getName())) {
return;
}
controller.boot(clickedOn);
}));
actions.add(SwingAction.of("Ban Player", e -> {
final int resultBanType = JOptionPane.showOptionDialog(LobbyFrame.this, "Select the type of ban:", "Select Ban Type", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, banOrMuteOptions.toArray(), banOrMuteOptions.get(banOrMuteOptions.size() - 1));
if (resultBanType < 0) {
return;
}
final String selectedBanType = banOrMuteOptions.get(resultBanType);
if (selectedBanType.equals("Cancel")) {
return;
}
TimespanDialog.prompt(this, "Select Timespan", "Please consult other admins before banning longer than 1 day. \n" + "And please remember to report this ban.", date -> {
if (selectedBanType.toLowerCase().contains("name")) {
controller.banUsername(clickedOn, date);
}
if (selectedBanType.toLowerCase().contains("mac")) {
controller.banMac(clickedOn, date);
}
// Should we keep this auto?
controller.boot(clickedOn);
});
}));
actions.add(SwingAction.of("Mute Player", e -> {
final int resultMuteType = JOptionPane.showOptionDialog(LobbyFrame.this, "<html>Select the type of mute: <br>Please consult other admins before muting longer than 1 day.</html>", "Select Mute Type", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, banOrMuteOptions.toArray(), banOrMuteOptions.get(banOrMuteOptions.size() - 1));
if (resultMuteType < 0) {
return;
}
final String selectedMuteType = banOrMuteOptions.get(resultMuteType);
if (selectedMuteType.equals("Cancel")) {
return;
}
TimespanDialog.prompt(this, "Select Timespan", "Please consult other admins before muting longer than 1 day. \n" + "And please remember to report this mute.", date -> {
if (selectedMuteType.toLowerCase().contains("name")) {
controller.muteUsername(clickedOn, date);
}
if (selectedMuteType.toLowerCase().contains("mac")) {
controller.muteMac(clickedOn, date);
}
});
}));
actions.add(SwingAction.of("Quick Mute", e -> {
final JLabel label = new JLabel("How many minutes should this player be muted?");
final JSpinner spinner = new JSpinner(new SpinnerNumberModel(10, 0, 60 * 24 * 2, 1));
final JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
panel.add(label);
panel.add(spinner);
if (JOptionPane.showConfirmDialog(LobbyFrame.this, panel, "Mute Player", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
final Object value = spinner.getValue();
if (value == null) {
return;
}
final long resultMuteLengthInMinutes = Long.parseLong(value.toString());
if (resultMuteLengthInMinutes < 0) {
return;
}
final Instant expire = Instant.now().plus(Duration.ofMinutes(resultMuteLengthInMinutes));
controller.muteUsername(clickedOn, Date.from(expire));
controller.muteMac(clickedOn, Date.from(expire));
}
}));
actions.add(SwingAction.of("Show player information", e -> {
final String text = controller.getInformationOn(clickedOn);
final JTextPane textPane = new JTextPane();
textPane.setEditable(false);
textPane.setText(text);
JOptionPane.showMessageDialog(null, textPane, "Player Info", JOptionPane.INFORMATION_MESSAGE);
}));
return actions;
}
use of games.strategy.engine.lobby.server.IModeratorController in project triplea by triplea-game.
the class LobbyGamePanel method stopGameHeadlessHostBot.
private void stopGameHeadlessHostBot() {
final int selectedIndex = gameTable.getSelectedRow();
if (selectedIndex == -1) {
return;
}
final int result = JOptionPane.showConfirmDialog(null, "Are you sure you want to perform a remote stop game on this host?", "Remote Stopgame Headless Host Bot", JOptionPane.OK_CANCEL_OPTION);
if (result != JOptionPane.OK_OPTION) {
return;
}
final INode lobbyWatcherNode = getLobbyWatcherNodeForTableRow(selectedIndex);
final IModeratorController controller = (IModeratorController) messengers.getRemoteMessenger().getRemote(AbstractModeratorController.getModeratorControllerName());
final JLabel label = new JLabel("Enter Host Remote Access Password, (Leave blank for no password).");
final JPasswordField passwordField = new JPasswordField();
final JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(label, BorderLayout.NORTH);
panel.add(passwordField, BorderLayout.CENTER);
final int selectedOption = JOptionPane.showOptionDialog(getTopLevelAncestor(), panel, "Host Remote Access Password?", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);
if (selectedOption != JOptionPane.OK_OPTION || passwordField.getPassword() == null) {
return;
}
final String password = new String(passwordField.getPassword());
final String salt = controller.getHeadlessHostBotSalt(lobbyWatcherNode);
final String hashedPassword = hashPassword(password, salt);
final String response = controller.stopGameHeadlessHostBot(lobbyWatcherNode, hashedPassword, salt);
JOptionPane.showMessageDialog(null, (response == null ? "Successfully attempted stop of current game on host" : "Failed: " + response));
}
use of games.strategy.engine.lobby.server.IModeratorController in project triplea by triplea-game.
the class LobbyGamePanel method getHostInfo.
private void getHostInfo() {
final int selectedIndex = gameTable.getSelectedRow();
if (selectedIndex == -1) {
return;
}
final INode lobbyWatcherNode = getLobbyWatcherNodeForTableRow(selectedIndex);
final IModeratorController controller = (IModeratorController) messengers.getRemoteMessenger().getRemote(AbstractModeratorController.getModeratorControllerName());
final String text = controller.getInformationOn(lobbyWatcherNode);
final String connections = controller.getHostConnections(lobbyWatcherNode);
final JTextPane textPane = new JTextPane();
textPane.setEditable(false);
textPane.setText(text + "\n\n" + connections);
JOptionPane.showMessageDialog(null, textPane, "Player Info", JOptionPane.INFORMATION_MESSAGE);
}
use of games.strategy.engine.lobby.server.IModeratorController in project triplea by triplea-game.
the class LobbyMenu method addUnbanMacAddressMenu.
private void addUnbanMacAddressMenu(final JMenu parentMenu) {
final JMenuItem item = new JMenuItem("Unban Hashed Mac Address");
item.addActionListener(e -> {
final String mac = JOptionPane.showInputDialog(null, "Enter the hashed Mac Address that you want to unban from the lobby.\n\n" + "Hashed Mac Addresses should be entered in this format: $1$MH$345ntXD4G3AKpAeHZdaGe3", "");
if (mac == null || mac.length() < 1) {
return;
}
if (!MacFinder.isValidHashedMacAddress(mac)) {
JOptionPane.showMessageDialog(lobbyFrame, "The hashed Mac Address you entered is invalid.", "Invalid Hashed Mac", JOptionPane.ERROR_MESSAGE);
return;
}
final IModeratorController controller = (IModeratorController) lobbyFrame.getLobbyClient().getMessengers().getRemoteMessenger().getRemote(ModeratorController.getModeratorControllerName());
controller.banMac(newDummyNode("__unknown__"), mac, Date.from(Instant.EPOCH));
});
item.setEnabled(true);
parentMenu.add(item);
}
Aggregations