Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ body:
label: Server logs and config
description: |
If you think it will be helpful, please include any server logs.
Also please provide the config.yml file from `plugins/EntityGenetics/config.yml`.
Also please provide the settings.yml file from `plugins/EntityGenetics/settings.yml`.
placeholder: Logs and configs (if you think it'll help!)
validations:
required: false
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Java CI with Gradle
on:
push:
branches:
- development
pull_request:
branches:
- development
jobs:
build:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
- name: Set up JDK
uses: actions/setup-java@v4.2.1
with:
distribution: adopt
java-version: 21
- name: Make build.gradle executable
run: chmod +x gradlew
- name: Build plugin
run: ./gradlew build
- name: Upload plugin
uses: actions/upload-artifact@v4.3.5
with:
name: EntityGenetics
path: "*/build/libs/*.jar"
- uses: dev-drprasad/delete-tag-and-release@v1.1
if: ${{ github.event_name == 'push' }}
with:
delete_release: true
tag_name: dev-build
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Find git version
id: git-version
run: echo "id=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Find correct JAR
if: ${{ github.event_name == 'push' }}
id: find-jar
run: |
output="$(find build/libs/ ! -name "*-javadoc.jar" ! -name "*-sources.jar" -type f -printf "%f\n")"
echo "::set-output name=jarname::$output"
- name: Release the build
if: ${{ github.event_name == 'push' }}
uses: ncipollo/release-action@v1
with:
artifacts: build/libs/${{ steps.find-jar.outputs.jarname }}
body: ${{ join(github.event.commits.*.message, '\n') }}
prerelease: true
name: Dev-build ${{ steps.git-version.outputs.id }}
tag: dev-build
- name: Upload to Modrinth
if: ${{ github.event_name == 'push' }}
uses: RubixDev/modrinth-upload@v1.0.0
with:
token: ${{ secrets.MODRINTH_TOKEN }}
file_path: build/libs/${{ steps.find-jar.outputs.jarname }}
name: Dev-build ${{ steps.git-version.outputs.id }}
version: ${{ steps.git-version.outputs.id }}
changelog: ${{ join(github.event.commits.*.message, '\n') }}
game_versions: 1.21,1.20.6,1.20.5,1.20.4,1.20.3,1.20.2,1.20.1,1.20,1.19.4,1.19.3,1.19.2,1.19.1,1.19,1.18.2,1.18.1,1.18,1.17.1,1.17,1.16.5,1.16.4,1.16.3,1.16.2,1.16.1,1.16,1.15.2,1.15.1,1.15,1.14.4,1.14.3,1.14.2,1.14.1,1.14,1.13.2,1.13.1,1.13,1.12.2,1.12.1,1.12,1.11.2,1.11.1,1.11,1.10.2,1.10.1,1.10,1.9.4,1.9.3,1.9.2,1.9.1,1.9,1.8.9,1.8.8,1.8.7,1.8.6,1.8.5,1.8.4,1.8.3,1.8.2,1.8.1,1.8
release_type: beta
loaders: bukkit,spigot,paper,purpur,folia
featured: false
project_id: Th1vTBns
2 changes: 0 additions & 2 deletions .github/workflows/pre_build_jars.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: Test compiling against Java 8, 11 and 16

on:
pull_request:
branches:
- development
paths:
- "src/**"
- "build.gradle"

jobs:
testBuilds:
strategy:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Java CI with Gradle
on:
release:
types: [published]
jobs:
build:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
- name: Set up JDK
uses: actions/setup-java@v4.2.1
with:
distribution: adopt
java-version: 21
- name: Make build.gradle executable
run: chmod +x gradlew
- name: Build plugin
run: ./gradlew build
- name: Upload plugin
uses: actions/upload-artifact@v4.3.5
with:
name: EntityGenetics
path: "*/build/libs/*.jar"
- name: Find correct JAR
id: find-jar
run: |
output="$(find build/libs/ ! -name "*-javadoc.jar" ! -name "*-sources.jar" -type f -printf "%f\n")"
echo "::set-output name=jarname::$output"
- name: Upload to the GitHub release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: build/libs/${{ steps.find-jar.outputs.jarname }}
asset_name: ${{ steps.find-jar.outputs.jarname }}
asset_content_type: application/java-archive
- name: Upload to Modrinth
uses: RubixDev/modrinth-upload@v1.0.0
with:
token: ${{ secrets.MODRINTH_TOKEN }}
file_path: build/libs/${{ steps.find-jar.outputs.jarname }}
name: Release ${{ github.event.release.tag_name }}
version: ${{ github.event.release.tag_name }}
changelog: ${{ github.event.release.body }}
game_versions: 1.21,1.20.6,1.20.5
release_type: release
loaders: bukkit,spigot,paper,purpur,folia
featured: true
project_id: Th1vTBns
18 changes: 10 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ version = property("projectVersion") as String

allprojects {
apply(plugin = "java")
tasks {
processResources {
filesMatching("**/plugin.yml") {
expand("version" to rootProject.version, "name" to rootProject.name)
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
filteringCharset = Charsets.UTF_8.name()
}
}
repositories {
mavenCentral()
maven("https://papermc.io/repo/repository/maven-public/") // Paper
Expand All @@ -29,8 +38,8 @@ allprojects {
}
dependencies {
compileOnly("org.spigotmc:spigot-api:$spigot")
compileOnly(fileTree("../libs/compileOnly/"))
compileOnly("org.projectlombok:lombok:$lombok")
compileOnly(fileTree("../libs/compileOnly/"))

implementation("org.bstats:bstats-bukkit:$bstats")
implementation(fileTree("../libs/implementation/"))
Expand All @@ -53,13 +62,6 @@ tasks {
compileJava.get().options.encoding = Charsets.UTF_8.name()
javadoc.get().options.encoding = Charsets.UTF_8.name()
processResources {
inputs.properties(
"version" to version,
"name" to rootProject.name
)
filesMatching("**/plugin.yml") {
expand(mapOf("version" to version, "name" to rootProject.name))
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
filteringCharset = Charsets.UTF_8.name()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package kz.hxncus.mc.entitygenetics;

import kz.hxncus.mc.entitygenetics.color.ColorManager;
import kz.hxncus.mc.entitygenetics.config.ConfigManager;
import kz.hxncus.mc.entitygenetics.listener.EntityListener;
import kz.hxncus.mc.entitygenetics.listener.PlayerListener;
import kz.hxncus.mc.minesonapi.MinesonAPI;
import kz.hxncus.mc.minesonapi.bukkit.event.EventManager;
import kz.hxncus.mc.minesonapi.random.SimpleRandom;
import kz.hxncus.mc.minesonapi.util.AttributeUtil;
import lombok.Getter;
import org.bukkit.plugin.PluginManager;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public final class EntityGenetics extends JavaPlugin {
private static EntityGenetics instance;
private ColorManager colorManager;
private ConfigManager configManager;

public EntityGenetics() {
instance = this;
Expand All @@ -24,17 +26,71 @@ public static EntityGenetics get() {

@Override
public void onEnable() {
registerManagers();
registerListeners(getServer().getPluginManager());
registerEvents();
}

private void registerManagers() {
this.colorManager = new ColorManager(this);
this.configManager = new ConfigManager(this);
}

private void registerListeners(PluginManager pluginManager) {
pluginManager.registerEvents(new EntityListener(), this);
pluginManager.registerEvents(new PlayerListener(), this);
private void registerEvents() {
EventManager eventManager = MinesonAPI.get().getEventManager();
eventManager.register(EntitySpawnEvent.class, event -> {
if (!(event.getEntity() instanceof LivingEntity livingEntity)) {
return;
}
double randomValue = SimpleRandom.get().nextDouble(-0.5, 0.5);
AttributeUtil.acceptIfExists(livingEntity.getAttribute(Attribute.GENERIC_SCALE), scaleAttribute -> {
double multiplier = scaleAttribute.getBaseValue() + randomValue;
scaleAttribute.setBaseValue(multiplier);
AttributeUtil.acceptIfExists(livingEntity.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_ATTACK_DAMAGE));
AttributeUtil.acceptIfExists(livingEntity.getAttribute(Attribute.GENERIC_ATTACK_SPEED),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_ATTACK_SPEED));
AttributeUtil.acceptIfExists(livingEntity.getAttribute(Attribute.GENERIC_FALL_DAMAGE_MULTIPLIER),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_FALL_DAMAGE_MULTIPLIER));
AttributeUtil.acceptIfExists(livingEntity.getAttribute(Attribute.GENERIC_JUMP_STRENGTH),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_JUMP_STRENGTH));
AttributeUtil.acceptIfExists(livingEntity.getAttribute(Attribute.GENERIC_MAX_HEALTH),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_MAX_HEALTH));
AttributeUtil.acceptIfExists(livingEntity.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_MOVEMENT_SPEED));
AttributeUtil.acceptIfExists(livingEntity.getAttribute(Attribute.GENERIC_SAFE_FALL_DISTANCE),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_SAFE_FALL_DISTANCE));
AttributeUtil.acceptIfExists(livingEntity.getAttribute(Attribute.GENERIC_STEP_HEIGHT),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_STEP_HEIGHT));
AttributeUtil.acceptIfExists(livingEntity.getAttribute(Attribute.ZOMBIE_SPAWN_REINFORCEMENTS),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.ZOMBIE_SPAWN_REINFORCEMENTS));
});
});
eventManager.register(PlayerJoinEvent.class, event -> {
Player player = event.getPlayer();
if (player.hasPlayedBefore()) {
return;
}
double randomValue = SimpleRandom.get().nextDouble(-0.5, 0.5);
AttributeUtil.acceptIfExists(player.getAttribute(Attribute.GENERIC_SCALE), scaleAttribute -> {
double multiplier = scaleAttribute.getBaseValue() + randomValue;
scaleAttribute.setBaseValue(multiplier);
AttributeUtil.acceptIfExists(player.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_ATTACK_DAMAGE));
AttributeUtil.acceptIfExists(player.getAttribute(Attribute.GENERIC_ATTACK_SPEED),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_ATTACK_SPEED));
AttributeUtil.acceptIfExists(player.getAttribute(Attribute.GENERIC_FALL_DAMAGE_MULTIPLIER),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_FALL_DAMAGE_MULTIPLIER));
AttributeUtil.acceptIfExists(player.getAttribute(Attribute.GENERIC_JUMP_STRENGTH),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_JUMP_STRENGTH));
AttributeUtil.acceptIfExists(player.getAttribute(Attribute.GENERIC_MAX_HEALTH),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_MAX_HEALTH));
AttributeUtil.acceptIfExists(player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_MOVEMENT_SPEED));
AttributeUtil.acceptIfExists(player.getAttribute(Attribute.GENERIC_SAFE_FALL_DISTANCE),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_SAFE_FALL_DISTANCE));
AttributeUtil.acceptIfExists(player.getAttribute(Attribute.GENERIC_STEP_HEIGHT),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.GENERIC_STEP_HEIGHT));
AttributeUtil.acceptIfExists(player.getAttribute(Attribute.PLAYER_BLOCK_BREAK_SPEED),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.PLAYER_BLOCK_BREAK_SPEED));
AttributeUtil.acceptIfExists(player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.PLAYER_BLOCK_INTERACTION_RANGE));
AttributeUtil.acceptIfExists(player.getAttribute(Attribute.PLAYER_ENTITY_INTERACTION_RANGE),
maxHealthAttribute -> maxHealthAttribute.setBaseValue(multiplier * AttributeUtil.PLAYER_ENTITY_INTERACTION_RANGE));
});
});
}
}
Loading
Loading