Skip to content

Commit fbaaef6

Browse files
committed
Version 1.1
1 parent ddceac4 commit fbaaef6

File tree

4 files changed

+93
-1
lines changed

4 files changed

+93
-1
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.redstoneboy0509</groupId>
88
<artifactId>JavaEZ</artifactId>
9-
<version>1.0</version>
9+
<version>1.1</version>
1010
<description>A simplification library to make Java easier for newcomers.</description>
1111
<name>${project.groupId}:${project.artifactId}</name>
1212
<packaging>jar</packaging>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package io.github.redstoneboy0509.javaez;
2+
3+
import java.io.BufferedReader;
4+
import java.io.InputStreamReader;
5+
import java.net.URL;
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
/**
10+
* Main class for JavaEZ
11+
* @author RedstoneBoy0509
12+
* @since 1.1
13+
*/
14+
public class JavaEZ {
15+
16+
/**
17+
* The current version of JavaEZ.
18+
* @since 1.1
19+
*/
20+
public static final String VERSION = "1.1";
21+
22+
/**
23+
* Prints info about your version of JavaEZ
24+
* @since 1.1
25+
*/
26+
public static void info() {
27+
System.out.println("=[JavaEZ Info]=");
28+
System.out.println("JavaEZ running on version " + VERSION);
29+
String latestVersion = getLatestVersion();
30+
boolean areWeUpdated = latestVersion.equalsIgnoreCase(VERSION);
31+
if(!areWeUpdated) {
32+
System.out.println("Attention: your JavaEZ is not at latest version, please consider updating!");
33+
System.out.println("Latest version: " + latestVersion);
34+
} else System.out.println("JavaEZ is up to date!");
35+
}
36+
37+
/**
38+
* Gets the latest version
39+
* @return The latest version
40+
* @since 1.1
41+
*/
42+
public static String getLatestVersion() {
43+
List<String> versions = getVersions();
44+
return versions.isEmpty() ? "Unknown" : versions.get(versions.size() - 1);
45+
}
46+
47+
/**
48+
* Returns a list of all known versions on the Internet
49+
* @return a list of all existent versions
50+
* @since 1.1
51+
*/
52+
public static List<String> getVersions() {
53+
try {
54+
URL url = new URL("https://gist.githubusercontent.com/RedstoneBoy0509/fb10258f9ae7d858f94b8cbaa651548f/raw/");
55+
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
56+
List<String> list = new ArrayList<>();
57+
String line;
58+
while((line = reader.readLine()) != null) {
59+
if(line.isEmpty()) continue;
60+
list.add(line);
61+
}
62+
reader.close();
63+
return list;
64+
} catch(Exception ex) {
65+
return new ArrayList<>();
66+
}
67+
}
68+
69+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-----BEGIN PGP SIGNATURE-----
2+
3+
iQEzBAABCAAdFiEEWi8VBza09/4dK/cJlP8Sq7x4Y/sFAmCVxjIACgkQlP8Sq7x4
4+
Y/u2Owf/YsqeDQFdUnPqOyGrbROa5GFRM41FYMDFNk/zpTsTUxwG2SXC2F7a1i8W
5+
ZDHETF0LoTlmM+/84lJPt38QEABWvbPapKwt/nDqgxeWMkgK0IqCKpq1CPoZBv6e
6+
Gy+kxxGC+ZOX6OLIMEFdUNOSs5UHzOcU+9EnM8Xo9Cc2oTL14ETh+u1Q3FuDbtf/
7+
HZMdMJzbZwVO6K5+7QnWbSvYvdfKrPpXyWyWfQum+ie902F1gQ7Hji1KaBRu7jTJ
8+
n1Tu5YjGixE5NRrtuAO3LTzzWV5JDlN0vM9nbWkBlU9SUI214B5pSy6NlD15DoIU
9+
sKmUcUyN9zCr9e05d1p2Pa4aIASZTQ==
10+
=op9n
11+
-----END PGP SIGNATURE-----

src/main/java/io/github/redstoneboy0509/javaez/extensions/Core.java

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.github.redstoneboy0509.javaez.backend.ErrorSystem;
55

66
import java.time.Duration;
7+
import java.util.Scanner;
78
import java.util.function.Supplier;
89

910
/**
@@ -136,4 +137,15 @@ public static void waitFor(int seconds) {
136137
}
137138
}
138139

140+
/**
141+
* Asks for input from the user. This function will wait until input is received.
142+
* @param prompt The prompt to prompt the user with
143+
* @return What the user entered
144+
*/
145+
public static String ask(String prompt) {
146+
Scanner scanner = new Scanner(System.in);
147+
System.out.println(prompt);
148+
return scanner.nextLine();
149+
}
150+
139151
}

0 commit comments

Comments
 (0)