Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lebogoo/modtest
https://github.com/lebogoo/modtest
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/lebogoo/modtest
- Owner: LeBogoo
- Created: 2023-12-18T21:00:18.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-16T19:18:37.000Z (12 months ago)
- Last Synced: 2024-01-17T03:36:11.336Z (12 months ago)
- Language: Java
- Size: 416 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Modding/Plugin System in Java
## Introduction
This is a simple modding/plugin system in Java. It is a proof of concept how it could be done.
This was originally created as a Demo for Home Grown - a Farming Game made by Thinmatrix.
## How to use
### Implementing the Mod System
Inside the `game.modding` folder you can see a few files.
The `ModLoader` will load all mods that are inside the `mods` folder and create, instantiate and initialize them with a reference to the `Game` object.
The `GameMod` is an interface that every mod has to implement.Inside the `Game` class a new `ModLoader` is created and updated every game cycle.
### Creating a Mod
To create a mod you have to create a new class that implements the `GameMod` interface.
Inside the `GameMod` interface you can see a few methods that you have to implement.```java
public interface GameMod {
void init(Game game);
void update();
}
```The `init` method is called when the mod is loaded and the `update` method is called every game cycle.
### Setting up this project inside your IDE
Since this project uses Maven it already comes with the correct configuration.
The Modders usually don't have access to the source code of the game, so they have to use the Game JAR itself as a dependency.
If they got the JAR they can modify the `pom.xml` file and change the `systemPath` of the dependency to the path of the JAR.
```xml
me.lebogo
game
1.0-SNAPSHOT
system
JAR PATH HERE
```### Creating a Mod JAR
Creating a Mod JAR is very simple. If you have Maven installed you can just run `mvn clean package` inside the mod folder and it will create a JAR inside the `target` folder.
This jar can be copied into the `mods` folder of the game and it will be loaded automatically.