#custom command registry[RESOLVED]
1 messages · Page 1 of 1 (latest)
show ur main.js file
the startup.subscribe must be executed on top level
it doesnt work if it's executed late
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';```
oh
i will try
i did something but it still didnt work
are the files imported?
yes
the first code i sent is in /commands/chatcommand
try logging the files thats imported
wdym?
this doesny log anything btw
just tested it
also what is logging files that are imported?
is that just putting a log at the top of the imported file?
so i put my imports after?
ye
that did nothing
does it log the index loaded?
yes
how about logging as well in this file like from the index
if it still doesnt work, i normally just console.warn in several lines of the code just to check which line the code stops
it stops at the beforevent startUp
up
i log just before it
it returns
after
nothing
hmm, weird
ikr
next is def try catch it
try {
//code
} catch (error) {
console.error("Error registering commands: " + error);
}```
inside the subscribe
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 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
looks like it's somethin else
like?
what about the rest of the imports in chatcommand file, does it log?
wdym
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
i moved them below like u said
does the code run there? like console.warn logs it
nothing runs after the beforevent
even when restarting the game?
oh well, that's pretty much all I can suggest
iirc system.beforeEvents.startUp doesnt run until u actually restart the world
reload doesnt trigger it. the point is in the name itself.
wellwellwell
restarting the world does nothing
it wont fire no matter what
try /reload all
dont it even log after world restart? (console.log/warn?)
done both
nothing in the beforeEvent
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
@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
what version of api r u using? what minecraft version?
newest beta api
2.2.0?
for server yes
ima say, they should run if the world is restarted. dont know about servers tho
he means the server module not a server
yes
uhm, try restarting again ig.
have you tried to put that in another file?
no
try it
okay
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
i put it in another file
nothing happened
same result
imported?
try writing some random things and see if it logs an error
it doesnt do anything the beforeEvent doesnt fire
thats the problem
the file should be fine, its the evnt
try it in your main file. would that run?
i know but im tring to figure out if the addon is updating its content on the game or its just not updating
that's why im saying to make the file have errors so you can see if the file changes for the game
lemme test the stuff out.
This is what im talking about
it works after doing reload even tho i changed the file, the game isnt updating the file
mine still doesnt work after filechange
@terse fjord where are the handler functions?
ok
they run for me.
how come
uh well, the event in itself runs.
for me the event will not fire
like anywhere? not even in main file?
nowhere
send us a vid if you can showing the codes and run em in minecraft. restart minecraft world as well. @terse fjord
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
for me it does not work
wasnt talkin to you when i said to send a vid, i was talking to OP
send us a vid
ah my bad
ok
.
its sending
should i send my vid?
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
here's my video, i recorded it on mobile cuz my pc is running too much.
[Scripting][warning]-Before the beforeEvent
[Scripting][warning]-after the beforevent
[Scripting][warning]-in the beforevent
[Scripting][inform]-hey!```
well idk. putting it into subdirs even of 3 and 4 degrees work for me.
then there is something in my bp thats making it wait before running?
what could even cause that
custom command registry[RESOLVED]
@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