Some minor Fixes
This commit is contained in:
parent
4f8840da68
commit
4d56796244
5 changed files with 23 additions and 29 deletions
|
@ -39,10 +39,7 @@ public class BCLib implements ModInitializer {
|
|||
TagAPI.init();
|
||||
CraftingRecipes.init();
|
||||
WorldDataAPI.registerModCache(MOD_ID);
|
||||
|
||||
DataExchangeAPI.registerMod(MOD_ID);
|
||||
//this will offer modMenu to clients if installed in the server
|
||||
DataExchangeAPI.registerModDependency("modmenu");
|
||||
|
||||
DataExchangeAPI.registerDescriptors(List.of(
|
||||
HelloClient.DESCRIPTOR,
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package ru.bclib.api.dataexchange.handler.autosync;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import ru.bclib.BCLib;
|
||||
import ru.bclib.api.dataexchange.DataExchangeAPI;
|
||||
|
@ -31,7 +29,6 @@ public class AutoSync {
|
|||
public boolean test(SyncFileHash clientHash, SyncFileHash serverHash, FileContentWrapper content);
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static class ClientConfig extends NamedPathConfig{
|
||||
public static final ConfigToken<Boolean> ENABLED = ConfigToken.Boolean(true, "enabled", SYNC_CATEGORY);
|
||||
@ConfigUI(leftPadding =8)
|
||||
|
|
|
@ -142,7 +142,7 @@ public class SendFiles extends DataHandler.FromServer {
|
|||
|
||||
@Environment(EnvType.CLIENT)
|
||||
static void writeSyncedFile(AutoSyncID e, byte[] data, File fileName) {
|
||||
if (!PathUtil.isChildOf(PathUtil.GAME_FOLDER, fileName.toPath())){
|
||||
if (fileName!=null && !PathUtil.isChildOf(PathUtil.GAME_FOLDER, fileName.toPath())){
|
||||
BCLib.LOGGER.error(fileName + " is not within game folder " + PathUtil.GAME_FOLDER);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -42,34 +42,32 @@ public class SyncFilesScreen extends BCLibScreen {
|
|||
|
||||
|
||||
final GridCheckboxCell mods;
|
||||
if (hasMods) {
|
||||
row = grid.addRow();
|
||||
mods = row.addCheckbox(new TranslatableComponent("message.bclib.syncfiles.mods"), true, BUTTON_HEIGHT, this.font);
|
||||
grid.addSpacerRow();
|
||||
} else mods=null;
|
||||
row = grid.addRow();
|
||||
mods = row.addCheckbox(new TranslatableComponent("message.bclib.syncfiles.mods"), hasMods, BUTTON_HEIGHT, this.font);
|
||||
mods.setEnabled(hasMods);
|
||||
grid.addSpacerRow();
|
||||
|
||||
|
||||
final GridCheckboxCell configs;
|
||||
if (hasConfigFiles) {
|
||||
row = grid.addRow();
|
||||
configs = row.addCheckbox(new TranslatableComponent("message.bclib.syncfiles.configs"), true, BUTTON_HEIGHT, this.font);
|
||||
grid.addSpacerRow();
|
||||
} else configs = null;
|
||||
row = grid.addRow();
|
||||
configs = row.addCheckbox(new TranslatableComponent("message.bclib.syncfiles.configs"), hasConfigFiles, BUTTON_HEIGHT, this.font);
|
||||
configs.setEnabled(hasConfigFiles);
|
||||
|
||||
grid.addSpacerRow();
|
||||
|
||||
row = grid.addRow();
|
||||
|
||||
final GridCheckboxCell folder;
|
||||
if (hasFiles) {
|
||||
folder = row.addCheckbox(new TranslatableComponent("message.bclib.syncfiles.folders"), true, BUTTON_HEIGHT, this.font);
|
||||
row.addSpacer();
|
||||
} else folder = null;
|
||||
folder = row.addCheckbox(new TranslatableComponent("message.bclib.syncfiles.folders"), hasFiles, BUTTON_HEIGHT, this.font);
|
||||
folder.setEnabled(hasFiles);
|
||||
row.addSpacer();
|
||||
|
||||
GridCheckboxCell delete;
|
||||
if (shouldDelete) {
|
||||
delete = row.addCheckbox(new TranslatableComponent("message.bclib.syncfiles.delete"), true, BUTTON_HEIGHT, this.font);
|
||||
} else delete = null;
|
||||
delete = row.addCheckbox(new TranslatableComponent("message.bclib.syncfiles.delete"), shouldDelete, BUTTON_HEIGHT, this.font);
|
||||
delete.setEnabled(shouldDelete);
|
||||
|
||||
|
||||
grid.addSpacerRow(30);
|
||||
|
||||
row = grid.addRow();
|
||||
row.addFiller();
|
||||
row.addButton(CommonComponents.GUI_NO, BUTTON_HEIGHT, this.font, (button) -> {
|
||||
|
@ -78,10 +76,10 @@ public class SyncFilesScreen extends BCLibScreen {
|
|||
row.addSpacer();
|
||||
row.addButton(CommonComponents.GUI_YES, BUTTON_HEIGHT, this.font, (button) -> {
|
||||
listener.proceed(
|
||||
mods!=null && mods.isChecked(),
|
||||
configs!=null && configs.isChecked(),
|
||||
folder != null && folder.isChecked(),
|
||||
delete !=null && delete.isChecked()
|
||||
mods.isChecked(),
|
||||
configs.isChecked(),
|
||||
folder.isChecked(),
|
||||
delete.isChecked()
|
||||
);
|
||||
});
|
||||
row.addFiller();
|
||||
|
|
|
@ -30,6 +30,8 @@ public class PathUtil {
|
|||
*/
|
||||
public static boolean isChildOf(Path parent, Path child) {
|
||||
if (child == null || parent == null) return false;
|
||||
parent = parent.toAbsolutePath().normalize();
|
||||
child = child.toAbsolutePath().normalize();
|
||||
|
||||
final int pCount = parent.getNameCount();
|
||||
final int cCount = child.getNameCount();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue