Skip to content
This repository has been archived by the owner on Nov 15, 2024. It is now read-only.

Commit

Permalink
1.1.0-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
VoxlDevv committed Jul 19, 2023
1 parent 520add4 commit c8bea07
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 72 deletions.
4 changes: 3 additions & 1 deletion scripts/main/plugins/Chat Ranks/system.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { world } from "@minecraft/server";
import { BeforeEvents, PlayerClass } from "../@modules";
import { BeforeEvents, Command, PlayerClass } from "../@modules";
import { RankConfig } from "./config";
BeforeEvents.on("chat", (rawdata) => {
const { sender, message } = rawdata;
if (message.startsWith(Command.getPrefix()))
return;
rawdata.cancel = true;
const player = new PlayerClass(sender);
const getRank = player.getTagStartsWith("rank:")?.slice(5) ?? RankConfig.defaultRank;
Expand Down
6 changes: 4 additions & 2 deletions scripts/main/plugins/Custom Commands/global/home/delhome.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command, CommandRegistration, Validation } from "../../../@modules";
import { HomeDB } from "./sethome";
const registration = new CommandRegistration()
.setName("delome")
.setName("delhome")
.setDescription("Delete home")
.setAliases(["deletehome", "dhome"])
.setInputs({ 0: ["string"] })
Expand All @@ -14,5 +14,7 @@ Command.BuildCommand(registration, (interaction) => {
return sender.sendMessage("§cHome name cannot be empty");
const homeDBFrmt = `${sender.name}_${homeName}`;
if (!HomeDB.hasKey(homeDBFrmt))
return sender.sendMessage(`§cHome with name ${homeName} doesn't exist`);
return sender.sendMessage(`§cHome with name §e${homeName} §cdoesn't exist`);
HomeDB.delete(homeDBFrmt);
return sender.sendMessage(`§aSuccessfully deleted home with name §e${homeName}`);
});
5 changes: 3 additions & 2 deletions scripts/main/plugins/Custom Commands/global/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ const registration = new CommandRegistration()
.setInputs({ 0: ["string"] })
.setUsage(["<homeName>"])
.setExample(["home myHome"]);
Command.BuildCommand(registration, (interaction) => {
Command.BuildCommand(registration, async (interaction) => {
const { sender, inputs } = interaction;
const homeName = inputs.getInput(0);
if (Validation.isUndefined(homeName))
return sender.sendMessage("§cHome name cannot be empty");
const homeDBFrmt = `${sender.name}_${homeName}`;
if (!HomeDB.hasKey(homeDBFrmt))
return sender.sendMessage(`§cHome with name ${homeName} doesn't exist`);
return sender.sendMessage(`§cHome with name §e${homeName} §cdoesn't exist`);
const parsedHome = HomeDB.get(homeDBFrmt);
await null;
sender.teleport({
x: parsedHome.coordinate[0],
y: parsedHome.coordinate[1],
Expand Down
23 changes: 12 additions & 11 deletions scripts/main/plugins/Custom Commands/global/home/listhome.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { Command, CommandRegistration, Validation } from "../../../@modules";
import { Command, CommandRegistration } from "../../../@modules";
import { HomeDB } from "./sethome";
const registration = new CommandRegistration()
.setName("listhome")
.setDescription("Get all home")
.setInputs({ 0: ["string"] })
.setUsage(["<homeName>"])
.setExample(["home myHome"]);
.setExample(["listhome myHome"]);
Command.BuildCommand(registration, (interaction) => {
const { sender, inputs } = interaction;
const homeName = inputs.getInput(0);
if (Validation.isUndefined(homeName))
return sender.sendMessage("§cHome name cannot be empty");
const findHome = HomeDB.find((home) => home.creator === sender.name);
return sender.sendMessage(`§b---- Home List ----\n\n${findHome.length === 0
const { sender } = interaction;
const homes = [];
for (const [, home] of HomeDB) {
if (home.creator === sender.name)
homes.push(home);
}
return sender.sendMessage(`§b---- Home List ----\n\n${homes.length === 0
? "§f# §7You don't have any home"
: findHome
: homes
.sort()
.map((home) => `§f# §7${home.name} - ${home.dimension}`)}`);
.map((home) => `§f# §a${home.name} §7- ${home.dimension}`)
.join("\n\n")}`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Command.BuildCommand(registration, (interaction) => {
return sender.sendMessage("§cHome name cannot be empty");
const homeDBFrmt = `${sender.name}_${homeName}`;
if (HomeDB.hasKey(homeDBFrmt))
return sender.sendMessage(`§eHome with name ${homeName} already exist`);
return sender.sendMessage(`§eHome with name §e${homeName} §calready exist`);
HomeDB.set(homeDBFrmt, {
name: homeName,
creator: sender.name,
Expand Down
22 changes: 16 additions & 6 deletions scripts/main/plugins/plugin.loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,26 @@ const pluginFolder = [
"Chat Ranks",
"Custom Commands",
];
//.
//.
//.
//.
//.
//.
//.
//.
//.
//.
//.
//.
//.
//.
// Don't Touch
import "./_ignore/index";
const start = Date.now();
for (const plugin of pluginFolder) {
const end = Date.now();
import(`./${plugin}/system`)
.then(() => {
throw `Loaded plugin: ${plugin} successfully, in ${end - start} ms`;
})
.catch((err) => {
throw `Error on loading plugin: ${plugin}\nError: ${err}\nStack: ${err.stack}`;
});
.then(() => console.warn(`Loaded plugin: ${plugin} successfully, in ${end - start} ms`))
.catch((err) => console.warn(`Error on loading plugin: ${plugin}\nError: ${err}\nStack: ${err.stack}`));
}
2 changes: 1 addition & 1 deletion src/main/@modules/storages/Database.Class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Database {
* Find data without key
* @param fn - Function
*/
find(fn: (value: any, key?: any, map?: Map<any, any>) => any): [] {
find(fn: (value: any, key?: any, map?: Map<any, any>) => any): any {
return this.RESTORED_DATA.find(fn);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/plugins/Chat Ranks/system.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { world } from "@minecraft/server";
import { BeforeEvents, PlayerClass } from "../@modules";
import { BeforeEvents, Command, PlayerClass } from "../@modules";
import { RankConfig } from "./config";

BeforeEvents.on("chat", (rawdata) => {
const { sender, message } = rawdata;
if (message.startsWith(Command.getPrefix())) return;
rawdata.cancel = true;
const player = new PlayerClass(sender);
const getRank =
Expand Down
10 changes: 7 additions & 3 deletions src/main/plugins/Custom Commands/global/home/delhome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Command, CommandRegistration, Validation } from "../../../@modules";
import { HomeDB } from "./sethome";

const registration: CommandRegistration = new CommandRegistration()
.setName("delome")
.setName("delhome")
.setDescription("Delete home")
.setAliases(["deletehome", "dhome"])
.setInputs({ 0: ["string"] })
Expand All @@ -17,7 +17,11 @@ Command.BuildCommand(registration, (interaction) => {
return sender.sendMessage("§cHome name cannot be empty");

const homeDBFrmt = `${sender.name}_${homeName}`;

if (!HomeDB.hasKey(homeDBFrmt))
return sender.sendMessage(`§cHome with name ${homeName} doesn't exist`);
return sender.sendMessage(`§cHome with name §e${homeName} §cdoesn't exist`);

HomeDB.delete(homeDBFrmt);
return sender.sendMessage(
`§aSuccessfully deleted home with name §e${homeName}`
);
});
10 changes: 7 additions & 3 deletions src/main/plugins/Custom Commands/global/home/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const registration: CommandRegistration = new CommandRegistration()
.setUsage(["<homeName>"])
.setExample(["home myHome"]);

Command.BuildCommand(registration, (interaction) => {
Command.BuildCommand(registration, async (interaction) => {
const { sender, inputs } = interaction;
const homeName = inputs.getInput(0) as any;

Expand All @@ -18,9 +18,11 @@ Command.BuildCommand(registration, (interaction) => {

const homeDBFrmt = `${sender.name}_${homeName}`;
if (!HomeDB.hasKey(homeDBFrmt))
return sender.sendMessage(`§cHome with name ${homeName} doesn't exist`);
return sender.sendMessage(`§cHome with name §e${homeName} §cdoesn't exist`);

const parsedHome = HomeDB.get(homeDBFrmt);

await null;
sender.teleport(
{
x: parsedHome.coordinate[0],
Expand All @@ -29,5 +31,7 @@ Command.BuildCommand(registration, (interaction) => {
},
{ dimension: world.getDimension(parsedHome.dimension) }
);
return sender.sendMessage(`§aSuccessfully teleported to home with name §e${homeName}`)
return sender.sendMessage(
`§aSuccessfully teleported to home with name §e${homeName}`
);
});
20 changes: 10 additions & 10 deletions src/main/plugins/Custom Commands/global/home/listhome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ import { HomeDB } from "./sethome";
const registration: CommandRegistration = new CommandRegistration()
.setName("listhome")
.setDescription("Get all home")
.setInputs({ 0: ["string"] })
.setUsage(["<homeName>"])
.setExample(["home myHome"]);
.setExample(["listhome myHome"]);

Command.BuildCommand(registration, (interaction) => {
const { sender, inputs } = interaction;
const homeName = inputs.getInput(0) as any;
const { sender } = interaction;
const homes = [];

if (Validation.isUndefined(homeName))
return sender.sendMessage("§cHome name cannot be empty");
for (const [, home] of HomeDB) {
if (home.creator === sender.name) homes.push(home);
}

const findHome = HomeDB.find((home) => home.creator === sender.name);
return sender.sendMessage(
`§b---- Home List ----\n\n${
findHome.length === 0
homes.length === 0
? "§f# §7You don't have any home"
: findHome
: homes
.sort()
.map(
(home: { name: string; dimension: string }) =>
`§f# §7${home.name} - ${home.dimension}`
`§f# §a${home.name} §7- ${home.dimension}`
)
.join("\n\n")
}`
);
});
2 changes: 1 addition & 1 deletion src/main/plugins/Custom Commands/global/home/sethome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Command.BuildCommand(registration, (interaction) => {

const homeDBFrmt = `${sender.name}_${homeName}`;
if (HomeDB.hasKey(homeDBFrmt))
return sender.sendMessage(`§eHome with name ${homeName} already exist`);
return sender.sendMessage(`§eHome with name §e${homeName} §calready exist`);

HomeDB.set(homeDBFrmt, {
name: homeName,
Expand Down
54 changes: 24 additions & 30 deletions src/main/plugins/plugin.loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,34 @@ const pluginFolder: string[] = [
"Custom Commands",
];

























//.
//.
//.
//.
//.
//.
//.
//.
//.
//.
//.
//.
//.
//.
// Don't Touch
import "./_ignore/index";
const start: number = Date.now();
for (const plugin of pluginFolder) {
const end: number = Date.now();
import(`./${plugin}/system`)
.then(() => {
throw `Loaded plugin: ${plugin} successfully, in ${end - start} ms`;
})
.catch((err) => {
throw `Error on loading plugin: ${plugin}\nError: ${err}\nStack: ${err.stack}`;
});
.then(() =>
console.warn(
`Loaded plugin: ${plugin} successfully, in ${end - start} ms`
)
)
.catch((err) =>
console.warn(
`Error on loading plugin: ${plugin}\nError: ${err}\nStack: ${err.stack}`
)
);
}

0 comments on commit c8bea07

Please sign in to comment.