diff --git a/src/lib/roles.ts b/src/lib/roles.ts index 2596588f..edf35d0c 100644 --- a/src/lib/roles.ts +++ b/src/lib/roles.ts @@ -168,17 +168,3 @@ if (!__VITEST__) { } }) } - -if (!__VITEST__) { - system.delay(() => { - const lastVersionId = 'lastVersion' - if (world.getDynamicProperty(lastVersionId) !== __GIT__) { - world - .getAllPlayers() - .filter(e => is(e.id, 'techAdmin')) - .forEach(e => e.sendMessage(`§9>§f ${__GIT__}`)) - - world.setDynamicProperty(lastVersionId, __GIT__) - } - }) -} diff --git a/src/modules/world-edit/lib/world-edit-tool.ts b/src/modules/world-edit/lib/world-edit-tool.ts index 21cdd4b5..e3414b77 100644 --- a/src/modules/world-edit/lib/world-edit-tool.ts +++ b/src/modules/world-edit/lib/world-edit-tool.ts @@ -24,6 +24,7 @@ type StorageKey = | 'radius' | 'blending' | 'factor' + | 'useInterval' const LORE_SEPARATOR = '\u00a0' @@ -133,6 +134,7 @@ export abstract class WorldEditTool { type: 'Тип', blending: 'Смешивание', factor: 'Фактор смешивания', + useInterval: 'Использовать интервал', } getStorage(slot: ContainerSlot | ItemStack, returnUndefined?: false): Storage diff --git a/src/modules/world-edit/tools/multi-shovel.ts b/src/modules/world-edit/tools/multi-shovel.ts index dbb32506..8fabe485 100644 --- a/src/modules/world-edit/tools/multi-shovel.ts +++ b/src/modules/world-edit/tools/multi-shovel.ts @@ -22,6 +22,20 @@ class MultiShovelTool extends WorldEditMultiTool { storage.tools, ) } + + constructor() { + super() + this.onInterval(10, (player, storage, slot, settings) => { + this.forEachTool( + slot, + (proxiedItem, tool, toolStorage) => { + if (!tool.onUse) return + tool.interval10?.(player, toolStorage, proxiedItem, settings) + }, + storage.tools, + ) + }) + } } new MultiShovelTool() diff --git a/src/modules/world-edit/tools/shovel.ts b/src/modules/world-edit/tools/shovel.ts index 63fdfe2b..3a64bf76 100644 --- a/src/modules/world-edit/tools/shovel.ts +++ b/src/modules/world-edit/tools/shovel.ts @@ -29,6 +29,7 @@ interface Storage { offset: number blending: number factor: number + useInterval: boolean } class ShovelTool extends WorldEditTool { @@ -36,7 +37,7 @@ class ShovelTool extends WorldEditTool { name = 'лопата' typeId = Items.WeShovel storageSchema = { - version: 4, + version: 5, blocksSet: ['', ''] as BlocksSetRef, replaceBlocksSet: ['', ''] as BlocksSetRef, @@ -46,6 +47,7 @@ class ShovelTool extends WorldEditTool { offset: -1, blending: -1, factor: 20, + useInterval: true, } getMenuButtonName(player: Player) { @@ -70,25 +72,30 @@ class ShovelTool extends WorldEditTool { storage.blending, ) .addSlider('Сила смешивания', 0, 100, 1, storage.factor) - .show(player, (_, radius, height, offset, blocksSet, replaceBlocksSet, replaceMode, blending, factor) => { - slot.nameTag = `§r§3Лопата §f${radius} §6${blocksSet}` - storage.radius = radius - storage.height = height - storage.offset = offset - storage.replaceMode = replaceMode ?? '' - storage.blending = Math.min(radius, blending) - storage.factor = factor - - storage.blocksSet = [player.id, blocksSet] - - if (replaceBlocksSet) storage.replaceBlocksSet = [player.id, replaceBlocksSet] - else storage.replaceBlocksSet = ['', ''] - - this.saveStorage(slot, storage) - player.success( - t`${storage.blocksSet[0] ? 'Отредактирована' : 'Создана'} лопата с ${blocksSet} набором блоков и радиусом ${radius}`, - ) - }) + .addToggle('Использовать интервал для активации', storage.useInterval) + .show( + player, + (_, radius, height, offset, blocksSet, replaceBlocksSet, replaceMode, blending, factor, useInterval) => { + slot.nameTag = `§r§3Лопата §f${radius} §6${blocksSet}` + storage.radius = radius + storage.height = height + storage.offset = offset + storage.replaceMode = replaceMode ?? '' + storage.blending = Math.min(radius, blending) + storage.factor = factor + storage.useInterval = useInterval + + storage.blocksSet = [player.id, blocksSet] + + if (replaceBlocksSet) storage.replaceBlocksSet = [player.id, replaceBlocksSet] + else storage.replaceBlocksSet = ['', ''] + + this.saveStorage(slot, storage) + player.success( + t`${storage.blocksSet[0] ? 'Отредактирована' : 'Создана'} лопата с ${blocksSet} набором блоков и радиусом ${radius}`, + ) + }, + ) } constructor() { @@ -107,9 +114,19 @@ class ShovelTool extends WorldEditTool { } } }) + + this.onInterval(10, (player, storage) => { + if (!storage.useInterval) return + this.run(player, storage) + }) } onUse(player: Player, _: ItemStack, storage: Storage) { + if (storage.useInterval) return + this.run(player, storage) + } + + run(player: Player, storage: Storage) { if (this.isLookingUp(player)) return const permutations = getBlocksInSet(storage.blocksSet)