Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 113 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -50,12 +50,16 @@ public class AutoPearl implements Module {
}
}
```
Make sure to add the line:
`package com.zergatul.cheatutils.modules.<folder>;`
`<folder>` 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
Expand All @@ -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() {

Expand All @@ -90,51 +95,81 @@ 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.

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:

```java
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

Expand All @@ -149,97 +184,111 @@ public class AutoPearlApi extends ModuleApi<AutoPearlConfig> {

@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:

```javascript
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']
});
}
```

##### 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
<div class="module-main" v-if="config">
Expand All @@ -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)
2 changes: 2 additions & 0 deletions common/java/com/zergatul/cheatutils/configs/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -82,6 +83,7 @@ public class Config implements Sanitizable {
@Override
public void sanitize() {
killAuraConfig.sanitize();
crystalAuraConfig.sanitize();
movementHackConfig.sanitize();
fastBreakConfig.sanitize();
elytraHackConfig.sanitize();
Expand Down
12 changes: 12 additions & 0 deletions common/java/com/zergatul/cheatutils/configs/CrystalAuraConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.zergatul.cheatutils.configs;

public class CrystalAuraConfig extends ModuleConfig implements Sanitizable {

CrystalAuraConfig() {

}
@Override
public void sanitize() {

}
}
1 change: 1 addition & 0 deletions common/java/com/zergatul/cheatutils/modules/Modules.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions common/java/com/zergatul/cheatutils/modules/hacks/CrystalAura.java
Original file line number Diff line number Diff line change
@@ -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(){

}
}
1 change: 1 addition & 0 deletions common/java/com/zergatul/cheatutils/scripting/Root.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<CrystalAuraConfig> {


@Override
protected CrystalAuraConfig getConfig() {
return ConfigStore.instance.getConfig().crystalAuraConfig;
}
}
Loading