diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b1622f47a..737452920 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,10 +25,13 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v3 - # Install python + # Install python and npm - uses: actions/setup-python@v3 with: python-version: '3.x' + - uses: bahmutov/npm-install@v1 + with: + node-version: 16 # Install isort and black for linting - name: Install isort and black @@ -41,6 +44,10 @@ jobs: # Run black - name: Run black run: black --check --color --diff . + + # Run eslint + - name: Test eslint + run: npm run lint # This workflow contains a single job called "build" build: @@ -67,9 +74,6 @@ jobs: - name: Install polib run: pip install polib - - name: Test eslint - run: npm run lint - - name: Run build script (${{ matrix.target }}) run: python build.py --clean --target ${{ matrix.target }} diff --git a/.gitignore b/.gitignore index 2abdb83e3..a0e1040c4 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ BP/scripts/* RP/manifest.json BP/manifest.json node_modules +.venv .vscode app/.import __pycache__ diff --git a/README.md b/README.md index 1d7732669..7bae64628 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ To properly add this addon to the server, you first need to upload an already ex WorldEdit currently has the following features. - Clipboard manipulation (Cut, Copy, Paste) - Masking blocks from certain actions -- Maniuplating region selections +- Manipulating region selections - Navigation commands and the Navigation Wand - Generating shapes - Multiblock patterns @@ -38,7 +38,7 @@ These features will be added in the near future. - More brushes and tools - More selection shapes - More selection operations -- Palletes +- Palettes - Basically, Java Parity ## Documentation diff --git a/app/biome_height_data.gd b/app/biome_height_data.gd index da5264202..f8a206f4f 100644 --- a/app/biome_height_data.gd +++ b/app/biome_height_data.gd @@ -11,7 +11,7 @@ var height_limit: int var _is_valid = false var _height_data = [] var _biome_data = [] -# var _biome_pallete_data = [] +# var _biome_palette_data = [] # warning-ignore:shadowed_variable func _init(x: int, z: int, dimension = 0) -> void: @@ -50,7 +50,7 @@ func load_from_db(leveldb: LevelDB, mutex: Mutex = null) -> void: var header = buffer.get_u8() if header == 0xff: _biome_data.append(null) -# _biome_pallete_data.append(null) +# _biome_palette_data.append(null) continue # warning-ignore:unused_variable @@ -72,26 +72,26 @@ func load_from_db(leveldb: LevelDB, mutex: Mutex = null) -> void: else: ids = _get_packed_bits(buffer, bits_per_entry, 4096) - var palletes = [] - var pallete_count = buffer.get_u8() + var palettes = [] + var palette_count = buffer.get_u8() buffer.big_endian = true - for i in pallete_count: + for i in palette_count: var biome = buffer.get_32() - palletes.append(biome) + palettes.append(biome) buffer.big_endian = false - buffer.seek(buffer.get_position() + 3) # strangely three bytes of padding seem to be added to the pallete + buffer.seek(buffer.get_position() + 3) # strangely three bytes of padding seem to be added to the palette var biome_ids = [] for id in ids: - biome_ids.append(palletes[id] if id < pallete_count else 0) + biome_ids.append(palettes[id] if id < palette_count else 0) _biome_data.append(biome_ids) -# _biome_pallete_data.append(palletes) +# _biome_palette_data.append(palettes) else: var id = buffer.get_32() _biome_data.append(id) -# _biome_pallete_data.append([id]) +# _biome_palette_data.append([id]) height_limit = min_height + _biome_data.size() * 16 _is_valid = true @@ -119,27 +119,27 @@ func save_to_db(leveldb: LevelDB, mutex: Mutex = null) -> int: buffer.put_u8(0xff) continue - var pallete: Array + var palette: Array if typeof(biomes) == TYPE_ARRAY: - var new_pallete := {} + var new_palette := {} for b in biomes: - new_pallete[b] = 0 - pallete = new_pallete.keys() + new_palette[b] = 0 + palette = new_palette.keys() else: - pallete = [biomes] + palette = [biomes] - if pallete.size() > 1: + if palette.size() > 1: # warning-ignore:narrowing_conversion - var bits_per_entry: int = nearest_po2(log(nearest_po2(pallete.size())) / log(2)) + var bits_per_entry: int = nearest_po2(log(nearest_po2(palette.size())) / log(2)) buffer.put_u8((bits_per_entry << 1) + 1) - var reverse_pallete = {} - for j in pallete.size(): - reverse_pallete[pallete[j]] = j + var reverse_palette = {} + for j in palette.size(): + reverse_palette[palette[j]] = j var ids = [] for biome in biomes: - ids.append(reverse_pallete[biome]) + ids.append(reverse_palette[biome]) if bits_per_entry > 2: var height_buffer = StreamPeerBuffer.new() @@ -153,16 +153,16 @@ func save_to_db(leveldb: LevelDB, mutex: Mutex = null) -> int: else: _put_packed_bits(buffer, bits_per_entry, ids) - buffer.put_u8(pallete.size()) + buffer.put_u8(palette.size()) buffer.big_endian = true - for p in pallete: + for p in palette: buffer.put_32(p) buffer.big_endian = false buffer.put_data([0x00, 0x00, 0x00]) else: buffer.put_u8(0x01) - buffer.put_32(pallete[0]) + buffer.put_32(palette[0]) if mutex: mutex.lock() @@ -336,29 +336,29 @@ func _put_packed_bits(buffer: StreamPeer, size: int, input: Array) -> void: # var new_biomes = _biome_changes[y_idx] # # var biomes = _biome_data[y_idx] -# var pallete = _biome_pallete_data[y_idx] +# var palette = _biome_palette_data[y_idx] # # for change in new_biomes: # var biome: int = new_biomes[change] # -# if pallete.size() == 1: -# if pallete[0] == biome: +# if palette.size() == 1: +# if palette[0] == biome: # continue # -# pallete.append(biome) +# palette.append(biome) # var new_data = [] # for i in 4096: -# new_data.append(pallete[0]) +# new_data.append(palette[0]) # _biome_data[y_idx] = new_data # biomes = new_data # # var subchunk_idx = xyz_to_idx(change.x, change.y, change.z) # -# if pallete.size() > 1: -# var new_pallete = {} +# if palette.size() > 1: +# var new_palette = {} # for b in biomes: -# new_pallete[b] = 0 +# new_palette[b] = 0 # -# _biome_pallete_data[y_idx] = new_pallete.keys() -# if new_pallete.size() == 1: -# _biome_data[y_idx] = new_pallete.keys()[0] +# _biome_palette_data[y_idx] = new_palette.keys() +# if new_palette.size() == 1: +# _biome_data[y_idx] = new_palette.keys()[0] diff --git a/app/nbt_parser.gd b/app/nbt_parser.gd index fb8253cda..386e2a2bc 100644 --- a/app/nbt_parser.gd +++ b/app/nbt_parser.gd @@ -37,15 +37,15 @@ class BaseTag extends Reference: tag_id = id func to_json() -> Dictionary: - printerr("to_json() needs to be overriden!") + printerr("to_json() needs to be overridden!") return { "type": tag_id } # warning-ignore:unused_argument func write(stream: StreamPeer) -> void: - printerr("write() needs to be overriden!") + printerr("write() needs to be overridden!") func duplicate() -> BaseTag: - printerr("duplicate() needs to be overriden!") + printerr("duplicate() needs to be overridden!") return null static func _read_string(stream: StreamPeer) -> String: diff --git a/app/world_processor.gd b/app/world_processor.gd index 7e60957ef..07fe4cfb6 100644 --- a/app/world_processor.gd +++ b/app/world_processor.gd @@ -90,16 +90,16 @@ func check_for_changes(world: MCWorld) -> Dictionary: var change := {} var biomes: Array = result.biomes - var pallete: Array = result.pallete + var palette: Array = result.palette - var palleteMap := { 0: -1 } - for i in pallete.size(): - palleteMap[i + 1] = pallete[i] + var paletteMap := { 0: -1 } + for i in palette.size(): + paletteMap[i + 1] = palette[i] for loc in 4096: loc = int(loc) var idx: int = biomes[loc] - var biome: int = palleteMap[idx] + var biome: int = paletteMap[idx] if biome >= 0: var loc_array := Vector3(loc % 16, int(floor(loc / 16)) % 16, int(floor(loc / 256)) % 16) change[loc_array] = biome diff --git a/src/library/classes/commandBuilder.ts b/src/library/classes/commandBuilder.ts index a1dc140e1..0cd53dac4 100644 --- a/src/library/classes/commandBuilder.ts +++ b/src/library/classes/commandBuilder.ts @@ -120,7 +120,7 @@ export class CommandBuilder { return commands; } /** - * Get all the registered informations + * Get a list of all registered information * @returns {Array} * @example getAllRegistration(); */ diff --git a/src/library/classes/eventEmitter.ts b/src/library/classes/eventEmitter.ts index aacbd9b9a..b578a7ba4 100644 --- a/src/library/classes/eventEmitter.ts +++ b/src/library/classes/eventEmitter.ts @@ -12,10 +12,10 @@ export const EventEmitter: EventEmitterConstructor = class Class implements Even * @private * @param {string} eventName Event type to listen for * @param {Function} listener Function to callback on fire - * @param {boolean} [once] Wheather to listen for the event only ONCE or not - * @param {boolean} [prepand] Insert the Event in the beginning of the Array, so it executes first + * @param {boolean} [once] Whether to listen for the event only ONCE or not + * @param {boolean} [prepend] Insert the Event in the beginning of the Array, so it executes first */ - private _addListener(eventName: string, listener: (...args: any[]) => void, once?: boolean, prepand?: boolean): void { + private _addListener(eventName: string, listener: (...args: any[]) => void, once?: boolean, prepend?: boolean): void { const listenerCount = this.listenerCount(eventName); if(listenerCount >= this._configurations.maxListeners) throw `Warning: Possible EventEmitter memory leak detected. ${listenerCount + 1} ${eventName} listeners added. Use emitter.setMaxListeners(n) to increase limit`; const data = { @@ -24,7 +24,7 @@ export const EventEmitter: EventEmitterConstructor = class Class implements Even once, executed: false }; - if(prepand) this._listeners.unshift(data); + if(prepend) this._listeners.unshift(data); else this._listeners.push(data); } diff --git a/src/library/utils/formatter.ts b/src/library/utils/formatter.ts index 5baa6e6f0..2289b63be 100644 --- a/src/library/utils/formatter.ts +++ b/src/library/utils/formatter.ts @@ -57,7 +57,7 @@ export function MS(value: StringValue | number, { compactDuration, fullDuration, } catch(err) { const message = isError(err) ? `${err.message}. Value = ${JSON.stringify(value)}` - : "An unknown error has occured."; + : "An unknown error has occurred."; throw new Error(message); } } diff --git a/src/server/modules/biome_data.ts b/src/server/modules/biome_data.ts index fa8f93cb7..3f3e5d64f 100644 --- a/src/server/modules/biome_data.ts +++ b/src/server/modules/biome_data.ts @@ -95,27 +95,27 @@ class BiomeChanges { biomes.length = 4096; biomes = biomes.fill(-1); } else { - const pallete: number[] = database.get("pallete"); - biomes = (database.get("biomes") as number[]).map(idx => idx ? pallete[idx - 1] : -1); + const palette: number[] = database.get("palette"); + biomes = (database.get("biomes") as number[]).map(idx => idx ? palette[idx - 1] : -1); } for (const [loc, biome] of data.entries()) { biomes[loc] = biome; } - const palleteMap = new Map(); + const paletteMap = new Map(); for (const biome of biomes) { if (biome >= 0) { - palleteMap.set(biome, null); + paletteMap.set(biome, null); } } - const newPallete = Array.from(palleteMap.keys()); - palleteMap.clear(); - newPallete.forEach((val, idx) => palleteMap.set(val, idx + 1)); - palleteMap.set(-1, 0); + const newPalette = Array.from(paletteMap.keys()); + paletteMap.clear(); + newPalette.forEach((val, idx) => paletteMap.set(val, idx + 1)); + paletteMap.set(-1, 0); - database.set("biomes", biomes.map(biome => palleteMap.get(biome))); - database.set("pallete", newPallete); + database.set("biomes", biomes.map(biome => paletteMap.get(biome))); + database.set("palette", newPalette); database.save(); } diff --git a/src/server/modules/extern/resource_pools.ts b/src/server/modules/extern/resource_pools.ts index a85c0392b..da35e33c4 100644 --- a/src/server/modules/extern/resource_pools.ts +++ b/src/server/modules/extern/resource_pools.ts @@ -27,7 +27,7 @@ import { TicksPerSecond } from "@minecraft/server"; import { setTickTimeout, clearTickTimeout } from "@notbeer-api"; import { EventEmitterTypes } from "library/@types/classes/eventEmitter"; -// Auxilary declarations +// Auxiliary declarations function* idGenerator(): Generator { let id = 0; @@ -134,7 +134,7 @@ class ResourcePool { try { obj.close(); } catch (err) { - this.log(0, "error calling resourse close method:", err); + this.log(0, "error calling resource close method:", err); } this.deleteFromBusy(obj); @@ -167,7 +167,7 @@ class ResourcePool { try { obj.close(); } catch (err) { - this.log(0, "error calling resourse close method:", err); + this.log(0, "error calling resource close method:", err); } this.deleteFromBusy(obj); diff --git a/src/server/modules/region_buffer.ts b/src/server/modules/region_buffer.ts index 1a3150dcd..d2692c5e3 100644 --- a/src/server/modules/region_buffer.ts +++ b/src/server/modules/region_buffer.ts @@ -138,7 +138,7 @@ export class RegionBuffer { if (shouldTransform) { transform = block => { const blockName = block.type.id; - const attachement = block.getState("attachement") as string; + const attachment = block.getState("attachment") as string; const direction = block.getState("direction") as number; const doorHingeBit = block.getState("door_hinge_bit") as boolean; const facingDir = block.getState("facing_direction") as number; @@ -168,9 +168,9 @@ export class RegionBuffer { } else if (doorHingeBit != null && direction != null) { const states = (this.transformMapping(mappings.doorMap, `${doorHingeBit}_${direction}`, ...rotFlip) as string).split("_"); block = withProperties({ "door_hinge_bit": states[0] == "true", "direction": parseInt(states[1]) }); - } else if (attachement != null && direction != null) { - const states = (this.transformMapping(mappings.bellMap, `${attachement}_${direction}`, ...rotFlip) as string).split("_"); - block = withProperties({ "attachement": states[0], "direction": parseInt(states[1]) }); + } else if (attachment != null && direction != null) { + const states = (this.transformMapping(mappings.bellMap, `${attachment}_${direction}`, ...rotFlip) as string).split("_"); + block = withProperties({ "attachment": states[0], "direction": parseInt(states[1]) }); } else if (cardinalDir != null) { const state = this.transformMapping(mappings.cardinalDirectionMap, cardinalDir, ...rotFlip); block = block.withState("minecraft:cardinal_direction", state); @@ -545,7 +545,7 @@ const mappings = { true_2: new Vector(-1, 0, 0.5), true_3: new Vector(-0.5, 0,-1) }, - bellMap: { // attachement - direction + bellMap: { // attachment - direction standing_0: new Vector( 1, 0.5, 0), standing_1: new Vector( 0, 0.5, 1), standing_2: new Vector(-1, 0.5, 0), diff --git a/src/server/sessions.ts b/src/server/sessions.ts index c33269e5e..f24270a1f 100644 --- a/src/server/sessions.ts +++ b/src/server/sessions.ts @@ -178,7 +178,7 @@ export class PlayerSession { } /** - * Get the position the player may use while excuting a command, such as ;fill and ;sphere + * Get the position the player may use while executing a command, such as ;fill and ;sphere * @returns placement position */ getPlacementPosition() {