This repository has been archived by the owner on Nov 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
19 changed files
with
324 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
18 changes: 18 additions & 0 deletions
18
scripts/main/plugins/Custom Commands/global/home/delhome.js
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,18 @@ | ||
import { Command, CommandRegistration, Validation } from "../../../@modules"; | ||
import { HomeDB } from "./sethome"; | ||
const registration = new CommandRegistration() | ||
.setName("delome") | ||
.setDescription("Delete home") | ||
.setAliases(["deletehome", "dhome"]) | ||
.setInputs({ 0: ["string"] }) | ||
.setUsage(["<homeName>"]) | ||
.setExample(["home myHome", "deletehome myHome", "dhome 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 homeDBFrmt = `${sender.name}_${homeName}`; | ||
if (!HomeDB.hasKey(homeDBFrmt)) | ||
return sender.sendMessage(`§cHome with name ${homeName} doesn't exist`); | ||
}); |
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,25 @@ | ||
import { world } from "@minecraft/server"; | ||
import { Command, CommandRegistration, Validation } from "../../../@modules"; | ||
import { HomeDB } from "./sethome"; | ||
const registration = new CommandRegistration() | ||
.setName("home") | ||
.setDescription("Teleport to home") | ||
.setInputs({ 0: ["string"] }) | ||
.setUsage(["<homeName>"]) | ||
.setExample(["home 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 homeDBFrmt = `${sender.name}_${homeName}`; | ||
if (!HomeDB.hasKey(homeDBFrmt)) | ||
return sender.sendMessage(`§cHome with name ${homeName} doesn't exist`); | ||
const parsedHome = HomeDB.get(homeDBFrmt); | ||
sender.teleport({ | ||
x: parsedHome.coordinate[0], | ||
y: parsedHome.coordinate[1], | ||
z: parsedHome.coordinate[2], | ||
}, { dimension: world.getDimension(parsedHome.dimension) }); | ||
return sender.sendMessage(`§aSuccessfully teleported to home with name §e${homeName}`); | ||
}); |
20 changes: 20 additions & 0 deletions
20
scripts/main/plugins/Custom Commands/global/home/listhome.js
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,20 @@ | ||
import { Command, CommandRegistration, Validation } from "../../../@modules"; | ||
import { HomeDB } from "./sethome"; | ||
const registration = new CommandRegistration() | ||
.setName("listhome") | ||
.setDescription("Get all home") | ||
.setInputs({ 0: ["string"] }) | ||
.setUsage(["<homeName>"]) | ||
.setExample(["home 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 | ||
? "§f# §7You don't have any home" | ||
: findHome | ||
.sort() | ||
.map((home) => `§f# §7${home.name} - ${home.dimension}`)}`); | ||
}); |
30 changes: 30 additions & 0 deletions
30
scripts/main/plugins/Custom Commands/global/home/sethome.js
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,30 @@ | ||
import { Command, CommandRegistration, Database, Validation, } from "../../../@modules"; | ||
const registration = new CommandRegistration() | ||
.setName("sethome") | ||
.setDescription("Sethome home") | ||
.setAliases(["shome"]) | ||
.setInputs({ 0: ["string"] }) | ||
.setUsage(["<homeName>"]) | ||
.setExample(["sethome myHome", "shome myHome"]); | ||
const HomeDB = new Database("HomeDB"); | ||
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 homeDBFrmt = `${sender.name}_${homeName}`; | ||
if (HomeDB.hasKey(homeDBFrmt)) | ||
return sender.sendMessage(`§eHome with name ${homeName} already exist`); | ||
HomeDB.set(homeDBFrmt, { | ||
name: homeName, | ||
creator: sender.name, | ||
coordinate: [ | ||
Math.floor(sender.location.x), | ||
Math.floor(sender.location.y), | ||
Math.floor(sender.location.z), | ||
], | ||
dimension: sender.dimension.id, | ||
}); | ||
return sender.sendMessage(`§aSuccessfully set home with name §e${homeName} §aat coordinates §eX: ${Math.floor(sender.location.x)} Y: ${Math.floor(sender.location.x)} Z: ${Math.floor(sender.location.z)}`); | ||
}); | ||
export { HomeDB }; |
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
// Information | ||
// Information | ||
import "./information/help"; | ||
import "./information/version"; | ||
// Global | ||
import "./global/home/home"; | ||
import "./global/home/sethome"; | ||
import "./global/home/delhome"; | ||
import "./global/home/listhome"; |
3 changes: 3 additions & 0 deletions
3
src/main/@modules/@types/handlers/command/RegistrationType.d.ts
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,3 @@ | ||
type inputs = ["string", "boolean", "number", "playername"] | ||
|
||
type SupportedInputs = inputs[number][] |
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,11 @@ | ||
type QueryName = | ||
| "isClimbing" | ||
| "isFalling" | ||
| "isFlying" | ||
| "isGliding" | ||
| "isInWater" | ||
| "isJumping" | ||
| "isOnGround" | ||
| "isSneaking" | ||
| "isSprinting" | ||
| "isSwimming"; |
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
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
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
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
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 @@ | ||
import { Command, CommandRegistration, Validation } from "../../../@modules"; | ||
import { HomeDB } from "./sethome"; | ||
|
||
const registration: CommandRegistration = new CommandRegistration() | ||
.setName("delome") | ||
.setDescription("Delete home") | ||
.setAliases(["deletehome", "dhome"]) | ||
.setInputs({ 0: ["string"] }) | ||
.setUsage(["<homeName>"]) | ||
.setExample(["home myHome", "deletehome myHome", "dhome myHome"]); | ||
|
||
Command.BuildCommand(registration, (interaction) => { | ||
const { sender, inputs } = interaction; | ||
const homeName = inputs.getInput(0) as any; | ||
|
||
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`); | ||
}); |
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,33 @@ | ||
import { world } from "@minecraft/server"; | ||
import { Command, CommandRegistration, Validation } from "../../../@modules"; | ||
import { HomeDB } from "./sethome"; | ||
|
||
const registration: CommandRegistration = new CommandRegistration() | ||
.setName("home") | ||
.setDescription("Teleport to home") | ||
.setInputs({ 0: ["string"] }) | ||
.setUsage(["<homeName>"]) | ||
.setExample(["home myHome"]); | ||
|
||
Command.BuildCommand(registration, (interaction) => { | ||
const { sender, inputs } = interaction; | ||
const homeName = inputs.getInput(0) as any; | ||
|
||
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`); | ||
|
||
const parsedHome = HomeDB.get(homeDBFrmt); | ||
sender.teleport( | ||
{ | ||
x: parsedHome.coordinate[0], | ||
y: parsedHome.coordinate[1], | ||
z: parsedHome.coordinate[2], | ||
}, | ||
{ dimension: world.getDimension(parsedHome.dimension) } | ||
); | ||
return sender.sendMessage(`§aSuccessfully teleported to home with name §e${homeName}`) | ||
}); |
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,32 @@ | ||
import { world } from "@minecraft/server"; | ||
import { Command, CommandRegistration, Validation } from "../../../@modules"; | ||
import { HomeDB } from "./sethome"; | ||
|
||
const registration: CommandRegistration = new CommandRegistration() | ||
.setName("listhome") | ||
.setDescription("Get all home") | ||
.setInputs({ 0: ["string"] }) | ||
.setUsage(["<homeName>"]) | ||
.setExample(["home myHome"]); | ||
|
||
Command.BuildCommand(registration, (interaction) => { | ||
const { sender, inputs } = interaction; | ||
const homeName = inputs.getInput(0) as any; | ||
|
||
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 | ||
? "§f# §7You don't have any home" | ||
: findHome | ||
.sort() | ||
.map( | ||
(home: { name: string; dimension: string }) => | ||
`§f# §7${home.name} - ${home.dimension}` | ||
) | ||
}` | ||
); | ||
}); |
Oops, something went wrong.