Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JadlionHD committed May 26, 2023
1 parent 38bc1c2 commit 8ecf871
Show file tree
Hide file tree
Showing 42 changed files with 4,151 additions and 705 deletions.
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"C_Cpp.default.includePath": [
"lib/include",
"${env:LOCALAPPDATA}\\node-gyp\\Cache\\18.16.0\\include\\node",
"${workspaceFolder}\\node_modules\\node-addon-api"
]
}
37 changes: 28 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Growtopia.js

![Github Version](https://img.shields.io/github/package-json/v/jadlionhd/growtopia.js?style=flat-square)
![NPM Version](https://img.shields.io/npm/v/growtopia.js?style=flat-square)
![NPM Minified](https://img.shields.io/bundlephobia/min/growtopia.js?style=flat-square)

A fork of [GrowSockets](https://github.com/Pogtopia/GrowSockets) to create a growtopia private servers.

## Requirements
Expand All @@ -19,7 +23,15 @@ npm i growtopia.js
```js
const { Client, TextPacket, Peer } = require("growtopia.js");

const client = new Client("127.0.0.1", 17091);
const client = new Client("127.0.0.1", 17091, { https: true });

client.on("ready", () => {
console.log(`Starting ENet server ${client.config.port} on ${client.config.ip}`);
});

client.on("error", (err) => {
console.log("Something wrong", err);
});

client.on("connect", (netID) => {
console.log(`Connected netID ${netID}`);
Expand All @@ -32,18 +44,25 @@ client.on("disconnect", (netID) => {
});

client.on("raw", (netID, data) => {
const type = data.readInt32LE();
const parsed = client.parseAction(data);
console.log("raw", data);
});

if (type === 3) {
if (parsed.action === "quit") {
client._client.disconnect(netID);
}
client.on("action", (peer, data) => {
console.log("action", { peer, data });
if (data.action === "quit") {
peer.disconnect();
}
console.log({ netID, type, parsed });
});

console.log(`Started ENet server ${client.config.port} on ${client.config.ip}`);
client.on("tank", (peer, tank) => {
console.log("tank", { peer, tank });
});

client.on("auth", (peer, data) => {
console.log("auth", { peer, data });
});

client.listen(1024);
```

## Links
Expand Down
22 changes: 4 additions & 18 deletions docs/assets/highlight.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@
--dark-hl-5: #B5CEA8;
--light-hl-6: #001080;
--dark-hl-6: #9CDCFE;
--light-hl-7: #AF00DB;
--dark-hl-7: #C586C0;
--light-hl-8: #000000FF;
--dark-hl-8: #D4D4D4;
--light-hl-9: #008000;
--dark-hl-9: #6A9955;
--light-hl-10: #267F99;
--dark-hl-10: #4EC9B0;
--light-hl-7: #000000FF;
--dark-hl-7: #D4D4D4;
--light-hl-8: #AF00DB;
--dark-hl-8: #C586C0;
--light-code-background: #FFFFFF;
--dark-code-background: #1E1E1E;
}
Expand All @@ -35,8 +31,6 @@
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--hl-10: var(--light-hl-10);
--code-background: var(--light-code-background);
} }

Expand All @@ -50,8 +44,6 @@
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--hl-10: var(--dark-hl-10);
--code-background: var(--dark-code-background);
} }

Expand All @@ -65,8 +57,6 @@
--hl-6: var(--light-hl-6);
--hl-7: var(--light-hl-7);
--hl-8: var(--light-hl-8);
--hl-9: var(--light-hl-9);
--hl-10: var(--light-hl-10);
--code-background: var(--light-code-background);
}

Expand All @@ -80,8 +70,6 @@
--hl-6: var(--dark-hl-6);
--hl-7: var(--dark-hl-7);
--hl-8: var(--dark-hl-8);
--hl-9: var(--dark-hl-9);
--hl-10: var(--dark-hl-10);
--code-background: var(--dark-code-background);
}

Expand All @@ -94,6 +82,4 @@
.hl-6 { color: var(--hl-6); }
.hl-7 { color: var(--hl-7); }
.hl-8 { color: var(--hl-8); }
.hl-9 { color: var(--hl-9); }
.hl-10 { color: var(--hl-10); }
pre, code { background: var(--code-background); }
2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

763 changes: 255 additions & 508 deletions docs/classes/Client.html

Large diffs are not rendered by default.

37 changes: 24 additions & 13 deletions docs/classes/Peer.html

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions docs/classes/TankPacket.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h4>Hierarchy</h4>
<ul class="tsd-hierarchy">
<li><span class="target">TankPacket</span></li></ul></section><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/JadlionHD/growtopia.js/blob/56b585f/src/packets/TankPacket.ts#L8">src/packets/TankPacket.ts:8</a></li></ul></aside>
<li>Defined in <a href="https://github.com/JadlionHD/growtopia.js/blob/38bc1c2/src/packets/TankPacket.ts#L8">src/packets/TankPacket.ts:8</a></li></ul></aside>
<section class="tsd-panel-group tsd-index-group">
<section class="tsd-panel tsd-index-panel">
<details class="tsd-index-content tsd-index-accordion" open><summary class="tsd-accordion-summary tsd-index-summary">
Expand Down Expand Up @@ -61,7 +61,7 @@ <h5><code class="tsd-tag ts-flagOptional">Optional</code> <span class="tsd-kind-
</div></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="TankPacket.html" class="tsd-signature-type tsd-kind-class">TankPacket</a></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/JadlionHD/growtopia.js/blob/56b585f/src/packets/TankPacket.ts#L13">src/packets/TankPacket.ts:13</a></li></ul></aside></li></ul></section></section>
<li>Defined in <a href="https://github.com/JadlionHD/growtopia.js/blob/38bc1c2/src/packets/TankPacket.ts#L13">src/packets/TankPacket.ts:13</a></li></ul></aside></li></ul></section></section>
<section class="tsd-panel-group tsd-member-group">
<h2>Properties</h2>
<section class="tsd-panel tsd-member"><a id="data" class="tsd-anchor"></a>
Expand All @@ -70,7 +70,7 @@ <h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagOptional">Optional</code
<div class="tsd-comment tsd-typography"><p>The tankpacket header and data.</p>
</div><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/JadlionHD/growtopia.js/blob/56b585f/src/packets/TankPacket.ts#L13">src/packets/TankPacket.ts:13</a></li></ul></aside></section></section>
<li>Defined in <a href="https://github.com/JadlionHD/growtopia.js/blob/38bc1c2/src/packets/TankPacket.ts#L13">src/packets/TankPacket.ts:13</a></li></ul></aside></section></section>
<section class="tsd-panel-group tsd-member-group">
<h2>Methods</h2>
<section class="tsd-panel tsd-member"><a id="parse" class="tsd-anchor"></a>
Expand All @@ -82,7 +82,7 @@ <h3 class="tsd-anchor-link"><span>parse</span><a href="#parse" aria-label="Perma
</div>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type ">Buffer</span></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/JadlionHD/growtopia.js/blob/56b585f/src/packets/TankPacket.ts#L55">src/packets/TankPacket.ts:55</a></li></ul></aside></li></ul></section>
<li>Defined in <a href="https://github.com/JadlionHD/growtopia.js/blob/38bc1c2/src/packets/TankPacket.ts#L55">src/packets/TankPacket.ts:55</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member"><a id="from" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagStatic">Static</code> <span>from</span><a href="#from" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
<ul class="tsd-signatures">
Expand All @@ -99,7 +99,7 @@ <h5><span class="tsd-kind-parameter">data</span>: <a href="../interfaces/Tank.ht
</div></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="TankPacket.html" class="tsd-signature-type tsd-kind-class">TankPacket</a></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/JadlionHD/growtopia.js/blob/56b585f/src/packets/TankPacket.ts#L19">src/packets/TankPacket.ts:19</a></li></ul></aside></li></ul></section>
<li>Defined in <a href="https://github.com/JadlionHD/growtopia.js/blob/38bc1c2/src/packets/TankPacket.ts#L19">src/packets/TankPacket.ts:19</a></li></ul></aside></li></ul></section>
<section class="tsd-panel tsd-member"><a id="fromBuffer" class="tsd-anchor"></a>
<h3 class="tsd-anchor-link"><code class="tsd-tag ts-flagStatic">Static</code> <span>from<wbr/>Buffer</span><a href="#fromBuffer" aria-label="Permalink" class="tsd-anchor-icon"><svg class="icon icon-tabler icon-tabler-link" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><use href="#icon-anchor-a"></use><use href="#icon-anchor-b"></use><use href="#icon-anchor-c"></use></svg></a></h3>
<ul class="tsd-signatures">
Expand All @@ -116,7 +116,7 @@ <h5><span class="tsd-kind-parameter">buf</span>: <span class="tsd-signature-type
</div></li></ul></div>
<h4 class="tsd-returns-title">Returns <a href="TankPacket.html" class="tsd-signature-type tsd-kind-class">TankPacket</a></h4><aside class="tsd-sources">
<ul>
<li>Defined in <a href="https://github.com/JadlionHD/growtopia.js/blob/56b585f/src/packets/TankPacket.ts#L27">src/packets/TankPacket.ts:27</a></li></ul></aside></li></ul></section></section></div>
<li>Defined in <a href="https://github.com/JadlionHD/growtopia.js/blob/38bc1c2/src/packets/TankPacket.ts#L27">src/packets/TankPacket.ts:27</a></li></ul></aside></li></ul></section></section></div>
<div class="col-sidebar">
<div class="page-menu">
<div class="tsd-navigation settings">
Expand Down Expand Up @@ -144,13 +144,24 @@ <h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.9389
<div class="site-menu">
<nav class="tsd-navigation"><a href="../modules.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-4-path"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)" id="icon-4-text"></path></svg><span>growtopia.js</span></a>
<ul class="tsd-small-nested-navigation">
<li><a href="../enums/VariantType.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-enum)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-8-path"></rect><path d="M9.45 16V7.24H14.49V8.224H10.518V10.936H14.07V11.908H10.518V15.016H14.49V16H9.45Z" fill="var(--color-text)" id="icon-8-text"></path></svg><span>Variant<wbr/>Type</span></a></li>
<li><a href="../enums/PacketTypes.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-enum)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-8-path"></rect><path d="M9.45 16V7.24H14.49V8.224H10.518V10.936H14.07V11.908H10.518V15.016H14.49V16H9.45Z" fill="var(--color-text)" id="icon-8-text"></path></svg><span>Packet<wbr/>Types</span></a></li>
<li><a href="../enums/TankTypes.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-8-path"></use><use href="#icon-8-text"></use></svg><span>Tank<wbr/>Types</span></a></li>
<li><a href="../enums/TileActionTypes.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-8-path"></use><use href="#icon-8-text"></use></svg><span>Tile<wbr/>Action<wbr/>Types</span></a></li>
<li><a href="../enums/TileCategoryFlags.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-8-path"></use><use href="#icon-8-text"></use></svg><span>Tile<wbr/>Category<wbr/>Flags</span></a></li>
<li><a href="../enums/TileExtraTypes.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-8-path"></use><use href="#icon-8-text"></use></svg><span>Tile<wbr/>Extra<wbr/>Types</span></a></li>
<li><a href="../enums/TileFlags.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-8-path"></use><use href="#icon-8-text"></use></svg><span>Tile<wbr/>Flags</span></a></li>
<li><a href="../enums/TileOptionsFlags.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-8-path"></use><use href="#icon-8-text"></use></svg><span>Tile<wbr/>Options<wbr/>Flags</span></a></li>
<li><a href="../enums/TilePropertiesFlags.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-8-path"></use><use href="#icon-8-text"></use></svg><span>Tile<wbr/>Properties<wbr/>Flags</span></a></li>
<li><a href="../enums/VariantTypes.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-8-path"></use><use href="#icon-8-text"></use></svg><span>Variant<wbr/>Types</span></a></li>
<li><a href="Client.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-128-path"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)" id="icon-128-text"></path></svg><span>Client</span></a></li>
<li><a href="Peer.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Peer</span></a></li>
<li><a href="TankPacket.html" class="current"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Tank<wbr/>Packet</span></a></li>
<li><a href="TextPacket.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Text<wbr/>Packet</span></a></li>
<li><a href="Variant.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-128-path"></use><use href="#icon-128-text"></use></svg><span>Variant</span></a></li>
<li><a href="../interfaces/ClientType.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-256-path"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)" id="icon-256-text"></path></svg><span>Client<wbr/>Type</span></a></li>
<li><a href="../interfaces/ActionEvent.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-interface)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-256-path"></rect><path d="M9.51 16V15.016H11.298V8.224H9.51V7.24H14.19V8.224H12.402V15.016H14.19V16H9.51Z" fill="var(--color-text)" id="icon-256-text"></path></svg><span>Action<wbr/>Event</span></a></li>
<li><a href="../interfaces/ClientOptions.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-256-path"></use><use href="#icon-256-text"></use></svg><span>Client<wbr/>Options</span></a></li>
<li><a href="../interfaces/ClientType.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-256-path"></use><use href="#icon-256-text"></use></svg><span>Client<wbr/>Type</span></a></li>
<li><a href="../interfaces/LoginInfo.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-256-path"></use><use href="#icon-256-text"></use></svg><span>Login<wbr/>Info</span></a></li>
<li><a href="../interfaces/Tank.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-256-path"></use><use href="#icon-256-text"></use></svg><span>Tank</span></a></li>
<li><a href="../interfaces/VariantOptions.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-256-path"></use><use href="#icon-256-text"></use></svg><span>Variant<wbr/>Options</span></a></li>
<li><a href="../types/Sendable.html"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-4194304-path"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)" id="icon-4194304-text"></path></svg><span>Sendable</span></a></li>
Expand Down
Loading

0 comments on commit 8ecf871

Please sign in to comment.