Skip to content

Commit

Permalink
2.6.5
Browse files Browse the repository at this point in the history
Moved lots of files around, fixed bugs with database
  • Loading branch information
smell-of-curry committed Jan 16, 2023
1 parent fdb2008 commit 8cee6e1
Show file tree
Hide file tree
Showing 115 changed files with 4,883 additions and 745 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ node_modules
.tsconfig.json
.gitignore

build.js

scripts/*
!scripts/index.js
!scripts/index.js.map
46 changes: 24 additions & 22 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,27 @@ if (!fsExtra.existsSync(dir)) {
}
fsExtra.emptyDirSync(dir);

esbuild.build({
entryPoints: ["src/index.ts"],
bundle: true,
outfile: "scripts/index.js",
minify: !isDev,
platform: "neutral",
sourcemap: true,
watch: isDev,
external: [
"@minecraft/server",
"@minecraft/server-ui",
"@minecraft/server-net",
"@minecraft/server-admin",
],
legalComments: isDev ? "none" : "none",
}).then((r) => {
console.log(
`\x1b[33m%s\x1b[0m`,
`[${new Date().toLocaleTimeString()}]`,
`Built for ${isDev ? "development" : "production"}...`
);
})
esbuild
.build({
entryPoints: ["src/index.ts"],
bundle: true,
outfile: "scripts/index.js",
minify: !isDev,
platform: "neutral",
sourcemap: true,
watch: isDev,
external: [
"@minecraft/server",
"@minecraft/server-ui",
"@minecraft/server-net",
"@minecraft/server-admin",
],
legalComments: isDev ? "none" : "none",
})
.then((r) => {
console.log(
`\x1b[33m%s\x1b[0m`,
`[${new Date().toLocaleTimeString()}]`,
`Built for ${isDev ? "development" : "production"}...`
);
});
4,234 changes: 4,231 additions & 3 deletions scripts/index.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions scripts/index.js.map

Large diffs are not rendered by default.

21 changes: 6 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
console.warn(`---- STARTING RUBEDO ----`);
import {
ItemStack,
MinecraftItemTypes,
system,
} from "@minecraft/server";
import "./lib/Command/index";
import "./lib/Chest GUI/index";
import "./plugins/import";
import "./database/index";
import { system } from "@minecraft/server";
import "./rubedo/lib/Command/index";
import "./rubedo/lib/Chest GUI/index";
import "./rubedo/database/index";
import "./rubedo/lib/Containers/index";
import "./vendor/import";

system.events.beforeWatchdogTerminate.subscribe((data) => {
data.cancel = true;
console.warn(`WATCHDOG TRIED TO CRASH = ${data.terminateReason}`);
});

/**
* This is air as a item,
*/
export const AIR = new ItemStack(MinecraftItemTypes.stick, 0);
10 changes: 0 additions & 10 deletions src/plugins/Anti-Cheat/modules/commands/version.ts

This file was deleted.

77 changes: 0 additions & 77 deletions src/plugins/Anti-Cheat/modules/protections/unobtainable.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/config/app.ts → src/rubedo/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,3 @@ export const VERSION = "2.6.4-beta";
|
*/
export const GAME_VERSION = "1.19.50";

/*
|--------------------------------------------------------------------------
| Appeal Link
|--------------------------------------------------------------------------
|
| This is the appeal link that gets showed when someone gets banned
| this link pops up at the bottom of the ban message to show
| where they can appeal there ban.
|
*/
export const APPEAL_LINK = "https://discord.gg/dMa3A5UYKX";
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions src/rubedo/config/containers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { MinecraftBlockTypes } from "@minecraft/server";

/**
* The currently supported block containers by script api
*/
export const API_CONTAINERS = [
MinecraftBlockTypes.chest.id,
MinecraftBlockTypes.trappedChest.id,
];

/**
* The block size to check for blockContainers
*/
export const CHECK_SIZE = { x: 7, y: 7, z: 7 };
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 11 additions & 14 deletions src/database/Database.ts → src/rubedo/database/Database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import {
MAX_DATABASE_STRING_SIZE,
} from "../config/database";
import { EntitiesLoad } from "../lib/Events/EntitiesLoad";
import { DIMENSIONS } from "../utils";
import { chunkString } from "../utils";
import { DIMENSIONS, chunkString } from "../../utils";

export class Database<Key extends string = string, Value = {}> {
/**
Expand Down Expand Up @@ -99,28 +98,26 @@ export class Database<Key extends string = string, Value = {}> {
entities.push(Database.createTableEntity(this.tableName));
}
}

let chunkIndex = 0;
for (const [i, entity] of entities.entries()) {
const inventory = entity.getComponent("inventory").container;
for (const [i, chunk] of chunks.entries()) {
if (!chunk) continue;
if (i > inventory.size - 1) break; // Exit because it has maxed items
while (chunkIndex < chunks.length && inventory.size > 0) {
let item = new ItemStack(MinecraftItemTypes.acaciaBoat);
item.nameTag = chunk;
item.nameTag = chunks[chunkIndex];
inventory.setItem(i, item);
chunks[i] = null; // Delete chunk because its been set.
chunkIndex++;
}
// Set all unUsed slots to air
for (let i = chunks.length + 1; i < inventory.size; i++) {
for (let i = inventory.size; i < INVENTORY_SIZE; i++) {
inventory.setItem(i, new ItemStack(MinecraftItemTypes.stick, 0));
}
entity.setDynamicProperty("index", i);
entities[i] = null; // Set this entity to null because its maxed out!
// If all chunks have been saved no need to go to next entity
if (!chunks.find((v) => v)) break;
}
// Check for unUsed entities and despawn them
entities.filter((e) => e).forEach((e) => e.triggerEvent("despawn"));
return;
for (let i = entities.length - 1; i >= chunkIndex / INVENTORY_SIZE; i--) {
entities[i].triggerEvent("despawn");
}
}

/**
Expand Down Expand Up @@ -286,6 +283,6 @@ export class Database<Key extends string = string, Value = {}> {
*/
async clear(): Promise<void> {
this.MEMORY = {} as { [key in Key]: Value };
return await this.saveData();
return this.saveData();
}
}
2 changes: 1 addition & 1 deletion src/database/index.ts → src/rubedo/database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
world,
} from "@minecraft/server";
import { ENTITY_IDENTIFIER, ENTITY_LOCATION } from "../config/database";
import { DIMENSIONS } from "../utils.js";
import { DIMENSIONS } from "../../utils.js";

world.events.worldInitialize.subscribe(({ propertyRegistry }) => {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,10 @@ import {
InventoryComponentContainer,
ItemStack,
Location,
MinecraftItemTypes,
} from "@minecraft/server";
import { AIR } from "../../../index.js";
import { DIMENSIONS } from "../../../utils.js";

/**
* Minecraft Bedrock Item Database
* @license MIT
* @author Smell of curry
* @version 1.0.0
* --------------------------------------------------------------------------
* Stores items in a database. This works by having a custom entity at a
* location then it grabs that entity and ads items to it inventory
* each item in the inventory is then stored in a scoreboard DB to find it
* --------------------------------------------------------------------------
*/

/**
* Where the entity is going to be at
*/
Expand Down Expand Up @@ -131,7 +119,7 @@ export class ItemDatabase {
for (let i = 0; i < inv.size; i++) {
const item = inv.getItem(i);
if (!item || !item.getLore().includes(id)) continue;
inv.setItem(i, AIR);
inv.setItem(i, new ItemStack(MinecraftItemTypes.acaciaBoat, 0));
return true;
}
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Entity, Player, system } from "@minecraft/server";
import { AIR } from "../../../index.js";
import { AIR } from "../index";
import { ENTITY_INVENTORY } from "../../../config/chest";
import {
ISlotChangeReturn,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Entity } from "@minecraft/server";
import { AIR } from "../../../index.js";
import { AIR } from "../index";
import { Page } from "./Page.js";

export type FillTypeCallback = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
} from "@minecraft/server-ui";
import { ChestGUI } from "./EntityChest";
import { ItemStack } from "@minecraft/server";
import { ItemDatabase } from "../database/Item";
import type { ISlot } from "./Page";
import type { ISlotChangeReturn } from "../../Events/onSlotChange";
import { sleep } from "../../../utils";
import { sleep } from "../../../../utils";
import { ItemDatabase } from "../../../database/types/Item";

type FormActionReturn<T> = T extends ActionFormData
? Promise<ActionFormResponse>
Expand Down
File renamed without changes.
File renamed without changes.
Empty file.
13 changes: 10 additions & 3 deletions src/lib/Chest GUI/index.ts → src/rubedo/lib/Chest GUI/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { system, world } from "@minecraft/server";
import {
ItemStack,
MinecraftItemTypes,
system,
world,
} from "@minecraft/server";
import { ENTITY_INVENTORY, GUI_ITEM } from "../../config/chest";
import { getRole } from "../../plugins/Anti-Cheat/utils.js";
import { ChestGUI } from "./Models/EntityChest";
import { CHESTGUIS, getHeldItem } from "./utils.js";
import "./pages/home";
import { DIMENSIONS } from "../../utils.js";
import { DIMENSIONS } from "../../../utils.js";
import { EntitiesLoad } from "../Events/EntitiesLoad";
import { getRole } from "../../../vendor/Anti-Cheat/utils";

export const AIR = new ItemStack(MinecraftItemTypes.acaciaBoat, 0);

EntitiesLoad.subscribe(() => {
system.runSchedule(() => {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Player, world } from "@minecraft/server";
import { TABLES } from "../../database/tables";
import { Database } from "../../database/Database";

/**
* Fetch an online players data
Expand Down Expand Up @@ -232,7 +232,8 @@ export class PlayerNameArgumentType implements IArgumentType {
type: string;
typeName = "playerName";
matches(value: string): IArgumentReturnData<string> {
const player = TABLES.ids.get(value);
const db = new Database<string, string>("ids");
const player = db.get(value);
return {
success: player ? true : false,
value: value,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Player } from "@minecraft/server";
import type { ROLES } from "../../types";
import type { Command } from "./Command";

export interface ICommandData {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BlockInventoryComponentContainer, ItemStack } from "@minecraft/server";

export class BlockInventory {
export class Container {
emptySlotsCount: number;
size: number;
items: Array<ItemStack>;
Expand Down
Loading

0 comments on commit 8cee6e1

Please sign in to comment.