Skip to content

Commit

Permalink
fixed more translation bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ForestOfLight committed Oct 16, 2024
1 parent 7f25bcb commit 1425b18
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 35 deletions.
1 change: 0 additions & 1 deletion Canopy [BP]/scripts/lib/canopy/help/HelpBook.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { HelpPage } from "./HelpPage";
import Utils from "stickycore/utils";
import { CommandHelpEntry } from "./HelpEntry";

class HelpBook {
constructor() {
Expand Down
17 changes: 9 additions & 8 deletions Canopy [BP]/scripts/src/classes/WorldSpawns.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,26 @@ class WorldSpawns {
for (const dimensionId in recents) {
output += `\n${Utils.getColoredDimensionName(dimensionId)}§7:`;
for (const category in recents[dimensionId]) {
if (Object.keys(recents[dimensionId][category]).length === 0) continue;
if (!recents[dimensionId][category] || Object.keys(recents[dimensionId][category])?.length === 0) continue;
output += `\n§7 > ${category.toUpperCase()}:`;
for (const mobname in recents[dimensionId][category]) {
const recentLocations = recents[dimensionId][category][mobname].map(location => Utils.stringifyLocation(location)).join(', ')
output += `\n§7 - ${mobname}: ${recentLocations}`;
for (const mobType in recents[dimensionId][category]) {
const recentLocations = recents[dimensionId][category][mobType].map(location => Utils.stringifyLocation(location)).join(', ')
output += `\n§7 - ${mobType}: ${recentLocations}`;
}
}
}
return output;
}

getRecents(mobname) {
getRecents(mobname = null) {
let recents = {};
for (const dimensionId in this.trackers) {
recents[dimensionId] = {};
for (const category in this.trackers[dimensionId]) {
const tracker = this.trackers[dimensionId][category];
if (mobname) recents[dimensionId][category] = tracker.getRecents()[mobname];
else recents[dimensionId][category] = tracker.getRecents();
recents[dimensionId][category] = {};
const trackerRecents = this.trackers[dimensionId][category].getRecents();
if (mobname !== null && trackerRecents[mobname]) recents[dimensionId][category][mobname] = trackerRecents[mobname];
else if (mobname === null) recents[dimensionId][category] = trackerRecents;
}
}
return recents;
Expand Down
2 changes: 1 addition & 1 deletion Canopy [BP]/scripts/src/commands/entitydensity.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function entityDensityCommand(sender, args) {
if (denseAreas.length === 0)
return sender.sendMessage({ translate: 'commands.entitydensity.fail.noentities', with: [validDimensionId] });

const message = { rawtext: [{ translate: 'commands.entitydensity.success.header', with: [validDimensionId, gridSize.toString()] }] };
const message = { rawtext: [{ translate: 'commands.entitydensity.success.header', with: [validDimensionId, String(gridSize), String(gridSize)] }] };
denseAreas.forEach(area => {
message.rawtext.push({ text: '\n' });
message.rawtext.push(formatAreaMessage(area))
Expand Down
2 changes: 1 addition & 1 deletion Canopy [BP]/scripts/src/commands/help.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command, Rule, InfoDisplayRule } from 'lib/canopy/Canopy';
import { HelpBook, CommandHelpPage, RuleHelpPage, InfoDisplayRuleHelpPage } from 'lib/canopy/Canopy';

const COMMANDS_PER_PAGE = 7;
const COMMANDS_PER_PAGE = 8;
const helpBook = new HelpBook();

const cmd = new Command({
Expand Down
8 changes: 3 additions & 5 deletions Canopy [BP]/scripts/src/commands/pos.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ new Command({
});

function posCommand(sender, args) {
const player = String(args.player);
let target = world.getPlayers({ name: player })[0];
if (player === null)
target = sender;
else if (!target)
const { player } = args;
const target = player === null ? sender : world.getPlayers({ name: String(player) })[0];
if (!target)
return sender.sendMessage({ translate: 'generic.player.notfound', with: [player] });

let output = `§a${player !== null ? `${target.name}'s` : 'Your'} position: §f${Utils.stringifyLocation(target.location, 2)}`;
Expand Down
2 changes: 1 addition & 1 deletion Canopy [BP]/scripts/src/commands/removeentity.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function removeEntityCommand(sender, args) {
target.remove();
sender.sendMessage({ translate: 'commands.removeentity.success', with: [target.typeId.replace('minecraft:', ''), target.id] });
} else if (id !== null) {
sender.sendMessage({ translate: 'commands.removeentity.fail.noid', with: [id] });
sender.sendMessage({ translate: 'commands.removeentity.fail.noid', with: [String(id)] });
} else {
sender.sendMessage({ translate: 'generic.entity.notfound' });
}
Expand Down
18 changes: 11 additions & 7 deletions Canopy [BP]/scripts/src/commands/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const cmd = new Command({
{ usage: 'spawn <mobName> [x1 y1 z1] [x2 y2 z2]', description: { translate: 'commands.spawn.tracking.mob' } },
{ usage: 'spawn tracking', description: { translate: 'commands.spawn.tracking.query' } },
{ usage: 'spawn tracking stop', description: { translate: 'commands.spawn.tracking.stop' } },
{ usage: 'spawn test', description: { translate: 'commands.spawn.test' } },
{ usage: 'spawn mocking <true/false>', description: { translate: 'commands.spawn.mocking' } }
]
});
Expand All @@ -44,14 +45,15 @@ let currActiveArea = null;

world.afterEvents.entitySpawn.subscribe(async (event) => {
const entity = event.entity;
if (worldSpawns && entity.typeId !== 'minecraft:item') worldSpawns.sendMobToTrackers(event.entity);
if (worldSpawns && entity.typeId !== 'minecraft:item')
worldSpawns.sendMobToTrackers(event.entity);

if (!isMocking || event.cause === 'Loaded' || !await Rule.getValue('commandSpawnMocking')) return;
let shouldCancelSpawn = false;
for (const category in categoryToMobMap) {
if (categoryToMobMap[category].includes(event.entity.typeId.replace('minecraft:', ''))) shouldCancelSpawn = true;
}
if (shouldCancelSpawn) event.entity.remove();
if (shouldCancelSpawn && event.entity) event.entity.remove();
});

function spawnCommand(sender, args) {
Expand Down Expand Up @@ -102,18 +104,20 @@ function resetSpawnsAndCounters(sender) {
return sender.sendMessage({ translate: 'commands.spawn.tracking.no' });
worldSpawns.reset();
channelMap.resetAll();
sender.sendMessage({ translate: 'commands.spawn.tracking.reset.success' });
Utils.broadcastActionBar({ translate: 'commands.spawn.tracking.reset.success.actionbar', with: [sender.name] }, sender);
sender.sendMessage({ translate: 'commands.spawn.tracking.test.success' });
Utils.broadcastActionBar({ translate: 'commands.spawn.tracking.test.success.actionbar', with: [sender.name] }, sender);
}

function recentSpawns(sender, actionTwo) {
if (worldSpawns === null)
return sender.sendMessage({ translate: 'commands.spawn.tracking.no' });
let output
if (actionTwo === null)
if (actionTwo === null) {
output = worldSpawns.getRecentsOutput();
else
output = worldSpawns.getRecentsOutput(actionTwo);
} else {
const mobname = actionTwo.includes('minecraft:') ? actionTwo : `minecraft:${actionTwo}`;
output = worldSpawns.getRecentsOutput(mobname);
}
sender.sendMessage(output);
}

Expand Down
4 changes: 2 additions & 2 deletions Canopy [BP]/scripts/src/commands/tick.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ system.runInterval(() => {
if (shouldStep > 0) {
shouldStep--;
if (shouldStep == 0)
world.sendMessage({ translate: 'commands.tick.done.success' });
world.sendMessage({ translate: 'commands.tick.step.done' });
return;
}
tickSpeed(targetMSPT);
Expand Down Expand Up @@ -77,7 +77,7 @@ function tickStep(sender, steps) {
shouldStep = 1;
else
shouldStep = steps;
world.sendMessage(``);
world.sendMessage({ translate: 'commands.tick.step.start', with: [sender.name, String(shouldStep)] });
}

function tickSleep(sender, milliseconds) {
Expand Down
4 changes: 2 additions & 2 deletions Canopy [BP]/scripts/src/commands/tntfuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ function tntfuseCommand(sender, args) {
ticks = 80;
sender.sendMessage({ translate: 'commands.tntfuse.reset.success' });
} else if (ticks < 0 || ticks > MAX_FUSE_TICKS)
return sender.sendMessage({ translate: 'commands.tntfuse.set.fail' });
return sender.sendMessage({ translate: 'commands.tntfuse.set.fail', with: [String(ticks), String(MAX_FUSE_TICKS)] });
else {
sender.sendMessage({ translate: 'commands.tntfuse.set.success', with: [ticks] });
sender.sendMessage({ translate: 'commands.tntfuse.set.success', with: [String(ticks)] });
}
world.setDynamicProperty('tntFuseTime', ticks);
}
4 changes: 2 additions & 2 deletions Canopy [BP]/scripts/src/commands/warp.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function addWarp(sender, name, warpMap) {
let warps = JSON.parse(world.getDynamicProperty('warps'));
warps.warpList[name] = new Warp(name, location, dimension);
world.setDynamicProperty(`warps`, JSON.stringify(warps));
sender.sendMessage(`§7Warp "${name}" has been added.`);
sender.sendMessage({ translate: 'commands.warp.add.success', with: [name] });
}

function removeWarp(sender, name, warpMap) {
Expand All @@ -104,7 +104,7 @@ function removeWarp(sender, name, warpMap) {

warpMap.delete(name);
setWarpMap(warpMap);
sender.sendMessage(`§7Warp "${name}" has been removed.`);
sender.sendMessage({ translate: 'commands.warp.remove.success', with: [name] });
}

function warpTP(sender, name, warpMap) {
Expand Down
13 changes: 8 additions & 5 deletions Canopy [RP]/texts/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ commands.spawn.tracking.query=Displays a summary of all spawns that have occurre
commands.spawn.tracking.query.dimension=§7Dimension %s§r:
commands.spawn.tracking.no=§cSpawns are not currently being tracked.
commands.spawn.tracking.already=§cSpawns are already being tracked.
commands.spawn.tracking.reset.success=§7Spawn counters and hopper counters reset.
commands.spawn.tracking.reset.success.actionbar=[%s] §7Reset spawn counters and hopper counters.
commands.spawn.tracking.test=Resets all spawn counters and hopper counters.
commands.spawn.tracking.test.success=§7Spawn counters and hopper counters reset.
commands.spawn.tracking.test.success.actionbar=[%s] §7Reset spawn counters and hopper counters.
commands.spawn.tracking.stop=Stops tracking mob spawns.
commands.spawn.tracking.stop.success=§7Spawns are no longer being tracked.
commands.spawn.tracking.stop.actionbar=[%s] §7Stopped tracking spawns.
Expand Down Expand Up @@ -192,8 +193,8 @@ commands.tick.sleep.fail=§cInvalid sleep time.
commands.tick.sleep.success=§7%1 pausing the server for %2 ms.

commands.tntfuse=Sets the fuse time of primed TNT in ticks.
commands.tntfuse.reset.successt=§7Reset TNT fuse time to §a80§7 ticks.
commands.tntfuse.set.fail=§cInvalid fuse time: %1 ticks. Must be between 0 and %2 seconds.
commands.tntfuse.reset.success=§7Reset TNT fuse time to §a80§7 ticks.
commands.tntfuse.set.fail=§cInvalid fuse time: %1 ticks. Must be between 0 and %2 ticks.
commands.tntfuse.set.success=§7TNT fuse time set to §a%s§7 ticks.

commands.trackevent=Count the number of times any event occurs. Displays the count in the InfoDisplay.
Expand All @@ -207,6 +208,8 @@ commands.warp.tp=Teleports you to a warp.
commands.warp.list=List all available warps.
commands.warp.exists=§cWarp '%s' already exists. Use ./warps to see the list of warps.
commands.warp.noexist=§cWarp '%s' not found. Use ./warps to see the list of warps.
commands.warp.add.success=§7Warp '%s' has been added.
commands.warp.remove.success=§7Warp '%s' has been removed.
commands.warp.tp.fail.dimension=§cPlease go to %1 to teleport to '%2'.
commands.warp.tp.success=§7Teleported to warp '%s'.
commands.warp.list.empty=§7There are no warps.
Expand Down Expand Up @@ -241,7 +244,7 @@ rules.beeNoDrown=Enables bees healing from drowning damage.
rules.cauldronConcreteConversion=Concrete powder items inside a cauldron filled with water will convert to concrete items.
rules.creativeOneHitKill=Allows creative players to one hit kill any entity. If sneaking, it will also kill nearby entities.
rules.dupeTnt=TNT can be duplicated when moved by a piston and powered next to a note blocks.
rules.durabilityNotifier=Enables a clink sound when your tool has %s durability left.
rules.durabilityNotifier=Enables a clink sound and tip when your tool has %s durability left.
rules.durabilityNotifier.alert=§cDurability remaining: %s
rules.entityInstantDeath=Removes the 20gt death animation. Entities will also not drop xp.
rules.explosionChainReactionOnly=Makes explosion only affect TNT blocks.
Expand Down

0 comments on commit 1425b18

Please sign in to comment.