Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/by1337/bpatcher
BPatcher is a tool designed to simplify bytecode modification for servers.
https://github.com/by1337/bpatcher
Last synced: about 1 month ago
JSON representation
BPatcher is a tool designed to simplify bytecode modification for servers.
- Host: GitHub
- URL: https://github.com/by1337/bpatcher
- Owner: By1337
- License: mit
- Created: 2024-06-28T18:16:28.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-08-11T23:29:25.000Z (5 months ago)
- Last Synced: 2024-08-12T00:30:30.493Z (5 months ago)
- Language: Java
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### Description
BPatcher is a tool designed to simplify bytecode modification for servers. With BPatcher, you can easily apply patches
to your Minecraft server.### Installation and Usage
To use BPatcher, you need to add `javaagent` to your server's startup command:
```shell
java -javaagent:BPatcher.jar -jar Server.jar
```Upon first launch, BPatcher will create a `patches` folder. You can move your patches to this folder, and they will be
applied the next time the server starts.### Creating Patches
1. Create a new project and add the following snippet to your `pom.xml`:
```xml
org.apache.maven.plugins
maven-compiler-plugin
3.8.1
${java.version}
${java.version}
org.by1337.bpatcher.annotation
AnnotationProcessor
1.2
by1337-repo
https://repo.by1337.space/repository/maven-releases/
org.by1337.bpatcher
BPatcher
1.2
provided
```
2. Create a class that implements the `Patcher` interface.3. Compile the project and move it to the `patches` folder.
### Patch Example
```java
import org.by1337.bpatcher.patcher.api.Patcher;
import org.by1337.bpatcher.util.ByteCodeBuilder;
import org.by1337.bpatcher.util.BytecodeHelper;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;@Patch
public class ExamplePatch implements Patcher {
@Override
public void apply(ClassNode classNode) {
MethodNode methodNode = BytecodeHelper.getMethod(classNode, "main");
AbstractInsnNode first = methodNode.instructions.getFirst();
ByteCodeBuilder builder = new ByteCodeBuilder();
builder.getstatic("java/lang/System", "out", "Ljava/io/PrintStream;");
builder.ldc("Example patch!");
builder.invokevirtual("java/io/PrintStream", "println", "(Ljava/lang/String;)V");
methodNode.instructions.insertBefore(first, builder.getSource());
}@Override
public String targetClass() {
return "org/bukkit/craftbukkit/Main";
}
}
```This example shows how to create a patch that inserts a print statement into the `main` method of
the `org/bukkit/craftbukkit/Main` class. This patch will print "Example patch!" to the console when the method is
executed.