Skip to content

Commit

Permalink
Merge pull request #78 from TheMrZZ/develop
Browse files Browse the repository at this point in the history
Changes in execute.if & data
  • Loading branch information
TheMrZZ authored Apr 5, 2021
2 parents df6ef4d + 46fcd3e commit 733b91f
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 193 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sandstone",
"description": "Sandstone, a Typescript library for Minecraft datapacks.",
"version": "0.10.2",
"version": "0.11.0",
"author": "TheMrZZ - Florian ERNST",
"bugs": {
"url": "https://github.com/TheMrZZ/sandstone/issues"
Expand Down
45 changes: 28 additions & 17 deletions src/commands/CommandsRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ export class CommandsRoot {
})
}

// experience command //
experience = new Experience(this)
// experience command (aliased as xp) //
xp = new Experience(this)

// fill command //
fill = (new Fill(this)).fill
Expand Down Expand Up @@ -473,7 +473,7 @@ export class CommandsRoot {
// team command //
team = new Team(this)

// teammessage command //
// teammsg command (aliased to tm) //
/**
* Specifies a message to send to team.
*
Expand All @@ -484,13 +484,13 @@ export class CommandsRoot {
*
* At least one message is necesarry.
*/
@command('teammessage', { isRoot: true })
teammessage = (...messages: AtLeastOne<MessageOrSelector>) => { }
@command('tm', { isRoot: true })
tm = (...messages: AtLeastOne<MessageOrSelector>) => { }

// teleport command //
teleport = (new Teleport(this)).teleport
// teleport command (aliased to tp) //
tp = (new Teleport(this)).tp

// tell command //
// msg command (aliased to w) //
/**
* Sends a private message to one or more players.
* @param targets Specifies the player(s) to send the message to.
Expand All @@ -499,8 +499,8 @@ export class CommandsRoot {
* The game replaces entity selectors in the message with the list of selected entities' names,
* which is formatted as "name1 and name2" for two entities, or "name1, name2, ... and namen" for n entities.
*/
@command('tell', { isRoot: true })
tell = (targets: MultiplePlayersArgument, ...messages: AtLeastOne<MessageOrSelector>) => { }
@command('w', { isRoot: true })
w = (targets: MultiplePlayersArgument, ...messages: AtLeastOne<MessageOrSelector>) => { }

// tellraw command //
@command('tellraw', { isRoot: true, parsers: { '1': (msg) => new JsonTextComponentClass(msg) } })
Expand All @@ -519,16 +519,27 @@ export class CommandsRoot {

worldborder = new WorldBorder(this)

// / ALIAS COMMANDS ///
// / ALIAS COMMANDS. ///

// msg command //
msg: CommandsRoot['tell'] = (...args) => this.tell(...args)
/*
* In Sandstone, data pack is considered a byproduct of the compilation,
* so the shorter aliases will always be the compiled result.
*/

// w command //
w: CommandsRoot['tell'] = (...args) => this.tell(...args)
// tell command //
tell = this.w

// xp command //
xp: CommandsRoot['experience'] = this.experience
// teammsg command //
teammsg = this.tm

// teleport command //
teleport = this.tp

// msg command //
msg = this.w

// experience command //
experience = this.xp
}

export default CommandsRoot
54 changes: 33 additions & 21 deletions src/commands/implementations/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,44 @@ class DataMerge extends Command {
}

class DataModifyValues extends Command {
/**
* Modify with the NBT of a block at the given position.
*
* @param sourcePosition The coordinates of the block to modify the NBT with.
* @param sourcePath The path of the NBT to modify with.
*/
@command(['from', 'block'], { parsers: { '0': coordinatesParser } })
fromBlock = (sourcePosition: Coordinates, sourcePath: string) => { }
private fromBlock = (...args: unknown[]) => { }

/**
* Modify with the NBT of a given entity.
*
* @param source The entity to modify the NBT with.
* @param sourcePath The path of the NBT to modify with.
*/
@command(['from', 'entity'])
fromEntity = (source: SingleEntityArgument, sourcePath: string) => { }
private fromEntity = (...args: unknown[]) => { }

/**
* Modify with the NBT of a given storage path.
*
* @param source The storage path to modify the NBT with.
* @param sourcePath The path of the NBT to modify with.
*/
@command(['from', 'storage'])
fromStorage = (source: string, sourcePath: string) => { }
private fromStorage = (...args: unknown[]) => { }

from: {
/**
* Modify with the NBT of a block at the given position.
*
* @param sourcePosition The coordinates of the block to modify the NBT with.
* @param sourcePath The path of the NBT to modify with.
*/
block: (sourcePosition: Coordinates, sourcePath: string) => void

/**
* Modify with the NBT of a given entity.
*
* @param source The entity to modify the NBT with.
* @param sourcePath The path of the NBT to modify with.
*/
entity: (source: SingleEntityArgument, sourcePath: string) => void

/**
* Modify with the NBT of a given storage path.
*
* @param source The storage path to modify the NBT with.
* @param sourcePath The path of the NBT to modify with.
*/
storage: (source: string, sourcePath: string) => void
} = {
block: this.fromBlock,
entity: this.fromEntity,
storage: this.fromStorage,
}

/**
* Modify the NBT with the given value.
Expand Down
Loading

0 comments on commit 733b91f

Please sign in to comment.