Initial BungeeCord edition
This commit is contained in:
parent
4416d55173
commit
23e8e80191
75 changed files with 1931 additions and 396 deletions
|
|
@ -0,0 +1,6 @@
|
|||
package net.frankheijden.serverutils.common.providers;
|
||||
|
||||
public interface ColorProvider {
|
||||
|
||||
String apply(String str);
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package net.frankheijden.serverutils.common.providers;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class PluginProvider<T> {
|
||||
|
||||
public abstract File getPluginsFolder();
|
||||
|
||||
public abstract List<T> getPlugins();
|
||||
|
||||
public abstract String getPluginName(T plugin);
|
||||
|
||||
public List<T> getPluginsSorted() {
|
||||
List<T> plugins = getPlugins();
|
||||
plugins.sort(Comparator.comparing(this::getPluginName));
|
||||
return plugins;
|
||||
}
|
||||
|
||||
public List<String> getPluginNames() {
|
||||
return getPlugins().stream()
|
||||
.map(this::getPluginName)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all files with a jar extension in the plugins/ folder and returns solely their name.
|
||||
* @return An list of jar file names.
|
||||
*/
|
||||
public List<String> getPluginFileNames() {
|
||||
return Arrays.stream(getPluginJars())
|
||||
.map(File::getName)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all files with a jar extension in the plugins/ folder.
|
||||
* @return An array of jar files.
|
||||
*/
|
||||
public File[] getPluginJars() {
|
||||
File parent = getPluginsFolder();
|
||||
if (parent == null || !parent.exists()) return new File[0];
|
||||
return parent.listFiles(f -> f.getName().endsWith(".jar"));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package net.frankheijden.serverutils.common.providers;
|
||||
|
||||
import net.frankheijden.serverutils.common.config.YamlConfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface ResourceProvider {
|
||||
|
||||
InputStream getResource(String resource);
|
||||
|
||||
YamlConfig load(InputStream is);
|
||||
|
||||
YamlConfig load(File file);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue