Java scripts¶
fkdr runs scripts written in Java: the .java files with onPreUpdate, onChat, modules.registerSlider and the rest. Put one in your scripts folder and it becomes a module in the Scripts tab, with its own switch, keybind and settings.
Enhanced only
Like JavaScript scripts, Java scripts are part of the enhanced version of fkdr.
You can also build one without writing any code, with easy mode.
Where to put them¶
In the same folder as your JavaScript scripts. /fkdr script folder, or Folder in the Scripts tab, opens it.
Then run /fkdr script reload (or press Reload in the Scripts tab), or restart the game. Scripts load the first time you are in a world.
- A file ending in
.javais a Java script. A.jsfile that is really Java code (Java-stylevoid onPreUpdate()handlers and nofunction) is recognised and loaded as one too, so a script saved with the wrong ending still works. - The file name is the module's name:
AutoGG.javabecomes the module AutoGG. It may be at most 14 characters, only letters, digits,_and-, and must not be the name of a module fkdr already has. A file whose name starts with_is skipped. - Each script is a module of its own in the Installed view of the Scripts tab. Its description reads a .java script. Its switch, keybind and setting values are kept with your config and survive reloads; a script that was on stays on after a reload.
The format¶
A script is the body of a class: fields, then the handlers you need. The usual imports (List, ArrayList, Map, HashMap, Set, Collection, Random, Pattern, Color, the atomic counters and the rest) are already there, so line numbers in an error are the lines of your own file.
int ticks;
void onLoad() {
modules.registerSlider("Every", " ticks", 20, 1, 100, 1);
modules.registerButton("Say it", true);
}
void onPreUpdate() {
if (++ticks % (int) modules.getSlider(scriptName, "Every") == 0 && modules.getButton(scriptName, "Say it")) {
client.print("&7hello from a java script");
}
}
Settings are declared in onLoad: a button becomes a switch, a slider a number, a slider with options a dropdown, and a description starts a group in the drawer. onEnable and onDisable run when the module is switched.
Load strings. A line load - "https://…" outside any method is replaced by the text at that address when the script loads (at most 2 MB, up to three levels deep).
Protected scripts load like any other. While one runs, its error messages say hidden (protected script) instead of showing its code. A few protected scripts cannot be loaded.
First load¶
The first time you load a Java script, fkdr downloads what it needs (about 3 MB, once) and chat says so. If the download fails, chat says why; the next reload tries again. The game does not freeze while scripts load.
Errors¶
A script that does not compile is listed in the Scripts tab as this script did not load; the error is in chat, and chat shows the error with the line number in your file (the full error is in the game log). An error while running prints error in script <name> with the message and line.
A script is refused, with it reaches for blocked code, when it uses things scripts may not touch, such as Java's own file, network, thread, process or reflection classes.
What works¶
Events¶
onLoad, onEnable, onDisable, onPreUpdate, onPreMotion, onPostMotion, onPostPlayerInput, onChat (every chat type), onMouse, onKey, onWorldJoin, onRenderTick, onRenderWorld, onGuiUpdate, onPacketSent, onPacketReceived, getRotations, getMovementYaw, onLocRaw, and two that come from fkdr's own modules:
onAntiCheatFlag(String check, Entity player)for every AntiCheat flag, with the check's name (AutoBlock,NoSlow,Legit Scaffold,Nuker,Bed Nuker,Scaffold,AimAssist,AutoClicker,Blink,FastMine,NoFall,Protocol).onBedWarsAlert(String alert, Entity player)for every Alerts line, with the alert's name, such asFIREBALL,ENDERPEARL,BOW_POWER,INVISIBLEorOBSIDIAN_PLACED.
The API¶
client, modules, render, world, util, keybinds, inventory, config, bridge, gl, the packet classes, Json, Message, simulations, text in 2D and 3D, and Json and Request/Response (with headers). Scripts written for the older shapes of those still work.
Request and WebSocket work, to public addresses only.
What does not¶
onIRCMessagenever fires: fkdr has no IRC chat.- Calls that read another module by name (
modules.isEnabled("…")) only see fkdr's modules and other scripts. - Scripts that use blocked code (see Errors) are refused.
Commands are the same as for every script: /fkdr script reload, /fkdr script on <name>, /fkdr script off <name>, /fkdr script errors. See the command reference.