use of com.fredtargaryen.fragileglass.config.behaviour.datamanager.DataManager in project Fragile-Glass by fredtargaryen.
the class ExportAllCommand method execute.
private static int execute(CommandSource source, String manager) {
DataManager dm = CommandsBase.getDataManager(manager);
if (dm == null) {
return 1;
}
StringBuilder sb = new StringBuilder();
if (manager.equals("blocks")) {
dm.getKeys().forEach(state -> {
try {
List<FragilityData> fdList = (List<FragilityData>) dm.getData(state);
fdList.forEach(fragilityData -> {
sb.append(dm.stringifyBehaviours(state, null, false));
sb.append("\n");
});
} catch (NullPointerException npe) {
source.sendFeedback(new StringTextComponent("No existing block state data for " + KeyParser.cleanBlockStateString(state.toString())), false);
}
});
} else if (manager.equals("entities")) {
dm.getKeys().forEach(type -> {
try {
sb.append(dm.stringifyBehaviours(type, null, false));
sb.append("\n");
} catch (NullPointerException npe) {
source.sendFeedback(new StringTextComponent("No existing entity data for " + ((EntityType) type).getRegistryName()), false);
}
});
} else {
// "tileentities"
dm.getKeys().forEach(type -> {
try {
List<FragilityData> fdList = (List<FragilityData>) dm.getData(type);
fdList.forEach(fragilityData -> {
sb.append(dm.stringifyBehaviours(type, null, false));
sb.append("\n");
});
} catch (NullPointerException npe) {
source.sendFeedback(new StringTextComponent("No existing tile entity data for " + ((TileEntityType) type).getRegistryName()), false);
}
});
}
try {
dm.export(sb.toString());
source.sendFeedback(new StringTextComponent("File exported successfully!"), true);
return 0;
} catch (IOException ioe) {
source.sendFeedback(new StringTextComponent("File failed to export."), true);
return 1;
}
}
use of com.fredtargaryen.fragileglass.config.behaviour.datamanager.DataManager in project Fragile-Glass by fredtargaryen.
the class ExportCommand method execute.
private static int execute(CommandSource source, String manager, DataManagerEntry entry) {
DataManager dm = CommandsBase.getDataManager(manager);
if (dm == null) {
return 1;
}
StringBuilder sb = new StringBuilder();
if (manager.equals("blocks")) {
entry.getBlockStateSet().forEach(state -> {
try {
sb.append(dm.stringifyBehaviours(state, null, false));
sb.append("\n");
} catch (NullPointerException npe) {
source.sendFeedback(new StringTextComponent("No existing block state data for " + KeyParser.cleanBlockStateString(state.toString())), false);
}
});
} else if (manager.equals("entities")) {
entry.getEntityTypeSet().forEach(type -> {
try {
sb.append(dm.stringifyBehaviours(type, null, false));
sb.append("\n");
} catch (NullPointerException npe) {
source.sendFeedback(new StringTextComponent("No existing entity data for " + type.getRegistryName()), false);
}
});
} else {
// "tileentities"
try {
sb.append(dm.stringifyBehaviours(entry.getTileEntityType(), null, false));
sb.append("\n");
} catch (NullPointerException npe) {
source.sendFeedback(new StringTextComponent("No existing tile entity data for " + entry.getTileEntityType().getRegistryName()), false);
}
}
try {
dm.export(sb.toString());
source.sendFeedback(new StringTextComponent("File exported successfully!"), true);
} catch (IOException ioe) {
source.sendFeedback(new StringTextComponent("File failed to export."), true);
return 1;
}
return 0;
}
use of com.fredtargaryen.fragileglass.config.behaviour.datamanager.DataManager in project Fragile-Glass by fredtargaryen.
the class ReloadCommand method execute.
private static int execute(CommandSource source, String manager) {
DataManager dm = CommandsBase.getDataManager(manager);
if (dm == null) {
return 1;
}
dm.clearData();
source.sendFeedback(FragileGlassBase.setReloadStatus(dm.loadData()), true);
return 0;
}
use of com.fredtargaryen.fragileglass.config.behaviour.datamanager.DataManager in project Fragile-Glass by fredtargaryen.
the class RemoveAllCommand method execute.
private static int execute(CommandSource source, String manager) {
DataManager dm = CommandsBase.getDataManager(manager);
if (dm == null) {
return 1;
}
dm.clearData();
return 0;
}
Aggregations