1- package com . twoweeksmc .dsm .console ;
1+ package de . eztxm .dsm .console ;
22
33import java .io .IOException ;
44import java .net .InetAddress ;
55import java .net .UnknownHostException ;
66import java .nio .charset .StandardCharsets ;
7+ import java .nio .file .Paths ;
78import java .util .Arrays ;
89
910import org .jline .reader .EndOfFileException ;
1516import org .jline .utils .AttributedString ;
1617import org .jline .utils .InfoCmp ;
1718
18- import com . twoweeksmc .dsm .common .server .ServerManager ;
19- import com . twoweeksmc .dsm .common .server .ServerState ;
19+ import de . eztxm .dsm .common .server . manager .ServerManager ;
20+ import de . eztxm .dsm .common .server .ServerState ;
2021
2122public final class JLineConsole {
2223 private final Terminal terminal ;
@@ -30,14 +31,14 @@ public JLineConsole() throws IOException {
3031 this .terminal = TerminalBuilder .builder ()
3132 .system (true )
3233 .jansi (true )
33- .dumb (true )
3434 .encoding (StandardCharsets .UTF_8 )
3535 .build ();
3636 this .terminal .enterRawMode ();
3737 this .reader = (LineReaderImpl ) LineReaderBuilder .builder ()
3838 .terminal (this .terminal )
3939 .option (LineReader .Option .DISABLE_EVENT_EXPANSION , true )
4040 .option (LineReader .Option .AUTO_PARAM_SLASH , false )
41+ .variable (LineReader .HISTORY_FILE , Paths .get (System .getProperty ("user.home" ), ".jline_history" ))
4142 .build ();
4243 AttributedString coloredPrefix = new AttributedString (this .userPrefix ());
4344 this .reader .setPrompt (coloredPrefix .toAnsi ());
@@ -60,43 +61,43 @@ public void start() {
6061 String [] args = Arrays .copyOfRange (inputParts , 1 , inputParts .length );
6162 switch (command ) {
6263 case "clear" -> this .clear ();
63- case "create-container" -> {
64+ case "create-container" , "create-con" -> {
6465 if (args .length < 2 ) {
6566 this .print ("[FF3333]Need platform and version argument" );
6667 continue ;
6768 }
6869 this .serverManager .createServerContainer (args [0 ].toLowerCase (), args [1 ].toLowerCase ());
6970 }
70- case "start-container" -> {
71+ case "start-container" , "start-con" -> {
7172 if (args .length < 1 ) {
7273 this .print ("[FF3333]Need container name" );
7374 continue ;
7475 }
7576 this .serverManager .startServerContainer (args [0 ]);
7677 }
77- case "recreate-container" -> {
78+ case "recreate-container" , "recreate-con" -> {
7879 if (args .length < 3 ) {
7980 this .print ("[FF3333]Need uniqueId, platform and version argument" );
8081 continue ;
8182 }
8283 this .serverManager .recreateServerContainer (args [1 ].toLowerCase (), args [2 ].toLowerCase (),
8384 args [0 ]);
8485 }
85- case "restart-container" -> {
86+ case "restart-container" , "restart-con" -> {
8687 if (args .length < 1 ) {
8788 this .print ("[FF3333]Need container name" );
8889 continue ;
8990 }
9091 this .serverManager .restartServerContainer (args [0 ]);
9192 }
92- case "stop-container" -> {
93+ case "stop-container" , "stop-con" -> {
9394 if (args .length < 1 ) {
9495 this .print ("[FF3333]Need container name" );
9596 continue ;
9697 }
9798 this .serverManager .stopServerContainer (args [0 ]);
9899 }
99- case "remove-container" -> {
100+ case "remove-container" , "remove-con" -> {
100101 if (args .length < 1 ) {
101102 this .print ("[FF3333]Need container name" );
102103 continue ;
@@ -106,7 +107,7 @@ public void start() {
106107 }
107108 this .serverManager .removeServerContainer (args [0 ]);
108109 }
109- case "list-containers" -> {
110+ case "list-containers" , "list-cons" -> {
110111 this .serverManager .getContainers ()
111112 .forEach (container -> this .print ("&e" + container .getNames ()[0 ].replace ("/" , "" ) + " - "
112113 + this .serverManager .getServerStateById (container .getId ())));
@@ -117,17 +118,16 @@ public void start() {
117118 }
118119 case "help" -> {
119120 this .print ("&7-------------------------------&eHelp&7-------------------------------" );
120- this .print (" &ecreate-container <platform> <version> &7- &f." );
121- this .print (" &estart-container <name> &7- &f." );
122- this .print (" &erecreate-container <uniqueId> <platform> <version> &7- &f." );
123- this .print (" &erestart-container <name> &7- &f." );
124- this .print (" &estart-container <name> &7- &f." );
125- this .print (" &estop-container <name> &7- &f." );
126- this .print (" &eremove-container <name> &7- &f." );
127- this .print (" &elist-containers &7- &f." );
128- this .print (" &eclear &7- &fClear the console." );
129- this .print (" &eexit, shutdown, stop &7- &fShutdown the cloud." );
130- this .print (" &ehelp &7- &fShow this help menu." );
121+ this .print ("&b create-container <platform> <version> &7- &fCreate a container with the platform and version" );
122+ this .print ("&b recreate-container <uniqueId> <platform> <version> &7- &fRecreate a container with the uniqueId" );
123+ this .print ("&b restart-container <name> &7- &fRestart a container with the name" );
124+ this .print ("&b start-container <name> &7- &fStart a container with the name" );
125+ this .print ("&b stop-container <name> &7- &fStop a container with the name" );
126+ this .print ("&b remove-container <name> &7- &fRemove a container with the name" );
127+ this .print ("&b list-containers &7- &fList of the containers as name" );
128+ this .print ("&b clear &7- &fClear the console" );
129+ this .print ("&b exit, shutdown, stop &7- &fShutdown the cloud" );
130+ this .print ("&b help &7- &fShow this help menu" );
131131 this .print ("&7-------------------------------&eHelp&7-------------------------------" );
132132 }
133133 default -> this .print ("Unknown command: " + command );
@@ -142,31 +142,25 @@ public void start() {
142142 }
143143
144144 public String prefix () {
145- String prefix = "[FB1364-F9A608]2weeksmc - dockermanager &7» &f" ;
145+ String prefix = "[33afff-33ffff] dockermanager &7» &f" ;
146146 return ConsoleColor .apply ("\r " + prefix );
147147 }
148148
149149 public String userPrefix () {
150150 try {
151151 String hostname = InetAddress .getLocalHost ().getHostName ();
152- String prefix = "[FB1364-F9A608 ]%hostname &7» &f" .replace ("%hostname" , hostname );
152+ String prefix = "[33afff-33ffff ]%hostname &7» &f" .replace ("%hostname" , hostname );
153153 return ConsoleColor .apply ("\r " + prefix );
154-
155154 } catch (UnknownHostException e ) {
156155 return ConsoleColor
157- .apply ("\r " + "[FB1364-F9A608]2weeksmc &7@&e%hostname &7» &f" .replace ("%hostname" , "unknown" ));
156+ .apply ("\r " + "[33afff-33ffff] &7@&e%hostname &7» &f" .replace ("%hostname" , "unknown" ));
158157 }
159158 }
160159
161160 public void sendWelcomeMessage () {
162161 System .out .print ("\n " );
163162 System .out .print ("\n " );
164- System .out
165- .println (ConsoleColor
166- .apply (" [FB1364-F9A608]2weeksmc - dockermanager &7- &e1.0.0&7@&edevelopment" ));
167- System .out .println (ConsoleColor .apply (" &fby &eezTxmMC&7 & &eDragonRex" ));
168- System .out .print ("\n " );
169- System .out .println (ConsoleColor .apply (" &fType &ehelp &fto list all commands." ));
163+ System .out .println (ConsoleColor .apply (" &fType &bhelp &fto list all commands." ));
170164 System .out .print ("\n " );
171165 System .out .print ("\n " );
172166 }
0 commit comments