#custom command registry[RESOLVED]

1 messages · Page 1 of 1 (latest)

terse fjord
#

theres no error and the commands are not showing up in chat
not useable either
it is imported to my main file too

#

anyone got ideas?

fossil bluff
#

the startup.subscribe must be executed on top level

#

it doesnt work if it's executed late

terse fjord
# fossil bluff show ur main.js file
console.warn('index loaded');
import './fill';
import './scoreboard';
import './commands/chatcommand';
import './spawn';
import './pvp';
import './border';
import './mobstack';
import './killer';
import './spawners/skeleton';
import './spawners/spider';
import './spawners/zombie';
import { ActionFormData } from '@minecraft/server-ui';
import { system, world } from '@minecraft/server';
import { AuctionHouse } from 'auctionHouse/auctionHouse';
import { ItemSaver } from 'auctionHouse/itemSaver';```
terse fjord
#

i will try

#

i did something but it still didnt work

fossil bluff
#

are the files imported?

terse fjord
#

the first code i sent is in /commands/chatcommand

fossil bluff
#

try logging the files thats imported

terse fjord
fossil bluff
#

also add

#

just to see if they're actually imported

terse fjord
#

just tested it

#

also what is logging files that are imported?

#

is that just putting a log at the top of the imported file?

fossil bluff
#

yeah, anywhere in the file

#

this is also possible

terse fjord
#

so i put my imports after?

fossil bluff
#

ye

terse fjord
fossil bluff
#

does it log the index loaded?

terse fjord
#

yes

fossil bluff
#

if it still doesnt work, i normally just console.warn in several lines of the code just to check which line the code stops

terse fjord
#

up

#

i log just before it

#

it returns

#

after

#

nothing

fossil bluff
#

hmm, weird

terse fjord
#

ikr

fossil bluff
#

next is def try catch it

terse fjord
#

what do i do?

fossil bluff
#
try {
    //code
} catch (error) {
    console.error("Error registering commands: " + error);
}```
#

inside the subscribe

terse fjord
#

@fossil bluffnothing returns

fossil bluff
#

can u send the index.js

terse fjord
# fossil bluff can u send the index.js
import './commands/chatcommand';
import './fill';
import './scoreboard';
import './spawn';
import './pvp';
import './border';
import './mobstack';
import './killer';
import './spawners/skeleton';
import './spawners/spider';
import './spawners/zombie';
import { ActionFormData } from '@minecraft/server-ui';
import { world } from '@minecraft/server';
import { AuctionHouse } from 'auctionHouse/auctionHouse';
import { ItemSaver } from 'auctionHouse/itemSaver';

console.warn('index loaded');
/**
 *
 * @param {Player} player
 */
export default function MasterAuctionHouseMenu(player) {
    const afd = new ActionFormData();
    afd.title('Auction House');
    afd.button('View All Listings', "textures/icons/ah1");
    afd.button('View My Listings', "textures/icons/ah");
    afd.button('List Items', "textures/icons/list");
    if (player.hasTag('admin')) {
        afd.divider();
        afd.header('Admin');
        afd.button('Reset All Properties');
        afd.button('Console Log Auctions');
    }
    afd.show(player).then(r => {
        if (r.canceled)
            return;
        switch (r.selection) {
            case 0:
                return AuctionHouse.mainMenu(player);
            case 1:
                return AuctionHouse.myAuctions(player);
            case 2:
                return ItemSaver.saveItemMenu(player);
            case 3:
                return world.clearDynamicProperties();
            case 4:
                return console.warn(JSON.stringify(world.getDynamicPropertyIds()));
        }
    });
}```
fossil bluff
#

idk abt this namespace exclusivity thing, but i have kc:cmds and it throws me this

terse fjord
#

@fossil bluffi had that so i put all the namespaces as one and it worked then like a while later i just noticed it stopped working fully

fossil bluff
#

looks like it's somethin else

terse fjord
fossil bluff
#

what about the rest of the imports in chatcommand file, does it log?

fossil bluff
#
import ShopUI from "../ui/shop";
import { caclulateRTP } from "./rtp";
import HomeUI from "ui/homes";
import { getSecondsLeftInPvP } from "pvp";
import MasterAuctionHouseMenu from "index";
import PayUI from "ui/payui";
import CrateUI from "../ui/crates";
```this parts
terse fjord
#

i moved them below like u said

fossil bluff
#

does the code run there? like console.warn logs it

terse fjord
#

nothing runs after the beforevent

fossil bluff
#

even when restarting the game?

terse fjord
#

i didnt restart game

#

i only did reload all

fossil bluff
#

oh well, that's pretty much all I can suggest

terse fjord
kindred wing
#

iirc system.beforeEvents.startUp doesnt run until u actually restart the world

#

reload doesnt trigger it. the point is in the name itself.

shy canyon
#

wellwellwell

terse fjord
#

it wont fire no matter what

silk harbor
#

try /reload all

kindred wing
#

dont it even log after world restart? (console.log/warn?)

terse fjord
terse fjord
silk harbor
#

are you importing the file of the script?

#

try to do console.warn("loaded") in the same file you have the startup event

#

and see if it fires or not

terse fjord
#

@silk harbor@kindred wingjs import { system, CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, CustomCommandOrigin, Player } from "@minecraft/server"; console.warn("Before the beforeEvent"); //this does work system.beforeEvents.startup.subscribe((init) => { console.warn("in the beforevent"); // this does not const shopCommand = { name: "realm:shop", description: "Opens The Shop", permissionLevel: CommandPermissionLevel.Any, }; const rtpCommand = { name: "realm:rtp", description: "Randomly teleports you somewhere", permissionLevel: CommandPermissionLevel.Any, }; const spawnCommand = { name: "realm:spawn", description: "Teleports you to spawn", permissionLevel: CommandPermissionLevel.Any, }; const homeCommand = { name: "realm:home", description: "Opens homes", permissionLevel: CommandPermissionLevel.Any, }; const ahCommand = { name: "realm:auctionhouse", description: "Opens the auctionhouse", permissionLevel: CommandPermissionLevel.Any, }; const payCommand = { name: "realm:pay", description: "Pays other players", permissionLevel: CommandPermissionLevel.Any, } init.customCommandRegistry.registerCommand(shopCommand, shopCmd); init.customCommandRegistry.registerCommand(rtpCommand, rtpCmd); init.customCommandRegistry.registerCommand(spawnCommand, spawnCmd); init.customCommandRegistry.registerCommand(homeCommand, homeCmd); init.customCommandRegistry.registerCommand(ahCommand, ahCmd); init.customCommandRegistry.registerCommand(payCommand, payCmd); }); console.warn("after the beforevent"); //this also works

silk harbor
terse fjord
silk harbor
#

2.2.0?

terse fjord
#

for server yes

kindred wing
#

ima say, they should run if the world is restarted. dont know about servers tho

silk harbor
#

he means the server module not a server

terse fjord
#

yes

kindred wing
#

uhm, try restarting again ig.

terse fjord
#

...

#

ive been doing that for 2 days g

silk harbor
#

have you tried to put that in another file?

terse fjord
#

no

silk harbor
#

try it

terse fjord
#

okay

silk harbor
#

sometimes it happens that minecraft somehow isnt updating anymore what i change, and i can find that very easily by writing random words in the file and see if it logs an error

terse fjord
#

nothing happened

#

same result

kindred wing
#

imported?

silk harbor
#

try writing some random things and see if it logs an error

terse fjord
#

thats the problem

kindred wing
terse fjord
#

i would guess that it wasnt run on the top level

#

but it is

#

and idk

kindred wing
#

try it in your main file. would that run?

terse fjord
#

i just did#

#

no running

silk harbor
#

that's why im saying to make the file have errors so you can see if the file changes for the game

kindred wing
#

lemme test the stuff out.

silk harbor
#

it works after doing reload even tho i changed the file, the game isnt updating the file

terse fjord
#

mine still doesnt work after filechange

rancid pulsar
terse fjord
#

they are below

#

they work fine

rancid pulsar
#

ok

#

i'll run this

terse fjord
#

ok

kindred wing
terse fjord
#

how come

kindred wing
#

uh well, the event in itself runs.

terse fjord
#

for me the event will not fire

kindred wing
#

like anywhere? not even in main file?

terse fjord
#

nowhere

rancid pulsar
#

bro they run fine

#

and they're registered

kindred wing
#

send us a vid if you can showing the codes and run em in minecraft. restart minecraft world as well. @terse fjord

rancid pulsar
#

i'll send the code

#
import { system, CommandPermissionLevel, CustomCommandParamType, CustomCommandStatus, CustomCommandOrigin, Player } from "@minecraft/server";
console.warn("Before the beforeEvent"); //this does work
system.beforeEvents.startup.subscribe((init) => {
    console.warn("in the beforevent"); // this does not
    const shopCommand = {
        name: "realm:shop",
        description: "Opens The Shop",
        permissionLevel: CommandPermissionLevel.Any,
        cheatsRequired: true
    };
    const rtpCommand = {
        name: "realm:rtp",
        description: "Randomly teleports you somewhere",
        permissionLevel: CommandPermissionLevel.Any,
        cheatsRequired: true
    };
    const spawnCommand = {
        name: "realm:spawn",
        description: "Teleports you to spawn",
        permissionLevel: CommandPermissionLevel.Any,
        cheatsRequired: true
    };
    const homeCommand = {
        name: "realm:home",
        description: "Opens homes",
        permissionLevel: CommandPermissionLevel.Any,
        cheatsRequired: true
    };
    const ahCommand = {
        name: "realm:auctionhouse",
        description: "Opens the auctionhouse",
        permissionLevel: CommandPermissionLevel.Any,
        cheatsRequired: true
    };
    const payCommand = {
        name: "realm:pay",
        description: "Pays other players",
        permissionLevel: CommandPermissionLevel.Any,
        cheatsRequired: true
    }
    init.customCommandRegistry.registerCommand(shopCommand, shopCmd);
    init.customCommandRegistry.registerCommand(rtpCommand, rtpCmd);
    init.customCommandRegistry.registerCommand(spawnCommand, spawnCmd);
    init.customCommandRegistry.registerCommand(homeCommand, homeCmd);
    init.customCommandRegistry.registerCommand(ahCommand, ahCmd);
    init.customCommandRegistry.registerCommand(payCommand, payCmd);
    console.log('hey!')
});
console.warn("after the beforevent");
#
function shopCmd() {
  return undefined;
}
function rtpCmd() {
  return undefined;
}
function spawnCmd() {
  return undefined;
}
function homeCmd() {
  return undefined;
}
function ahCmd() {
  return undefined;
}
function payCmd() {
  return undefined;
}```
#

they're in the same snippet

#

anyway

#

let me get the recording rq

terse fjord
#

for me it does not work

kindred wing
kindred wing
terse fjord
terse fjord
#

its sending

rancid pulsar
#

should i send my vid?

terse fjord
rancid pulsar
#

yeah idk

#

oh well

#

there are two things that could cause this

#

either it's a bug

#

or your file is being imported and ran after the event has long since fired

#

in my test case, i was putting the command in the entry

#

in yours, you have it in a subdir

#

check how the chatcommand.js is imported

#
[Scripting][warning]-Before the beforeEvent
[Scripting][warning]-after the beforevent
[Scripting][warning]-in the beforevent
[Scripting][inform]-hey!```
kindred wing
#

well idk. putting it into subdirs even of 3 and 4 degrees work for me.

terse fjord
#

then there is something in my bp thats making it wait before running?

#

what could even cause that

terse fjord
#

custom command registry[RESOLVED]

tall pasture
#

@terse fjord how did you solved this? i even tried changing the manifest uuid and still doesnt work, i had the same problem with yours