Update Via API usage (#702)

This commit is contained in:
EnZaXD 2024-03-24 22:10:06 +01:00 committed by GitHub
parent 59a621315b
commit 082cc010b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,6 +24,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
public class BackwardsMappingDataLoader extends MappingDataLoader { public class BackwardsMappingDataLoader extends MappingDataLoader {
@ -34,11 +35,6 @@ public class BackwardsMappingDataLoader extends MappingDataLoader {
super(dataLoaderClass, dataPath); super(dataLoaderClass, dataPath);
} }
@Override
public File getFile(final String name) {
return new File(ViaBackwards.getPlatform().getDataFolder(), name);
}
/** /**
* Returns nbt data from the plugin folder or packed assets. * Returns nbt data from the plugin folder or packed assets.
* If a file with the same name exists in the plugin folder, the data of the original packed tag will be merged with the file's tag. * If a file with the same name exists in the plugin folder, the data of the original packed tag will be merged with the file's tag.
@ -49,12 +45,12 @@ public class BackwardsMappingDataLoader extends MappingDataLoader {
public @Nullable CompoundTag loadNBTFromDir(final String name) { public @Nullable CompoundTag loadNBTFromDir(final String name) {
final CompoundTag packedData = loadNBT(name); final CompoundTag packedData = loadNBT(name);
final File file = new File(ViaBackwards.getPlatform().getDataFolder(), name); final File file = new File(getDataFolder(), name);
if (!file.exists()) { if (!file.exists()) {
return packedData; return packedData;
} }
ViaBackwards.getPlatform().getLogger().info("Loading " + name + " from plugin folder"); getLogger().info("Loading " + name + " from plugin folder");
try { try {
final CompoundTag fileData = MAPPINGS_READER.read(file.toPath(), false); final CompoundTag fileData = MAPPINGS_READER.read(file.toPath(), false);
return mergeTags(packedData, fileData); return mergeTags(packedData, fileData);
@ -78,4 +74,14 @@ public class BackwardsMappingDataLoader extends MappingDataLoader {
} }
return original; return original;
} }
@Override
public Logger getLogger() {
return ViaBackwards.getPlatform().getLogger();
}
@Override
public File getDataFolder() {
return ViaBackwards.getPlatform().getDataFolder();
}
} }