mirror of
https://github.com/SimplexDevelopment/SimplexCore.git
synced 2024-12-22 08:37:37 +00:00
BLEEDING EDGE 1.3_07
This commit is contained in:
parent
628b87bfc1
commit
298c7d5d7a
@ -30,6 +30,7 @@ public final class SimplexCorePlugin extends SimplexAddon<SimplexCorePlugin> {
|
||||
instances.getRegistry().register(this);
|
||||
instances.getCommandLoader().classpath(Command_info.class).load();
|
||||
instances.getConfig().reload();
|
||||
instances.getInternals().reload();
|
||||
//
|
||||
SimplexListener.register(new DependencyListener(), this);
|
||||
new Announcer();
|
||||
|
@ -11,33 +11,34 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public final class Constants {
|
||||
private static final SimplexCorePlugin plugin = JavaPlugin.getPlugin(SimplexCorePlugin.class);
|
||||
private static final Server server = plugin.getServer();
|
||||
private static final Logger logger = plugin.getLogger();
|
||||
private static final PluginManager manager = server.getPluginManager();
|
||||
private static final BukkitScheduler scheduler = server.getScheduler();
|
||||
|
||||
public static SimplexCorePlugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public static Server getServer() {
|
||||
return server;
|
||||
return plugin.getServer();
|
||||
}
|
||||
|
||||
public static Logger getLogger() {
|
||||
return logger;
|
||||
return plugin.getServer().getLogger();
|
||||
}
|
||||
|
||||
public static PluginManager getManager() {
|
||||
return manager;
|
||||
return plugin.getServer().getPluginManager();
|
||||
}
|
||||
|
||||
public static BukkitScheduler getScheduler() {
|
||||
return scheduler;
|
||||
return plugin.getServer().getScheduler();
|
||||
}
|
||||
|
||||
public static File getDataFolder() {
|
||||
return plugin.getDataFolder();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ public final class Instances {
|
||||
private final DependencyManagement dpm = new DependencyManagement();
|
||||
private final Yaml config = new YamlFactory(Constants.getPlugin()).setDefaultPathways();
|
||||
private final TimeValues time = new TimeValues();
|
||||
private final Yaml internals = new YamlFactory(Constants.getPlugin()).from("internals.yml", Constants.getDataFolder(), "internals.yml");
|
||||
|
||||
public synchronized AddonRegistry getRegistry() {
|
||||
return AddonRegistry.getInstance();
|
||||
@ -30,4 +31,6 @@ public final class Instances {
|
||||
public Yaml getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public Yaml getInternals() { return internals; }
|
||||
}
|
||||
|
@ -2,17 +2,21 @@ package io.github.simplexdev.simplexcore.utils;
|
||||
|
||||
import io.github.simplexdev.api.func.Path;
|
||||
import io.github.simplexdev.simplexcore.ban.BanType;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.SplittableRandom;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class Utilities {
|
||||
private static final SplittableRandom random = new SplittableRandom();
|
||||
private static final SplittableRandom numbers = new SplittableRandom();
|
||||
private static final List<String> versions = Constants.getPlugin().getInstances().getInternals().getStringList(pathway("supported_versions"));
|
||||
|
||||
private static final List<Character> list = new ArrayList<>() {{
|
||||
add('0');
|
||||
add('1');
|
||||
@ -73,4 +77,31 @@ public final class Utilities {
|
||||
public static Path pathway(String pathway) {
|
||||
return () -> pathway;
|
||||
}
|
||||
|
||||
public static String getNMSVersion() {
|
||||
return Bukkit.getServer().getClass().getPackage().getName().substring(23).replaceFirst("v", "");
|
||||
}
|
||||
|
||||
public static String[] formatVersion(String version) {
|
||||
return (version).split(":");
|
||||
}
|
||||
|
||||
public static boolean matchVersions() {
|
||||
return versions.contains(getNMSVersion());
|
||||
}
|
||||
|
||||
public static String getSpigotVersion() {
|
||||
if (!matchVersions()) return "UNKNOWN";
|
||||
|
||||
for (String version : versions) {
|
||||
String nms = formatVersion(version)[0];
|
||||
String spigot = formatVersion(version)[1];
|
||||
if (nms.equalsIgnoreCase(getNMSVersion())) {
|
||||
return spigot;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("Unable to determine the Spigot version: NMS v"
|
||||
+ getNMSVersion() + " is not supported!");
|
||||
}
|
||||
}
|
11
src/main/resources/internals.yml
Normal file
11
src/main/resources/internals.yml
Normal file
@ -0,0 +1,11 @@
|
||||
supported_versions:
|
||||
- 1_10_R1:1.10.2
|
||||
- 1_11_R1:1.11
|
||||
- 1_12_R1:1.12
|
||||
- 1_13_R1:1.13
|
||||
- 1_13_R2:1.13.1
|
||||
- 1_14_R1:1.14
|
||||
- 1_15_R1:1.15
|
||||
- 1_16_R1:1.16.1
|
||||
- 1_16_R2:1.16.3
|
||||
- 1_16_R3:1.16.4
|
Loading…
Reference in New Issue
Block a user