diff --git a/Canopy [BP]/scripts/lib/canopy/help/HelpBook.js b/Canopy [BP]/scripts/lib/canopy/help/HelpBook.js index b9c8d52..8333f25 100644 --- a/Canopy [BP]/scripts/lib/canopy/help/HelpBook.js +++ b/Canopy [BP]/scripts/lib/canopy/help/HelpBook.js @@ -1,6 +1,5 @@ import { HelpPage } from "./HelpPage"; import Utils from "stickycore/utils"; -import { CommandHelpEntry } from "./HelpEntry"; class HelpBook { constructor() { diff --git a/Canopy [BP]/scripts/src/classes/WorldSpawns.js b/Canopy [BP]/scripts/src/classes/WorldSpawns.js index 9b683bb..bbcb52f 100644 --- a/Canopy [BP]/scripts/src/classes/WorldSpawns.js +++ b/Canopy [BP]/scripts/src/classes/WorldSpawns.js @@ -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; diff --git a/Canopy [BP]/scripts/src/commands/entitydensity.js b/Canopy [BP]/scripts/src/commands/entitydensity.js index 2d4d3d5..2359678 100644 --- a/Canopy [BP]/scripts/src/commands/entitydensity.js +++ b/Canopy [BP]/scripts/src/commands/entitydensity.js @@ -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)) diff --git a/Canopy [BP]/scripts/src/commands/help.js b/Canopy [BP]/scripts/src/commands/help.js index ffad269..45ae335 100644 --- a/Canopy [BP]/scripts/src/commands/help.js +++ b/Canopy [BP]/scripts/src/commands/help.js @@ -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({ diff --git a/Canopy [BP]/scripts/src/commands/pos.js b/Canopy [BP]/scripts/src/commands/pos.js index cf158bf..f49172c 100644 --- a/Canopy [BP]/scripts/src/commands/pos.js +++ b/Canopy [BP]/scripts/src/commands/pos.js @@ -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)}`; diff --git a/Canopy [BP]/scripts/src/commands/removeentity.js b/Canopy [BP]/scripts/src/commands/removeentity.js index 865c34b..d31ce51 100644 --- a/Canopy [BP]/scripts/src/commands/removeentity.js +++ b/Canopy [BP]/scripts/src/commands/removeentity.js @@ -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' }); } diff --git a/Canopy [BP]/scripts/src/commands/spawn.js b/Canopy [BP]/scripts/src/commands/spawn.js index 0c94154..d73c8de 100644 --- a/Canopy [BP]/scripts/src/commands/spawn.js +++ b/Canopy [BP]/scripts/src/commands/spawn.js @@ -33,6 +33,7 @@ const cmd = new Command({ { usage: 'spawn [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 ', description: { translate: 'commands.spawn.mocking' } } ] }); @@ -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) { @@ -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); } diff --git a/Canopy [BP]/scripts/src/commands/tick.js b/Canopy [BP]/scripts/src/commands/tick.js index 702968b..4048156 100644 --- a/Canopy [BP]/scripts/src/commands/tick.js +++ b/Canopy [BP]/scripts/src/commands/tick.js @@ -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); @@ -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) { diff --git a/Canopy [BP]/scripts/src/commands/tntfuse.js b/Canopy [BP]/scripts/src/commands/tntfuse.js index 1422d52..625a1a0 100644 --- a/Canopy [BP]/scripts/src/commands/tntfuse.js +++ b/Canopy [BP]/scripts/src/commands/tntfuse.js @@ -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); } diff --git a/Canopy [BP]/scripts/src/commands/warp.js b/Canopy [BP]/scripts/src/commands/warp.js index d093fd5..bce01eb 100644 --- a/Canopy [BP]/scripts/src/commands/warp.js +++ b/Canopy [BP]/scripts/src/commands/warp.js @@ -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) { @@ -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) { diff --git a/Canopy [RP]/texts/en_US.lang b/Canopy [RP]/texts/en_US.lang index f9d4c02..97b0312 100644 --- a/Canopy [RP]/texts/en_US.lang +++ b/Canopy [RP]/texts/en_US.lang @@ -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. @@ -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. @@ -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. @@ -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.