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