Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. private static void serverArguments(String[] args) {
  2. String combinedArguments = "";
  3. for (int index = 0; index < args.length; index++) {
  4. combinedArguments = combinedArguments + args[index]; // creates a new StringBuilder object each loop iteration
  5. }
  6.  
  7. if (args.length > 0) {
  8. List<String> argumentsAsList = Arrays.asList(args); // should be used more, no need for combinedArguments
  9.  
  10. int port = Integer.parseInt(args[0]); // will fail without telling user HOW they messed up args
  11.  
  12. ServerConfiguration.PORT = port; // PORT = Integer.parseInt(args[0]); local variable port is useless
  13.  
  14. if (combinedArguments.contains("ECO")) {
  15. GameType.gameType = GameType.OSRS_ECO;
  16. }
  17. else if (combinedArguments.contains("PVP")) {
  18. GameType.gameType = GameType.OSRS_PVP;
  19.  
  20. } else if (combinedArguments.contains("PRE_EOC")) {
  21. GameType.gameType = GameType.PRE_EOC;
  22.  
  23. }
  24.  
  25. if (combinedArguments.contains("LIVE")) { // no if needed: DEBUG_MODE = !combinedArguments.contains("LIVE");
  26. ServerConfiguration.DEBUG_MODE = false;
  27. }
  28.  
  29. if (argumentsAsList.contains("BENCHMARK")) { // no if needed
  30. ServerConfiguration.BENCHMARK = true;
  31. }
  32. if (!combinedArguments.contains("SQL") && !combinedArguments.contains("HIKARI_SQL")) { // no if needed
  33. ServerConfiguration.MOCK_SQL = true;
  34. }
  35. }
  36.  
  37. if (FileUtility.fileExists("dedicated_server.txt")) { // no if needed
  38. ServerConfiguration.FORCE_DEDICATED_SERVER = true;
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement