-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
267 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.ts] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
export * from './tags.d'; | ||
|
||
type Callback<T> = (err: undefined|Error, ret?: T) => void; | ||
|
||
interface TagsType { | ||
TAGByte: new () => TAGByte, | ||
TAGShort: new () => TAGShort, | ||
TAGInt: new () => TAGInt, | ||
TAGLong: new () => TAGLong, | ||
TAGFloat: new () => TAGFloat, | ||
TAGDouble: new () => TAGDouble, | ||
TAGByteArray: new () => TAGByteArray, | ||
TAGString: new () => TAGString, | ||
TAGList: new () => TAGList, | ||
TAGCompound: new () => TAGCompound, | ||
TAGIntArray: new () => TAGIntArray, | ||
|
||
"1": new () => AGByte, | ||
"2": new () => AGShort, | ||
"3": new () => AGInt, | ||
"4": new () => AGLong, | ||
"5": new () => AGFloat, | ||
"6": new () => AGDouble, | ||
"7": new () => AGByteArray, | ||
"8": new () => AGString, | ||
"9": new () => AGList, | ||
"10": new () =>TAGCompound, | ||
"11": new () =>TAGIntArray, | ||
|
||
TAG_Byte: number, | ||
TAG_Short: number, | ||
TAG_Int: number, | ||
TAG_Long: number, | ||
TAG_Float: number, | ||
TAG_Double: number, | ||
TAG_Byte_Array: number, | ||
TAG_String: number, | ||
TAG_List: number, | ||
TAG_Compound: number, | ||
TAG_Int_Array: number, | ||
} | ||
|
||
export = class NBT { | ||
loadFromBuffer(buff: Buffer, callback: Callback<void>): void; | ||
loadFromZlibCompressedBuffer(buff: Buffer, callback: Callback<void>): void; | ||
|
||
writeToCompressedBuffer(callback: Callback<void>, method?: string): void; | ||
writeToBuffer(): Buffer; | ||
|
||
static Tags: TagsType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export type JSONObject = { [key: string]: any; }; | ||
|
||
export = class BaseTag { | ||
readFromBuffer(buff: Buffer, offset: number): number; | ||
writeBuffer(buff: Buffer, offset: number): number; | ||
calcBufferLength(): number; | ||
|
||
getType(): string; | ||
getName(): string; | ||
getId(): string; | ||
getValue(): any; | ||
setValue(value: any): void; | ||
|
||
getNextTag(buff: Buffer, offset: number): { length: number, tag: BaseTag }; | ||
|
||
count(): number; | ||
|
||
selectAt(idx: number): BaseTag|undefined; | ||
getAt(idx: number): BaseTag|undefined; | ||
select(name: string): BaseTag|undefined; | ||
get(name: string): BaseTag|undefined; | ||
|
||
getTypeId(): number; | ||
|
||
inspect(): string; | ||
toString(): string; | ||
toJSON(): JSONObject; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import * as TAGByte from './tags/byte.d'; | ||
import * as TAGByteArray from './tags/byte_array.d'; | ||
import * as TAGCompound from './tags/compound.d'; | ||
import * as TAGDouble from './tags/double.d'; | ||
import * as TAGFloat from './tags/float.d'; | ||
import * as TAGInt from './tags/int.d'; | ||
import * as TAGIntArray from './tags/int_array.d'; | ||
import * as TAGList from './tags/list.d'; | ||
import * as TAGLong from './tags/long.d'; | ||
import * as TAGShort from './tags/short.d'; | ||
import * as TAGString from './tags/string.d'; | ||
|
||
export = { | ||
TAGByte: TAGByte, | ||
TAGShort: TAGShort, | ||
TAGInt: TAGInt, | ||
TAGLong: TAGLong, | ||
TAGFloat: TAGFloat, | ||
TAGDouble: TAGDouble, | ||
TAGByteArray: TAGByteArray, | ||
TAGString: TAGString, | ||
TAGList: TAGList, | ||
TAGCompound: TAGCompound, | ||
TAGIntArray: TAGIntArray, | ||
|
||
// Class id -> Class | ||
"1": TAGByte, | ||
"2": TAGShort, | ||
"3": TAGInt, | ||
"4": TAGLong, | ||
"5": TAGFloat, | ||
"6": TAGDouble, | ||
"7": TAGByteArray, | ||
"8": TAGString, | ||
"9": TAGList, | ||
"10": TAGCompound, | ||
"11": TAGIntArray, | ||
|
||
// Tag name -> Class id | ||
TAG_Byte: 1, | ||
TAG_Short: 2, | ||
TAG_Int: 3, | ||
TAG_Long: 4, | ||
TAG_Float: 5, | ||
TAG_Double: 6, | ||
TAG_Byte_Array: 7, | ||
TAG_String: 8, | ||
TAG_List: 9, | ||
TAG_Compound: 10, | ||
TAG_Int_Array: 11, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as BaseTag from '../base_tag.d'; | ||
|
||
export = class TAGByte extends BaseTag { | ||
getType(): 'TAG_Byte'; | ||
|
||
getValue(): number; | ||
setValue(value: number): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import BaseTag from '../base_tag.d'; | ||
|
||
export default class TAGByteArray extends BaseTag { | ||
getType(): 'TAG_Byte_Array'; | ||
|
||
getValue(): number[]; | ||
setValue(value: number[]): void; | ||
|
||
unshift(value: number): number; | ||
shift(): number; | ||
push(value: number): number; | ||
pop(): number; | ||
insert(value: number, pos: number): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as BaseTag from '../base_tag.d'; | ||
|
||
export = class TAGCompound extends BaseTag { | ||
getType(): 'TAG_Compound'; | ||
|
||
getValue(): { [key: string]: BaseTag; }; | ||
setValue(value: { [key: string]: BaseTag; }): void; | ||
|
||
setByName(name: string, value: BaseTag, replace?: boolean): void; | ||
deleteByName(name: string): void; | ||
clean(): void; | ||
|
||
getNames(): string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as BaseTag from '../base_tag.d'; | ||
|
||
export = class TAGDouble extends BaseTag { | ||
getType(): 'TAG_Double'; | ||
|
||
getValue(): number; | ||
setValue(value: number): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as BaseTag from '../base_tag.d'; | ||
|
||
export = class TAGFloat extends BaseTag { | ||
getType(): 'TAG_Float'; | ||
|
||
getValue(): number; | ||
setValue(value: number): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as BaseTag from '../base_tag.d'; | ||
|
||
export = class TAGInt extends BaseTag { | ||
getType(): 'TAG_Int'; | ||
|
||
getValue(): number; | ||
setValue(value: number): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as BaseTag from '../base_tag.d'; | ||
|
||
export = class TAGIntArray extends BaseTag { | ||
getType(): 'TAG_Int_Array'; | ||
|
||
getValue(): number[]; | ||
setValue(value: number[]): void; | ||
|
||
unshift(value: number): number; | ||
shift(): number; | ||
push(value: number): number; | ||
pop(): number; | ||
insert(value: number, pos: number): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as BaseTag from '../base_tag.d'; | ||
|
||
export = class TAGList extends BaseTag { | ||
childType: 'TAG_End'; | ||
|
||
getType(): 'TAG_List'; | ||
|
||
getValue(): BaseTag[]; | ||
setValue(value: BaseTag[]): void; | ||
|
||
unshift(value: BaseTag): number; | ||
shift(): BaseTag; | ||
push(value: BaseTag): number; | ||
pop(): BaseTag; | ||
insert(value: BaseTag, pos: number): void; | ||
|
||
clean(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Long from 'long'; | ||
|
||
import * as BaseTag from '../base_tag.d'; | ||
|
||
export = class TAGLong extends BaseTag { | ||
getType(): 'TAG_Long'; | ||
|
||
getValue(): Long; | ||
setValue(value: Long): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as BaseTag from '../base_tag.d'; | ||
|
||
export = class TAGShort extends BaseTag { | ||
getType(): 'TAG_Short'; | ||
|
||
getValue(): number; | ||
setValue(value: number): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as BaseTag from '../base_tag.d'; | ||
|
||
export = class TAGString extends BaseTag { | ||
getType(): 'TAG_String'; | ||
|
||
getValue(): string; | ||
setValue(value: string): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,4 +240,6 @@ NBT.prototype.toJSON = function() { | |
return res; | ||
}; | ||
|
||
NBT.Tags = require('./lib/tags'); | ||
|
||
module.exports = NBT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters