Skip to content
This repository was archived by the owner on Feb 9, 2020. It is now read-only.

Commit a4c70f9

Browse files
committed
other stuff
binary stuff, globals stuff, npm stuff, etc
1 parent 434848c commit a4c70f9

6 files changed

Lines changed: 31 additions & 52 deletions

File tree

package-lock.json

Lines changed: 4 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/pocketnode/PocketNode.js

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ require("./utils/methods/Globals");
55
const Logger = pocketnode("logger/Logger");
66
const Server = pocketnode("Server");
77

8-
const g = global;
9-
108
function PocketNode(paths){
11-
global.pocketnode.START_TIME = Date.now();
12-
global.pocketnode.NAME = "PocketNode";
13-
global.pocketnode.CODENAME = "[BEGINNINGS]";
14-
global.pocketnode.VERSION = "0.0.4";
15-
global.pocketnode.API_VERSION = "1.0.0";
9+
this.START_TIME = Date.now();
10+
this.NAME = "PocketNode";
11+
this.CODENAME = "[BEGINNINGS]";
12+
this.VERSION = "0.0.5";
13+
this.API_VERSION = "1.0.0";
1614

1715
let logger = new Logger("Server");
1816
let path = {
@@ -21,19 +19,12 @@ function PocketNode(paths){
2119
plugins: Path.normalize(__dirname + "/../../plugins/")
2220
};
2321

24-
for(let i in paths){
25-
if(typeof path[i] !== "undefined"){
26-
path[i] = paths[i];
27-
}
28-
}
22+
for(let i in paths) if(typeof path[i] !== "undefined") path[i] = paths[i];
2923

3024
logger.info("Loading PocketNode...");
3125

32-
global.pocketnode.TRAVIS_BUILD = process.argv.indexOf("--travis-build") !== -1;
33-
global.pocketnode.RUNNING_LOCALLY = (process.argv.indexOf("--local") !== -1 || process.argv.indexOf("-l") !== -1);
34-
35-
let server = new Server(logger, path);
36-
if(pocketnode.TRAVIS_BUILD === true){
26+
let server = new Server(this, logger, path);
27+
if(TRAVIS_BUILD === true){
3728
server.shutdown();
3829
}
3930

src/pocketnode/Server.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const SFS = pocketnode("utils/SimpleFileSystem");
2323

2424
class Server {
2525
initVars(){
26+
this._pocketnode = {};
27+
2628
this._bannedIps = {};
2729
this._bannedNames = {};
2830
this._ops = {};
@@ -70,9 +72,11 @@ class Server {
7072
this._entityCount = 0;
7173
}
7274

73-
constructor(logger, paths){
75+
constructor(pocketnode, logger, paths){
7476
this.initVars();
7577

78+
this._pocketnode = pocketnode;
79+
7680
this._logger = logger;
7781
this._paths = paths;
7882

@@ -108,7 +112,7 @@ class Server {
108112
this._maxPlayers = this._config.getNested("server.max-players", 20);
109113
this._onlineMode = this._config.getNested("server.online-mode", true);
110114

111-
if(!pocketnode.TRAVIS_BUILD) process.stdout.write("\x1b]0;" + this.getName() + " " + this.getPocketNodeVersion() + "\x07");
115+
if(!TRAVIS_BUILD) process.stdout.write("\x1b]0;" + this.getName() + " " + this.getPocketNodeVersion() + "\x07");
112116

113117
this.getLogger().debug("Server Id:", this._serverId);
114118

@@ -145,7 +149,7 @@ class Server {
145149

146150
this._tickCounter = 0;
147151

148-
this.getLogger().info("Done ("+(Date.now() - pocketnode.START_TIME)+"ms)!");
152+
this.getLogger().info("Done ("+(Date.now() - this._pocketnode.START_TIME)+"ms)!");
149153

150154
this.tickProcessor();
151155
//this.forceShutdown();
@@ -180,21 +184,21 @@ class Server {
180184
* @return {string}
181185
*/
182186
getName(){
183-
return pocketnode.NAME;
187+
return this._pocketnode.NAME;
184188
}
185189

186190
/**
187191
* @return {string}
188192
*/
189193
getCodeName(){
190-
return pocketnode.CODENAME;
194+
return this._pocketnode.CODENAME;
191195
}
192196

193197
/**
194198
* @return {string}
195199
*/
196200
getPocketNodeVersion(){
197-
return pocketnode.VERSION;
201+
return this._pocketnode.VERSION;
198202
}
199203

200204
/**
@@ -215,7 +219,7 @@ class Server {
215219
* @return {string}
216220
*/
217221
getApiVersion(){
218-
return pocketnode.API_VERSION;
222+
return this._pocketnode.API_VERSION;
219223
}
220224

221225
/**
@@ -303,7 +307,7 @@ class Server {
303307
* @return {string}
304308
*/
305309
getMotd(){
306-
return this._config.getNested("server.motd", pocketnode.NAME + " Server");
310+
return this._config.getNested("server.motd", this._pocketnode.NAME + " Server");
307311
}
308312

309313
/**

src/pocketnode/network/RakNetAdapter.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
console.log(global.pocketnode.RUNNING_LOCALLY);
2-
3-
const RakNetServer = (pocketnode.RUNNING_LOCALLY ? require("../../../../RakNet") : require("raknet"));
1+
const RakNetServer = (global.RUNNING_LOCALLY ? require("../../../../RakNet") : require("raknet"));
42

53
const Logger = pocketnode("logger/Logger");
64

src/pocketnode/network/minecraft/protocol/LoginPacket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class LoginPacket extends DataPacket {
4949
return;
5050
}
5151

52-
let stream = new BinaryStream(this.readString(true));
52+
let stream = new BinaryStream(this.read(this.readUnsignedVarInt()));
5353
this.chainData = JSON.parse(stream.read(stream.readLInt()).toString());
5454

5555
this.chainData.chain.forEach(chain => {

src/pocketnode/network/minecraft/protocol/TextPacket.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class TextPacket extends DataPacket {
2525
this.xuid = "";
2626
}
2727

28+
constructor(){
29+
super();
30+
this.initVars();
31+
}
32+
2833
_decodePayload(){
2934
this.type = this.readByte();
3035
this.needsTranslation = this.readBool();

0 commit comments

Comments
 (0)