congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
MegaMek
Code IndexAdd Tabnine to your IDE (free)

How to use
MegaMek
in
megamek

Best Java code snippets using megamek.MegaMek (Showing top 10 results out of 315)

origin: MegaMek/megamek

private static void configureLogging(@Nullable final String logFileName) {
  final String qualifiedLogFilename =
      PreferenceManager.getClientPreferences().getLogDirectory() +
      File.separator +
      logFileName;
  resetLogFile(qualifiedLogFilename);
  configureLegacyLogging(logFileName);
  configureLog4j(logFileName);
}
origin: MegaMek/megamek

/**
 * Starts a dedicated server with the arguments in args. See
 * {@link megamek.server.DedicatedServer#start(String[])} for more
 * information.
 *
 * @param args
 *            the arguments to the dedicated server.
 */
private static void startDedicatedServer(String[] args) {
  StringBuffer message = new StringBuffer("Starting Dedicated Server. "); //$NON-NLS-1$
  MegaMek.dumpArgs(message, args);
  MegaMek.displayMessage(message.toString(),
              "startDedicatedServer(String[])");
  DedicatedServer.start(args);
}
origin: MegaMek/megamek

/**
 * Return the Interface to the GUI specified by the name in guiName.
 *
 * @param guiName
 *            the name of the GUI, will be passed on to
 *            {@link #getGUIClassName(String)}.
 * @return An that can start a GUI such as
 *         {@link IMegaMekGUI}.
 */
@SuppressWarnings({ "rawtypes" })
private static IMegaMekGUI getGui(String guiName) {
  assert (guiName != null) : "guiName must be non-null"; //$NON-NLS-1$
  String guiClassName = MegaMek.getGUIClassName(guiName);
  if (guiClassName != null) {
    try {
      Class guiClass = Class.forName(guiClassName);
      if (IMegaMekGUI.class.isAssignableFrom(guiClass)) {
        IMegaMekGUI result = (IMegaMekGUI) guiClass.newInstance();
        return result;
      }
    } catch (Exception e) {
      MegaMek.displayMessage(GUI_CLASS_NOT_FOUND_MESSAGE
                  + guiClassName, "getGui(String)");
    }
  }
  return null;
}
origin: MegaMek/megamek

configureLogging(logFileName);
MegaMek.showInfo();
  MegaMek.startDedicatedServer(restArgs);
} else {
        .getGUIName();
  MegaMek.startGUI(interfaceName, restArgs);
    .append(e.getMessage()).append('\n');
message.append(ARGUMENTS_DESCRIPTION_MESSAGE);
MegaMek.displayMessageAndExit(message.toString(),
               "main(String[])");
origin: MegaMek/megamek

  return;
IMegaMekGUI mainGui = MegaMek.getGui(guiName);
if (mainGui == null) {
  MegaMek.displayMessageAndExit(UNKNOWN_GUI_MESSAGE + guiName,
                 METHOD_NAME);
} else {
  StringBuffer message = new StringBuffer("Starting GUI "); //$NON-NLS-1$
  message.append(guiName).append(". "); //$NON-NLS-1$
  MegaMek.dumpArgs(message, args);
  MegaMek.displayMessage(message.toString(),
              METHOD_NAME);
  mainGui.start(args);
origin: MegaMek/mekhq

/**
 * This function redirects the standard error and output streams to the
 * given File name.
 *
 */
private static void redirectOutput() {
  try {
    System.out.println("Redirecting output to mekhqlog.txt"); //$NON-NLS-1$
    File logDir = new File("logs");
    if (!logDir.exists()) {
      logDir.mkdir();
    }
    final String logFilename = "logs" + File.separator + "mekhqlog.txt";
    MegaMek.resetLogFile(logFilename);
    PrintStream ps = new PrintStream(
        new BufferedOutputStream(
            new FileOutputStream(logFilename,
                       true),
            64));
    System.setOut(ps);
    System.setErr(ps);
  } catch (Exception e) {
    System.err.println("Unable to redirect output to mekhqlog.txt"); //$NON-NLS-1$
    e.printStackTrace();
  }
}
origin: MegaMek/megamek

private static String getGUIClassName(String guiName) {
  assert (guiName != null) : "guiName must be non-null"; //$NON-NLS-1$
  Properties p = new Properties();
  String key = "gui." + guiName; //$NON-NLS-1$
  final String PROPERTIES_FILE = "megamek/MegaMek.properties";
  try(InputStream is = MegaMek.class.getClassLoader().getResourceAsStream(PROPERTIES_FILE)) {
    if (is != null) {
      p.load(is);
      return p.getProperty(key);
    }
  } catch (IOException e) {
    MegaMek.displayMessage("Property file load failed.",
                "getGUIClassName(String)"); //$NON-NLS-1$
  }
  return null;
}
origin: MegaMek/megamek

Object[] versionData = new Object[2];
versionData[0] = MegaMek.VERSION;
versionData[1] = MegaMek.getMegaMekSHA256();
send(new Packet(Packet.COMMAND_CLIENT_VERSIONS, versionData));
break;
origin: MegaMek/megamek

/**
 * Prints some information about MegaMek. Used in logfiles to figure out the
 * JVM and version of MegaMek.
 */
private static void showInfo() {
  final String METHOD_NAME = "showInfo";
  // echo some useful stuff
  String msg = "Starting MegaMek v" + VERSION + " ..."; //$NON-NLS-1$ //$NON-NLS-2$
  msg += "\n\tCompiled on " + new Date(TIMESTAMP).toString(); //$NON-NLS-1$
  msg += "\n\tToday is " + new Date().toString(); //$NON-NLS-1$
  msg += "\n\tJava vendor " + System.getProperty("java.vendor"); //$NON-NLS-1$ //$NON-NLS-2$
  msg += "\n\tJava version " + System.getProperty("java.version"); //$NON-NLS-1$ //$NON-NLS-2$
  msg += "\n\tPlatform " //$NON-NLS-1$
      + System.getProperty("os.name") //$NON-NLS-1$
      + " " //$NON-NLS-1$
      + System.getProperty("os.version") //$NON-NLS-1$
      + " (" //$NON-NLS-1$
      + System.getProperty("os.arch") //$NON-NLS-1$
      + ")"; //$NON-NLS-1$
  long maxMemory = Runtime.getRuntime().maxMemory() / 1024;
  msg += "\n\tTotal memory available to MegaMek: " + MegaMek.commafy.format(maxMemory) + " kB"; //$NON-NLS-1$ //$NON-NLS-2$
  displayMessage(msg, METHOD_NAME);
}
origin: MegaMek/megamek

/**
 * Prints the message to stdout and then exits with errorcode 1.
 *
 * @param message
 *            the message to be displayed.
 */
private static void displayMessageAndExit(String message,
                     String methodName) {
  MegaMek.displayMessage(message, methodName);
  TimerSingleton.getInstance().killTimer();
  System.exit(1);
}
megamekMegaMek

Most used methods

  • resetLogFile
    This needs to be done as we are currently using two different loggers. Both loggers must be set to a
  • configureLegacyLogging
  • configureLog4j
  • configureLogging
  • displayMessage
    Prints the message and flushes the output stream.
  • displayMessageAndExit
    Prints the message to stdout and then exits with errorcode 1.
  • dumpArgs
    This function appends 'agrs: []', to the buffer, with a space separated list of args[] elements betw
  • getGUIClassName
  • getGui
    Return the Interface to the GUI specified by the name in guiName.
  • getMegaMekSHA256
    Calculates the SHA-256 hash of the MegaMek.jar file Used primarily for purposes of checksum comparis
  • redirectOutput
    This function redirects the standard error and output streams to the given File name.
  • showInfo
    Prints some information about MegaMek. Used in logfiles to figure out the JVM and version of MegaMek
  • redirectOutput,
  • showInfo,
  • startDedicatedServer,
  • startGUI

Popular in Java

  • Updating database using SQL prepared statement
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Runner (org.openjdk.jmh.runner)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now