Make version handling more flexible

This commit is contained in:
Blue (Lukas Rieger) 2021-05-23 10:12:34 +02:00
parent 9447606267
commit c1f3122c68
No known key found for this signature in database
GPG Key ID: 904C4995F9E1F800
24 changed files with 263 additions and 217 deletions

View File

@ -26,15 +26,15 @@
import de.bluecolored.bluemap.common.plugin.Plugin; import de.bluecolored.bluemap.common.plugin.Plugin;
import de.bluecolored.bluemap.common.plugin.serverinterface.ServerInterface; import de.bluecolored.bluemap.common.plugin.serverinterface.ServerInterface;
import de.bluecolored.bluemap.common.web.WebSettings;
import de.bluecolored.bluemap.core.MinecraftVersion; import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.config.*; import de.bluecolored.bluemap.core.config.*;
import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.core.map.BmMap; import de.bluecolored.bluemap.core.map.BmMap;
import de.bluecolored.bluemap.core.mca.MCAWorld;
import de.bluecolored.bluemap.core.map.hires.RenderSettings; import de.bluecolored.bluemap.core.map.hires.RenderSettings;
import de.bluecolored.bluemap.core.mca.MCAWorld;
import de.bluecolored.bluemap.core.resourcepack.ParseResourceException; import de.bluecolored.bluemap.core.resourcepack.ParseResourceException;
import de.bluecolored.bluemap.core.resourcepack.ResourcePack; import de.bluecolored.bluemap.core.resourcepack.ResourcePack;
import de.bluecolored.bluemap.common.web.WebSettings;
import de.bluecolored.bluemap.core.world.SlicedWorld; import de.bluecolored.bluemap.core.world.SlicedWorld;
import de.bluecolored.bluemap.core.world.World; import de.bluecolored.bluemap.core.world.World;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@ -197,7 +197,7 @@ private synchronized void loadWorldsAndMaps() throws IOException, InterruptedExc
public synchronized ResourcePack getResourcePack() throws IOException, InterruptedException { public synchronized ResourcePack getResourcePack() throws IOException, InterruptedException {
if (resourcePack == null) { if (resourcePack == null) {
File defaultResourceFile = new File(getCoreConfig().getDataFolder(), "minecraft-client-" + minecraftVersion.getVersionString() + ".jar"); File defaultResourceFile = new File(getCoreConfig().getDataFolder(), "minecraft-client-" + minecraftVersion.getResource().getVersion().getVersionString() + ".jar");
File resourceExtensionsFile = new File(getCoreConfig().getDataFolder(), "resourceExtensions.zip"); File resourceExtensionsFile = new File(getCoreConfig().getDataFolder(), "resourceExtensions.zip");
File textureExportFile = new File(getRenderConfig().getWebRoot(), "data" + File.separator + "textures.json"); File textureExportFile = new File(getRenderConfig().getWebRoot(), "data" + File.separator + "textures.json");
@ -210,9 +210,9 @@ public synchronized ResourcePack getResourcePack() throws IOException, Interrupt
//download file //download file
try { try {
Logger.global.logInfo("Downloading " + minecraftVersion.getClientDownloadUrl() + " to " + defaultResourceFile + " ..."); Logger.global.logInfo("Downloading " + minecraftVersion.getResource().getClientUrl() + " to " + defaultResourceFile + " ...");
FileUtils.forceMkdirParent(defaultResourceFile); FileUtils.forceMkdirParent(defaultResourceFile);
FileUtils.copyURLToFile(new URL(minecraftVersion.getClientDownloadUrl()), defaultResourceFile, 10000, 10000); FileUtils.copyURLToFile(new URL(minecraftVersion.getResource().getClientUrl()), defaultResourceFile, 10000, 10000);
} catch (IOException e) { } catch (IOException e) {
throw new IOException("Failed to download resources!", e); throw new IOException("Failed to download resources!", e);
} }
@ -226,7 +226,7 @@ public synchronized ResourcePack getResourcePack() throws IOException, Interrupt
if (resourceExtensionsFile.exists()) FileUtils.forceDelete(resourceExtensionsFile); if (resourceExtensionsFile.exists()) FileUtils.forceDelete(resourceExtensionsFile);
FileUtils.forceMkdirParent(resourceExtensionsFile); FileUtils.forceMkdirParent(resourceExtensionsFile);
FileUtils.copyURLToFile(Plugin.class.getResource("/de/bluecolored/bluemap/" + minecraftVersion.getResourcePrefix() + "/resourceExtensions.zip"), resourceExtensionsFile, 10000, 10000); FileUtils.copyURLToFile(Plugin.class.getResource("/de/bluecolored/bluemap/" + minecraftVersion.getResource().getResourcePrefix() + "/resourceExtensions.zip"), resourceExtensionsFile, 10000, 10000);
//find more resource packs //find more resource packs
File[] resourcePacks = resourcePackFolder.listFiles(); File[] resourcePacks = resourcePackFolder.listFiles();

View File

@ -74,7 +74,7 @@ public class Plugin {
private WebServerConfig webServerConfig; private WebServerConfig webServerConfig;
private PluginConfig pluginConfig; private PluginConfig pluginConfig;
private PluginStatus pluginStatus; private PluginState pluginState;
private Map<UUID, World> worlds; private Map<UUID, World> worlds;
private Map<String, BmMap> maps; private Map<String, BmMap> maps;
@ -122,15 +122,15 @@ public void load() throws IOException, ParseResourceException {
true true
)); ));
//load plugin status //load plugin state
try { try {
GsonConfigurationLoader loader = GsonConfigurationLoader.builder() GsonConfigurationLoader loader = GsonConfigurationLoader.builder()
.file(new File(getCoreConfig().getDataFolder(), "pluginStatus.json")) .file(new File(getCoreConfig().getDataFolder(), "pluginState.json"))
.build(); .build();
pluginStatus = loader.load().get(PluginStatus.class); pluginState = loader.load().get(PluginState.class);
} catch (SerializationException ex) { } catch (SerializationException ex) {
Logger.global.logWarning("Failed to load pluginStatus.json (invalid format), creating a new one..."); Logger.global.logWarning("Failed to load pluginState.json (invalid format), creating a new one...");
pluginStatus = new PluginStatus(); pluginState = new PluginState();
} }
//create and start webserver //create and start webserver
@ -183,13 +183,13 @@ public void load() throws IOException, ParseResourceException {
//update all maps //update all maps
for (BmMap map : maps.values()) { for (BmMap map : maps.values()) {
if (pluginStatus.getMapStatus(map).isUpdateEnabled()) { if (pluginState.getMapState(map).isUpdateEnabled()) {
renderManager.scheduleRenderTask(new MapUpdateTask(map)); renderManager.scheduleRenderTask(new MapUpdateTask(map));
} }
} }
//start render-manager //start render-manager
if (pluginStatus.isRenderThreadsEnabled()) { if (pluginState.isRenderThreadsEnabled()) {
renderManager.start(coreConfig.getRenderThreadCount()); renderManager.start(coreConfig.getRenderThreadCount());
} else { } else {
Logger.global.logInfo("Render-Threads are STOPPED! Use the command 'bluemap start' to start them."); Logger.global.logInfo("Render-Threads are STOPPED! Use the command 'bluemap start' to start them.");
@ -233,7 +233,7 @@ public void run() {
//watch map-changes //watch map-changes
this.regionFileWatchServices = new HashMap<>(); this.regionFileWatchServices = new HashMap<>();
for (BmMap map : maps.values()) { for (BmMap map : maps.values()) {
if (pluginStatus.getMapStatus(map).isUpdateEnabled()) { if (pluginState.getMapState(map).isUpdateEnabled()) {
startWatchingMap(map); startWatchingMap(map);
} }
} }
@ -302,7 +302,7 @@ public void unload() {
webServerConfig = null; webServerConfig = null;
pluginConfig = null; pluginConfig = null;
pluginStatus = null; pluginState = null;
//done //done
loaded = false; loaded = false;
@ -318,14 +318,14 @@ public void reload() throws IOException, ParseResourceException {
} }
public synchronized void save() { public synchronized void save() {
if (pluginStatus != null) { if (pluginState != null) {
try { try {
GsonConfigurationLoader loader = GsonConfigurationLoader.builder() GsonConfigurationLoader loader = GsonConfigurationLoader.builder()
.file(new File(getCoreConfig().getDataFolder(), "pluginStatus.json")) .file(new File(getCoreConfig().getDataFolder(), "pluginState.json"))
.build(); .build();
loader.save(loader.createNode().set(PluginStatus.class, pluginStatus)); loader.save(loader.createNode().set(PluginState.class, pluginState));
} catch (IOException ex) { } catch (IOException ex) {
Logger.global.logError("Failed to save pluginStatus.json!", ex); Logger.global.logError("Failed to save pluginState.json!", ex);
} }
} }
@ -379,8 +379,8 @@ public PluginConfig getPluginConfig() {
return pluginConfig; return pluginConfig;
} }
public PluginStatus getPluginStatus() { public PluginState getPluginState() {
return pluginStatus; return pluginState;
} }
public World getWorld(UUID uuid){ public World getWorld(UUID uuid){

View File

@ -32,10 +32,10 @@
@SuppressWarnings("FieldMayBeFinal") @SuppressWarnings("FieldMayBeFinal")
@ConfigSerializable @ConfigSerializable
public class PluginStatus { public class PluginState {
private boolean renderThreadsEnabled = true; private boolean renderThreadsEnabled = true;
private Map<String, MapStatus> maps = new HashMap<>(); private Map<String, MapState> maps = new HashMap<>();
public boolean isRenderThreadsEnabled() { public boolean isRenderThreadsEnabled() {
return renderThreadsEnabled; return renderThreadsEnabled;
@ -45,12 +45,12 @@ public void setRenderThreadsEnabled(boolean renderThreadsEnabled) {
this.renderThreadsEnabled = renderThreadsEnabled; this.renderThreadsEnabled = renderThreadsEnabled;
} }
public MapStatus getMapStatus(BmMap map) { public MapState getMapState(BmMap map) {
return maps.computeIfAbsent(map.getId(), k -> new MapStatus()); return maps.computeIfAbsent(map.getId(), k -> new MapState());
} }
@ConfigSerializable @ConfigSerializable
public static class MapStatus { public static class MapState {
private boolean updateEnabled = true; private boolean updateEnabled = true;

View File

@ -44,7 +44,7 @@
import de.bluecolored.bluemap.api.marker.MarkerSet; import de.bluecolored.bluemap.api.marker.MarkerSet;
import de.bluecolored.bluemap.api.marker.POIMarker; import de.bluecolored.bluemap.api.marker.POIMarker;
import de.bluecolored.bluemap.common.plugin.Plugin; import de.bluecolored.bluemap.common.plugin.Plugin;
import de.bluecolored.bluemap.common.plugin.PluginStatus; import de.bluecolored.bluemap.common.plugin.PluginState;
import de.bluecolored.bluemap.common.plugin.serverinterface.CommandSource; import de.bluecolored.bluemap.common.plugin.serverinterface.CommandSource;
import de.bluecolored.bluemap.common.plugin.text.Text; import de.bluecolored.bluemap.common.plugin.text.Text;
import de.bluecolored.bluemap.common.plugin.text.TextColor; import de.bluecolored.bluemap.common.plugin.text.TextColor;
@ -351,16 +351,19 @@ public int versionCommand(CommandContext<S> context) {
source.sendMessage(Text.of(TextFormat.BOLD, TextColor.BLUE, "Version: ", TextColor.WHITE, BlueMap.VERSION)); source.sendMessage(Text.of(TextFormat.BOLD, TextColor.BLUE, "Version: ", TextColor.WHITE, BlueMap.VERSION));
source.sendMessage(Text.of(TextColor.GRAY, "Implementation: ", TextColor.WHITE, plugin.getImplementationType())); source.sendMessage(Text.of(TextColor.GRAY, "Implementation: ", TextColor.WHITE, plugin.getImplementationType()));
source.sendMessage(Text.of(TextColor.GRAY, "Minecraft compatibility: ", TextColor.WHITE, plugin.getMinecraftVersion().getVersionString())); source.sendMessage(Text.of(
TextColor.GRAY, "Minecraft compatibility: ", TextColor.WHITE, plugin.getMinecraftVersion().getVersionString(),
TextColor.GRAY, " (" + plugin.getMinecraftVersion().getResource().getVersion().getVersionString() + ")"
));
source.sendMessage(Text.of(TextColor.GRAY, "Render-threads: ", TextColor.WHITE, renderThreadCount)); source.sendMessage(Text.of(TextColor.GRAY, "Render-threads: ", TextColor.WHITE, renderThreadCount));
source.sendMessage(Text.of(TextColor.GRAY, "Available processors: ", TextColor.WHITE, Runtime.getRuntime().availableProcessors())); source.sendMessage(Text.of(TextColor.GRAY, "Available processors: ", TextColor.WHITE, Runtime.getRuntime().availableProcessors()));
source.sendMessage(Text.of(TextColor.GRAY, "Available memory: ", TextColor.WHITE, (Runtime.getRuntime().maxMemory() / 1024L / 1024L) + " MiB")); source.sendMessage(Text.of(TextColor.GRAY, "Available memory: ", TextColor.WHITE, (Runtime.getRuntime().maxMemory() / 1024L / 1024L) + " MiB"));
if (plugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MC_1_15)) { if (plugin.getMinecraftVersion().isAtLeast(new MinecraftVersion(1, 15))) {
String clipboardValue = String clipboardValue =
"Version: " + BlueMap.VERSION + "\n" + "Version: " + BlueMap.VERSION + "\n" +
"Implementation: " + plugin.getImplementationType() + "\n" + "Implementation: " + plugin.getImplementationType() + "\n" +
"Minecraft compatibility: " + plugin.getMinecraftVersion().getVersionString() + "\n" + "Minecraft compatibility: " + plugin.getMinecraftVersion().getVersionString() + " (" + plugin.getMinecraftVersion().getResource().getVersion().getVersionString() + ")\n" +
"Render-threads: " + renderThreadCount + "\n" + "Render-threads: " + renderThreadCount + "\n" +
"Available processors: " + Runtime.getRuntime().availableProcessors() + "\n" + "Available processors: " + Runtime.getRuntime().availableProcessors() + "\n" +
"Available memory: " + Runtime.getRuntime().maxMemory() / 1024L / 1024L + " MiB"; "Available memory: " + Runtime.getRuntime().maxMemory() / 1024L / 1024L + " MiB";
@ -537,7 +540,7 @@ public int stopCommand(CommandContext<S> context) {
if (plugin.getRenderManager().isRunning()) { if (plugin.getRenderManager().isRunning()) {
new Thread(() -> { new Thread(() -> {
plugin.getPluginStatus().setRenderThreadsEnabled(false); plugin.getPluginState().setRenderThreadsEnabled(false);
plugin.getRenderManager().stop(); plugin.getRenderManager().stop();
source.sendMessage(Text.of(TextColor.GREEN, "Render-Threads stopped!")); source.sendMessage(Text.of(TextColor.GREEN, "Render-Threads stopped!"));
@ -557,7 +560,7 @@ public int startCommand(CommandContext<S> context) {
if (!plugin.getRenderManager().isRunning()) { if (!plugin.getRenderManager().isRunning()) {
new Thread(() -> { new Thread(() -> {
plugin.getPluginStatus().setRenderThreadsEnabled(true); plugin.getPluginState().setRenderThreadsEnabled(true);
plugin.getRenderManager().start(plugin.getCoreConfig().getRenderThreadCount()); plugin.getRenderManager().start(plugin.getCoreConfig().getRenderThreadCount());
source.sendMessage(Text.of(TextColor.GREEN, "Render-Threads started!")); source.sendMessage(Text.of(TextColor.GREEN, "Render-Threads started!"));
@ -584,10 +587,10 @@ public int freezeCommand(CommandContext<S> context) {
return 0; return 0;
} }
PluginStatus.MapStatus mapStatus = plugin.getPluginStatus().getMapStatus(map); PluginState.MapState mapState = plugin.getPluginState().getMapState(map);
if (mapStatus.isUpdateEnabled()) { if (mapState.isUpdateEnabled()) {
new Thread(() -> { new Thread(() -> {
mapStatus.setUpdateEnabled(false); mapState.setUpdateEnabled(false);
plugin.stopWatchingMap(map); plugin.stopWatchingMap(map);
plugin.getRenderManager().removeRenderTasksIf(task -> { plugin.getRenderManager().removeRenderTasksIf(task -> {
@ -625,10 +628,10 @@ public int unfreezeCommand(CommandContext<S> context) {
return 0; return 0;
} }
PluginStatus.MapStatus mapStatus = plugin.getPluginStatus().getMapStatus(map); PluginState.MapState mapState = plugin.getPluginState().getMapState(map);
if (!mapStatus.isUpdateEnabled()) { if (!mapState.isUpdateEnabled()) {
new Thread(() -> { new Thread(() -> {
mapStatus.setUpdateEnabled(true); mapState.setUpdateEnabled(true);
plugin.startWatchingMap(map); plugin.startWatchingMap(map);
plugin.getRenderManager().scheduleRenderTask(new MapUpdateTask(map)); plugin.getRenderManager().scheduleRenderTask(new MapUpdateTask(map));
@ -829,7 +832,7 @@ public int mapsCommand(CommandContext<S> context) {
source.sendMessage(Text.of(TextColor.BLUE, "Maps loaded by BlueMap:")); source.sendMessage(Text.of(TextColor.BLUE, "Maps loaded by BlueMap:"));
for (BmMap map : plugin.getMapTypes()) { for (BmMap map : plugin.getMapTypes()) {
boolean unfrozen = plugin.getPluginStatus().getMapStatus(map).isUpdateEnabled(); boolean unfrozen = plugin.getPluginState().getMapState(map).isUpdateEnabled();
if (unfrozen) { if (unfrozen) {
source.sendMessage(Text.of( source.sendMessage(Text.of(
TextColor.GRAY, " - ", TextColor.GRAY, " - ",

View File

@ -24,66 +24,150 @@
*/ */
package de.bluecolored.bluemap.core; package de.bluecolored.bluemap.core;
import de.bluecolored.bluemap.core.util.Lazy;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Objects;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public enum MinecraftVersion { public class MinecraftVersion implements Comparable<MinecraftVersion> {
MC_1_12 (101200, "1.12", "mc1_12", "https://launcher.mojang.com/v1/objects/0f275bc1547d01fa5f56ba34bdc87d981ee12daf/client.jar"),
MC_1_13 (101300, "1.13", "mc1_13", "https://launcher.mojang.com/v1/objects/30bfe37a8db404db11c7edf02cb5165817afb4d9/client.jar"),
MC_1_14 (101400, "1.14", "mc1_13", "https://launcher.mojang.com/v1/objects/8c325a0c5bd674dd747d6ebaa4c791fd363ad8a9/client.jar"),
MC_1_15 (101500, "1.15", "mc1_15", "https://launcher.mojang.com/v1/objects/e3f78cd16f9eb9a52307ed96ebec64241cc5b32d/client.jar"),
MC_1_16 (101600, "1.16", "mc1_16", "https://launcher.mojang.com/v1/objects/653e97a2d1d76f87653f02242d243cdee48a5144/client.jar");
private static final Pattern VERSION_REGEX = Pattern.compile("(?:(?<major>\\d+)\\.(?<minor>\\d+))(?:\\.(?<patch>\\d+))?(?:\\-(?:pre|rc)\\d+)?"); private static final Pattern VERSION_REGEX = Pattern.compile("(?:(?<major>\\d+)\\.(?<minor>\\d+))(?:\\.(?<patch>\\d+))?(?:\\-(?:pre|rc)\\d+)?");
private final int versionOrdinal; public static final MinecraftVersion LATEST_SUPPORTED = new MinecraftVersion(1, 16, 5);
private final String versionString; public static final MinecraftVersion EARLIEST_SUPPORTED = new MinecraftVersion(1, 12, 2);
private final String resourcePrefix; public static final MinecraftVersion THE_FLATTENING = new MinecraftVersion(1, 13);
private final String clientDownloadUrl;
private final int major, minor, patch;
MinecraftVersion(int versionOrdinal, String versionString, String resourcePrefix, String clientDownloadUrl) { private final Lazy<MinecraftResource> resource;
this.versionOrdinal = versionOrdinal;
this.versionString = versionString; public MinecraftVersion(int major, int minor) {
this.resourcePrefix = resourcePrefix; this(major, minor, 0);
this.clientDownloadUrl = clientDownloadUrl; }
public MinecraftVersion(int major, int minor, int patch) {
this.major = major;
this.minor = minor;
this.patch = patch;
this.resource = new Lazy<>(this::findBestMatchingResource);
} }
public String getVersionString() { public String getVersionString() {
return this.versionString; return major + "." + minor + "." + patch;
} }
public String getResourcePrefix() { public MinecraftResource getResource() {
return this.resourcePrefix; return this.resource.getValue();
}
public String getClientDownloadUrl() {
return this.clientDownloadUrl;
} }
public boolean isAtLeast(MinecraftVersion minVersion) { public boolean isAtLeast(MinecraftVersion minVersion) {
return this.versionOrdinal >= minVersion.versionOrdinal; return compareTo(minVersion) >= 0;
} }
public boolean isAtMost(MinecraftVersion maxVersion) { public boolean isAtMost(MinecraftVersion maxVersion) {
return this.versionOrdinal <= maxVersion.versionOrdinal; return compareTo(maxVersion) <= 0;
} }
public static MinecraftVersion fromVersionString(String versionString) { public boolean isBefore(MinecraftVersion minVersion) {
return compareTo(minVersion) < 0;
}
public boolean isAfter(MinecraftVersion minVersion) {
return compareTo(minVersion) > 0;
}
@Override
public int compareTo(MinecraftVersion other) {
int result;
result = Integer.compare(major, other.major);
if (result != 0) return result;
result = Integer.compare(minor, other.minor);
if (result != 0) return result;
result = Integer.compare(patch, other.patch);
return result;
}
public boolean majorEquals(MinecraftVersion that) {
return major == that.major;
}
public boolean minorEquals(MinecraftVersion that) {
return major == that.major && minor == that.minor;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MinecraftVersion that = (MinecraftVersion) o;
return major == that.major && minor == that.minor && patch == that.patch;
}
@Override
public int hashCode() {
return Objects.hash(major, minor, patch);
}
private MinecraftResource findBestMatchingResource() {
MinecraftResource[] resources = MinecraftResource.values();
Arrays.sort(resources, Comparator.comparing(MinecraftResource::getVersion).reversed());
for (MinecraftResource resource : resources){
if (isAtLeast(resource.version)) return resource;
}
return resources[resources.length - 1];
}
public static MinecraftVersion of(String versionString) {
Matcher matcher = VERSION_REGEX.matcher(versionString); Matcher matcher = VERSION_REGEX.matcher(versionString);
if (!matcher.matches()) throw new IllegalArgumentException("Not a valid version string!"); if (!matcher.matches()) throw new IllegalArgumentException("Not a valid version string!");
String normalizedVersionString = matcher.group("major") + "." + matcher.group("minor"); int major = Integer.parseInt(matcher.group("major"));
int minor = Integer.parseInt(matcher.group("minor"));
for (MinecraftVersion mcv : values()) { int patch = 0;
if (mcv.versionString.equals(normalizedVersionString)) return mcv; String patchString = matcher.group("patch");
} if (patchString != null) patch = Integer.parseInt(patchString);
throw new IllegalArgumentException("No matching version found!"); return new MinecraftVersion(major, minor, patch);
} }
public static MinecraftVersion getLatest() { public enum MinecraftResource {
return MC_1_16;
MC_1_12 (new MinecraftVersion(1, 12), "mc1_12", "https://launcher.mojang.com/v1/objects/0f275bc1547d01fa5f56ba34bdc87d981ee12daf/client.jar"),
MC_1_13 (new MinecraftVersion(1, 13), "mc1_13", "https://launcher.mojang.com/v1/objects/30bfe37a8db404db11c7edf02cb5165817afb4d9/client.jar"),
MC_1_14 (new MinecraftVersion(1, 14), "mc1_13", "https://launcher.mojang.com/v1/objects/8c325a0c5bd674dd747d6ebaa4c791fd363ad8a9/client.jar"),
MC_1_15 (new MinecraftVersion(1, 15), "mc1_15", "https://launcher.mojang.com/v1/objects/e3f78cd16f9eb9a52307ed96ebec64241cc5b32d/client.jar"),
MC_1_16 (new MinecraftVersion(1, 16), "mc1_16", "https://launcher.mojang.com/v1/objects/228fdf45541c4c2fe8aec4f20e880cb8fcd46621/client.jar"),
MC_1_16_2 (new MinecraftVersion(1, 16, 2), "mc1_16", "https://launcher.mojang.com/v1/objects/653e97a2d1d76f87653f02242d243cdee48a5144/client.jar");
private final MinecraftVersion version;
private final String resourcePrefix;
private final String clientUrl;
MinecraftResource(MinecraftVersion version, String resourcePrefix, String clientUrl) {
this.version = version;
this.resourcePrefix = resourcePrefix;
this.clientUrl = clientUrl;
}
public MinecraftVersion getVersion() {
return version;
}
public String getResourcePrefix() {
return resourcePrefix;
}
public String getClientUrl() {
return clientUrl;
}
} }
} }

View File

@ -30,7 +30,6 @@
import de.bluecolored.bluemap.core.resourcepack.ResourcePack; import de.bluecolored.bluemap.core.resourcepack.ResourcePack;
import de.bluecolored.bluemap.core.resourcepack.ResourcePack.Resource; import de.bluecolored.bluemap.core.resourcepack.ResourcePack.Resource;
import de.bluecolored.bluemap.core.util.FileUtils; import de.bluecolored.bluemap.core.util.FileUtils;
import de.bluecolored.bluemap.core.util.Preconditions;
import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.gson.GsonConfigurationLoader; import org.spongepowered.configurate.gson.GsonConfigurationLoader;
import org.spongepowered.configurate.hocon.HoconConfigurationLoader; import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
@ -120,7 +119,7 @@ public ConfigurationNode loadOrCreate(File configFile, URL defaultConfig, URL de
public void loadResourceConfigs(File configFolder, ResourcePack resourcePack) throws IOException { public void loadResourceConfigs(File configFolder, ResourcePack resourcePack) throws IOException {
//load blockColors.json from resources, config-folder and resourcepack //load blockColors.json from resources, config-folder and resourcepack
URL blockColorsConfigUrl = BlueMap.class.getResource("/de/bluecolored/bluemap/" + resourcePack.getMinecraftVersion().getResourcePrefix() + "/blockColors.json"); URL blockColorsConfigUrl = BlueMap.class.getResource("/de/bluecolored/bluemap/" + resourcePack.getMinecraftVersion().getResource().getResourcePrefix() + "/blockColors.json");
File blockColorsConfigFile = new File(configFolder, "blockColors.json"); File blockColorsConfigFile = new File(configFolder, "blockColors.json");
ConfigurationNode blockColorsConfigNode = loadOrCreate( ConfigurationNode blockColorsConfigNode = loadOrCreate(
blockColorsConfigFile, blockColorsConfigFile,
@ -133,7 +132,7 @@ public void loadResourceConfigs(File configFolder, ResourcePack resourcePack) th
resourcePack.getBlockColorCalculator().loadColorConfig(blockColorsConfigNode); resourcePack.getBlockColorCalculator().loadColorConfig(blockColorsConfigNode);
//load blockIds.json from resources, config-folder and resourcepack //load blockIds.json from resources, config-folder and resourcepack
URL blockIdsConfigUrl = BlueMap.class.getResource("/de/bluecolored/bluemap/" + resourcePack.getMinecraftVersion().getResourcePrefix() + "/blockIds.json"); URL blockIdsConfigUrl = BlueMap.class.getResource("/de/bluecolored/bluemap/" + resourcePack.getMinecraftVersion().getResource().getResourcePrefix() + "/blockIds.json");
File blockIdsConfigFile = new File(configFolder, "blockIds.json"); File blockIdsConfigFile = new File(configFolder, "blockIds.json");
ConfigurationNode blockIdsConfigNode = loadOrCreate( ConfigurationNode blockIdsConfigNode = loadOrCreate(
blockIdsConfigFile, blockIdsConfigFile,
@ -148,7 +147,7 @@ public void loadResourceConfigs(File configFolder, ResourcePack resourcePack) th
); );
//load blockProperties.json from resources, config-folder and resourcepack //load blockProperties.json from resources, config-folder and resourcepack
URL blockPropertiesConfigUrl = BlueMap.class.getResource("/de/bluecolored/bluemap/" + resourcePack.getMinecraftVersion().getResourcePrefix() + "/blockProperties.json"); URL blockPropertiesConfigUrl = BlueMap.class.getResource("/de/bluecolored/bluemap/" + resourcePack.getMinecraftVersion().getResource().getResourcePrefix() + "/blockProperties.json");
File blockPropertiesConfigFile = new File(configFolder, "blockProperties.json"); File blockPropertiesConfigFile = new File(configFolder, "blockProperties.json");
ConfigurationNode blockPropertiesConfigNode = loadOrCreate( ConfigurationNode blockPropertiesConfigNode = loadOrCreate(
blockPropertiesConfigFile, blockPropertiesConfigFile,
@ -164,7 +163,7 @@ public void loadResourceConfigs(File configFolder, ResourcePack resourcePack) th
); );
//load biomes.json from resources, config-folder and resourcepack //load biomes.json from resources, config-folder and resourcepack
URL biomeConfigUrl = BlueMap.class.getResource("/de/bluecolored/bluemap/" + resourcePack.getMinecraftVersion().getResourcePrefix() + "/biomes.json"); URL biomeConfigUrl = BlueMap.class.getResource("/de/bluecolored/bluemap/" + resourcePack.getMinecraftVersion().getResource().getResourcePrefix() + "/biomes.json");
File biomeConfigFile = new File(configFolder, "biomes.json"); File biomeConfigFile = new File(configFolder, "biomes.json");
ConfigurationNode biomeConfigNode = loadOrCreate( ConfigurationNode biomeConfigNode = loadOrCreate(
biomeConfigFile, biomeConfigFile,

View File

@ -27,6 +27,7 @@
import com.flowpowered.math.vector.Vector3f; import com.flowpowered.math.vector.Vector3f;
import com.flowpowered.math.vector.Vector3i; import com.flowpowered.math.vector.Vector3i;
import com.flowpowered.math.vector.Vector4f; import com.flowpowered.math.vector.Vector4f;
import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.map.hires.blockmodel.BlockStateModel; import de.bluecolored.bluemap.core.map.hires.blockmodel.BlockStateModel;
import de.bluecolored.bluemap.core.map.hires.blockmodel.BlockStateModelFactory; import de.bluecolored.bluemap.core.map.hires.blockmodel.BlockStateModelFactory;
import de.bluecolored.bluemap.core.resourcepack.NoSuchResourceException; import de.bluecolored.bluemap.core.resourcepack.NoSuchResourceException;
@ -46,14 +47,11 @@ public class HiresModelRenderer {
public HiresModelRenderer(ResourcePack resourcePack, RenderSettings renderSettings) { public HiresModelRenderer(ResourcePack resourcePack, RenderSettings renderSettings) {
this.renderSettings = renderSettings; this.renderSettings = renderSettings;
this.modelFactory = new BlockStateModelFactory(resourcePack, renderSettings); this.modelFactory = new BlockStateModelFactory(resourcePack, renderSettings);
switch (resourcePack.getMinecraftVersion()) { if (resourcePack.getMinecraftVersion().isBefore(MinecraftVersion.THE_FLATTENING)) {
case MC_1_12: grassId = "minecraft:tall_grass";
grassId = "minecraft:tall_grass"; } else {
break; grassId = "minecraft:grass";
default:
grassId = "minecraft:grass";
break;
} }
} }

View File

@ -56,18 +56,20 @@ public class LiquidModelBuilder {
"minecraft:bubble_column" "minecraft:bubble_column"
)); ));
private BlockState liquidBlockState; private final BlockState liquidBlockState;
private Block block; private final Block block;
private MinecraftVersion minecraftVersion; private final RenderSettings renderSettings;
private RenderSettings renderSettings; private final BlockColorCalculator colorCalculator;
private BlockColorCalculator colorCalculator;
private final boolean useWaterColorMap;
public LiquidModelBuilder(Block block, BlockState liquidBlockState, MinecraftVersion minecraftVersion, RenderSettings renderSettings, BlockColorCalculator colorCalculator) { public LiquidModelBuilder(Block block, BlockState liquidBlockState, MinecraftVersion minecraftVersion, RenderSettings renderSettings, BlockColorCalculator colorCalculator) {
this.block = block; this.block = block;
this.minecraftVersion = minecraftVersion;
this.renderSettings = renderSettings; this.renderSettings = renderSettings;
this.liquidBlockState = liquidBlockState; this.liquidBlockState = liquidBlockState;
this.colorCalculator = colorCalculator; this.colorCalculator = colorCalculator;
this.useWaterColorMap = minecraftVersion.isAtLeast(new MinecraftVersion(1, 13));
} }
public BlockStateModel build(TransformedBlockModelResource bmr) { public BlockStateModel build(TransformedBlockModelResource bmr) {
@ -108,7 +110,7 @@ public BlockStateModel build(BlockModelResource bmr) {
int textureId = texture.getId(); int textureId = texture.getId();
Vector3f tintcolor = Vector3f.ONE; Vector3f tintcolor = Vector3f.ONE;
if (minecraftVersion != MinecraftVersion.MC_1_12 && liquidBlockState.getFullId().equals("minecraft:water")) { if (useWaterColorMap && liquidBlockState.getFullId().equals("minecraft:water")) {
tintcolor = colorCalculator.getWaterAverageColor(block); tintcolor = colorCalculator.getWaterAverageColor(block);
} }

View File

@ -37,13 +37,11 @@
import java.util.Set; import java.util.Set;
public class DoorExtension implements BlockStateExtension { public class DoorExtension implements BlockStateExtension {
private final Set<String> affectedBlockIds; private final Set<String> affectedBlockIds;
public DoorExtension(MinecraftVersion version) { public DoorExtension(MinecraftVersion version) {
switch (version) { if (version.isBefore(MinecraftVersion.THE_FLATTENING)) {
case MC_1_12: affectedBlockIds = new HashSet<>(Arrays.asList(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:wooden_door", "minecraft:wooden_door",
"minecraft:iron_door", "minecraft:iron_door",
"minecraft:spruce_door", "minecraft:spruce_door",
@ -51,10 +49,9 @@ public DoorExtension(MinecraftVersion version) {
"minecraft:jungle_door", "minecraft:jungle_door",
"minecraft:acacia_door", "minecraft:acacia_door",
"minecraft:dark_oak_door" "minecraft:dark_oak_door"
)); ));
break; } else {
default: affectedBlockIds = new HashSet<>(Arrays.asList(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:oak_door", "minecraft:oak_door",
"minecraft:iron_door", "minecraft:iron_door",
"minecraft:spruce_door", "minecraft:spruce_door",
@ -62,8 +59,7 @@ public DoorExtension(MinecraftVersion version) {
"minecraft:jungle_door", "minecraft:jungle_door",
"minecraft:acacia_door", "minecraft:acacia_door",
"minecraft:dark_oak_door" "minecraft:dark_oak_door"
)); ));
break;
} }
} }

View File

@ -30,32 +30,25 @@
import de.bluecolored.bluemap.core.util.Direction; import de.bluecolored.bluemap.core.util.Direction;
import de.bluecolored.bluemap.core.world.BlockState; import de.bluecolored.bluemap.core.world.BlockState;
import java.util.Arrays; import java.util.*;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
public class DoublePlantExtension implements BlockStateExtension { public class DoublePlantExtension implements BlockStateExtension {
private final Set<String> affectedBlockIds; private final Set<String> affectedBlockIds;
public DoublePlantExtension(MinecraftVersion version) { public DoublePlantExtension(MinecraftVersion version) {
switch (version) { if (version.isBefore(MinecraftVersion.THE_FLATTENING)) {
case MC_1_12: affectedBlockIds = new HashSet<>(Collections.singletonList(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:double_plant" "minecraft:double_plant"
)); ));
break; } else {
default: affectedBlockIds = new HashSet<>(Arrays.asList(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:sunflower", "minecraft:sunflower",
"minecraft:lilac", "minecraft:lilac",
"minecraft:tall_grass", "minecraft:tall_grass",
"minecraft:large_fern", "minecraft:large_fern",
"minecraft:rose_bush", "minecraft:rose_bush",
"minecraft:peony" "minecraft:peony"
)); ));
break;
} }
} }

View File

@ -41,23 +41,20 @@ public class SnowyExtension implements BlockStateExtension {
private final String snowBlockId; private final String snowBlockId;
public SnowyExtension(MinecraftVersion version) { public SnowyExtension(MinecraftVersion version) {
switch (version) { if (version.isBefore(MinecraftVersion.THE_FLATTENING)) {
case MC_1_12: affectedBlockIds = new HashSet<>(Arrays.asList(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:grass", "minecraft:grass",
"minecraft:mycelium" "minecraft:mycelium"
)); ));
snowLayerId = "minecraft:snow_layer"; snowLayerId = "minecraft:snow_layer";
snowBlockId = "minecraft:snow"; snowBlockId = "minecraft:snow";
break; } else {
default: affectedBlockIds = new HashSet<>(Arrays.asList(
affectedBlockIds = new HashSet<>(Arrays.asList( "minecraft:grass_block",
"minecraft:grass_block", "minecraft:podzol"
"minecraft:podzol" ));
)); snowLayerId = "minecraft:snow";
snowLayerId = "minecraft:snow"; snowBlockId = "minecraft:snow_block";
snowBlockId = "minecraft:snow_block";
break;
} }
} }

View File

@ -35,27 +35,24 @@ public class WoodenFenceConnectExtension extends ConnectSameOrFullBlockExtension
private final Set<String> affectedBlockIds; private final Set<String> affectedBlockIds;
public WoodenFenceConnectExtension(MinecraftVersion version) { public WoodenFenceConnectExtension(MinecraftVersion version) {
switch (version) { if (version.isBefore(MinecraftVersion.THE_FLATTENING)) {
case MC_1_12: affectedBlockIds = new HashSet<>(Arrays.asList(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:fence", "minecraft:fence",
"minecraft:spruce_fence", "minecraft:spruce_fence",
"minecraft:birch_fence", "minecraft:birch_fence",
"minecraft:jungle_fence", "minecraft:jungle_fence",
"minecraft:dark_oak_fence", "minecraft:dark_oak_fence",
"minecraft:acacia_fence" "minecraft:acacia_fence"
)); ));
break; } else {
default: affectedBlockIds = new HashSet<>(Arrays.asList(
affectedBlockIds = new HashSet<>(Arrays.asList(
"minecraft:oak_fence", "minecraft:oak_fence",
"minecraft:spruce_fence", "minecraft:spruce_fence",
"minecraft:birch_fence", "minecraft:birch_fence",
"minecraft:jungle_fence", "minecraft:jungle_fence",
"minecraft:dark_oak_fence", "minecraft:dark_oak_fence",
"minecraft:acacia_fence" "minecraft:acacia_fence"
)); ));
break;
} }
} }

View File

@ -26,6 +26,7 @@
import com.flowpowered.math.vector.Vector2f; import com.flowpowered.math.vector.Vector2f;
import com.flowpowered.math.vector.Vector3i; import com.flowpowered.math.vector.Vector3i;
import de.bluecolored.bluemap.core.MinecraftVersion;
import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.logger.Logger;
import de.bluecolored.bluemap.core.resourcepack.PropertyCondition.All; import de.bluecolored.bluemap.core.resourcepack.PropertyCondition.All;
import de.bluecolored.bluemap.core.resourcepack.fileaccess.FileAccess; import de.bluecolored.bluemap.core.resourcepack.fileaccess.FileAccess;
@ -44,7 +45,9 @@
import java.util.Map.Entry; import java.util.Map.Entry;
public class BlockStateResource { public class BlockStateResource {
private static final MinecraftVersion NEW_MODEL_PATH_VERSION = new MinecraftVersion(1, 13);
private final List<Variant> variants = new ArrayList<>(0); private final List<Variant> variants = new ArrayList<>(0);
private final Collection<Variant> multipart = new ArrayList<>(0); private final Collection<Variant> multipart = new ArrayList<>(0);
@ -242,13 +245,10 @@ private Weighted<TransformedBlockModelResource> loadModel(ConfigurationNode node
String modelPath; String modelPath;
switch (resourcePack.getMinecraftVersion()) { if (resourcePack.getMinecraftVersion().isBefore(NEW_MODEL_PATH_VERSION)) {
case MC_1_12: modelPath = ResourcePack.namespacedToAbsoluteResourcePath(namespacedModelPath, "models/block") + ".json";
modelPath = ResourcePack.namespacedToAbsoluteResourcePath(namespacedModelPath, "models/block") + ".json"; }else {
break; modelPath = ResourcePack.namespacedToAbsoluteResourcePath(namespacedModelPath, "models") + ".json";
default:
modelPath = ResourcePack.namespacedToAbsoluteResourcePath(namespacedModelPath, "models") + ".json";
break;
} }
BlockModelResource model = resourcePack.blockModelResources.get(modelPath); BlockModelResource model = resourcePack.blockModelResources.get(modelPath);

View File

@ -44,6 +44,7 @@ public Lazy(T value) {
public T getValue() { public T getValue() {
if (!isLoaded()) { if (!isLoaded()) {
this.value = loader.get(); this.value = loader.get();
this.loader = null;
} }
return this.value; return this.value;

View File

@ -210,11 +210,11 @@ public static void main(String[] args) {
} }
//minecraft version //minecraft version
MinecraftVersion version = MinecraftVersion.getLatest(); MinecraftVersion version = MinecraftVersion.LATEST_SUPPORTED;
if (cmd.hasOption("v")) { if (cmd.hasOption("v")) {
String versionString = cmd.getOptionValue("v"); String versionString = cmd.getOptionValue("v");
try { try {
version = MinecraftVersion.fromVersionString(versionString); version = MinecraftVersion.of(versionString);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Logger.global.logWarning("Could not determine a version from the provided version-string: '" + versionString + "'"); Logger.global.logWarning("Could not determine a version from the provided version-string: '" + versionString + "'");
System.exit(1); System.exit(1);

View File

@ -24,24 +24,8 @@
*/ */
package de.bluecolored.bluemap.fabric; package de.bluecolored.bluemap.fabric;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import org.apache.logging.log4j.LogManager;
import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache; import com.github.benmanes.caffeine.cache.LoadingCache;
import de.bluecolored.bluemap.common.plugin.Plugin; import de.bluecolored.bluemap.common.plugin.Plugin;
import de.bluecolored.bluemap.common.plugin.commands.Commands; import de.bluecolored.bluemap.common.plugin.commands.Commands;
import de.bluecolored.bluemap.common.plugin.serverinterface.Player; import de.bluecolored.bluemap.common.plugin.serverinterface.Player;
@ -60,6 +44,14 @@
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import org.apache.logging.log4j.LogManager;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
public class FabricMod implements ModInitializer, ServerInterface { public class FabricMod implements ModInitializer, ServerInterface {
@ -81,7 +73,7 @@ public FabricMod() {
this.onlinePlayerMap = new ConcurrentHashMap<>(); this.onlinePlayerMap = new ConcurrentHashMap<>();
this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>()); this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>());
pluginInstance = new Plugin(MinecraftVersion.MC_1_15, "fabric-1.15.2", this); pluginInstance = new Plugin(new MinecraftVersion(1, 15, 2), "fabric-1.15.2", this);
this.worldUUIDs = new ConcurrentHashMap<>(); this.worldUUIDs = new ConcurrentHashMap<>();
this.eventForwarder = new FabricEventForwarder(this); this.eventForwarder = new FabricEventForwarder(this);

View File

@ -24,24 +24,8 @@
*/ */
package de.bluecolored.bluemap.fabric; package de.bluecolored.bluemap.fabric;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import org.apache.logging.log4j.LogManager;
import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache; import com.github.benmanes.caffeine.cache.LoadingCache;
import de.bluecolored.bluemap.common.plugin.Plugin; import de.bluecolored.bluemap.common.plugin.Plugin;
import de.bluecolored.bluemap.common.plugin.commands.Commands; import de.bluecolored.bluemap.common.plugin.commands.Commands;
import de.bluecolored.bluemap.common.plugin.serverinterface.Player; import de.bluecolored.bluemap.common.plugin.serverinterface.Player;
@ -62,6 +46,14 @@
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.WorldSavePath; import net.minecraft.util.WorldSavePath;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.dimension.DimensionType;
import org.apache.logging.log4j.LogManager;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
public class FabricMod implements ModInitializer, ServerInterface { public class FabricMod implements ModInitializer, ServerInterface {
@ -83,7 +75,7 @@ public FabricMod() {
this.onlinePlayerMap = new ConcurrentHashMap<>(); this.onlinePlayerMap = new ConcurrentHashMap<>();
this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>()); this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>());
pluginInstance = new Plugin(MinecraftVersion.MC_1_16, "fabric-1.16.1", this); pluginInstance = new Plugin(new MinecraftVersion(1, 16, 1), "fabric-1.16.1", this);
this.worldUUIDs = new ConcurrentHashMap<>(); this.worldUUIDs = new ConcurrentHashMap<>();
this.eventForwarder = new FabricEventForwarder(this); this.eventForwarder = new FabricEventForwarder(this);

View File

@ -24,24 +24,8 @@
*/ */
package de.bluecolored.bluemap.fabric; package de.bluecolored.bluemap.fabric;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import org.apache.logging.log4j.LogManager;
import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache; import com.github.benmanes.caffeine.cache.LoadingCache;
import de.bluecolored.bluemap.common.plugin.Plugin; import de.bluecolored.bluemap.common.plugin.Plugin;
import de.bluecolored.bluemap.common.plugin.commands.Commands; import de.bluecolored.bluemap.common.plugin.commands.Commands;
import de.bluecolored.bluemap.common.plugin.serverinterface.Player; import de.bluecolored.bluemap.common.plugin.serverinterface.Player;
@ -62,6 +46,14 @@
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.WorldSavePath; import net.minecraft.util.WorldSavePath;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.dimension.DimensionType;
import org.apache.logging.log4j.LogManager;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
public class FabricMod implements ModInitializer, ServerInterface { public class FabricMod implements ModInitializer, ServerInterface {
@ -83,7 +75,7 @@ public FabricMod() {
this.onlinePlayerMap = new ConcurrentHashMap<>(); this.onlinePlayerMap = new ConcurrentHashMap<>();
this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>()); this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>());
pluginInstance = new Plugin(MinecraftVersion.MC_1_16, "fabric-1.16.2", this); pluginInstance = new Plugin(new MinecraftVersion(1, 16, 2), "fabric-1.16.2", this);
this.worldUUIDs = new ConcurrentHashMap<>(); this.worldUUIDs = new ConcurrentHashMap<>();
this.eventForwarder = new FabricEventForwarder(this); this.eventForwarder = new FabricEventForwarder(this);

View File

@ -78,7 +78,7 @@ public ForgeMod() {
this.onlinePlayerMap = new ConcurrentHashMap<>(); this.onlinePlayerMap = new ConcurrentHashMap<>();
this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>()); this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>());
this.pluginInstance = new Plugin(MinecraftVersion.MC_1_14, "forge-1.14.4", this); this.pluginInstance = new Plugin(new MinecraftVersion(1, 14, 4), "forge-1.14.4", this);
this.worldUUIDs = new ConcurrentHashMap<>(); this.worldUUIDs = new ConcurrentHashMap<>();
this.eventForwarder = new ForgeEventForwarder(); this.eventForwarder = new ForgeEventForwarder();

View File

@ -78,7 +78,7 @@ public ForgeMod() {
this.onlinePlayerMap = new ConcurrentHashMap<>(); this.onlinePlayerMap = new ConcurrentHashMap<>();
this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>()); this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>());
this.pluginInstance = new Plugin(MinecraftVersion.MC_1_15, "forge-1.15.2", this); this.pluginInstance = new Plugin(new MinecraftVersion(1, 15, 2), "forge-1.15.2", this);
this.worldUUIDs = new ConcurrentHashMap<>(); this.worldUUIDs = new ConcurrentHashMap<>();
this.eventForwarder = new ForgeEventForwarder(); this.eventForwarder = new ForgeEventForwarder();

View File

@ -80,7 +80,7 @@ public ForgeMod() {
this.onlinePlayerMap = new ConcurrentHashMap<>(); this.onlinePlayerMap = new ConcurrentHashMap<>();
this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>()); this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>());
this.pluginInstance = new Plugin(MinecraftVersion.MC_1_16, "forge-1.16.2", this); this.pluginInstance = new Plugin(new MinecraftVersion(1, 16, 2), "forge-1.16.2", this);
this.worldUUIDs = new ConcurrentHashMap<>(); this.worldUUIDs = new ConcurrentHashMap<>();
this.eventForwarder = new ForgeEventForwarder(); this.eventForwarder = new ForgeEventForwarder();

View File

@ -69,14 +69,14 @@ public class BukkitPlugin extends JavaPlugin implements ServerInterface, Listene
public BukkitPlugin() { public BukkitPlugin() {
Logger.global = new JavaLogger(getLogger()); Logger.global = new JavaLogger(getLogger());
MinecraftVersion version = MinecraftVersion.getLatest(); MinecraftVersion version = MinecraftVersion.LATEST_SUPPORTED;
//try to get best matching minecraft-version //try to get best matching minecraft-version
try { try {
String versionString = getServer().getBukkitVersion(); String versionString = getServer().getBukkitVersion();
Matcher versionMatcher = Pattern.compile("(\\d+\\.\\d+\\.\\d+)[-_].*").matcher(versionString); Matcher versionMatcher = Pattern.compile("(\\d+\\.\\d+\\.\\d+)[-_].*").matcher(versionString);
if (!versionMatcher.matches()) throw new IllegalArgumentException(); if (!versionMatcher.matches()) throw new IllegalArgumentException();
version = MinecraftVersion.fromVersionString(versionMatcher.group(1)); version = MinecraftVersion.of(versionMatcher.group(1));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Logger.global.logWarning("Failed to detect the minecraft version of this server! Using latest version: " + version.getVersionString()); Logger.global.logWarning("Failed to detect the minecraft version of this server! Using latest version: " + version.getVersionString());
} }

View File

@ -86,14 +86,14 @@ public SpongePlugin(org.slf4j.Logger logger, Metrics.Factory metricsFactory) {
this.onlinePlayerMap = new ConcurrentHashMap<>(); this.onlinePlayerMap = new ConcurrentHashMap<>();
this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>()); this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>());
MinecraftVersion version = MinecraftVersion.MC_1_12; MinecraftVersion version = new MinecraftVersion(1, 12);
try { try {
version = MinecraftVersion.fromVersionString(Sponge.getPlatform().getMinecraftVersion().getName()); version = MinecraftVersion.of(Sponge.getPlatform().getMinecraftVersion().getName());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Logger.global.logWarning("Failed to find a matching version for version-name '" + Sponge.getPlatform().getMinecraftVersion().getName() + "'! Using latest known sponge-version: " + version.getVersionString()); Logger.global.logWarning("Failed to find a matching version for version-name '" + Sponge.getPlatform().getMinecraftVersion().getName() + "'! Using latest known sponge-version: " + version.getVersionString());
} }
this.pluginInstance = new Plugin(version, "sponge", this); this.pluginInstance = new Plugin(version, "sponge-7.2.0", this);
this.commands = new SpongeCommands(pluginInstance); this.commands = new SpongeCommands(pluginInstance);
//bstats //bstats

View File

@ -93,14 +93,14 @@ public SpongePlugin(org.apache.logging.log4j.Logger logger, PluginContainer plug
this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>()); this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>());
final String versionFromSponge = Sponge.platform().container(Platform.Component.GAME).metadata().version(); final String versionFromSponge = Sponge.platform().container(Platform.Component.GAME).metadata().version();
MinecraftVersion version = MinecraftVersion.MC_1_16; MinecraftVersion version = new MinecraftVersion(1, 16);
try { try {
version = MinecraftVersion.fromVersionString(versionFromSponge); version = MinecraftVersion.of(versionFromSponge);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Logger.global.logWarning("Failed to find a matching version for version-name '" + versionFromSponge + "'! Using latest known sponge-version: " + version.getVersionString()); Logger.global.logWarning("Failed to find a matching version for version-name '" + versionFromSponge + "'! Using latest known sponge-version: " + version.getVersionString());
} }
this.pluginInstance = new Plugin(version, "sponge", this); this.pluginInstance = new Plugin(version, "sponge-8.0.0", this);
this.commands = new SpongeCommands(pluginInstance); this.commands = new SpongeCommands(pluginInstance);
//bstats //bstats