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
35 changes: 35 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# .clang-format
BasedOnStyle: LLVM

# never wrap
ColumnLimit: 0
ReflowComments: false
BreakStringLiterals: false

# keep call args/params on one line
BinPackArguments: true
BinPackParameters: true
AllowAllArgumentsOnNextLine: true
PenaltyBreakBeforeFirstCallParameter: 1000000

# your other prefs…
UseTab: ForIndentation
ContinuationIndentWidth: 4
AlignAfterOpenBracket: DontAlign
AlignOperands: false
IndentWidth: 4
TabWidth: 4
MaxEmptyLinesToKeep: 1
SeparateDefinitionBlocks: Always
AllowShortIfStatementsOnASingleLine: true # (or: WithoutElse on newer versions)
KeepEmptyLinesAtTheStartOfBlocks: true

SortIncludes: true
IncludeBlocks: Preserve

# never keep {} on one line (forces multi-line bodies)
AllowShortFunctionsOnASingleLine: false
AllowShortBlocksOnASingleLine: Never

---
Language: Java
45 changes: 45 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Continuous Deployment

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "microsoft"

- name: Make Gradle wrapper executable
run: chmod +x ./gradlew

# Get version from gradle.properties setting it as an environment variable
- name: Get Version
id: get_version
run: |
version=$(grep '^plugin_version' gradle.properties | cut -d'=' -f2 | xargs)
echo "version=$version" >> $GITHUB_ENV

- name: Build with Gradle Wrapper
run: ./gradlew build --no-daemon

- name: Create Release
uses: softprops/action-gh-release@v1
with:
draft: false
generate_release_notes: true
tag_name: v${{ env.version }}
files: build/libs/*.jar
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"githubPullRequests.ignoredPullRequestBranches": [
"master"
],
"java.configuration.updateBuildConfiguration": "automatic"
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

version = project.plugin_version
group = project.maven_group
archivesBaseName = project.plugin_name
archivesBaseName = project.plugin_id

configurations {
rusherhackApi
Expand Down
17 changes: 8 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx2G

# plugin name
plugin_name = example-plugin

# plugin version
# plugin info
plugin_id = example-plugin
plugin_name = Example Plugin
plugin_version = 1.0.0

maven_group = org.example

# use java 17 for minecraft versions 1.20.4 and older
# use java 21 for minecraft versions 1.20.5 and newer
java_version = 17
java_version = 21

# minecraft version to compile with
# other supported versions of the game can be added in rusherhack-plugin.json
minecraft_version = 1.20.1
minecraft_version = 1.21.4

# parchment mappings
parchment_version = 1.20.1:2023.09.03
parchment_version = 1.21.4:2025.03.23

# fabric loader version
fabric_loader_version = 0.16.9
fabric_loader_version = 0.17.2
31 changes: 15 additions & 16 deletions src/main/java/org/example/ExampleCommand.java
Original file line number Diff line number Diff line change
@@ -1,66 +1,65 @@
package org.example;

import org.rusherhack.client.api.feature.command.Command;
import org.rusherhack.core.command.annotations.CommandExecutor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.rusherhack.client.api.feature.command.Command;
import org.rusherhack.core.command.annotations.CommandExecutor;

/**
* Example rusherhack command
*
* @author John200410
*/
public class ExampleCommand extends Command {

private final List<String> stringList = new ArrayList<>(Arrays.asList("test1", "test2"));

public ExampleCommand() {
super("ExampleCommand", "description");
}

/**
* base command that takes in no arguments
*/
@CommandExecutor
private String example() {
//when return type is String you return the message you want to return to the user
// when return type is String you return the message you want to return to
// the user
return "Hello World!";
}

/**
* arguments example
*/
@CommandExecutor
@CommandExecutor.Argument({"string", "boolean"}) //must set argument names
@CommandExecutor.Argument({"string", "boolean"}) // must set argument names
private String exampleWithArguments(String requiredString, Optional<Boolean> optionalBoolean) {
return requiredString + " " + optionalBoolean.orElse(false);
}

/**
* sub command examples
*/
@CommandExecutor(subCommand = "list")
private String exampleList() {
return String.join(", ", this.stringList);
}

@CommandExecutor(subCommand = "add")
@CommandExecutor.Argument("string") //must set argument names
@CommandExecutor.Argument("string") // must set argument names
private String addToExampleList(String string) {
this.stringList.add(string);
return "Added " + string;
}

@CommandExecutor(subCommand = {"remove", "del"})
@CommandExecutor.Argument("string") //must set argument names
@CommandExecutor.Argument("string") // must set argument names
private String removeFromExampleList(String string) {
if(this.stringList.remove(string)) {
if (this.stringList.remove(string)) {
return "Removed " + string;
}
return string + " not found";
}

}
14 changes: 7 additions & 7 deletions src/main/java/org/example/ExampleHudElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,34 @@
* @author John200410
*/
public class ExampleHudElement extends ResizeableHudElement {

private TextureGraphic graphic = null;

public ExampleHudElement() {
super("ExampleHudElement");

//try loading graphic
try {
this.graphic = new TextureGraphic("exampleplugin/graphics/rh_head.png", 235, 234);
} catch (Throwable t) {
this.getLogger().error("Failed to load graphic", t);
}
}

@Override
public void renderContent(RenderContext context, double mouseX, double mouseY) {
//positions are relative to the top left corner of the hud element, so start drawing stuff from 0,0

if (this.graphic != null) {
this.getRenderer().drawGraphicRectangle(this.graphic, 0, 0, this.getWidth(), this.getHeight());
}
}

@Override
public double getWidth() {
return 200;
}

@Override
public double getHeight() {
return 200;
Expand Down
Loading