diff --git a/main.ts b/main.ts index a41e552..f82852f 100644 --- a/main.ts +++ b/main.ts @@ -15,7 +15,7 @@ import { FactCollector, type Joiner } from './src/collector.js'; import { filterFrom, instanceMatches } from './src/filters.js'; import { notifyAll, type Report } from './src/notify.js'; import { ReportPanel } from './src/panel.js'; -import { settings } from './src/settings.js'; +import { migrateTemplate, settings } from './src/settings.js'; import { toSelf, type Self } from './src/vrcnext-data.js'; type Ctx = PluginContext; @@ -138,6 +138,9 @@ export default definePlugin({ settings, activate(ctx) { + const template = ctx.settings.get('template'); + const migrated = migrateTemplate(template); + if (migrated !== template) void ctx.settings.set('template', migrated); new ClubSecurity(ctx).start(); }, diff --git a/src/settings.ts b/src/settings.ts index f435f7e..426b872 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -29,6 +29,15 @@ export const DEFAULT_TEMPLATE = [ 'Rejoin?: {rejoinText}', ].join('\n'); +/** + * The first version's variables were text; they are booleans now, with the wording under + * `…Text`. A stored template written against the old names is rewritten once on activation, so + * an edited format keeps rendering words rather than `true`. + */ +export function migrateTemplate(template: string): string { + return template.replace(/\{(ageVerified|pcRank|questRank|inGroup|rejoin)\}/g, '{$1Text}'); +} + export const settings = { enabled: { kind: 'boolean',