Skip to content

Commit

Permalink
Version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ImplicitSaber committed May 7, 2021
1 parent ddceac4 commit fbaaef6
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.redstoneboy0509</groupId>
<artifactId>JavaEZ</artifactId>
<version>1.0</version>
<version>1.1</version>
<description>A simplification library to make Java easier for newcomers.</description>
<name>${project.groupId}:${project.artifactId}</name>
<packaging>jar</packaging>
Expand Down
69 changes: 69 additions & 0 deletions src/main/java/io/github/redstoneboy0509/javaez/JavaEZ.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package io.github.redstoneboy0509.javaez;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

/**
* Main class for JavaEZ
* @author RedstoneBoy0509
* @since 1.1
*/
public class JavaEZ {

/**
* The current version of JavaEZ.
* @since 1.1
*/
public static final String VERSION = "1.1";

/**
* Prints info about your version of JavaEZ
* @since 1.1
*/
public static void info() {
System.out.println("=[JavaEZ Info]=");
System.out.println("JavaEZ running on version " + VERSION);
String latestVersion = getLatestVersion();
boolean areWeUpdated = latestVersion.equalsIgnoreCase(VERSION);
if(!areWeUpdated) {
System.out.println("Attention: your JavaEZ is not at latest version, please consider updating!");
System.out.println("Latest version: " + latestVersion);
} else System.out.println("JavaEZ is up to date!");
}

/**
* Gets the latest version
* @return The latest version
* @since 1.1
*/
public static String getLatestVersion() {
List<String> versions = getVersions();
return versions.isEmpty() ? "Unknown" : versions.get(versions.size() - 1);
}

/**
* Returns a list of all known versions on the Internet
* @return a list of all existent versions
* @since 1.1
*/
public static List<String> getVersions() {
try {
URL url = new URL("https://gist.githubusercontent.com/RedstoneBoy0509/fb10258f9ae7d858f94b8cbaa651548f/raw/");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
List<String> list = new ArrayList<>();
String line;
while((line = reader.readLine()) != null) {
if(line.isEmpty()) continue;
list.add(line);
}
reader.close();
return list;
} catch(Exception ex) {
return new ArrayList<>();
}
}

}
11 changes: 11 additions & 0 deletions src/main/java/io/github/redstoneboy0509/javaez/JavaEZ.java.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----BEGIN PGP SIGNATURE-----

iQEzBAABCAAdFiEEWi8VBza09/4dK/cJlP8Sq7x4Y/sFAmCVxjIACgkQlP8Sq7x4
Y/u2Owf/YsqeDQFdUnPqOyGrbROa5GFRM41FYMDFNk/zpTsTUxwG2SXC2F7a1i8W
ZDHETF0LoTlmM+/84lJPt38QEABWvbPapKwt/nDqgxeWMkgK0IqCKpq1CPoZBv6e
Gy+kxxGC+ZOX6OLIMEFdUNOSs5UHzOcU+9EnM8Xo9Cc2oTL14ETh+u1Q3FuDbtf/
HZMdMJzbZwVO6K5+7QnWbSvYvdfKrPpXyWyWfQum+ie902F1gQ7Hji1KaBRu7jTJ
n1Tu5YjGixE5NRrtuAO3LTzzWV5JDlN0vM9nbWkBlU9SUI214B5pSy6NlD15DoIU
sKmUcUyN9zCr9e05d1p2Pa4aIASZTQ==
=op9n
-----END PGP SIGNATURE-----
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.github.redstoneboy0509.javaez.backend.ErrorSystem;

import java.time.Duration;
import java.util.Scanner;
import java.util.function.Supplier;

/**
Expand Down Expand Up @@ -136,4 +137,15 @@ public static void waitFor(int seconds) {
}
}

/**
* Asks for input from the user. This function will wait until input is received.
* @param prompt The prompt to prompt the user with
* @return What the user entered
*/
public static String ask(String prompt) {
Scanner scanner = new Scanner(System.in);
System.out.println(prompt);
return scanner.nextLine();
}

}

0 comments on commit fbaaef6

Please sign in to comment.