-
Notifications
You must be signed in to change notification settings - Fork 3
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
56 changed files
with
3,826 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 @@ | ||
{ | ||
"name": "classich", | ||
"author": "dottych", | ||
"dependencies": { | ||
"perlin-noise": "^0.0.1", | ||
"request": "^2.88.2" | ||
} | ||
} |
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,73 @@ | ||
{ | ||
"server": { | ||
"port": 25565, | ||
|
||
"name": "My ClassiCH Server", | ||
|
||
"maxPlayers": 64, | ||
|
||
"public": false, | ||
"authentication": false, | ||
|
||
"joinKick": false, | ||
|
||
"motdTitle": "%servername%", | ||
"motdDescription": "%greeting%, %playername%! -noclip", | ||
"motdDescriptionOP": "%greeting%, %playername%!", | ||
|
||
"checkForUpdate": true | ||
}, | ||
|
||
"world": { | ||
"name": "world", | ||
|
||
"size": { | ||
"x": 256, | ||
"y": 128, | ||
"z": 256 | ||
}, | ||
|
||
"spawn": { | ||
"x": -1, | ||
"y": -1, | ||
"z": -1 | ||
}, | ||
|
||
"saveInterval": 45, | ||
|
||
"generationType": "land", | ||
|
||
"spamCount": 80, | ||
"spamInterval": 5, | ||
|
||
"features": { | ||
"blastRadius": 2, | ||
"explosions": false, | ||
"slabs": true, | ||
"saplings": true, | ||
"sponges": true | ||
} | ||
}, | ||
|
||
"messages": { | ||
"spamCount": 5, | ||
"spamInterval": 5 | ||
}, | ||
|
||
"commands": { | ||
"selfActions": false, | ||
"8ballDelay": 10, | ||
"flipDelay": 10 | ||
}, | ||
|
||
"heartbeat": { | ||
"enabled": true, | ||
"url": "https://www.classicube.net/server/heartbeat", | ||
"interval": 45 | ||
}, | ||
|
||
"logging": { | ||
"console": true, | ||
"file": true | ||
} | ||
} |
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 @@ | ||
[ | ||
"Hello", | ||
"Hi", | ||
"Hey", | ||
"Hello there", | ||
"Hi there", | ||
"Hey there", | ||
"Howdy", | ||
"What's up", | ||
"Welcome", | ||
"Greetings", | ||
"Sup", | ||
"Yo" | ||
] |
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,7 @@ | ||
@ECHO OFF | ||
|
||
:run | ||
cls | ||
node ../src/Server.js | ||
pause | ||
goto run |
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 @@ | ||
const ServerMessagePacket = require('./Packets/Server/Message'); | ||
|
||
class Command { | ||
constructor(client, args) { | ||
this.client = client; | ||
this.args = args; | ||
} | ||
|
||
// default response | ||
execute() { | ||
new ServerMessagePacket([this.client], 0xFF, "Command does not exist!"); | ||
} | ||
} | ||
|
||
module.exports = Command; |
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,36 @@ | ||
const fs = require('fs'); | ||
|
||
const utils = require('./Utils'); | ||
const lists = require('./Lists'); | ||
|
||
let commands = {}; | ||
|
||
for (let command of fs.readdirSync('../src/Commands/')) { | ||
// check if it's a module | ||
if (!command.endsWith('.js')) continue; | ||
|
||
// remove ".js" from the end | ||
command = command.slice(0, -3); | ||
|
||
// register command and add its information to list | ||
try { | ||
commands[command.toLowerCase()] = require(`./Commands/${command}`); | ||
|
||
const tempCommand = new (commands[command.toLowerCase()])(null, []); | ||
|
||
lists.commands[command.toLowerCase()] = { | ||
|
||
description: tempCommand.description, | ||
op: tempCommand.op, | ||
hidden: tempCommand.hidden | ||
|
||
}; | ||
} catch(error) { | ||
console.log(error); | ||
delete commands[command.toLowerCase()]; | ||
delete lists.commands[command.toLowerCase()] | ||
utils.log(`"${command}" is NOT a valid command! Ignoring file`); | ||
} | ||
} | ||
|
||
module.exports = commands; |
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,76 @@ | ||
const Command = require('../Command'); | ||
|
||
const ServerMessagePacket = require('../Packets/Server/Message'); | ||
|
||
const utils = require('../Utils'); | ||
const lists = require('../Lists'); | ||
const config = require('../Config') | ||
|
||
class Command8ball extends Command { | ||
constructor(client, args) { | ||
super(client, args); | ||
|
||
this.name = "8ball"; | ||
this.description = "Ask 8-Ball something."; | ||
|
||
this.op = false; | ||
this.hidden = false; | ||
} | ||
|
||
wait(ms) { | ||
return new Promise(r => setTimeout(r, ms)); | ||
} | ||
|
||
execute() { | ||
const me = lists.players[this.client.id]; | ||
|
||
if (this.args.length <= 0) { | ||
new ServerMessagePacket([this.client], 0xFF, `You must ask a question.`); | ||
return; | ||
} | ||
|
||
if (performance.now() < me.commandVars.asked + config.self.commands["8ballDelay"] * 1000) { | ||
new ServerMessagePacket([this.client], 0xFF, `Ask later.`); | ||
return; | ||
} | ||
|
||
me.commandVars.asked = Math.round(performance.now()); | ||
|
||
async function ask(self) { | ||
let questionMessages = utils.splitString(`${me.name} asked 8-Ball: ${self.args.join(' ')}`, "&7"); | ||
|
||
for (let questionMessage of questionMessages) | ||
new ServerMessagePacket( | ||
|
||
utils.getAllPlayerClients(), | ||
0xFF, | ||
questionMessage | ||
|
||
); | ||
|
||
await self.wait(1000 + Math.round(Math.random() * 1000)); | ||
|
||
let answerMessages = utils.splitString( | ||
|
||
`8-Ball: ${me.name}, ${lists.answers[Math.floor(Math.random() * lists.answers.length)].toLowerCase().replaceAll(' i ', ' I ')}.`, | ||
"&7" | ||
|
||
); | ||
|
||
for (let answerMessage of answerMessages) | ||
new ServerMessagePacket( | ||
|
||
utils.getAllPlayerClients(), | ||
0xFF, | ||
answerMessage | ||
|
||
); | ||
|
||
utils.log(answerMessages.join('')); | ||
} | ||
|
||
ask(this); | ||
} | ||
} | ||
|
||
module.exports = Command8ball; |
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,23 @@ | ||
const Command = require('../Command'); | ||
|
||
const ServerMessagePacket = require('../Packets/Server/Message'); | ||
|
||
const config = require('../Config'); | ||
|
||
class CommandAbout extends Command { | ||
constructor(client, args) { | ||
super(client, args); | ||
|
||
this.name = "about"; | ||
this.description = "Says stuff about the server."; | ||
|
||
this.op = false; | ||
this.hidden = false; | ||
} | ||
|
||
execute() { | ||
new ServerMessagePacket([this.client], 0xFF, config.self.server.name); | ||
} | ||
} | ||
|
||
module.exports = CommandAbout; |
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 @@ | ||
const Command = require('../Command'); | ||
|
||
const ServerMessagePacket = require('../Packets/Server/Message'); | ||
|
||
const world = require('../World'); | ||
|
||
class CommandAbout extends Command { | ||
constructor(client, args) { | ||
super(client, args); | ||
|
||
this.name = "backup"; | ||
this.description = "Saves a backup of the current world."; | ||
|
||
this.op = true; | ||
this.hidden = false; | ||
} | ||
|
||
execute() { | ||
new ServerMessagePacket([this.client], 0xFF, "Saving backup..."); | ||
|
||
if (world.backup()) | ||
new ServerMessagePacket([this.client], 0xFF, "Backup saved."); | ||
else | ||
new ServerMessagePacket([this.client], 0xFF, "Something went wrong."); | ||
} | ||
} | ||
|
||
module.exports = CommandAbout; |
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,50 @@ | ||
const Command = require('../Command'); | ||
|
||
const ServerMessagePacket = require('../Packets/Server/Message'); | ||
const ServerDisconnectPacket = require('../Packets/Server/Disconnect'); | ||
|
||
const lists = require('../Lists'); | ||
const utils = require('../Utils'); | ||
const config = require('../Config'); | ||
|
||
class CommandBan extends Command { | ||
constructor(client, args) { | ||
super(client, args); | ||
|
||
this.name = "ban"; | ||
this.description = "Bans a specified player."; | ||
|
||
this.op = true; | ||
this.hidden = false; | ||
} | ||
|
||
execute() { | ||
if (this.args.length <= 0) { | ||
new ServerMessagePacket([this.client], 0xFF, "You must provide a name!"); | ||
return; | ||
} | ||
|
||
if (!config.self.commands.selfActions && this.args[0] === lists.players[this.client.id].name) { | ||
new ServerMessagePacket([this.client], 0xFF, "You can't ban yourself!"); | ||
return; | ||
} | ||
|
||
let name = this.args.shift() | ||
let player = utils.findPlayerByName(name); | ||
let reason = this.args.join(' '); | ||
|
||
if (lists.addBan(name, reason)) { | ||
if (player != undefined) | ||
if (reason.trim() !== "") | ||
new ServerDisconnectPacket([player.client], `Banned: ${reason}`); | ||
else | ||
new ServerDisconnectPacket([player.client], "You were banned!"); | ||
|
||
new ServerMessagePacket([this.client], 0xFF, `${name} is now banned.`); | ||
} else | ||
new ServerMessagePacket([this.client], 0xFF, `${name} is already banned!`); | ||
|
||
} | ||
} | ||
|
||
module.exports = CommandBan; |
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,47 @@ | ||
const Command = require('../Command'); | ||
|
||
const ServerMessagePacket = require('../Packets/Server/Message'); | ||
const ServerTypePacket = require('../Packets/Server/Type'); | ||
|
||
const lists = require('../Lists'); | ||
const utils = require('../Utils'); | ||
const config = require('../Config'); | ||
|
||
class CommandDeOP extends Command { | ||
constructor(client, args) { | ||
super(client, args); | ||
|
||
this.name = "deop"; | ||
this.description = "DeOPs a specified player."; | ||
|
||
this.op = true; | ||
this.hidden = false; | ||
} | ||
|
||
execute() { | ||
if (this.args.length <= 0) { | ||
new ServerMessagePacket([this.client], 0xFF, "You must provide a name!"); | ||
return; | ||
} | ||
|
||
if (!config.self.commands.selfActions && this.args[0] === lists.players[this.client.id].name) { | ||
new ServerMessagePacket([this.client], 0xFF, "You can't deop yourself!"); | ||
return; | ||
} | ||
|
||
if (lists.removeOp(this.args[0])) { | ||
let player = utils.findPlayerByName(this.args[0]); | ||
|
||
if (player != undefined) { | ||
player.op = false; | ||
new ServerTypePacket([player.client], 0x00); | ||
} | ||
|
||
new ServerMessagePacket([this.client], 0xFF, `${this.args[0]} is no longer OP.`); | ||
} else | ||
new ServerMessagePacket([this.client], 0xFF, `${this.args[0]} isn't OP!`); | ||
|
||
} | ||
} | ||
|
||
module.exports = CommandDeOP; |
Oops, something went wrong.