From bf341dd8d394227c7c117c714ee5654e40d38b92 Mon Sep 17 00:00:00 2001 From: Steven Tracey Date: Wed, 21 Jul 2021 22:10:55 -0400 Subject: [PATCH] Added Features --- .gitignore | 6 +- .../6.7/executionHistory/executionHistory.bin | Bin 100734 -> 100734 bytes .../executionHistory/executionHistory.lock | Bin 17 -> 17 bytes .gradle/6.7/fileHashes/fileHashes.bin | Bin 21197 -> 21297 bytes .gradle/6.7/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes .gradle/6.7/javaCompile/classAnalysis.bin | Bin 25222 -> 26488 bytes .gradle/6.7/javaCompile/javaCompile.lock | Bin 17 -> 17 bytes .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .../compileJava/source-classes-mapping.txt | 4 +- src/main/java/tech/nevets/lunarbot/Bot.java | 2 +- .../lunarbot/commands/wiki/InfoCmd.java | 9 +- .../nevets/lunarbot/webserver/WebAPI.java | 25 --- .../lunarbot/webserver/WebGenerator.java | 4 +- .../nevets/lunarbot/webserver/WebServer.java | 200 ------------------ 14 files changed, 12 insertions(+), 238 deletions(-) delete mode 100644 src/main/java/tech/nevets/lunarbot/webserver/WebServer.java diff --git a/.gitignore b/.gitignore index 5bafa86..be8afc3 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,6 @@ hs_err_pid* #Files with sensitive info config.yml -/WebAPI -/build -/.idea +WebAPI/ +build/ +.idea/ diff --git a/.gradle/6.7/executionHistory/executionHistory.bin b/.gradle/6.7/executionHistory/executionHistory.bin index 49244850a28e67e06958c5edf7f684d49cfe21bc..83bb31d93304913c8c2f74bced2053851e1fa156 100644 GIT binary patch delta 434 zcmex2iS6GcwhhHQHTADCFz7|k&dtltGpQ;vN-axIHqB2d&N44F$;dBA%FJZ|1E&1x z3Tlk5+vU|59fUV4o(*OcNb%ZmW^Qkj<`xTvU4L$zwx0a{ocQzv8OGwxeCIbY3tUlj zyd?1M;=?cYbH#&>pIEy2!XW3W^ja`$@uW95G9(yRPyTpLbh6wvQO3KI z4X=8u#e}COxu@o(7A2PC7wKgsmL)O^*k|R>O$eWIooW5_Q@;iN*D!8`YU1UDE1mA6 z#AqzAdpFCyLgOPTM`imGuS`3XKfPaxQEapF^+YCtSq^di^6!7G%-*wmMoMVcz3u(Z zjLeLir{8L45&AIWg!t>lYs70}Tid-$c$FESPu_SZbn=FKER*@}^KG7f--kt@FhDRs zlWo-k89Sk6&!2UqO@H9Z=r{SnRl&*ncY=U4uQJ>%ddWG7#l_45PdhFgnDnwF@ynD+ zE;*YfBr(32eDO&n2Ta{${ipTy&wL_KA;^*Ke+S>dVBKu{rQrB_osm Pf^Q^6&UAL8C5bs!1n11 zYK*Si<<%G+gf}am4Q3Qb5cqP{(0pIbR^d1`1DU7OCci%?K0QH(v3N7z`Ay6M2Vz5y zgv*?rAKQ`8-EJZHVe^Gc>dZnfZP$4|%?P{rhgbOflaC&5jH@SqJSRF??wTm$t;vR0 zy(b4eVUZ6`Eh9TaO(E;xBvaG?J)Yen(_JM#CwsO`|n4w2+U=Y-Fqx%qq;{i8Wne%LrEpb*}YO udx85)I)CkEcKzbEOILQ!qI2iA$0##;GO;oOqatSWhfOvtn>pT;%>@9)541G^ diff --git a/.gradle/6.7/executionHistory/executionHistory.lock b/.gradle/6.7/executionHistory/executionHistory.lock index 6e3d99f1311b1bec1791199c24d64115742a9976..db1467a2be7db2f78c1534e92135ffd439fedc27 100644 GIT binary patch literal 17 TcmZRU4>_TkAiO1+0RsF1BuE26 literal 17 TcmZRU4>_TkAiO1+0RmhABs~K* diff --git a/.gradle/6.7/fileHashes/fileHashes.bin b/.gradle/6.7/fileHashes/fileHashes.bin index 4609bf76e004ac1d911a8e8f158bc802909b9039..e564a009ffde32ef13a1f24e874080016cd42190 100644 GIT binary patch delta 474 zcmX@RlyT!S#tkMCj24?sB{CQV)_s<^pu71<4Febi{hvHla)ZFll{bFe{}{OeDtLCY zt&}h`W8g-`AL1JgP6%yw^!UcCkm9xB%-r54%`FxTyZ+obZOy>ISamw%;9ZC&wzSRR zK8qL?W;w+5%fJ7%GJDVN87ZM%_rR($vn(O1xHu19dcmnoB6ayCs! Of?C22(ZMPT(g6Vbqn#1} delta 339 zcmdnEjPdMJ#tkMCjAolnB{CQ%ZO$R!9)|a@Ej$ zU(HtGI5h*Ar_&f17^@EHismtZ0bA_maGynt3XI=`+;>@v|7LmrR<*rk-&2Sxu{RJ^ zoWCba`n_X0q$|!encH6v#Ne823t{kX&i8j?R5%bDdL&%t?EKh{gzk0=!4Dt<4*q>y z1Tlbh+T^PNYCwHrUnl<$02v_mW3pkOo*j_!8)}C*kk&H>5}H7)2*Lu#XV`3EICcB_ z+yDO8b{PF!4RMt?BTy0uc)TXh4J=c5X}iwzX-3$^KfJ=YT} jkc+}xCfVJ$HzZsTvRvXizcPIe)FeKLBF4nY(}T;Xzb-Sm#~#sIt?P2cK$yU z9JboO^W)T+J`nMgqm%ba{19M0)_*r+O?MGQFsW_wTFDFn2SZU#o@3jEpeoZR^GbCy zKHRAILwuuwh3IBS4_7HZV+IDs8$f&kglA4x3>2NL7oR^lCwTT`#YD}?h4HGBbwW}Z z?@rc8iUTQTVgxGu3BoYN?2J5<6+@LLN5)S9Di@o4Ad#2DJvA@2D6u4evO}!GWS)fE z{7h^>y$oSM><7Y=KPGCKGPWmGmZV0uu`sX|vq4Bj E8lG1X9smFU diff --git a/.gradle/6.7/javaCompile/javaCompile.lock b/.gradle/6.7/javaCompile/javaCompile.lock index 1951ba2d4ac6679c16a1e0591fe589fabd8a1ba7..bb1606895d672c03806ba5e0b65a9d66d02cfcd1 100644 GIT binary patch literal 17 UcmZQh+_kd2@L63h0|fX1064$|&j0`b literal 17 UcmZQh+_kd2@L63h0|eLu064J(zyJUM diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 5c1580a6d17763fb344bea5213a15c2223147d41..8dbe89431ef05de3980b1693e8865f40216b5704 100644 GIT binary patch literal 17 UcmZSHc=v~%qbcVm1_&qx05p*VUH||9 literal 17 UcmZSHc=v~%qbcVm1_;Oo05pdLQ~&?~ diff --git a/build/tmp/compileJava/source-classes-mapping.txt b/build/tmp/compileJava/source-classes-mapping.txt index 7ac3826..79d3fa5 100644 --- a/build/tmp/compileJava/source-classes-mapping.txt +++ b/build/tmp/compileJava/source-classes-mapping.txt @@ -4,8 +4,8 @@ tech/nevets/lunarbot/config/ConfigUtils.java tech.nevets.lunarbot.config.ConfigUtils tech/nevets/lunarbot/config/Config.java tech.nevets.lunarbot.config.Config -tech/nevets/lunarbot/webserver/WebServer.java - tech.nevets.lunarbot.webserver.WebServer +tech/nevets/lunarbot/webserver/WebGenerator.java + tech.nevets.lunarbot.webserver.WebGenerator tech/nevets/lunarbot/commands/games/CoinCmd.java tech.nevets.lunarbot.commands.games.CoinCmd tech/nevets/lunarbot/commands/wiki/InfoCmd.java diff --git a/src/main/java/tech/nevets/lunarbot/Bot.java b/src/main/java/tech/nevets/lunarbot/Bot.java index 8513571..90feb5e 100644 --- a/src/main/java/tech/nevets/lunarbot/Bot.java +++ b/src/main/java/tech/nevets/lunarbot/Bot.java @@ -41,7 +41,7 @@ public class Bot { System.out.println("Finished Building Bot!"); WebAPI.main(null); - WebGenerator.main(null); + WebGenerator.generator(null); } } \ No newline at end of file diff --git a/src/main/java/tech/nevets/lunarbot/commands/wiki/InfoCmd.java b/src/main/java/tech/nevets/lunarbot/commands/wiki/InfoCmd.java index fc9549c..af5580a 100644 --- a/src/main/java/tech/nevets/lunarbot/commands/wiki/InfoCmd.java +++ b/src/main/java/tech/nevets/lunarbot/commands/wiki/InfoCmd.java @@ -19,11 +19,10 @@ public class InfoCmd extends ListenerAdapter { if (content.equalsIgnoreCase(prefix + "info")) { EmbedBuilder info = new EmbedBuilder(); - info.setTitle("📚・Information・📚"); - info.setDescription("Information about Sugarcane"); - info.addField("Creator", "nevetS-718", false); - info.setFooter("SugarcaneMC", "https://cdn.discordapp.com/icons/855918593497759754/a_978a67a83330554987cd7521f638fea8.gif?size=4096"); - info.setColor(0x73fc03); + info.setTitle("📚・LunarBot・📚"); + info.setDescription("Lunarbot cuz y not"); + info.setFooter("LunarBot: Created by nevetS & 5gi", "https://cdn.discordapp.com/icons/855918593497759754/a_978a67a83330554987cd7521f638fea8.gif?size=4096"); + info.setColor(0x2a2ea3); e.getChannel().sendTyping().queue(); e.getChannel().sendMessage(info.build()).queue(); diff --git a/src/main/java/tech/nevets/lunarbot/webserver/WebAPI.java b/src/main/java/tech/nevets/lunarbot/webserver/WebAPI.java index ccab3bf..2b2546f 100644 --- a/src/main/java/tech/nevets/lunarbot/webserver/WebAPI.java +++ b/src/main/java/tech/nevets/lunarbot/webserver/WebAPI.java @@ -209,31 +209,6 @@ public class WebAPI implements Runnable{ } - - - - - - - - - - - - - - - - - - - - - - - - - /** static final File WEB_ROOT = new File("/WebAPI"); static final String DEFAULT_File = "index.html"; static final String FILE_NOT_FOUND = "404.html"; diff --git a/src/main/java/tech/nevets/lunarbot/webserver/WebGenerator.java b/src/main/java/tech/nevets/lunarbot/webserver/WebGenerator.java index 820d2b2..ce1e206 100644 --- a/src/main/java/tech/nevets/lunarbot/webserver/WebGenerator.java +++ b/src/main/java/tech/nevets/lunarbot/webserver/WebGenerator.java @@ -5,9 +5,9 @@ import java.util.Scanner; public class WebGenerator { - public static void main(String args[]) { + public static void generator(String args[]) { - System.out.println(""); + System.out.println(); Scanner sc = new Scanner(System.in); String path = sc.next(); //Using Scanner class to get the folder name from the user diff --git a/src/main/java/tech/nevets/lunarbot/webserver/WebServer.java b/src/main/java/tech/nevets/lunarbot/webserver/WebServer.java deleted file mode 100644 index d293e7b..0000000 --- a/src/main/java/tech/nevets/lunarbot/webserver/WebServer.java +++ /dev/null @@ -1,200 +0,0 @@ -package tech.nevets.lunarbot.webserver; - - -import java.io.*; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.Date; -import java.util.StringTokenizer; - -public class WebServer implements Runnable { - - static final File WEB_ROOT = new File("."); - static final String DEFAULT_FILE = "index.html"; - static final String FILE_NOT_FOUND = "404.html"; - static final String METHOD_NOT_SUPPORTED = "mns.html"; - - static final int PORT = 80; - - private Socket connect; - public WebServer(Socket c) { - connect = c; - } - - public static void main(String[] args) { - try { - ServerSocket serverConnect = new ServerSocket(PORT); - while (true) { - WebServer myServer = new WebServer(serverConnect.accept()); - Thread thread = new Thread(myServer); - thread.start(); - } - } catch (IOException e) { - System.out.println("Error occurred while connecting"); - e.printStackTrace(); - } - } - - @Override - public void run() { - BufferedReader in = null; - PrintWriter out = null; - BufferedOutputStream dataOut = null; - String fileRequested = null; - - try { - in = new BufferedReader(new InputStreamReader(connect.getInputStream())); - out = new PrintWriter(connect.getOutputStream()); - dataOut = new BufferedOutputStream(connect.getOutputStream()); - String input = in.readLine(); - StringTokenizer parse = new StringTokenizer(input); - String method = parse.nextToken().toUpperCase(); - fileRequested = parse.nextToken().toLowerCase(); - - if (!method.equals("GET") && !method.equals("HEAD")) { - File file = new File(WEB_ROOT, METHOD_NOT_SUPPORTED); - int fileLength = (int) file.length(); - String contentMimeType = "text/html"; - byte[] fileData = readFileData(file, fileLength); - - out.println("HTTP/1.1 501 Not Implemented"); - out.println("Server: Java HTTP Server from SSaurel : 1.0"); - out.println("Date: " + new Date()); - out.println("Content-type: " + contentMimeType); - out.println("Content-length: " + fileLength); - out.println(); - out.flush(); - dataOut.write(fileData, 0, fileLength); - dataOut.flush(); - - } else { - if (fileRequested.endsWith("/")) { - fileRequested += DEFAULT_FILE; - } - - File file = new File(WEB_ROOT, fileRequested); - int fileLength = (int) file.length(); - String content = getContentType(fileRequested); - - if (method.equals("GET")) { - byte[] fileData = readFileData(file, fileLength); - - out.println("HTTP/1.1 200 OK"); - out.println("Server: Java HTTP Server from SSaurel : 1.0"); - out.println("Date: " + new Date()); - out.println("Content-type: " + content); - out.println("Content-length: " + fileLength); - out.println(); - out.flush(); - - dataOut.write(fileData, 0, fileLength); - dataOut.flush(); - } - } - - } catch (FileNotFoundException fnfe) { - try { - fileNotFound(out, dataOut, fileRequested); - } catch (IOException ioe) { - System.err.println("Error with file not found exception : " + ioe.getMessage()); - } - - } catch (IOException ioe) { - System.err.println("Server error : " + ioe); - } finally { - try { - in.close(); - out.close(); - dataOut.close(); - connect.close(); - } catch (Exception e) { - System.err.println("Error closing stream : " + e.getMessage()); - } - } - - - } - - private byte[] readFileData(File file, int fileLength) throws IOException { - FileInputStream fileIn = null; - byte[] fileData = new byte[fileLength]; - - try { - fileIn = new FileInputStream(file); - fileIn.read(fileData); - } finally { - if (fileIn != null) - fileIn.close(); - } - - return fileData; - } - - private String getContentType(String fileRequested) { - if (fileRequested.endsWith(".htm") || fileRequested.endsWith(".html")) - return "text/html"; - else - return "text/plain"; - } - - private void fileNotFound(PrintWriter out, OutputStream dataOut, String fileRequested) throws IOException { - File file = new File(WEB_ROOT, FILE_NOT_FOUND); - int fileLength = (int) file.length(); - String content = "text/html"; - byte[] fileData = readFileData(file, fileLength); - - out.println("HTTP/1.1 404 File Not Found"); - out.println("Server: Java HTTP Server from SSaurel : 1.0"); - out.println("Date: " + new Date()); - out.println("Content-type: " + content); - out.println("Content-length: " + fileLength); - out.println(); - out.flush(); - - dataOut.write(fileData, 0, fileLength); - dataOut.flush(); - } - - /** - protected void start() { - ServerSocket s; - - System.out.println("Webserver starting up on port 80"); - System.out.println("(press ctrl-c to exit)"); - try { - // create the main server socket - s = new ServerSocket(80); - } catch (Exception e) { - System.out.println("Error: " + e); - return; - } - - System.out.println("Waiting for connection"); - for (;;) { - try { - - Socket remote = s.accept(); - - System.out.println("Connection, sending data."); - BufferedReader in = new BufferedReader(new InputStreamReader( - remote.getInputStream())); - PrintWriter out = new PrintWriter(remote.getOutputStream()); - - String str = "."; - while (!str.equals("")) - str = in.readLine(); - - out.println("HTTP/1.0 200 OK"); - out.println("Content-Type: text/html"); - out.println("Server: Bot"); - out.println(""); - out.println("

WebAPI is running

"); - out.flush(); - remote.close(); - } catch (Exception e) { - System.out.println("Error: " + e); - } - } - } - **/ -}