mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2025-09-08 00:46:15 +02:00
Cleanup formatting / spacing
This commit is contained in:
@@ -38,28 +38,35 @@ public class FileUtil {
|
||||
|
||||
public static List<Class<?>> getClasses(String folder, String fileName, Class<?> type) {
|
||||
List<Class<?>> list = new ArrayList<>();
|
||||
|
||||
try {
|
||||
File f = new File(PlaceholderAPIPlugin.getInstance().getDataFolder(), folder);
|
||||
if (!f.exists()) {
|
||||
return list;
|
||||
}
|
||||
|
||||
FilenameFilter fileNameFilter = (dir, name) -> {
|
||||
if (fileName != null) {
|
||||
return name.endsWith(".jar") && name.replace(".jar", "")
|
||||
.equalsIgnoreCase(fileName.replace(".jar", ""));
|
||||
}
|
||||
|
||||
return name.endsWith(".jar");
|
||||
};
|
||||
|
||||
File[] jars = f.listFiles(fileNameFilter);
|
||||
if (jars == null) {
|
||||
return list;
|
||||
}
|
||||
|
||||
for (File file : jars) {
|
||||
list = gather(file.toURI().toURL(), list, type);
|
||||
}
|
||||
|
||||
return list;
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -67,19 +74,23 @@ public class FileUtil {
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
try (URLClassLoader cl = new URLClassLoader(new URL[]{jar}, clazz.getClassLoader()); JarInputStream jis = new JarInputStream(jar.openStream())) {
|
||||
while (true) {
|
||||
JarEntry j = jis.getNextJarEntry();
|
||||
if (j == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
String name = j.getName();
|
||||
if (name == null || name.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name.endsWith(".class")) {
|
||||
name = name.replace("/", ".");
|
||||
String cname = name.substring(0, name.lastIndexOf(".class"));
|
||||
|
||||
Class<?> c = cl.loadClass(cname);
|
||||
if (clazz.isAssignableFrom(c)) {
|
||||
list.add(c);
|
||||
@@ -88,6 +99,7 @@ public class FileUtil {
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@
|
||||
package me.clip.placeholderapi.util;
|
||||
|
||||
public enum TimeFormat {
|
||||
|
||||
DAYS,
|
||||
HOURS,
|
||||
MINUTES,
|
||||
|
@@ -23,7 +23,6 @@ package me.clip.placeholderapi.util;
|
||||
public class TimeUtil {
|
||||
|
||||
public static String getRemaining(int seconds, TimeFormat type) {
|
||||
|
||||
if (seconds < 60) {
|
||||
switch (type) {
|
||||
case DAYS:
|
||||
@@ -33,12 +32,14 @@ public class TimeUtil {
|
||||
case SECONDS:
|
||||
return String.valueOf(seconds);
|
||||
}
|
||||
|
||||
return String.valueOf(seconds);
|
||||
}
|
||||
|
||||
int minutes = seconds / 60;
|
||||
int s = 60 * minutes;
|
||||
int secondsLeft = seconds - s;
|
||||
|
||||
if (minutes < 60) {
|
||||
switch (type) {
|
||||
case DAYS:
|
||||
@@ -49,6 +50,7 @@ public class TimeUtil {
|
||||
case SECONDS:
|
||||
return String.valueOf(secondsLeft);
|
||||
}
|
||||
|
||||
return String.valueOf(seconds);
|
||||
}
|
||||
|
||||
@@ -56,6 +58,7 @@ public class TimeUtil {
|
||||
int hours = minutes / 60;
|
||||
int inMins = 60 * hours;
|
||||
int leftOver = minutes - inMins;
|
||||
|
||||
switch (type) {
|
||||
case DAYS:
|
||||
return "0";
|
||||
@@ -66,6 +69,7 @@ public class TimeUtil {
|
||||
case SECONDS:
|
||||
return String.valueOf(secondsLeft);
|
||||
}
|
||||
|
||||
return String.valueOf(seconds);
|
||||
}
|
||||
|
||||
@@ -84,12 +88,14 @@ public class TimeUtil {
|
||||
case SECONDS:
|
||||
return String.valueOf(secondsLeft);
|
||||
}
|
||||
|
||||
return String.valueOf(seconds);
|
||||
|
||||
} else {
|
||||
int hours = leftOver / 60;
|
||||
int hoursInMins = 60 * hours;
|
||||
int minsLeft = leftOver - hoursInMins;
|
||||
|
||||
switch (type) {
|
||||
case DAYS:
|
||||
return String.valueOf(days);
|
||||
@@ -100,6 +106,7 @@ public class TimeUtil {
|
||||
case SECONDS:
|
||||
return String.valueOf(secondsLeft);
|
||||
}
|
||||
|
||||
return String.valueOf(seconds);
|
||||
}
|
||||
}
|
||||
@@ -113,6 +120,7 @@ public class TimeUtil {
|
||||
int minutes = seconds / 60;
|
||||
int s = 60 * minutes;
|
||||
int secondsLeft = seconds - s;
|
||||
|
||||
if (minutes < 60) {
|
||||
if (secondsLeft > 0) {
|
||||
return minutes + "m " + secondsLeft + "s";
|
||||
@@ -120,18 +128,22 @@ public class TimeUtil {
|
||||
return minutes + "m";
|
||||
}
|
||||
}
|
||||
|
||||
if (minutes < 1440) {
|
||||
String time;
|
||||
int hours = minutes / 60;
|
||||
time = hours + "h";
|
||||
int inMins = 60 * hours;
|
||||
int leftOver = minutes - inMins;
|
||||
|
||||
if (leftOver >= 1) {
|
||||
time = time + " " + leftOver + "m";
|
||||
}
|
||||
|
||||
if (secondsLeft > 0) {
|
||||
time = time + " " + secondsLeft + "s";
|
||||
}
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
@@ -140,20 +152,24 @@ public class TimeUtil {
|
||||
time = days + "d";
|
||||
int inMins = 1440 * days;
|
||||
int leftOver = minutes - inMins;
|
||||
|
||||
if (leftOver >= 1) {
|
||||
if (leftOver < 60) {
|
||||
time = time + " " + leftOver + "m";
|
||||
} else {
|
||||
int hours = leftOver / 60;
|
||||
time = time + " " + hours + "h";
|
||||
|
||||
int hoursInMins = 60 * hours;
|
||||
int minsLeft = leftOver - hoursInMins;
|
||||
time = time + " " + minsLeft + "m";
|
||||
}
|
||||
}
|
||||
|
||||
if (secondsLeft > 0) {
|
||||
time = time + " " + secondsLeft + "s";
|
||||
}
|
||||
|
||||
return time;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user