Skip to content

Commit

Permalink
Update deno, add support for classicube
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Apr 13, 2022
1 parent 76381c1 commit cbe8ec2
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 97 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Patbox
Copyright (c) 2021, 2022 Patbox

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Cobblestone is a server for Minecraft Classic 0.30. It's written in Typescript a
- Multiworld support
- Easy to modify - It's written in TypeScript
- Custom plugin support
- Works with Betacraft (~~including online mode~~)
- Works with Betacraft (including online mode)
- Moddern Mojang UUID support (with online mode)
- Stores worlds in [ClassicWorld](https://wiki.vg/ClassicWorld_file_format) format
- Uses Deno - no more big `node_modules` folder
Expand Down
14 changes: 9 additions & 5 deletions server/core/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export function setupCommands(server: Server, commands: Map<string, Command>) {
let x = 0;
let i = 0;
const commandArray = Array.from(commands);
while (true) {

while (commandArray[x + page * 8]) {
const cmd = commandArray[x + page * 8][1];
x += 1;

Expand All @@ -89,7 +89,6 @@ export function setupCommands(server: Server, commands: Map<string, Command>) {
} else {
const pages = commands.get(command)?.help ?? [];
size = pages.length;

if (size == 0) {
return;
}
Expand All @@ -109,8 +108,13 @@ export function setupCommands(server: Server, commands: Map<string, Command>) {
ctx.send(`&cThis help page doesn't exist!`);
}
} catch (e) {
server.logger.error(`${ctx.player?.username ?? 'Console'} tried to excute ${ctx.command} and it failed!`);
server.logger.error(e);
server.logger.error(`${ctx.player?.username ?? 'Console'} tried to execute ${ctx.command} and it failed!`);
if (e instanceof TypeError) {
server.logger.error(e.message);
if (e.stack) server.logger.error(e.stack);
} else {
server.logger.error(e);
}
ctx.send('&cError occured while executing this command.');
}
} catch {
Expand Down
9 changes: 6 additions & 3 deletions server/core/deps.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
export { gzip, ungzip } from 'https://cdn.skypack.dev/pako';
export * as uuid from 'https://deno.land/std@0.121.0/uuid/mod.ts';
export * as uuidHelpers from 'https://deno.land/std@0.121.0/uuid/_common.ts';
export * as uuid from 'https://deno.land/std@0.122.0/uuid/mod.ts';
export * as uuidHelpers from 'https://deno.land/std@0.122.0/uuid/_common.ts';
export * as opensimplex from 'https://deno.land/x/open_simplex_noise@v2.5.0/mod.ts';
export * as fractalnoise from 'https://deno.land/x/fractal_noise@v1.2.0/mod.ts';
export * as semver from 'https://deno.land/x/semver@v1.4.0/mod.ts';
export * as msgpack from 'https://deno.land/x/msgpack@v1.4/mod.ts';
export * as FastNoiseLite from 'https://raw.githubusercontent.com/Auburn/FastNoiseLite/master/JavaScript/FastNoiseLite.js';
export * as FastNoiseLite from 'https://raw.githubusercontent.com/Auburn/FastNoiseLite/master/JavaScript/FastNoiseLite.js';

export * as base64 from 'https://deno.land/std@0.122.0/encoding/base64.ts';
export * as hex from 'https://deno.land/std@0.122.0/encoding/hex.ts';
20 changes: 13 additions & 7 deletions server/core/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Server {
// Main informations about server
static readonly softwareName = 'Cobblestone';
static readonly softwareId = 'cobblestone';
static readonly softwareVersion = '0.0.16';
static readonly softwareVersion = '0.0.17';

static readonly targetGame = 'Minecraft Classic';
static readonly targetVersion = '0.30c';
Expand All @@ -29,7 +29,7 @@ export class Server {
readonly targetProtocol = Server.targetProtocol;

// Version of API, goes up when new methods are added
readonly _apiVersion = '0.0.16';
readonly _apiVersion = '0.0.17';

// Minimal compatible API
readonly _minimalApiVersion = '0.0.16';
Expand Down Expand Up @@ -320,10 +320,10 @@ export class Server {
const result = await this.authenticatePlayer({
uuid: overrides?.uuid ?? playerInfo.username.toLowerCase(),
username: overrides?.username ?? playerInfo.username,
authProvider: overrides?.authProvider ?? 'None',
service: overrides?.service ?? 'Minecraft',
secret: overrides?.secret ?? playerInfo.key,
authenticated: overrides?.authenticated ?? false,
subService: overrides?.subService ?? null,
});

if (result.allow) {
Expand All @@ -332,11 +332,11 @@ export class Server {
return;
}

const subService = result.auth.subService ? `/${result.auth.subService}` : '';
const authProvider = result.auth.authProvider ? `/${result.auth.authProvider}` : '';
this.logger.conn(
result.auth.service == 'Unknown'
? `User ${result.auth.username} (${result.auth.uuid}) doesn't use any auth...`
: `User ${result.auth.username} (${result.auth.uuid}) is logged with ${result.auth.service}${subService} auth!`
: `User ${result.auth.username} (${result.auth.uuid}) is logged with ${result.auth.service} (${authProvider}) auth!`
);

const player = new Player(
Expand Down Expand Up @@ -924,13 +924,16 @@ export interface IConfig {

defaultWorldName: string;

classicOnlineMode: boolean;
onlineMode: boolean;
//useMineOnlineHeartbeat: boolean;
//publicOnMineOnline: boolean;

useBetaCraftHeartbeat: boolean;
publicOnBetaCraft: boolean;

useClassiCubeHeartbeat: boolean;
publicOnClassiCube: boolean;

allowOffline: boolean;

messages: {
Expand Down Expand Up @@ -960,14 +963,17 @@ const defaultConfig: IConfig = {

defaultWorldName: 'main',

classicOnlineMode: false,
onlineMode: true,

//useMineOnlineHeartbeat: false,
//publicOnMineOnline: false,

useBetaCraftHeartbeat: false,
publicOnBetaCraft: false,

useClassiCubeHeartbeat: false,
publicOnClassiCube: false,

allowOffline: true,

messages: {
Expand Down
7 changes: 4 additions & 3 deletions server/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ export interface Position {

export type Nullable<T> = null | T;

export type Services = 'Unknown' | 'Minecraft' | 'VoxelSrv' | 'ClassiCube';
export type Services = 'Unknown' | 'Minecraft' | 'ClassiCube';

export type AuthProvider = 'None' | 'Mojang' | 'Betacraft' | 'ClassiCube';

export type SubServices = 'Betacraft';

export interface AuthData {
username: string;
authProvider: AuthProvider;
service: Services;
subService: Nullable<SubServices>;
uuid: Nullable<string>;
secret: Nullable<string>;
authenticated: boolean;
Expand Down
4 changes: 2 additions & 2 deletions server/deno/deps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * as fs from 'https://deno.land/std@0.121.0/fs/mod.ts';
export { createHash } from 'https://deno.land/std@0.121.0/hash/mod.ts';
export { serve, serveTls } from 'https://deno.land/std@0.121.0/http/server.ts';
export { serve, serveTls } from 'https://deno.land/std@0.121.0/http/server.ts';
export { crypto as crypto2 } from 'https://deno.land/std@0.121.0/_wasm_crypto/mod.ts';
Loading

0 comments on commit cbe8ec2

Please sign in to comment.