start reformating strings into RawMessages

This commit is contained in:
ForestOfLight
2025-10-01 00:08:48 -07:00
Unverified
parent 99972285a2
commit 7fcda7bb04
13 changed files with 79 additions and 32 deletions
@@ -20,10 +20,21 @@ export class BuilderForm {
for (let i = 0; i < optionIds.length; i++) {
const option = BuilderOptions.get(optionIds[i]);
const changedToValue = option.setValue(this.player.id, formValues[i]);
if (changedToValue === true)
this.player.sendMessage(`§a${option.displayName} is now enabled!§7 ${option.howToUse}`);
else if (changedToValue === false)
this.player.sendMessage(`§c${option.displayName} is now disabled.`)
if (changedToValue === true) {
this.player.sendMessage({ rawtext: [
{ text: `§a` },
option.displayName,
{ translate: 'construct.option.enabled' },
{ text: `§7 ` },
{ translate: option.howToUse }
]});
} else if (changedToValue === false) {
this.player.sendMessage({ rawtext: [
{ text: `§c` },
option.displayName,
{ translate: 'construct.option.disabled' }
]});
}
}
}
@@ -8,9 +8,9 @@ export class BuilderFormBuilder {
.title(MenuFormBuilder.menuTitle);
for (const optionId of BuilderOptions.getOptionIds()) {
const option = BuilderOptions.get(optionId);
form.toggle(`${option.displayName}`, { defaultValue: option.isEnabled(player.id), tooltip: option.description });
form.toggle(option.displayName, { defaultValue: option.isEnabled(player.id), tooltip: option.description });
}
form.submitButton('§2Apply');
form.submitButton({ translate: "construct.menu.submit" });
return form;
}
}
@@ -1,16 +1,16 @@
export const InstanceButtons = Object.freeze({
Unknown: 'Unknown',
Unknown: 'construct.menu.instance.button.unknown',
MainMenu: '<<',
Place: '§aPlace Instance',
Enable: '§aEnable Instance',
Disable: '§cDisable Instance',
Rename: 'Rename Instance',
Delete: '§cDelete Instance',
NextLayer: 'Increase Layer',
PreviousLayer: 'Decrease Layer',
Move: 'Move Here',
FlexibleMove: 'Flexible Move',
Statistics: 'Statistics',
Settings: 'Settings',
Materials: 'Material List'
Place: 'construct.menu.instance.button.place',
Enable: 'construct.menu.instance.button.enable',
Disable: 'construct.menu.instance.button.disable',
Rename: 'construct.menu.instance.button.rename',
Delete: 'construct.menu.instance.button.delete',
NextLayer: 'construct.menu.instance.button.nextLayer',
PreviousLayer: 'construct.menu.instance.button.previousLayer',
Move: 'construct.menu.instance.button.move',
FlexibleMove: 'construct.menu.instance.button.flexibleMove',
Statistics: 'construct.menu.instance.button.statistics',
Settings: 'construct.menu.instance.button.settings',
Materials: 'construct.menu.instance.button.materials'
});
@@ -23,7 +23,7 @@ export class FlexibleInstanceMove {
tryStart() {
if (this.instance.isFlexibleMoving()) {
this.sendFeedback('§cThis instance is already being moved.');
this.sendFeedback({ translate: 'construct.instance.flexibleMove.alreadyMoving' });
return;
}
this.start();
@@ -48,7 +48,7 @@ export class FlexibleInstanceMove {
this.allowPlayerMovement(false);
world.beforeEvents.itemUse.subscribe(this.onPlayerUseItemBound);
world.beforeEvents.playerLeave.unsubscribe(this.onPlayerLeaveBound);
this.sendFeedback(`§aNow moving "${this.instance.getName()}". Use the Construct item when finished.`);
this.sendFeedback({ translate: 'construct.instance.flexibleMove.start', with: [this.instance.getName()] });
}
onFlexibleMovementTick() {
@@ -109,7 +109,10 @@ export class FlexibleInstanceMove {
builder.flexibleInstanceMovement = void 0;
world.beforeEvents.itemUse.unsubscribe(this.onPlayerUseItemBound);
world.beforeEvents.playerLeave.unsubscribe(this.onPlayerLeaveBound);
this.sendFeedback(`§aMoved "${this.instance.getName()}" to ${this.currentInstanceLocation.floor()}.`);
this.sendFeedback({ translate: 'construct.instance.flexibleMove.finish', with: [
this.instance.getName(),
String(this.currentInstanceLocation.floor())
] });
}
allowPlayerMovement(enable) {
@@ -113,7 +113,7 @@ export class InstanceForm {
new MenuForm(this.player, { jumpToInstance: false });
break;
default:
this.player.sendMessage(`§cUnknown option: ${option}`);
this.player.sendMessage({ translate: 'construct.menu.instance.unknownOption', with: [option] });
break;
}
}
@@ -124,15 +124,14 @@ export class InstanceForm {
return;
const newName = response.formValues[0];
if (newName === '') {
this.player.sendMessage('§cInstance name cannot be empty.');
this.player.sendMessage({ translate: 'construct.menu.instance.nameEmpty' });
return;
}
try {
structureCollection.rename(this.instanceName, newName);
this.instanceName = newName;
} catch (e) {
this.player.sendMessage(`§cError renaming instance: ${e.message}`);
return;
this.player.sendMessage({ translate: 'construct.instance.rename.error', with: [e.message] });
}
});
}
@@ -23,7 +23,7 @@ export class MaterialGrabberForm {
});
} catch (e) {
if (e.message === 'Menu timed out.') {
this.player.sendMessage('§8Menu timed out.');
this.player.sendMessage({ translate: 'construct.menu.open.timeout' });
return;
}
throw e;
+1 -1
View File
@@ -42,7 +42,7 @@ export class MenuForm {
});
} catch (e) {
if (e.message === 'Menu timed out.') {
this.player.sendMessage('§8Menu timed out.');
this.player.sendMessage({ translate: 'construct.menu.open.timeout' });
return;
}
throw e;
+1 -1
View File
@@ -8,7 +8,7 @@ export async function forceShow(player, form, timeout = Infinity) {
while ((system.currentTick - startTick) < timeout) {
const response = await form.show(player);
if (startTick + 1 === system.currentTick && response.cancelationReason === FormCancelationReason.UserBusy)
player.sendMessage("§8Close your chat window to access the menu.");
player.sendMessage({ translate: 'construct.menu.open.closeChat' });
if (response.cancelationReason !== FormCancelationReason.UserBusy)
return response;
}