Skip to content

Commit

Permalink
Merge branch 'master' into l10n_master
Browse files Browse the repository at this point in the history
  • Loading branch information
SIsilicon authored Dec 2, 2024
2 parents f10c66e + 2ca22ef commit 5dca536
Show file tree
Hide file tree
Showing 86 changed files with 2,024 additions and 1,619 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"plugins": [ "prettier" ],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"linebreak-style": [
"error",
"windows"
Expand Down
6 changes: 3 additions & 3 deletions mc_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"version": [
0,
9,
2
4
],
"min_engine_version": [
1,
21,
30
50
]
},
"bp_modules": [
Expand Down Expand Up @@ -58,7 +58,7 @@
"bp_dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.15.0-beta"
"version": "1.17.0-beta"
},
{
"module_name": "@minecraft/server-ui",
Expand Down
48 changes: 33 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"typescript": "^4.7.4"
},
"dependencies": {
"@minecraft/server": "1.15.0-beta.1.21.30-preview.24",
"@minecraft/server": "1.17.0-beta.1.21.50-preview.25",
"@minecraft/server-admin": "1.0.0-beta.1.19.80-stable",
"@minecraft/server-ui": "1.4.0-beta.1.21.30-preview.24"
"@minecraft/server-ui": "1.4.0-beta.1.21.50-preview.25"
},
"overrides": {
"@minecraft/server-ui": {
"@minecraft/server": "1.15.0-beta.1.21.30-preview.24"
"@minecraft/server": "1.17.0-beta.1.21.50-preview.25"
}
}
}
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ export default {
};

// WorldEdit version (do not change)
export const VERSION = "0.9.2";
export const VERSION = "0.9.3";
66 changes: 10 additions & 56 deletions src/library/@types/classes/databaseBuilder.d.ts
Original file line number Diff line number Diff line change
@@ -1,66 +1,20 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface Database<T = { [key: string]: any }> {
/**
* Save a value or update a value in the Database under a key
* @param key The key you want to save the value as
* @param value The value you want to save
* @example Database.set('Test Key', 'Test Value');
*/
set<S extends keyof T>(key: S, value: T[S]): void;
/** Database's data. */
data: T;

/**
* Get the value of the key
* @param key
* @returns value
* @example Database.get('Test Key');
*/
get<S extends keyof T>(key: S): T[S];
/** Returns whether the database is a valid object that can have functions called and data read from. */
isValid(): boolean;

/**
* Check if the key exists in the table
* @param key
* @returns Whether the key exists
* @example Database.has('Test Key');
*/
has(key: keyof T): boolean;
/** Returns whether the database has loaded its data from its provider. */
isLoaded(): boolean;

/**
* Delete the key from the table
* @param key
* @example Database.delete('Test Key');
*/
delete(key: keyof T): void;

/**
* Clear everything in the table
* @example Database.clear()
*/
/** Clears everything in the database. */
clear(): void;

/**
* Save all changes made in the database.
* @example Database.save()
*/
/** Saves all changes made in the database. */
save(): void;

/**
* Get all the keys in the database
* @returns Array of keys
* @example Database.keys();
*/
keys(): (keyof T)[];

/**
* Get all the values in the database
* @returns Array of values
* @example Database.values();
*/
values(): T[keyof T][];

/**
* Get all the keys and values in the database in pairs
* @returns Array of key/value pairs
* @example Database.entries();
*/
entries<S extends keyof T>(): [S, T[S]][];
/** Deletes the database from the provider it was loaded from. */
delete(): void;
}
5 changes: 1 addition & 4 deletions src/library/Minecraft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,20 @@ export * from "./utils/index.js";

import { Player as PlayerBuilder } from "./classes/playerBuilder.js";
import { Command } from "./classes/commandBuilder.js";
import { Structure } from "./classes/structureBuilder.js";
import { ServerBuilder } from "./classes/serverBuilder.js";
import { UIForms } from "./classes/uiFormBuilder.js";
import { Block } from "./classes/blockBuilder.js";

export { CustomArgType, CommandPosition } from "./classes/commandBuilder.js";
export { commandSyntaxError, registerInformation as CommandInfo } from "./@types/classes/CommandBuilder";
export { StructureSaveOptions, StructureLoadOptions } from "./classes/structureBuilder.js";
export { getDatabase, deleteDatabase } from "./classes/databaseBuilder.js";
export { Databases } from "./classes/databaseBuilder.js";
export { configuration } from "./configurations.js";

class ServerBuild extends ServerBuilder {
public block = Block;
public player = PlayerBuilder;
public command = Command;
public uiForms = UIForms;
public structure = Structure;

constructor() {
super();
Expand Down
4 changes: 2 additions & 2 deletions src/library/classes/blockBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export class BlockBuilder {
function* recurseStates(i: number): Generator<BlockPermutation> {
const state = props[--i];
for (const val of Array.from(BlockStates.get(state).validValues)) {
permutation = permutation.withState(state, val);
if (permutation.getState(state) != val) return;
permutation = permutation.withState(<any>state, val);
if (permutation.getState(<any>state) != val) return;
if (i == 0) {
yield permutation;
} else {
Expand Down
52 changes: 26 additions & 26 deletions src/library/classes/commandBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { contentLog, RawText } from "../utils/index.js";

export class CustomArgType {
static parseArgs: (args: Array<string>, argIndex: number) => argParseResult<unknown>;
static clone: (argType: CustomArgType) => CustomArgType;
clone: () => CustomArgType;
}

export class CommandPosition implements CustomArgType {
Expand All @@ -20,6 +20,29 @@ export class CommandPosition implements CustomArgType {
yRelative = true;
zRelative = true;

clone() {
const pos = new CommandPosition();
pos.x = this.x;
pos.y = this.y;
pos.z = this.z;
pos.xRelative = this.xRelative;
pos.yRelative = this.yRelative;
pos.zRelative = this.zRelative;
return pos;
}

relativeTo(player: Player, isBlockLoc = false): Vector3 {
const loc = { x: 0, y: 0, z: 0 };
const x = this.x + (this.xRelative ? player.location.x : 0);
const y = this.y + (this.yRelative ? player.location.y : 0);
const z = this.z + (this.zRelative ? player.location.z : 0);

loc.x = isBlockLoc ? Math.floor(x) : x;
loc.y = isBlockLoc ? Math.floor(y) : y;
loc.z = isBlockLoc ? Math.floor(z) : z;
return loc;
}

static parseArgs(args: Array<string>, index: number, is3d = true) {
const pos = new CommandPosition();
for (let i = 0; i < (is3d ? 3 : 2); i++) {
Expand Down Expand Up @@ -57,29 +80,6 @@ export class CommandPosition implements CustomArgType {
}
return { result: pos, argIndex: index };
}

static clone(original: CommandPosition) {
const pos = new CommandPosition();
pos.x = original.x;
pos.y = original.y;
pos.z = original.z;
pos.xRelative = original.xRelative;
pos.yRelative = original.yRelative;
pos.zRelative = original.zRelative;
return pos;
}

relativeTo(player: Player, isBlockLoc = false): Vector3 {
const loc = { x: 0, y: 0, z: 0 };
const x = this.x + (this.xRelative ? player.location.x : 0);
const y = this.y + (this.yRelative ? player.location.y : 0);
const z = this.z + (this.zRelative ? player.location.z : 0);

loc.x = isBlockLoc ? Math.floor(x) : x;
loc.y = isBlockLoc ? Math.floor(y) : y;
loc.z = isBlockLoc ? Math.floor(z) : z;
return loc;
}
}

export class CommandBuilder {
Expand Down Expand Up @@ -443,8 +443,8 @@ export class CommandBuilder {
const argDef = argDefs[defIdx];
if (!("flag" in argDef)) {
if ("type" in argDef && argDef?.default != undefined && !("subName" in argDef)) {
// TODO: use clone command of customArgType here
result.set(argDef.name, argDef.default);
const def = argDef.default.clone?.() ?? argDef.default;
result.set(argDef.name, def);
} else if ("subName" in argDef) {
processSubCmd(i, "");
} else {
Expand Down
Loading

0 comments on commit 5dca536

Please sign in to comment.