diff --git a/README.md b/README.md index 20bb112c..8120c4f7 100644 --- a/README.md +++ b/README.md @@ -27,20 +27,20 @@ Now local website uses static files from this directory instead of mod resources ### Adding a module to the mod :- -#### Step 1 +#### Step 1: Create your main class file. -Create your main class file. This is where most of your modules code will be written. -First, navigate to the modules folder located in `common/java/com/zergatul/cheatutils/modules`. +First, navigate to the modules folder located in [`common/java/com/zergatul/cheatutils/modules`](common/java/com/zergatul/cheatutils/modules). Select the folder that best fits your module type. from here on, we will refer to a theoretical module named "AutoPearl", however you should follow the same naming conventions -Create a new file : `"AutoPearl.java"`. +Create a new file : [`"AutoPearl.java"`](common/java/com/zergatul/cheatutils/modules). the class should be in this format: ```java +package com.zergatul.cheatutils.modules.automation; import com.zergatul.cheatutils.modules.Module; public class AutoPearl implements Module { @@ -50,12 +50,16 @@ public class AutoPearl implements Module { } } ``` +Make sure to add the line: +`package com.zergatul.cheatutils.modules.;` +`` should be where your class file lives inside the [`modules`](./common/java/com/zergatul/cheatutils/modules) folder. +in this example, we are putting this under automation: +`package com.zergatul.cheatutils.modules.automation;` -#### Step 2 +#### Step 2: Register your module in the mod. -For the purposes of this explaination, it is assumed your module is named as "AutoPearl" -Register your module in the mod. -Navigate to `Modules.java` in the same directory. +For the purposes of this explanation, it is assumed your module is named as "AutoPearl" +Navigate to [`Modules.java`](./common/java/com/zergatul/cheatutils/modules/Modules.java) Add your module to the following function ```java @@ -64,20 +68,21 @@ public static void register() { } ``` -Make sure you place it in the right position, modules are initialized in the order listed here. This includes the order of their events added to EventsApi +Make sure you place it in the right position, modules are initialized in the order listed here. This includes the order of their events added to EventsApi -#### Step 3 +>[!NOTE] +> This only applies to legacy modules that do not specify their own importance. Default importance for attached events is `0` -Add your configuration class +#### Step 3: Add your configuration class -Navigate to `common/java/com/zergatul/cheatutils/configs` +Navigate to [`common/java/com/zergatul/cheatutils/configs`](./common/java/com/zergatul/cheatutils/configs) create a new file `AutoPearlConfig.java` ```java package com.zergatul.cheatutils.configs; -public class AutoPearlConfig extends ModuleConfig implements ValidatableConfig { +public class AutoPearlConfig extends ModuleConfig implements Sanitizable { AutoPearlConfig() { @@ -90,11 +95,11 @@ public class AutoPearlConfig extends ModuleConfig implements ValidatableConfig { } ``` -add your config validation inside the `validate()` function, this is where you will add limits to your variables, for example clampign the range of a value. -If your API will be accessible from the scripting, it is highly recomended to include validation for any variables. +add your config validation inside the `Sanitize()` function, this is where you will add limits to your variables, for example clamping the range of a value. +If your API will be accessible from the scripting, it is highly recommended to include validation for any variables. >[!NOTE] -> In case if your module does not require validation, you can skip `implements ValidatableConfig` and the overriden `public void validate()` function. When doing this, also skip adding validation to [`Root.java`](#adding-a-module-to-the-mod--) +> In case if your module does not require validation, you can skip `implements Sanitizable` and the overridden `public void Sanitize()` function. When doing this, also skip adding validation to [`Root.java`](#adding-a-module-to-the-mod--) > > If your module does not require enable / disable, you can skip `extends ModuleConfig` as well. This also means you cannot use the `enabled` boolean or the `isEnabled()` inherited functions. Keep this in mind when creating the website / code for it. @@ -102,12 +107,29 @@ you can also add any more functions or values to change here. for example: ```java -public boolean bl1; -public double db1; +package com.zergatul.cheatutils.configs; + +public class AutoPearlConfig extends ModuleConfig implements Sanitizable { + public boolean bl1; + public double db1; + + AutoPearlConfig() { + bl1 = true; + db1 = 100; + } + + @Override + public void Sanitize() { + return; + } +} ``` -and so on. These must be public, you can also use functions internally, however functions will not work with the website API. -The API directly changes variables. +And so on. These must be public, you can also use functions internally, however functions will not work with the website API. +That API directly modifies variables. + +Any assignments in the class constructor are only used if your saved configuration in the mod has **no matching values** +This means that these assignments act as the **default configuration** of your module before the user makes any changes. an example of a minimal config which does not need validation or enable variable: @@ -115,26 +137,39 @@ an example of a minimal config which does not need validation or enable variable public class AutoPearlConfig {} ``` -Next, navigate to `Config.java`, located in the same directory. - -Add your config to the class +**How to access config** +Use this pattern to access the config variables: ```java - public AutoPearlConfig classNameConfig = new AutoPearlConfig(); +import com.zergatul.cheatutils.configs.AutoPearlConfig; +import com.zergatul.cheatutils.configs.ConfigStore; + +AutoPearlConfig config = ConfigStore.instance.getConfig().autoPearlConfig; + +// Access variables with usual class pattern +if(!config.enabled)return; ``` -Now, navigate to `configStore.java`, located in the same directory and add these lines +\ +\ +**Next, navigate to [`Config.java`](./common/java/com/zergatul/cheatutils/configs/Config.java), located in the same directory.** + +Add your config to the class ```java - private void onConfigLoaded() { - config.classNameConfig.validate(); + public AutoPearlConfig autoPearlConfig = new AutoPearlConfig(); ``` +\ +**IF your module uses `sanitize()` method, make sure to add these lines under `public void sanitize()`** -#### Step 4 +``` + autoPearlConfig.sanitize(); +``` -Adding the module API for the website to work with. -Navigate to `common/java/com/zergatul/cheatutils/scripting/modules/` -make a new file `AutoPearlConfig.java` +#### Step 4: Adding the module API for the website to work with. + +Navigate to [`common/java/com/zergatul/cheatutils/scripting/modules/`](./common/java/com/zergatul/cheatutils/scripting/modules/) +make a new file `AutoPearlApi.java` add these lines @@ -149,79 +184,92 @@ public class AutoPearlApi extends ModuleApi { @Override protected AutoPearlConfig getConfig() { - return ConfigStore.instance.getConfig().classNameconfig; + return ConfigStore.instance.getConfig().autoPearlConfig; } } ``` -#### Step 5 +#### Step 5 Allow the API to be accessed from scripting tools -Allow the API to be accessed from scripting tools (this refers to user side scripting) +(refers to user side scripting) -Navigate to `common/java/com/zergatul/cheatutils/scripting/Root.java` +This step is **OPTIONAL** and not required for module to function. +If you want your module configuration to be accessed from scripting +However, it is recommended to do this step -Add the following lines inside the Root class. + +Navigate to [`common/java/com/zergatul/cheatutils/scripting/Root.java`](./common/java/com/zergatul/cheatutils/scripting/Root.java) + +Add the following lines inside the `Root` class. ```java -public static AutoPearlApi className = new AutoPearlApi(); +public static AutoPearlApi autoPearl = new AutoPearlApi(); ``` -This step is OPTIONAL and not required for module to function. -If you want your module configuration to be accessed from scripting -However, it is recomended to do this step - #### Step 6 Adding your module to the website -Navigate to `common/resources/web/modules.js` +Navigate to [`common/resources/web/modules.js`](./common/resources/web/modules.js) -Add your module under line 21 with the following format: +Add your module under `line 21` with the following format: ```javascript module({ - group: 'automation', + group: 'groupName', name: 'Display Name', - component: 'AutoPearl', + component: 'componentName', path: 'class-name', tags: ['search', 'terms', 'identifers'] }); ``` - -Make sure you add your module to the correct section with the rest of its group -There are the following groups that can be used: +The search terms (tags) used should be reflective of the function of the module. +Make sure you add your module to the correct section with the rest of its group +These are the following groups that can be used: ```javascript -`automation` -`esp` -`hacks` -`visuals` -`scripting` -`utility` +'automation' +'esp' +'hacks' +'visuals' +'scripting' +'utility' ``` +\ +\ +In our example, we use `'automation'`, change this to match your module type: +Example: -In our example, we used `'automation'`, you can change this to match your module type +```javascript +module({ + group: 'automation', + name: 'Auto Pearl', + component: 'AutoPearl', + path: 'auto-pearl', + tags: ['pearl', 'automation', 'throw'] +}); +``` -now navigate to `common/resources/web/components` +now navigate to [`common/resources/web/components`](./common/resources/web/components) next, navigate to the relevant folder for your module from the available folders. This is mapped to the groups used, so ensure you use the same folder. -Create 2 new files: +**Create 2 new files:** * AutoPearl.js * AutoPearl.html -inside the javascript file, add the following: +inside the `JavaScript` file, add the following: ```javascript import { createSimpleComponent } from '/components/SimpleModule.js'; export function createComponent(template) { - return createSimpleComponent('/api/class-name', template); + return createSimpleComponent('/api/auto-pearl', template); } ``` -if you use any new components as listed in `common/resources/web/components.js` in your html, make sure to include them in your javascript file +if you use any new components as listed in [`common/resources/web/components.js`](./common/resources/web/components.js) in your html, make sure to include them in your javascript file for example: @@ -229,7 +277,7 @@ for example: import { createSimpleComponent } from '/components/SimpleModule.js' export function createComponent(template) { - return createSimpleComponent('/api/class-name', template, { + return createSimpleComponent('/api/auto-pearl', template, { components: ['CodeBlock', 'ColorBox'] }); } @@ -237,9 +285,10 @@ export function createComponent(template) { ##### How to make your html file -This guide will focus on the working, for style and other formatting / component usage, look at the html of other modules already implemented +This guide will focus on the working. +For style and other formatting / component usage, look at the html of other modules already implemented -your barebones html file should look like this: +**your barebones html file should look like this:** ```html
@@ -249,4 +298,4 @@ your barebones html file should look like this: all components can be found at `common/resources/web/components/common` -[Refer to this Document for more information and examples](./common/\/resources/web/Web%20Examples.md) +[Refer to this Document for more information and examples](./common/resources/web/Web%20Examples.md) diff --git a/common/java/com/zergatul/cheatutils/configs/Config.java b/common/java/com/zergatul/cheatutils/configs/Config.java index 565a1a19..c1458043 100644 --- a/common/java/com/zergatul/cheatutils/configs/Config.java +++ b/common/java/com/zergatul/cheatutils/configs/Config.java @@ -9,6 +9,7 @@ public class Config implements Sanitizable { public EntitiesConfig entities = new EntitiesConfig(); public LightLevelConfig lightLevelConfig = new LightLevelConfig(); public KillAuraConfig killAuraConfig = new KillAuraConfig(); + public CrystalAuraConfig crystalAuraConfig = new CrystalAuraConfig(); public BoatHackConfig boatHackConfig = new BoatHackConfig(); public ShulkerTooltipConfig shulkerTooltipConfig = new ShulkerTooltipConfig(); public ProjectilePathConfig projectilePathConfig = new ProjectilePathConfig(); @@ -82,6 +83,7 @@ public class Config implements Sanitizable { @Override public void sanitize() { killAuraConfig.sanitize(); + crystalAuraConfig.sanitize(); movementHackConfig.sanitize(); fastBreakConfig.sanitize(); elytraHackConfig.sanitize(); diff --git a/common/java/com/zergatul/cheatutils/configs/CrystalAuraConfig.java b/common/java/com/zergatul/cheatutils/configs/CrystalAuraConfig.java new file mode 100644 index 00000000..adbefb33 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/configs/CrystalAuraConfig.java @@ -0,0 +1,12 @@ +package com.zergatul.cheatutils.configs; + +public class CrystalAuraConfig extends ModuleConfig implements Sanitizable { + + CrystalAuraConfig() { + + } + @Override + public void sanitize() { + + } +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/modules/Modules.java b/common/java/com/zergatul/cheatutils/modules/Modules.java index b0dc83c4..016ca355 100644 --- a/common/java/com/zergatul/cheatutils/modules/Modules.java +++ b/common/java/com/zergatul/cheatutils/modules/Modules.java @@ -91,6 +91,7 @@ public static void register() { register(AfterPlayerAiStepExecutor.instance); register(AfterSendPlayerPosExecutor.instance); register(KillAura.instance); + register(KillAura.instance); register(SpearRange.instance); register(AutoStunner.instance); diff --git a/common/java/com/zergatul/cheatutils/modules/hacks/CrystalAura.java b/common/java/com/zergatul/cheatutils/modules/hacks/CrystalAura.java new file mode 100644 index 00000000..dd40a987 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/modules/hacks/CrystalAura.java @@ -0,0 +1,10 @@ +package com.zergatul.cheatutils.modules.hacks; + +import com.zergatul.cheatutils.modules.Module; + +public class CrystalAura implements Module { + public static final CrystalAura instance = new CrystalAura(); + CrystalAura(){ + + } +} \ No newline at end of file diff --git a/common/java/com/zergatul/cheatutils/scripting/Root.java b/common/java/com/zergatul/cheatutils/scripting/Root.java index dfb1da05..5f18cb4d 100644 --- a/common/java/com/zergatul/cheatutils/scripting/Root.java +++ b/common/java/com/zergatul/cheatutils/scripting/Root.java @@ -37,6 +37,7 @@ public class Root { public static FastBreakApi fastBreak = new FastBreakApi(); public static FlyHackApi flyHack = new FlyHackApi(); public static KillAuraApi killAura = new KillAuraApi(); + public static CrystalAuraApi crystalAuraApi = new CrystalAuraApi(); public static MovementApi movement = new MovementApi(); public static NoFallApi noFall = new NoFallApi(); public static ScaffoldApi scaffold = new ScaffoldApi(); diff --git a/common/java/com/zergatul/cheatutils/scripting/modules/CrystalAuraApi.java b/common/java/com/zergatul/cheatutils/scripting/modules/CrystalAuraApi.java new file mode 100644 index 00000000..7949ac68 --- /dev/null +++ b/common/java/com/zergatul/cheatutils/scripting/modules/CrystalAuraApi.java @@ -0,0 +1,13 @@ +package com.zergatul.cheatutils.scripting.modules; + +import com.zergatul.cheatutils.configs.CrystalAuraConfig; +import com.zergatul.cheatutils.configs.ConfigStore; + +public class CrystalAuraApi extends ModuleApi { + + + @Override + protected CrystalAuraConfig getConfig() { + return ConfigStore.instance.getConfig().crystalAuraConfig; + } +} \ No newline at end of file diff --git a/common/resources/web/Web Examples.md b/common/resources/web/Web Examples.md index cdfb42d8..6c5f3dc1 100644 --- a/common/resources/web/Web Examples.md +++ b/common/resources/web/Web Examples.md @@ -1,6 +1,6 @@ # Website components -## Explanation:- +## Explanation: - `v-model="config.VariableName"` This defines the variable to be modified. @@ -8,7 +8,7 @@ ### [Website uses Vue components](https://vuejs.org/guide/introduction.html) -## Component Examples:- +## Component Examples: ### Switch diff --git a/common/resources/web/components/hacks/CrystalAura.html b/common/resources/web/components/hacks/CrystalAura.html new file mode 100644 index 00000000..798681da --- /dev/null +++ b/common/resources/web/components/hacks/CrystalAura.html @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/common/resources/web/components/hacks/CrystalAura.js b/common/resources/web/components/hacks/CrystalAura.js new file mode 100644 index 00000000..e3404370 --- /dev/null +++ b/common/resources/web/components/hacks/CrystalAura.js @@ -0,0 +1,5 @@ +import { createSimpleComponent } from '/components/SimpleModule.js'; + +export function createComponent(template) { + return createSimpleComponent('/api/crystal-aura', template); +} \ No newline at end of file diff --git a/common/resources/web/modules.js b/common/resources/web/modules.js index 55c97126..6285f8f1 100644 --- a/common/resources/web/modules.js +++ b/common/resources/web/modules.js @@ -222,6 +222,15 @@ module({ path: 'kill-aura', tags: ['kill', 'aura', 'auto', 'attack'] }); + +module({ + group: 'hacks', + name: 'Crystal Aura', + component: 'CrystalAura', + path: 'crystal-aura', + tags: ['kill', 'crystal', 'aura', 'auto', 'attack', 'blow', 'explode'] +}); + module({ group: 'hacks', name: 'Elytra Fly', diff --git a/neoforge/gradle/wrapper/gradle-wrapper.jar b/neoforge/gradle/wrapper/gradle-wrapper.jar index f8e1ee31..d997cfc6 100644 Binary files a/neoforge/gradle/wrapper/gradle-wrapper.jar and b/neoforge/gradle/wrapper/gradle-wrapper.jar differ