Additional Log output
This commit is contained in:
parent
5c11fb5424
commit
ace3156fb2
3 changed files with 20 additions and 7 deletions
|
@ -4,6 +4,7 @@ import net.minecraft.network.FriendlyByteBuf;
|
|||
import ru.bclib.api.dataexchange.DataHandler;
|
||||
import ru.bclib.api.dataexchange.FileHash;
|
||||
import ru.bclib.util.Pair;
|
||||
import ru.bclib.util.Triple;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -53,13 +54,13 @@ class AutoFileSyncEntry extends DataExchange.AutoSyncID {
|
|||
return serializeFileContent(buf);
|
||||
}
|
||||
|
||||
public static Pair<AutoFileSyncEntry, byte[]> deserializeContent(FriendlyByteBuf buf) {
|
||||
public static Triple<AutoFileSyncEntry, byte[], DataExchange.AutoSyncID> deserializeContent(FriendlyByteBuf buf) {
|
||||
final String modID = DataHandler.readString(buf);
|
||||
final String uniqueID = DataHandler.readString(buf);
|
||||
byte[] data = deserializeFileContent(buf);
|
||||
|
||||
AutoFileSyncEntry entry = AutoFileSyncEntry.findMatching(modID, uniqueID);
|
||||
return new Pair<>(entry, data);
|
||||
return new Triple<>(entry, data, new DataExchange.AutoSyncID(modID, uniqueID));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -54,16 +54,19 @@ public class HelloClient extends DataHandler {
|
|||
|
||||
@Override
|
||||
protected void serializeData(FriendlyByteBuf buf) {
|
||||
final String vbclib = getBCLibVersion();
|
||||
BCLib.LOGGER.info("Sending Hello to Client. (server="+vbclib+")");
|
||||
final List<String> mods = DataExchangeAPI.registeredMods();
|
||||
|
||||
//write BCLibVersion (=protocol version)
|
||||
buf.writeInt(DataFixerAPI.getModVersion(getBCLibVersion()));
|
||||
|
||||
buf.writeInt(DataFixerAPI.getModVersion(vbclib));
|
||||
//write Plugin Versions
|
||||
buf.writeInt(mods.size());
|
||||
for (String modID : mods) {
|
||||
writeString(buf, modID);
|
||||
buf.writeInt(DataFixerAPI.getModVersion(getModVersion(modID)));
|
||||
final String ver = getModVersion(modID);
|
||||
buf.writeInt(DataFixerAPI.getModVersion(ver));
|
||||
BCLib.LOGGER.info(" - Listing Mod " + modID + " v" + ver);
|
||||
}
|
||||
|
||||
//send config Data
|
||||
|
@ -72,6 +75,7 @@ public class HelloClient extends DataHandler {
|
|||
for (AutoFileSyncEntry entry : autoSyncFiles) {
|
||||
//System.out.println("Serializing " + entry.getFileHash());
|
||||
entry.serialize(buf);
|
||||
BCLib.LOGGER.info(" - Offering File " + entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,9 @@ import ru.bclib.api.dataexchange.DataHandler;
|
|||
import ru.bclib.api.dataexchange.DataHandlerDescriptor;
|
||||
import ru.bclib.gui.screens.ConfirmRestartScreen;
|
||||
import ru.bclib.util.Pair;
|
||||
import ru.bclib.util.Triple;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
@ -38,6 +40,12 @@ public class SendFiles extends DataHandler {
|
|||
@Override
|
||||
protected void serializeData(FriendlyByteBuf buf) {
|
||||
List<AutoFileSyncEntry> existingFiles = files.stream().filter(e -> e.fileName.exists()).collect(Collectors.toList());
|
||||
/*
|
||||
//this will try to send a file that was not registered or requested by the client
|
||||
existingFiles.add(new AutoFileSyncEntry("none", new File("D:\\MinecraftPlugins\\BetterNether\\run\\server.properties"),true,(a, b, content) -> {
|
||||
System.out.println("Got Content:" + content.length);
|
||||
return true;
|
||||
}));*/
|
||||
writeString(buf, token);
|
||||
buf.writeInt(existingFiles.size());
|
||||
|
||||
|
@ -64,12 +72,12 @@ public class SendFiles extends DataHandler {
|
|||
receivedFiles = new ArrayList<>(size);
|
||||
BCLib.LOGGER.info("Server sent " + size + " Files:");
|
||||
for (int i=0; i<size; i++){
|
||||
Pair<AutoFileSyncEntry, byte[]> p = AutoFileSyncEntry.deserializeContent(buf);
|
||||
Triple<AutoFileSyncEntry, byte[], DataExchange.AutoSyncID> p = AutoFileSyncEntry.deserializeContent(buf);
|
||||
if (p.first != null) {
|
||||
receivedFiles.add(p);
|
||||
BCLib.LOGGER.info(" - " + p.first + " (" + p.second.length + " Bytes)");
|
||||
} else {
|
||||
BCLib.LOGGER.error(" - Failed to receive File");
|
||||
BCLib.LOGGER.error(" - Failed to receive File " +p.third+ ", possibly sent from a Mod that is not installed on the client.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue