mirror of
https://github.com/BG-Software-LLC/WildLoaders.git
synced 2025-02-08 00:11:21 +01:00
Changed mappings checking to be done against a remote server instead of hardcoded values
This commit is contained in:
parent
1574f86914
commit
c0829d8e19
@ -53,6 +53,7 @@ dependencies {
|
||||
|
||||
implementation 'com.bgsoftware.common.reflection:ReflectionUtils:latest'
|
||||
implementation 'com.bgsoftware.common.config:CommentedConfiguration:1.0.3'
|
||||
implementation 'com.bgsoftware.common.mappings:MappingsChecker:1.0.0'
|
||||
|
||||
// Spigot jars
|
||||
compileOnly "org.spigotmc:v1_8_R3:latest"
|
||||
@ -68,7 +69,7 @@ jar {
|
||||
}
|
||||
|
||||
processResources {
|
||||
outputs.upToDateWhen {false}
|
||||
outputs.upToDateWhen { false }
|
||||
String versionNumber = System.getenv("BUILD_NUMBER") == null ? version : version + "." + System.getenv("BUILD_NUMBER")
|
||||
eachFile { details ->
|
||||
if (details.name.contentEquals('plugin.yml')) {
|
||||
@ -82,10 +83,9 @@ processResources {
|
||||
shadowJar {
|
||||
dependsOn(jar)
|
||||
|
||||
if(System.getenv("BUILD_NUMBER") == null){
|
||||
if (System.getenv("BUILD_NUMBER") == null) {
|
||||
archiveName = rootProject.name + "-" + version + ".jar"
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
archiveName = rootProject.name + "-" + version + "-b" + System.getenv("BUILD_NUMBER") + ".jar"
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.bgsoftware.wildloaders;
|
||||
|
||||
import com.bgsoftware.common.mappings.MappingsChecker;
|
||||
import com.bgsoftware.wildloaders.api.WildLoaders;
|
||||
import com.bgsoftware.wildloaders.api.WildLoadersAPI;
|
||||
import com.bgsoftware.wildloaders.command.CommandsHandler;
|
||||
@ -13,10 +14,12 @@ import com.bgsoftware.wildloaders.listeners.ChunksListener;
|
||||
import com.bgsoftware.wildloaders.listeners.PlayersListener;
|
||||
import com.bgsoftware.wildloaders.metrics.Metrics;
|
||||
import com.bgsoftware.wildloaders.nms.NMSAdapter;
|
||||
import com.bgsoftware.wildloaders.nms.mapping.TestRemaps;
|
||||
import com.bgsoftware.wildloaders.utils.database.Database;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public final class WildLoadersPlugin extends JavaPlugin implements WildLoaders {
|
||||
@ -38,7 +41,7 @@ public final class WildLoadersPlugin extends JavaPlugin implements WildLoaders {
|
||||
plugin = this;
|
||||
new Metrics(this);
|
||||
|
||||
loadNMSAdapter();
|
||||
shouldEnable = loadNMSAdapter();
|
||||
loadAPI();
|
||||
|
||||
if (!shouldEnable)
|
||||
@ -89,19 +92,34 @@ public final class WildLoadersPlugin extends JavaPlugin implements WildLoaders {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadNMSAdapter() {
|
||||
private boolean loadNMSAdapter() {
|
||||
String version = getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
try {
|
||||
nmsAdapter = (NMSAdapter) Class.forName(String.format("com.bgsoftware.wildloaders.nms.%s.NMSAdapter", version)).newInstance();
|
||||
if (!nmsAdapter.isMappingsSupported()) {
|
||||
log("WildLoaders does not support your version mappings... Please contact @Ome_R");
|
||||
shouldEnable = false;
|
||||
|
||||
String mappingVersionHash = nmsAdapter.getMappingsHash();
|
||||
|
||||
if (mappingVersionHash != null && !MappingsChecker.checkMappings(mappingVersionHash, version)) {
|
||||
log("WildStacker does not support your version mappings... Please contact @Ome_R");
|
||||
log("Your mappings version: " + mappingVersionHash);
|
||||
return false;
|
||||
}
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
|
||||
shouldEnable = false;
|
||||
log("Couldn't load up with an adapter " + version + ". Please contact @Ome_R");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
File mappingsFile = new File("mappings");
|
||||
if (mappingsFile.exists()) {
|
||||
try {
|
||||
TestRemaps.testRemapsForClassesInPackage(mappingsFile,
|
||||
plugin.getClassLoader(), "com.bgsoftware.wildloaders.nms." + version);
|
||||
} catch (Exception error) {
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void loadAPI() {
|
||||
|
@ -6,11 +6,13 @@ import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface NMSAdapter {
|
||||
|
||||
boolean isMappingsSupported();
|
||||
@Nullable
|
||||
String getMappingsHash();
|
||||
|
||||
String getTag(ItemStack itemStack, String key, String def);
|
||||
|
||||
|
@ -32,8 +32,8 @@ public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapt
|
||||
private static final ReflectMethod<Void> TILE_ENTITY_LOAD = new ReflectMethod<>(TileEntity.class, "load", NBTTagCompound.class);
|
||||
|
||||
@Override
|
||||
public boolean isMappingsSupported() {
|
||||
return true;
|
||||
public String getMappingsHash() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,8 +30,8 @@ public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapt
|
||||
private static final WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
|
||||
|
||||
@Override
|
||||
public boolean isMappingsSupported() {
|
||||
return true;
|
||||
public String getMappingsHash() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,11 +39,9 @@ public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapt
|
||||
private static final ReflectMethod<TickingBlockEntity> CREATE_TICKING_BLOCK = new ReflectMethod<>(
|
||||
Chunk.class, "a", TileEntity.class, BlockEntityTicker.class);
|
||||
|
||||
private static final String BUILT_AGAINST_MAPPING = "acd6e6c27e5a0a9440afba70a96c27c9";
|
||||
|
||||
@Override
|
||||
public boolean isMappingsSupported() {
|
||||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion().equals(BUILT_AGAINST_MAPPING);
|
||||
public String getMappingsHash() {
|
||||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,11 +40,9 @@ public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapt
|
||||
net.minecraft.world.level.chunk.Chunk.class, "a",
|
||||
net.minecraft.world.level.block.entity.TileEntity.class, BlockEntityTicker.class);
|
||||
|
||||
private static final String BUILT_AGAINST_MAPPING = "20b026e774dbf715e40a0b2afe114792";
|
||||
|
||||
@Override
|
||||
public boolean isMappingsSupported() {
|
||||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion().equals(BUILT_AGAINST_MAPPING);
|
||||
public String getMappingsHash() {
|
||||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,11 +40,9 @@ public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapt
|
||||
net.minecraft.world.level.chunk.Chunk.class, "a",
|
||||
net.minecraft.world.level.block.entity.TileEntity.class, BlockEntityTicker.class);
|
||||
|
||||
private static final String BUILT_AGAINST_MAPPING = "eaeedbff51b16ead3170906872fda334";
|
||||
|
||||
@Override
|
||||
public boolean isMappingsSupported() {
|
||||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion().equals(BUILT_AGAINST_MAPPING);
|
||||
public String getMappingsHash() {
|
||||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,11 +40,9 @@ public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapt
|
||||
net.minecraft.world.level.chunk.Chunk.class, "a",
|
||||
net.minecraft.world.level.block.entity.TileEntity.class, BlockEntityTicker.class);
|
||||
|
||||
private static final String BUILT_AGAINST_MAPPING = "4cc0cc97cac491651bff3af8b124a214";
|
||||
|
||||
@Override
|
||||
public boolean isMappingsSupported() {
|
||||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion().equals(BUILT_AGAINST_MAPPING);
|
||||
public String getMappingsHash() {
|
||||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,8 +28,8 @@ public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapt
|
||||
private static final WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
|
||||
|
||||
@Override
|
||||
public boolean isMappingsSupported() {
|
||||
return true;
|
||||
public String getMappingsHash() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,8 +28,8 @@ public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapt
|
||||
private static final WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
|
||||
|
||||
@Override
|
||||
public boolean isMappingsSupported() {
|
||||
return true;
|
||||
public String getMappingsHash() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user