Compare commits

..
185 Commits
Author SHA1 Message Date
Michał Wojtas 786d480a11 GH-446 Bump runpaper version to 26.3, fix wrong config instance in SpearService, update names for better readability (#446) 2026-10-21 22:20:41 +02:00
renovate[bot] 6546694c7c dependency: Update Gradle to v9.8.0 (#441)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-25 18:18:04 +02:00
Martin Sulikowski e3508f3be6 Bump version to 2.6.0-SNAPSHOT 2026-09-22 00:55:15 +02:00
Martin Sulikowski fdd5147f18 [ci skip] Release 2.5.2 2026-09-22 00:40:18 +02:00
Martin Sulikowski 2265b66dfc Update dependencies for Minecraft 26.2 compatibility and improve README 2026-09-22 00:38:38 +02:00
Martin Sulikowski 07821a62f0 Rename crystalpvp classes and update package structure for clarity 2026-09-22 00:30:27 +02:00
Martin Sulikowski 78db24b23f Fix README for improved formatting and clarity 2026-09-22 00:27:19 +02:00
Martin Sulikowski 9ea261517a GH-180 Add GriefPrevention region support for combat restrictions (#423) 2026-09-22 00:26:08 +02:00
renovate[bot] 7363d57b0e dependency: Update dependency java-jdk to v25 (#432)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-22 00:19:08 +02:00
renovate[bot] 0951ef3b97 dependency: Update dependency com.github.ben-manes.caffeine:caffeine to v3.3.0 (#435)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-22 00:18:55 +02:00
renovate[bot] 8a48eb55bf dependency: Update Gradle to v9.7.1 (#426)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-20 11:54:58 +02:00
renovate[bot] dd1688af28 dependency: Update dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8 to v2.4.20 (#428)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-20 11:54:48 +02:00
renovate[bot] fbce3c2c0b dependency: Update dependency com.modrinth.minotaur:com.modrinth.minotaur.gradle.plugin to v2.10.0 (#433)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-09-20 11:54:36 +02:00
Norbert Dejlich 2de95627d5 Fix PacketEvents version in gradle Versions declaration (#434) 2026-09-17 20:50:20 +02:00
Michał Wojtas f31a459c13 GH-334 Folia pearl fix (#334)
* Move FoliaChecker to final class - used it in FightTagController, add runFolia to runPlugin configuration

* Make it configurable

* Follow Gemini review

* Follow jakubek's review

* Remove unnecessary configuration

* Adjust to @imDMK review

* Follow Rollczi and imDMK reviews - remove synchronized and cache

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

* Follow Rollczi overdue review

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

---------

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>
2026-09-14 21:04:14 +02:00
Michał WojtasandJakub Kędziora 9fe7a1d067 GH-414 feat: add spear with lunge cooldown (#414)
* add spear cooldown and lunge support based on new api handling without building against it due to support for older versions

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

* Resolve AI review. Add gif to readme

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

* Optimise SpearLungeController

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

* Update eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/spear/SpearLungeController.java

Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>

* Update eternalcombat-api/src/main/java/com/eternalcode/combat/fight/spear/SpearService.java

Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>

---------

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>
Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>
2026-09-14 21:03:14 +02:00
renovate[bot] b5c289c2b1 dependency: Update dependency xyz.jpenilla:run-task to v3.1.0 (#420)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-08-17 21:37:50 +02:00
Martin Sulikowski 5b4f9d1911 GH-422 Keep combat tag active below void height to prevent evasion (#422)
* Keep combat tag active below void height to prevent evasion

* Respect ignored worlds for void combat
2026-08-17 21:37:36 +02:00
Martin Sulikowski e024b2fae9 Add opponent placeholder to combat tag chat message (#421)
* Add opponent placeholder to combat tag chat message

* Pass opponent UUID when tagging for combat
2026-08-17 21:37:12 +02:00
renovate[bot] b2776936ed dependency: Update junit-framework monorepo to v6.1.3 (#418)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-08-17 20:58:09 +02:00
Martin Sulikowski d2aa5dfa84 GH-395 Add combat sign editing blocker (#395)
* Add combat sign editing blocker

* Fix.
2026-08-17 20:57:17 +02:00
renovate[bot] 5c88af692d dependency: Update Gradle to v9.7.0 (#419)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-08-17 20:50:56 +02:00
renovate[bot] 390195edb2 dependency: Update dependency com.gradleup.shadow:com.gradleup.shadow.gradle.plugin to v9.6.1 (#413)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-22 10:11:56 +02:00
renovate[bot] 8808331f0a dependency: Update junit-framework monorepo to v6.1.2 (#411)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-14 17:14:08 +02:00
renovate[bot] 99b3a5aa27 dependency: Update dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8 to v2.4.10 (#412)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-14 17:14:00 +02:00
renovate[bot] 9d1716d9db dependency: Update Gradle to v9.6.1 (#405)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-08 22:52:33 +02:00
renovate[bot] 7b94ab4b7a dependency: Update Versions.PACKETS_EVENTS (#402)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-08 22:52:13 +02:00
renovate[bot] daee189865 dependency: Update dependency me.clip:placeholderapi to v2.12.3 (#407)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-08 22:51:59 +02:00
renovate[bot] 1aef1e6f1d dependency: Update junit-framework monorepo to v6.1.1 (#408)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-08 22:51:49 +02:00
renovate[bot] 788a2a668c dependency: Update dependency com.gradleup.shadow:com.gradleup.shadow.gradle.plugin to v9.5.1 (#409)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-07-08 22:51:41 +02:00
Nico SendanandMartin Sulikowski 93d7ffdd0f GH-400 Resolve EntityMountEvent registration failure on modern Paper (#400)
* Fix: Resolve EntityMountEvent registration failure on modern Paper

Newer Paper builds (e.g. 26.1.2) removed org.spigotmc.event.entity.EntityMountEvent, causing KnockbackRegionController registration to fail and region knockback protection to be disabled.

Resolve EntityMountEvent at runtime (checking Bukkit, Paper, and Spigot packages) and register it reflectively while preserving the 1.19.3 compile target for compatibility.

* Optimize dynamic mount event handling

---------

Co-authored-by: Martin Sulikowski <vluckyyy.biznes@gmail.com>
2026-06-21 15:30:55 +02:00
renovate[bot] fb6db7a008 dependency: Update Gradle to v9.6.0 (#397)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-20 14:14:16 +02:00
renovate[bot] 7d8a01b7d7 dependency: Update Versions.LITE_COMMANDS to v3.11.0 (#398)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-20 14:13:50 +02:00
renovate[bot] 08c7482cee dependency: Update actions/checkout action to v7 (#399)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-20 14:12:36 +02:00
7e24e5afa6 GH-266 New features for Trident and Pearls (#303)
* I've added new options to Pearl and Trident that reset the timer when we use them

* I made the corrections that gemini noticed

* The improvements suggested by the team have been implemented

* Implemented suggestions from the team

* Make tridents throw check work on all tridents, regardless of enchantment

* Implemented suggestions from the team and fixed `FightTridentController` logic

* Corrected comments and field names

* Implemented CitralFlo suggestions

* Implemented CitralFlo suggestions again

* Follow igoyek's review from 21.10.25

* CR

* Simplify naming - extract logic to service for Pearls

* make it more logical

* Refactor trident-related classes and services for improved clarity and consistency

* Rename trident cooldown methods to improve clarity and update comments for riptide usage

* Fixes after tests - everything should be working now!

* Remove commented line

* Add cooldown to enderpearl - hack by:https://www.spigotmc.org/threads/modify-vanilla-ender-pearl-cooldown.629232/

* Bump minecraft version in runServer task to 1.21.11

* Add combat restrictions for Riptide tridents and improve event handling

* Update eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/trident/TridentSettings.java

* Apply suggestion from @Jakubk15

* Migrate to commons delay

* Resolve conflicts

* CR

* resolve merge

* resolve merge conflicts and update

---------

Co-authored-by: Jakubk15 <77227023+Jakubk15@users.noreply.github.com>
Co-authored-by: Michał Wojtas <wojtas.michal90@gmail.com>
Co-authored-by: Rollczi <ndejlich5@gmail.com>
Co-authored-by: Martin Sulikowski <vluckyyy.biznes@gmail.com>
2026-06-07 22:36:05 +02:00
bb130ae10e GH-373 Add opponent placeholder in combat notification (#373)
* Add opponent placeholder in combat notification

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

* Update eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/FightTask.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Norbert Dejlich <ndejlich5@gmail.com>
2026-06-07 21:46:10 +02:00
Igor MichalskiandRollczi 2c5b007d02 GH-331 Add pearl teleport (#331)
* Add pearl stasis prevention feature

Took 27 minutes

* Add message to pearl stasis prevention feature

Took 8 minutes

* CR

---------

Co-authored-by: Rollczi <ndejlich5@gmail.com>
2026-06-07 21:11:41 +02:00
Martin Sulikowski 51b365df1b bump version to 2.5.2-SNAPSHOT for further development 2026-06-06 21:25:32 +02:00
Martin Sulikowski 4f23105ba1 Release: bump version to 2.5.1 for official release 2026-06-06 21:21:25 +02:00
Martin Sulikowski d0c221c184 Fix: Add PlaceholderAPI dependency and ensure safe API initialization/deinitialization 2026-06-06 21:18:29 +02:00
Martin Sulikowski bf529dce32 Readme: Extend supported Minecraft versions to 26.1.2 2026-06-06 02:04:05 +02:00
Martin Sulikowski 74ec795581 Fix: bump version to 2.5.1-SNAPSHOT for further development 2026-06-06 02:03:30 +02:00
Martin Sulikowski b3550110c8 bump version to 2.5.1-SNAPSHOT for further development 2026-06-06 01:57:48 +02:00
Martin Sulikowski 326f7363f1 bump version to 2.5.0 for release 2026-06-06 01:56:00 +02:00
Martin Sulikowski 5645f0473b Modularize build scripts for publishing and run configurations 2026-06-06 01:52:57 +02:00
Martin Sulikowski d0336441ce GH-389 Use paper native, support 26+ minecraft versions. (#389)
* refactor: migrate plugin to modern Paper API

Switch build metadata to Paper plugin descriptors and paper-api from 1.19.3 onward.

Use native Paper Adventure audiences, async chunk loading, and teleport APIs without relocating Adventure.

Add repository guidance and bug report notes.

* Fix.

* fix: disable config cache for paper plugin descriptor task

The plugin-yml paper generator reads Task.project during task execution, which Gradle 9.5 rejects when storing configuration cache state.

Declare the generated descriptor task incompatible with configuration cache so CI can complete while keeping cache enabled for the rest of the build.

* fix: use paper-compatible multification notices

Replace BukkitNotice builders with core Notice builders after moving to multification-paper.

Use the Adventure sound resolver so config serialization no longer depends on multification-bukkit classes.

* fix: resolve combat potion effects through XSeries

Use XPotion for default combat effects so removed Bukkit enum constants such as DAMAGE_RESISTANCE do not crash on newer Paper versions.

Guard plugin disable cleanup when enable fails before the API provider is initialized.

* Fix.

* fix: support modern Paper without Adventure 5

* fix: update EternalCode Commons

* fix: downgrade Java toolchain to 21 and set custom launcher for runServer task
2026-06-06 01:44:12 +02:00
renovate[bot] bc6df07609 dependency: Update dependency com.gradleup.shadow:com.gradleup.shadow.gradle.plugin to v9.4.2 (#384)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-06 00:46:18 +02:00
renovate[bot] 440f77e387 dependency: Update Versions.CAFFEINE to v3.2.4 (#380)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-06 00:46:04 +02:00
renovate[bot] 3dc115c1f6 dependency: Update Gradle to v9.5.1 (#381)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-06 00:45:57 +02:00
renovate[bot] 591ba20221 dependency: Update Versions.XSERIES to v13.8.0 (#382)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-06 00:45:50 +02:00
renovate[bot] 4d2d2222aa dependency: Update junit-framework monorepo to v6.1.0 (#383)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-06 00:45:39 +02:00
renovate[bot] 62975caf58 dependency: Update Versions.WORLD_GUARD_BUKKIT to v7.0.17 (#385)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-06 00:45:29 +02:00
renovate[bot] d7c7ac2916 dependency: Update Versions.PACKETS_EVENTS to v2.12.2 (#386)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-06 00:45:22 +02:00
renovate[bot] d250a6a720 dependency: Update kotlin monorepo to v2.4.0 (#387)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-06-06 00:45:17 +02:00
Joël | NoPermissionandRollczi 5c6ac79579 GH-374 fix(combat): patch elytra escape exploit (#374)
* - Changed old methods to new worldguard methods

* fix(knockback): prevent roof teleport exploit & improve safe knockback handling

Fixed an issue where players using fight charge could remain inside knockback regions
and get teleported onto the map roof (above playable area).

### Key changes:
- Reworked knockback direction to push players toward nearest region edge
  instead of center-based vector
- Added velocity dampening system for more consistent knockback behavior
- Improved vertical handling:
  - Separate ground vs air vertical values
  - Prevent excessive vertical stacking while airborne

### Teleport fallback system:
- Introduced optional smart fallback teleport when knockback fails
- Added continuous velocity check before teleporting (prevents false triggers)
- Prevent duplicate fallback tasks using active tracking set
- Improved force knockback logic with edge distance + velocity validation

### Safe location handling:
- Implemented safe ground detection system:
  - Avoid unsafe blocks (lava, cactus, magma, etc.)
  - Ensure 2-block air clearance above ground
- Added configurable fallback scanning from highest block
- Prevent teleport if no safe location is found (optional)

### Stability improvements:
- Added recursion limit for region expansion to prevent infinite loops
- Improved region overlap handling during location generation
- Reduced unnecessary teleports and edge-case glitches

### Config additions:
- vertical / maxAirVertical
- dampenVelocity / dampenFactor
- useTeleport (smart fallback)
- safeGroundCheck + safeHighestFallback
- unsafeGroundBlocks
- groundOffset
- maxAttempts
- cancelIfNoSafeGround

Result:
- Eliminates roof teleport exploit
- More natural and predictable knockback
- Safer teleport fallback system
- Better handling of edge cases and overlapping regions

* fix(combat): prevent elytra escape exploit & improve glide restriction handling

Fixed an issue where players could abuse elytra (e.g. cliff jumping, trident launching, or mid-air tagging) to escape combat and bypass restrictions.

### Key changes:
- Fully disabled elytra usage during combat
- Blocked glide activation via EntityToggleGlideEvent
- Added continuous glide checks to stop mid-air abuse
- Forced downward velocity to prevent spacebar glide spam

### Elytra handling system:
- Introduced automatic elytra unequip on combat tag
- Prevents players from staying airborne when entering combat
- Moves elytra safely to inventory or drops if full
- Eliminates pre-glide and mid-air tagging exploits

### Inventory protection:
- Blocked equipping elytra during combat:
  - Click equip
  - Shift-click
  - Hotbar swap (number keys)
- Prevents all known re-equip bypass methods

### Flight & movement improvements:
- Disabled flight properly on combat start
- Prevents glide reactivation while moving

### Messaging improvements:
- Added dedicated elytra combat message
- Clear feedback when elytra is blocked or removed

### Config additions:
- unequipElytraOnCombat
- blockElytraEquipDuringCombat
- elytraDisabledDuringCombat

Result:
- Eliminates cliff jump & trident launch exploits
- Prevents all elytra-based combat escapes
- Provides consistent and predictable combat behavior
- Matches behavior of high-end PvP combat systems

* CR

* CR 2

---------

Co-authored-by: Rollczi <ndejlich5@gmail.com>
2026-06-05 19:48:47 +02:00
Martin Sulikowski 59f0612405 GH-328 Add /combatlog stats command and related permissions and messages. (#306) 2026-05-07 20:01:54 +02:00
renovate[bot] 84d1d5aeb6 dependency: Update Gradle to v9.5.0 (#378)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-28 20:00:54 +02:00
renovate[bot] e73864923f dependency: Update dependency com.github.retrooper:packetevents-spigot to v2.12.1 (#376)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-28 20:00:47 +02:00
renovate[bot] 195e45ed34 dependency: Update dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8 to v2.3.21 (#377)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-28 20:00:39 +02:00
imgbot[bot]andImgBotApp 459ff06f18 [ImgBot] Optimize images (#361)
*Total -- 20,587.83kb -> 17,156.76kb (16.67%)

/assets/lightning.gif -- 4,208.49kb -> 2,771.07kb (34.16%)
/assets/flare.gif -- 6,525.52kb -> 5,502.98kb (15.67%)
/assets/readme-banner.png -- 112.85kb -> 98.39kb (12.81%)
/assets/border.gif -- 6,004.89kb -> 5,373.86kb (10.51%)
/assets/combatlog.gif -- 2,949.14kb -> 2,658.24kb (9.86%)
/assets/crystals.gif -- 786.95kb -> 752.21kb (4.41%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
2026-04-19 20:59:49 +02:00
renovate[bot] 4a153d5557 dependency: Update actions/github-script action to v9 (#372)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-12 11:07:04 +02:00
renovate[bot] 3e5b060923 dependency: Update dependency com.github.retrooper:packetevents-spigot to v2.12.0 (#370)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-12 11:06:38 +02:00
renovate[bot] 03768ccd8d dependency: Update dependency com.sk89q.worldguard:worldguard-bukkit to v7.0.16 (#368)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-12 11:06:14 +02:00
renovate[bot] ba59d85996 dependency: Update dependency com.gradleup.shadow:com.gradleup.shadow.gradle.plugin to v9.4.1 (#369)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-12 11:06:04 +02:00
renovate[bot] 1c432cbcb3 dependency: Update dependency com.github.angeschossen:LandsAPI to v7.25.4 (#366)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-12 11:03:33 +02:00
renovate[bot] de6b76526c dependency: Update gradle/actions action to v6 (#367)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-12 11:03:23 +02:00
renovate[bot] 7de452ac15 dependency: Update Gradle to v9.4.1 (#365)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-22 09:31:52 +01:00
renovate[bot]andJakub Kędziora 7e578d63f7 dependency: Update dependency com.gradleup.shadow:com.gradleup.shadow.gradle.plugin to v9.4.0 (#363)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>
2026-03-22 09:31:44 +01:00
renovate[bot] e5f86c53a2 dependency: Update dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8 to v2.3.20 (#364)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-22 09:31:15 +01:00
renovate[bot] 22260e87d0 dependency: Update plugin com.modrinth.minotaur to v2.9.0 (#359)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-08 19:06:51 +01:00
fe73466cfb GH-352 Add Arc Riders style flare - firework - indicating players death location (#352)
* Innit

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

* geminaj review

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

* Add try catch

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

* CR

* CR 2

* Add flare damage cancel. Add info to config

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

* make it private

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

* Resolve ImDMK review

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

* CR

* CR

* adjust default configuration to vLucky's review

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>

* Update eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/death/DeathFlareController.java

Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>

---------

Signed-off-by: Michał Wojtas <wojtas.michal90@gmail.com>
Co-authored-by: Rollczi <ndejlich5@gmail.com>
Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>
2026-03-08 18:48:58 +01:00
renovate[bot] c299aed434 dependency: Update Versions.ETERNALCODE_COMMONS to v1.3.4 (#351)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-07 11:19:36 +01:00
renovate[bot]andJakub Kędziora 8dbaf9ae98 dependency: Update actions/upload-artifact action to v7 (#353)
* dependency: Update actions/upload-artifact action to v7

* Remove archive option from upload-artifact step

Remove unnecessary archive option from upload-artifact.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>
2026-03-07 11:12:59 +01:00
renovate[bot] db4ab96377 dependency: Update dependency org.bstats:bstats-bukkit to v3.2.1 (#350)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-07 11:12:51 +01:00
renovate[bot] 0dca7e7d42 dependency: Update Gradle to v9.4.0 (#356)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-07 11:12:24 +01:00
renovate[bot] bb080b5ce9 dependency: Update dependency com.gradleup.shadow:com.gradleup.shadow.gradle.plugin to v9.3.2 (#354)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-03-07 10:12:10 +00:00
Martin SulikowskiandRollczi 9f4ae311a7 GH-345 Fix enforcing region knockback for mounted combat players (#345)
* fix: enforce region knockback for mounted combat players

* CR

---------

Co-authored-by: Rollczi <ndejlich5@gmail.com>
2026-03-03 23:28:16 +01:00
Martin Sulikowski 96deb783b7 Update README.md 2026-02-23 23:54:02 +01:00
bee80d22aa GH-313 Migrate issue templates to GitHub Forms and add enhanced contribution documentation.
* Migrate issue templates to GitHub Forms and add enhanced contribution documentation.

* Update .github/CONTRIBUTING.md

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update .github/CONTRIBUTING.md

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update pull request template to use `GH-{NUMBER}` in title format.

* Update .github/CONTRIBUTING.md

* Apply suggestions from code review

* Apply suggestions from code review

* Update label for additional context field

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>
2026-02-20 15:52:50 +01:00
renovate[bot] 4202e86eaa dependency: Update Versions.ETERNALCODE_COMMONS to v1.3.3 (#349)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-20 15:34:30 +01:00
renovate[bot] e109b38705 dependency: Update junit-framework monorepo to v6.0.3 (#342)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-20 10:50:16 +01:00
renovate[bot] 9bba5bd418 dependency: Update dependency com.github.angeschossen:LandsAPI to v7.24.1 (#341)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-20 10:50:07 +01:00
renovate[bot] 77940ca7b6 dependency: Update dependency org.jetbrains:annotations to v26.1.0 (#346)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-20 10:49:44 +01:00
Michał Wojtas a4cc6d0e8b GH-347 Add lightning effect on player death and settings (#347)
* Add lightning effect on player death and settings

* Add lightning gif to readme

* typo fix

* use public for controller - consistency
2026-02-19 22:54:25 +01:00
Martin Sulikowski 2028c5eafd GH-338 Add option to block specific inventories during combat (#338)
* feat: Add option to block specific inventories during combat

* refactor: Simplify inventory type reference in FightActionBlockerController

* Move to dedicated class.

* refactor: Remove blocking of player's own and creative inventories in FightInventoryController
2026-02-08 20:02:14 +01:00
renovate[bot] 042c5848df dependency: Update dependency me.clip:placeholderapi to v2.12.2 (#340)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-08 20:01:56 +01:00
renovate[bot] c30860070f dependency: Update dependency com.github.retrooper:packetevents-spigot to v2.11.2 (#330)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-08 11:22:15 +01:00
Jakub Kędziora 20c3515082 GH-339 Move renovate.json to .github directory (#339) 2026-02-07 22:00:46 +01:00
Rollczi 07b22a1141 Fix snapshots 2026-02-07 18:38:10 +01:00
renovate[bot] 2fc9bc580b dependency: Update dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8 to v2.3.10 (#337)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-05 20:53:38 +01:00
renovate[bot] 7730956dbc dependency: Update dependency me.clip:placeholderapi to v2.12.1 (#336)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-05 20:53:20 +01:00
Rollczi 48ef3e5d0a Simplify snapshots 2026-02-02 20:39:49 +01:00
renovate[bot] abd097401f dependency: Update Gradle to v9.3.1 (#332)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-30 16:22:21 +01:00
Martin Sulikowski 1d0d182cc8 Update Discord invite link in README.md 2026-01-26 00:40:24 +01:00
Martin Sulikowski 60b4e6ee9c bump version to 2.5.0-SNAPSHOT for further development. 2026-01-25 21:15:28 +01:00
Martin Sulikowski b096cb5d6f update dependency references in README 2026-01-25 21:13:08 +01:00
Martin Sulikowski d596202278 Release v2.4.1 2026-01-25 21:07:13 +01:00
Martin Sulikowski b879497840 Add WorldGuard as a soft dependency 2026-01-25 21:06:35 +01:00
renovate[bot] ccad96ae96 dependency: Update gradle/actions action to v5 (#329)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-24 21:39:47 +01:00
Martin Sulikowski 0e782a0cf5 Release 2.5.0-SNAPSHOT 2026-01-23 21:16:40 +01:00
Martin Sulikowski 0979d449c6 Release 2.4.0 2026-01-23 20:37:50 +01:00
renovate[bot] dee65e5f59 dependency: Update actions/upload-artifact action to v6 (#327)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-23 20:30:16 +01:00
renovate[bot] 01d3491d44 dependency: Update dependency com.github.angeschossen:LandsAPI to v7.23.1 (#314)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-23 20:30:00 +01:00
renovate[bot] 9896069577 dependency: Update dependency com.gradleup.shadow:com.gradleup.shadow.gradle.plugin to v9.3.1 (#316)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-23 20:29:53 +01:00
renovate[bot] f682508172 dependency: Update actions/setup-java action to v5 (#326)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-23 20:29:45 +01:00
renovate[bot] a988abcd17 dependency: Update dependency com.sk89q.worldguard:worldguard-bukkit to v7.0.15 (#307)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-23 20:26:53 +01:00
renovate[bot] b0fa197e99 dependency: Update Versions.MULTIFICATION to v1.2.4 (#311)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-23 20:26:42 +01:00
renovate[bot] 5300b5a007 dependency: Update Versions.LITE_COMMANDS to v3.10.9 (#315)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-23 20:26:07 +01:00
renovate[bot] c1f282832c dependency: Update dependency net.kyori:adventure-text-minimessage to v4.26.1 (#317)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-23 20:25:23 +01:00
renovate[bot] 972fc52e69 dependency: Update dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8 to v2.3.0 (#318)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-23 20:25:16 +01:00
renovate[bot] b79ed28edf dependency: Update actions/checkout action to v6 (#320)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-23 20:25:00 +01:00
renovate[bot] 025f49685c dependency: Update actions/github-script action to v8 (#321)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-23 20:24:53 +01:00
Martin Sulikowski 4d957d2c8a Update README to include bug reporting, feature requests, and donation link 2026-01-23 20:19:54 +01:00
d7a04ef0c2 GH-249 Skip only collidable blocks in the fake wall. Keep plants proper restoring. (#301)
* Update BorderBlockController.java

* Update BorderBlockController.java

* Update BorderBlockController.java

* Update eternalcombat-plugin/src/main/java/com/eternalcode/combat/border/animation/block/BorderBlockController.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Follow suggestions

* Code style

* Save WrappedBlockState

* Use inner point for border rendering

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Rollczi <ndejlich5@gmail.com>
2026-01-23 19:54:10 +01:00
Michał Wojtas 0bd9911df3 GH-325 Fix bypass permission and excludeAdminsFromCombat interaction (#325)
* Fix information about bypass permission

* Changes requested after talking to vLucky
2026-01-23 00:01:09 +01:00
Martin Sulikowski 3062378c66 Improve -SNAPSHOT version update checker. 2026-01-17 02:45:14 +01:00
renovate[bot] 0799081813 dependency: Update dependency me.clip:placeholderapi to v2.11.7 (#300)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-17 02:21:24 +01:00
renovate[bot] 16a2df1a08 dependency: Update junit-framework monorepo to v6.0.2 (#299)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-17 02:21:20 +01:00
renovate[bot] cd3681f8f6 dependency: Update Gradle to v9.3.0 (#298)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-17 02:21:14 +01:00
renovate[bot] 885f514e17 dependency: Update dependency com.github.ben-manes.caffeine:caffeine to v3.2.3 (#297)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-17 02:21:10 +01:00
renovate[bot] 5b84881b94 dependency: Update dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8 to v2.2.21 (#294)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-17 02:21:04 +01:00
renovate[bot] e69a42ba0f dependency: Update dependency com.github.retrooper:packetevents-spigot to v2.11.1 (#293)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-17 02:20:58 +01:00
renovate[bot] 9783d7a025 dependency: Update dependency xyz.jpenilla:run-task to v3.0.2 (#291)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-17 02:20:51 +01:00
Martin Sulikowski 99a93ce249 Bump Hangar publish plugin to version 0.1.4 in build script. 2026-01-17 02:15:29 +01:00
Martin Sulikowski 1c2797225a GH-310 Add Hangar publishing workflow and configure build script for Hangar integration (#312)
* GH-310 Add Hangar publishing workflow and configure build script for Hangar integration

* Expand supported Paper versions in `gradle.properties` to include versions 1.17 through 1.21.11.
2026-01-17 02:09:41 +01:00
renovate[bot] 1af5710ac9 dependency: Update Versions.LITE_COMMANDS to v3.10.8 (#289)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-16 20:14:35 +00:00
Martin Sulikowski 1938ae409d [ci skip] Update tested Minecraft versions in README to include 1.21.11. 2026-01-16 20:48:57 +01:00
Martin Sulikowski 88fa996202 Update Gradle workflow to use latest upload-artifact action and ensure full git history fetch. Add enhanced error handling for versioning in build script. 2026-01-16 20:13:56 +01:00
Martin Sulikowski e3c4f2c26d Improve versioning logic in build script and set fetch-depth to 0 in Modrinth workflow. 2026-01-16 20:04:52 +01:00
Martin Sulikowski e87060d2b9 Simplify changelog retrieval by removing redundant nullable type qualifier. 2026-01-16 19:24:49 +01:00
Martin Sulikowski dfe70a65d7 Enhance Modrinth workflow to include changelog support 2026-01-16 19:21:20 +01:00
Martin Sulikowski fbade09087 Update Modrinth publishing workflow for release compatibility 2026-01-16 00:53:46 +01:00
Martin Sulikowski 660b8b5519 Bump version to 2.4.0-SNAPSHOT. 2026-01-16 00:53:13 +01:00
Martin Sulikowski 13eb6dead2 Switch MODRINTH_TOKEN retrieval to System.getenv in build script. 2026-01-16 00:32:06 +01:00
Martin Sulikowski eafb4c9318 Simplify version number retrieval in Modrinth configuration. 2026-01-16 00:30:14 +01:00
Martin Sulikowski bfc632d518 GH-309 Add Modrinth publishing workflow and configure Minotaur (#309)
* Add Modrinth publishing workflow and configure Minotaur

* Replace println with logger in build script, retrieve environment variables via providers API.
2026-01-16 00:26:42 +01:00
Michał Wojtas 02d5a2f46d GH-308 Fix issue where master head.ref cannot be accessed (#308) 2026-01-11 19:06:55 +01:00
Michał WojtasandRollczi 9e3f28ee10 GH-305 Update GitHub Actions workflow to set build label for each branch (#305)
* Update GitHub Actions workflow to set build label for release and snapshot

* Fix artifact containing not correct name info

* Adjust space

* Use sha in name as @Jakubk15 suggested

* Fix deprecation warnings

* Fix ugly SHA

* Use gradle instead of gradlew made for gradleWrapper

* run fix

* run fix v2

* Simplify by using github script

* Bump gradle cache

* Remove master / snapshot from name - already branch name is used.

---------

Co-authored-by: Rollczi <ndejlich5@gmail.com>
2026-01-10 20:49:04 +01:00
Michał Wojtas e5fb0d4b32 GH-276 Extract bypass conditions to controller class. (#302)
* Extract bypass conditions to extra class.

Took 2 minutes

* Resolve Gemini review

Took 4 minutes

* Move Controller to controller package and remove empty line

Took 5 minutes

* Use build in Modrinth method to download plugins

Took 23 minutes

* Resolve igoyek's review

Took 3 minutes

* Resolve jakubek's review

Took 15 minutes

* Try #1 resolve imDMK comment

Took 5 minutes
2026-01-07 19:13:11 +01:00
Michał Wojtas 3325a2f8d3 GH-285 Remove border when player is not in combat (#290)
* Remove border when player is not in combat. Add WorldEdit for easier tests

* Add 5 tick delay which reduces 90% of done tests - remove initial solution

* Resolve AI review

* Use our scheduler, add isInCombat check to negate race condition

* Add comment explaining race confition, follow rollczi suggestion
2025-10-13 09:50:51 +02:00
a0bd8494f8 GH-253 Add configurable placeholder settings and new placeholders (#253)
* Add configurable placeholder settings and new placeholders

Introduces PlaceholderSettings to allow customization of placeholder output, specifically for isInCombat_formatted. Adds new placeholders isInCombat and isInCombat_formatted to FightTagPlaceholder, updates BridgeService and PluginConfig to support the new settings, and adjusts command permission annotation placement. Also updates build scripts and dependencies.

* rollback version

* Add papi plugin to runServer

* remove unused import

* follow gemini's suggestion

* Add more comments for configuration, merge time combat placeholders

Took 14 minutes

* change download source to spigot - got 503 on download from github during tests

Took 10 minutes

* follow Rollczi's suggestion -> refactored placeholder registry

* empty string -> null (papi, when receiving null in the code, marks it and sends an empty string)

* Update eternalcombat-plugin/src/main/java/com/eternalcode/combat/bridge/placeholder/FightTagPlaceholder.java

Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>

* Refactor FightTagPlaceholder and update build script

- Simplified conversion to string in handleIsInCombat.
- Adjusted build script to use Modrinth URLs for plugin downloads and rolled back Minecraft version to 1.21.

---------

Co-authored-by: Michał Wojtas <wojtas.michal90@gmail.com>
Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>
2025-10-13 02:35:07 +02:00
Martin Sulikowski 08cfe7c0c4 Release v2.3.0 2025-10-06 19:50:07 +02:00
Martin Sulikowski ed30d43736 Update readme-banner.png asset. 2025-10-06 19:43:10 +02:00
Martin Sulikowski b6347517b6 Update dependencies and support Minecraft 1.21.9 2025-10-06 19:41:14 +02:00
renovate[bot] 3f729beffe dependency: Update dependency net.kyori:adventure-text-minimessage to v4.25.0 (#288)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-06 18:51:47 +02:00
Jakub Kędziora 337eb7d765 GH-278 Move updater to eternalcode-commons library (#287)
* Move updater to eternalcode-commons library

* Use gson 2.11.0 for WorldGuard and update gradle.properties to latest standards
2025-10-06 18:49:03 +02:00
renovate[bot] b02231bc0c GH-283 Update junit-framework monorepo to v6 (major)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-04 18:01:12 +02:00
renovate[bot] ee6f5aecd3 GH-284 Update dependency xyz.jpenilla:run-task to v3.0.1
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-04 17:57:26 +02:00
renovate[bot] 6eb89607bf GH-286 Update dependency com.github.angeschossen:LandsAPI to v7.17.2
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-04 17:56:50 +02:00
renovate[bot] 9f33de088b GH-280 Update dependency com.gradleup.shadow:com.gradleup.shadow.gradle.plugin to v9.2.2
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-04 17:56:06 +02:00
815b63c7bf GH-188 Add support for folia-based servers. (#275)
* Release v2.3.0-SNAPSHOT

* Update eternalcombat-plugin/src/main/java/com/eternalcode/combat/CombatSchedulerAdapter.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Make `CombatSchedulerAdapter` uninstantiable.

* Update eternalcombat-plugin/src/main/java/com/eternalcode/combat/CombatSchedulerAdapter.java

Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>

* Resolve gemini issues.

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>
2025-09-29 00:01:58 +02:00
Michał Wojtas 410289a2b8 GH-274 Region priority sort fix (#274) 2025-09-28 23:55:52 +02:00
renovate[bot] e40a37e2ff dependency: Update Gradle to v9.1.0 (#277)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-21 21:38:35 +02:00
renovate[bot] 1bae5c547d dependency: Update dependency com.sk89q.worldguard:worldguard-bukkit to v7.0.14 (#256)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-15 22:53:52 +02:00
renovate[bot] 986895d5a4 dependency: Update dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8 to v2.2.20 (#246)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-15 22:47:27 +02:00
renovate[bot] 4776714893 dependency: Update dependency com.github.retrooper:packetevents-spigot to v2.9.5 (#268)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-15 22:45:06 +02:00
renovate[bot] 6154f26977 dependency: Update dependency eu.okaeri:okaeri-configs-serdes-bukkit to v5.0.13 (#270)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-15 22:43:58 +02:00
renovate[bot] 2f010ee978 dependency: Update Versions.MULTIFICATION to v1.2.2 (#259)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-15 22:43:37 +02:00
renovate[bot] 7d5d074811 dependency: Update dependency dev.rollczi:litecommands-bukkit to v3.10.5 (#269)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-15 22:42:48 +02:00
renovate[bot] 8315e198b3 dependency: Update dependency eu.okaeri:okaeri-configs-serdes-commons to v5.0.13 (#271)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-15 22:42:13 +02:00
renovate[bot] b0cbdc04c8 dependency: Update dependency org.jetbrains:annotations to v26.0.2-1 (#272)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-15 22:42:03 +02:00
renovate[bot] f46f9ca268 dependency: Update dependency xyz.jpenilla:run-task to v3 (#273)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-15 22:41:52 +02:00
renovate[bot] d789d3b47e dependency: Update dependency net.kyori:adventure-text-minimessage to v4.24.0 (#260)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-13 15:43:06 +02:00
renovate[bot] dd7eaf2de8 dependency: Update Versions.ETERNALCODE_COMMONS to v1.3.1 (#261)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-13 15:42:54 +02:00
renovate[bot] a985774272 dependency: Update actions/checkout action to v5 (#262)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-13 15:42:43 +02:00
renovate[bot] fa000b4a3a dependency: Update actions/setup-java action to v5 (#263)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-13 15:42:33 +02:00
renovate[bot] 80edd3b425 dependency: Update dependency com.gradleup.shadow:com.gradleup.shadow.gradle.plugin to v9 (#264)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-13 15:42:24 +02:00
renovate[bot] fc4a6c28a3 dependency: Update dependency gradle to v9 (#265)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-13 15:42:15 +02:00
vLuckyyy e4eb847b56 Release v2.3.0-SNAPSHOT 2025-08-30 15:23:19 +02:00
renovate[bot] f5884119d6 dependency: Update dependency net.kyori:adventure-platform-bukkit to v4.4.1 (#257)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-23 21:01:59 +02:00
renovate[bot] 0cd9d50086 dependency: Update dependency gradle to v8.14.3 (#241)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-23 21:01:45 +02:00
renovate[bot] 7043d7baff dependency: Update dependency eu.okaeri:okaeri-configs-serdes-bukkit to v5.0.9 (#239)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-23 21:01:28 +02:00
renovate[bot] 26d3f5b1ce dependency: Update dependency com.gradleup.shadow:com.gradleup.shadow.gradle.plugin to v8.3.9 (#255)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-23 21:01:13 +02:00
Martin Sulikowski 455b66e136 Use global renovate config. 2025-08-23 20:51:59 +02:00
renovate[bot] 881d9b633a dependency: Update dependency dev.rollczi:litecommands-bukkit to v3.10.4 (#238)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-23 20:50:44 +02:00
renovate[bot] ac80f1bb0c dependency: Update junit-framework monorepo to v5.13.4 (#243)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-23 20:49:19 +02:00
renovate[bot] cd36abae37 dependency: Update dependency eu.okaeri:okaeri-configs-serdes-commons to v5.0.9 (#240)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-23 20:49:03 +02:00
renovate[bot] 817b907170 dependency: Update dependency com.github.retrooper:packetevents-spigot to v2.9.4 (#245)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-23 20:44:55 +02:00
renovate[bot] b9dfb293e4 dependency: Update dependency org.jetbrains.kotlin:kotlin-stdlib-jdk8 to v2.1.21 (#242)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-23 20:44:40 +02:00
renovate[bot] 11bfddfc9f dependency: Update dependency com.github.ben-manes.caffeine:caffeine to v3.2.2 (#247)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-23 20:43:44 +02:00
74d0f487c3 GH-254 Add configuration for disabling fireworks during combat (#254)
* Add FireworkController, move CrystalPvpSettings to configuration package - same as other settings in this project

* Add message sent to the player. Remove unused import

* Add notice service :/

* Update eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/CombatSettings.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update eternalcombat-plugin/src/main/java/com/eternalcode/combat/fight/firework/FireworkController.java

Co-authored-by: Igor Michalski <imichalsky00@gmail.com>

* Update eternalcombat-plugin/src/main/java/com/eternalcode/combat/config/implementation/MessagesSettings.java

Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Igor Michalski <imichalsky00@gmail.com>
Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com>
2025-08-22 00:48:46 +02:00
vLuckyyy f4cc51e9a1 Mark as supported for 1.21.8. Fix readme. 2025-07-29 23:23:35 +02:00
Martin SulikowskiandJakubk15 e579ca4a22 Release v2.2.0, Support 1.21.8 (#251)
* Support 1.21.8

* update repo

* Release v2.2.0, remove default sound in combat notification.

---------

Co-authored-by: Jakubk15 <77227023+Jakubk15@users.noreply.github.com>
2025-07-29 23:06:04 +02:00
Michał Wojtas 4c13a61752 GH-250 Update readme with new .gif and new logo (#250)
* Update readme with new .gif and new logo

Took 8 minutes

* Add notice about PacketEvents requirement update banner and resize gif

Took 10 minutes

* Move Crystal pvp section down

Took 1 minute

* Add accessibility changes for gifs

Took 3 minutes
2025-07-27 21:37:01 +02:00
Michał Wojtasandcoderabbitai[bot] dad09ba196 GH-218 Add CrystalPVP expansion (#218)
* Init

* Add anchor support

* Add anchor to api

* Add meta data contants create static methods to retrive uuid. Follow @ImDMK and @coderabbitai reviews

* Use coderabbit suggestion to version compatibility

* Follow coderabbit review

* Update eternalcombat-plugin/src/main/java/com/eternalcode/combat/crystalpvp/CrystalPvpConstants.java

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Resolve review. Add documentation comment, add ignored worlds check and event.cancelled check. Fix method name to use `UniqueId` instead of `UUID`

* Remove isCancelled() check -> follow coderabbit <3

* follow coderabbit - add one check for hasDamagerBlockState method declaration check

* Resolve vLuckyyy review

* e -> exception rename

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-07-22 23:03:30 +02:00
120 changed files with 4026 additions and 1120 deletions

No files matched your search

+52 -24
View File
@@ -1,36 +1,64 @@
# Contributing to EternalCombat
# 👋 Contributing to EternalCombat
We welcome all contributions to the EternalCombat project!
First off, thanks for taking the time to contribute! 🎉
We love user contributions and want to make it as easy as possible for you to get involved.
### How to Contribute
## 🛠️ Development Setup
1. Fork the repository.
2. Create a new branch for your feature or bug fix.
3. Make your changes, and test them thoroughly.
4. Commit your changes and push them to your fork.
5. Submit a pull request to the main repository.
To start contributing, you'll need to set up your environment:
### Code of Conduct
1. **Java 21**: We use Java 21 for development. Ensure you have a JDK 21 installed.
2. **IDE**: We recommend [IntelliJ IDEA](https://www.jetbrains.com/idea/).
3. **Git**: Ensure you have Git installed.
We expect all contributors to follow our [code of conduct](CODE_OF_CONDUCT.md).
### 📥 Getting the Code
### Reporting Issues
```bash
# Fork the repository on GitHub first!
# https://github.com/EternalCodeTeam/EternalCombat/fork
git clone https://github.com/YOUR-USERNAME/EternalCombat.git
cd EternalCombat
```
If you find an issue with the plugin, please report it in
the [Issues tab](https://github.com/EternalCodeTeam/EternalCombat/issues). Please provide as much information as
possible, including the version of Minecraft and the plugin you are using, as well as any error messagesSettings or logs.
### 🔨 Building the Project
### Compatibility
Run this command in your terminal:
CombatLog has been tested on versions 1.17.1 - 1.19.3, but probably works on most versions of Minecraft. If you find
compatibility issues, please report them in the Issues tab. CombatLog uses java 11+, so you need to have it installed on
your server.
```bash
./gradlew build
```
### Submitting a Pull Request
## 🤝 How to Contribute
When submitting a pull request, please make sure to follow these guidelines:
1. **Fork & Clone**: Fork the repo to your own account and clone it.
2. **Branch**: Create a new branch for your feature or fix.
```bash
git checkout -b feat/my-awesome-feature
```
3. **Code**: Hack away! 💻
4. **Test**: Run manual test by `runServer` to ensure you haven't broken anything.
```bash
./gradlew runServer
```
5. **Push**: Push your changes to your fork.
6. **Pull Request**: Open a PR against the `master` branch.
- Make sure that your code adheres to the plugin's existing coding style.
- Test your changes thoroughly before submitting the pull request.
- If your pull request is related to an existing issue, please reference the issue in your pull request.
- Thank you for your contributions to the EternalCombat project!
## 📏 Code Style
Make sure that your code adheres to the plugin's existing coding style.
## 🐛 Reporting Bugs
If you find a bug, please use the **Bug Report** issue template.
- Check if the issue already exists.
- Provide a minimal reproduction if possible.
- Include logs and screenshots.
## 💡 Feature Requests
Have an idea? Use the **Feature Request** issue template.
- Explain *why* this feature is useful.
- Describe how it should look or behave.
## 📄 License
By contributing, you agree that your contributions will be licensed under the project's [License](../LICENSE).
-33
View File
@@ -1,33 +0,0 @@
---
name: Bug report
about: Create a bug report to help us improve EternalCombat <3
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Platform (please complete the following information):**
- Java Version: [e.g. JDK Temurin 17]
- Server software, ex. PaperMC 1.19.3 build #1
**Additional notes**
Add any other context about the problem here.
+84
View File
@@ -0,0 +1,84 @@
name: 🐛 Bug Report
description: File a bug report to help us improve EternalCombat
title: "[Bug]: "
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
Please ensure that you have searched the existing issues to see if this bug has already been reported.
- type: textarea
id: description
attributes:
label: Bug description
description: A clear and concise description of what the bug is.
placeholder: I was doing X and Y happened...
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Steps to reproduce
description: Please provide a step-by-step guide to reproduce the issue.
placeholder: |
1. Launch the server
2. Tag yourself using the '/combat tag' command
3. See error
validations:
required: true
- type: textarea
id: expected-behavior
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
id: screenshots
attributes:
label: Screenshots/Video
description: If applicable, add screenshots or a video to help explain your problem.
- type: dropdown
id: server-software
attributes:
label: Server Software
description: What server software are you using?
options:
- Paper
- Purpur
- Spigot
- Folia
- Other (please specify in logs)
validations:
required: true
- type: input
id: minecraft-version
attributes:
label: Minecraft Version
description: What version of Minecraft are you running? (e.g. 1.21.11)
placeholder: 1.21.11
validations:
required: true
- type: input
id: plugin-version
attributes:
label: Plugin Version
description: What version of EternalCombat are you running? (Check with /eternalcombat version)
placeholder: v2.4.1
validations:
required: true
- type: textarea
id: logs
attributes:
label: Logs / Stack Trace
description: Please paste any relevant logs or stack traces here. Use a pastebin service if the log is too long.
render: shell
+8
View File
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: 💬 Discord Community
url: https://discord.com/invite/FQ7jmGBd6c
about: Please ask questions and discuss ideas in our Discord server before opening a generic issue.
- name: 📖 Documentation
url: https://eternalcode.pl/docs/eternalcombat/introduction
about: Read the documentation to see if your question is already answered.
-20
View File
@@ -1,20 +0,0 @@
---
name: Feature request
about: Suggest an idea for EternalCombat <3
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
@@ -0,0 +1,38 @@
name: 💡 Feature Request
description: Suggest an idea for EternalCombat
title: "[Feature]: "
labels: ["feature"]
body:
- type: markdown
attributes:
value: |
Thanks for suggesting a new feature! Please explain your idea in detail.
- type: textarea
id: problem
attributes:
label: Is your feature request related to a problem?
description: Please describe the problem you are trying to solve.
placeholder: I'm always frustrated when...
validations:
required: true
- type: textarea
id: solution
attributes:
label: Describe the solution you'd like
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Describe alternatives you've considered
description: A clear and concise description of any alternative solutions or features you've considered.
- type: textarea
id: additional-context
attributes:
label: Additional context
description: Add any other context or screenshots about the feature request here.
+35 -1
View File
@@ -1 +1,35 @@
**Please describe the changes made by this PR and why they need to be merged:**
---
name: Pull Request
about: Submit a contribution to EternalCombat
title: 'GH-{NUMBER} <title>'
labels: []
assignees: []
---
## 📝 Description
<!--
Please submit your PR using the following title format:
feat: Description of the new feature
fix: Description of the bug fix
chore: Maintenance tasks
docs: Documentation changes
-->
<!-- Describe your changes clearly and concisely. Why is this change needed? What does it accomplish? -->
## 🎯 Type of Change
<!-- Please check the boxes that apply to your changes -->
- [ ] 🐛 Bug fix (non-breaking change which fixes an issue)
- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] 🔧 Refactoring (no functional changes, just code improvements)
- [ ] 🎨 Style/Cosmetic (formatting, whitespace, visual changes)
- [ ] 📚 Documentation (updates to documentation or README)
- [ ] 🤖 CI/CD/Build (changes to workflows, gradle, etc.)
**Test Environment:**
- **Minecraft Version:** <!-- e.g. 1.20.4 -->
- **Java Version:** <!-- e.g. 21 -->
- **Platform:** <!-- e.g. Windows/Linux/MacOS -->
## 📸 Screenshots (if applicable)
+5
View File
@@ -0,0 +1,5 @@
{
"extends": [
"local>EternalCodeTeam/.github:renovate-config"
]
}
+29 -23
View File
@@ -5,38 +5,44 @@ on:
branches: [ "master" ]
pull_request:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
java-version: '17'
java-version: '25'
distribution: 'temurin'
- name: Cache Gradle
uses: actions/cache@v4
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Set Variables & Build
uses: actions/github-script@v9
with:
path: ~/.gradle/caches
key: >-
${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*',
'**/gradle-wrapper.properties') }}
restore-keys: '${{ runner.os }}-gradle-'
- name: Make gradlew executable
run: chmod +x gradlew
script: |
const isPR = context.eventName === 'pull_request';
const branch = isPR ? context.payload.pull_request.head.ref.replace(/\//g, '-') : 'master';
const sha = (isPR ? context.payload.pull_request.head.sha : context.sha).substring(0, 7);
const artifactName = `EternalCombat ${branch}+${sha}`;
core.exportVariable('FULL_ARTIFACT_NAME', artifactName);
- name: Build with Gradle
uses: gradle/gradle-build-action@093dfe9d598ec5a42246855d09b49dc76803c005
run: ./gradlew shadowJar
- name: Upload build artifact
uses: actions/upload-artifact@v7
with:
arguments: shadowJar
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: 'Successfully build EternalCombat'
name: ${{ env.FULL_ARTIFACT_NAME }}
path: eternalcombat-plugin/build/libs/*.jar
archive: false
+34
View File
@@ -0,0 +1,34 @@
name: Publish to Hangar
on:
push:
branches:
- master
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
if: (github.event_name == 'push' && !contains(github.event.head_commit.message, '[ci skip]')) || github.event_name == 'release'
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '25'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Publish to Hangar
run: ./gradlew :eternalcombat-plugin:publishPluginPublicationToHangar
env:
HANGAR_API_TOKEN: ${{ secrets.HANGAR_API_TOKEN }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
CHANGELOG: ${{ github.event_name == 'release' && github.event.release.body || github.event.head_commit.message }}
+34
View File
@@ -0,0 +1,34 @@
name: Publish to Modrinth
on:
push:
branches:
- master
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
if: (github.event_name == 'push' && !contains(github.event.head_commit.message, '[ci skip]')) || github.event_name == 'release'
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '25'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Publish to Modrinth
run: ./gradlew :eternalcombat-plugin:modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
CHANGELOG: ${{ github.event_name == 'release' && github.event.release.body || github.event.head_commit.message }}
+3 -3
View File
@@ -9,13 +9,13 @@ jobs:
environment: deployment
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Set up JDK
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 17
java-version: 25
cache: 'gradle'
- name: Grant execute permission for gradlew
+1
View File
@@ -1,6 +1,7 @@
.classpath
.idea
.gradle
.kotlin
.project
.settings
bin
+46 -17
View File
@@ -1,6 +1,6 @@
<div align="center">
![](/assets/readme-banner.png)
![Readme banner](https://github.com/EternalCodeTeam/EternalCombat/blob/master/assets/readme-banner.png?raw=true)
[![Available on SpigotMC](https://raw.githubusercontent.com/vLuckyyy/badges/main/available-on-spigotmc.svg)](https://www.spigotmc.org/resources/eternalcombat-%E2%9C%94%EF%B8%8F-enchance-your-combat-system-with-eternalcombat.109056/)
[![Available on Modrinth](https://raw.githubusercontent.com/vLuckyyy/badges/main/avaiable-on-modrinth.svg)](https://modrinth.com/plugin/eternalcombat)
@@ -9,15 +9,27 @@
[![Chat on Discord](https://raw.githubusercontent.com/vLuckyyy/badges/main//chat-with-us-on-discord.svg)](https://discord.com/invite/FQ7jmGBd6c)
[![Read the Docs](https://raw.githubusercontent.com/vLuckyyy/badges/main/read-the-documentation.svg)](https://docs.eternalcode.pl/eternalcombat/introduction)
[![Available on BStats](https://raw.githubusercontent.com/vLuckyyy/badges/main/available-on-bstats.svg)](https://bstats.org/plugin/bukkit/EternalCombat/17803)
[Report Bug](https://github.com/EternalCodeTeam/EternalCombat/issues) • [Request Feature](https://github.com/EternalCodeTeam/EternalCombat/issues) • [Join Discord](https://discord.com/invite/FQ7jmGBd6c)
<br>
<a href="https://ko-fi.com/eternalcodeteam">
<img src="https://github.com/intergrav/devins-badges/blob/v3/assets/cozy/donate/kofi-plural-alt_64h.png?raw=true" height="64" alt="Support us on Ko-fi">
</a>
</div>
### Information
EternalCombat 2.0 has been tested on Minecraft versions **1.17.1 to 1.21.5**, but it should work seamlessly on most
## EternalCombat requires PacketEvents plugin to work.
You can download it from [here](https://modrinth.com/plugin/packetevents)
EternalCombat 2.0 has been tested on Minecraft versions **1.17.1 to 26.2**, but it should work seamlessly on most
other versions too.
If you run into any compatibility issues, please let us know in
the [Issues tab](https://github.com/EternalCodeTeam/EternalCombat/issues).
The plugin requires **Java 17 or later**, so
The plugin requires **Java 21 or later**, so
ensure your server is ready.
Ready for action?
Install EternalCombat and dive in now!
@@ -27,15 +39,30 @@ Install EternalCombat and dive in now!
Take your server’s PvP experience to epic heights with **EternalCombat 2.0**! Our robust combat logging system ensures
fair, heart-pounding battles that keep players on their toes. Here’s a rundown of what makes it stand out:
- **Combat Logging**
No more dodging fights by logging out! Once players are in combat, they’re committed until the showdown ends. Watch it
in action:
![](/assets/combatlog.gif)
<img alt="Combat log anti logout feature" src="https://github.com/EternalCodeTeam/EternalCombat/blob/master/assets/combatlog.gif?raw=true" width="420">
- **Support for newest features**
Our plugin features cooldown and delays for tridents, spears and much more. With **out of the box** configurable feats.
<img alt="Trident and spear cooldown feature" src="https://github.com/EternalCodeTeam/EternalCombat/blob/master/assets/spear.gif?raw=true" width="420">
- **Customize combat experience**
Add custom effects to players in combat or death. Everything should be configurable and user-friendly:
<img alt="Lightning strikes when players die" src="https://github.com/EternalCodeTeam/EternalCombat/blob/master/assets/lightning.gif?raw=true" width="420">
<img alt="Flare indicates players death location" src="https://github.com/EternalCodeTeam/EternalCombat/blob/master/assets/flare.gif?raw=true" width="420">
- **Spawn Protection (Configurable)**
Stop players from fleeing to safety! Block access to spawn or safe zones during combat – tweak it to fit your server’s
rules. See how it works:
![](/assets/border.gif)
<img alt="Border around protected region" src="https://github.com/EternalCodeTeam/EternalCombat/blob/master/assets/border.gif?raw=true" width="420">
- **Crystal PvP support**
Engage in intense Crystal PvP battles without worrying about players logging out mid-fight! EternalCombat keeps
everyone in the game until the last anchor hit. Check it out:
<img alt="Crystal PvP showcase" src="https://github.com/EternalCodeTeam/EternalCombat/blob/master/assets/crystals.gif?raw=true" width="420">
- **Fully Customizable Combat**
Tailor the combat experience to your liking with a ton of options! From disabling elytra to setting drop rates for
@@ -59,14 +86,16 @@ EternalCombat in full swing and learn why it’s a game-changer for your server!
Control who can use EternalCombat’s powerful features with these permissions:
| Permission | Description |
|--------------------------------|--------------------------------------------------------------------------|
| `eternalcombat.status` | Check a player’s combat status with `/combatlog status <player>`. |
| `eternalcombat.tag` | Start a fight between players using `/combatlog tag <player> [player2]`. |
| `eternalcombat.untag` | Remove a player from combat with `/combatlog untag <player>`. |
| `eternalcombat.reload` | Reload the plugin with `/combatlog reload`. |
| `eternalcombat.receiveupdates` | Receive notifications about new plugin versions on join. |
| `eternalcombat.bypass` | Bypass combat tagging, need's `excludeAdminsFromCombat` to be enabled |
| Permission | Description |
|--------------------------------|-------------------------------------------------------------------------------------------------------|
| `eternalcombat.status` | Check a player’s combat status with `/combatlog status <player>`. |
| `eternalcombat.tag` | Start a fight between players using `/combatlog tag <player> [player2]`. |
| `eternalcombat.untag` | Remove a player from combat with `/combatlog untag <player>`. |
| `eternalcombat.untagall` | Remove all players from combat with `/combatlog untagall`. |
| `eternalcombat.stats` | View combat statistics with `/combatlog stats`. |
| `eternalcombat.reload` | Reload the plugin with `/combatlog reload`. |
| `eternalcombat.receiveupdates` | Receive notifications about new plugin versions on join. |
| `eternalcombat.bypass` | When exclude `excludeAdminsFromCombat` is set to `true` users with this permission will not be tagged |
## PlaceholderAPI
@@ -114,7 +143,7 @@ With Maven:
With Gradle:
```kts
compileOnly("com.eternalcode:eternalcombat-api:2.1.1")
compileOnly("com.eternalcode:eternalcombat-api:2.6.0-SNAPSHOT")
```
With Maven:
@@ -124,7 +153,7 @@ With Maven:
<dependency>
<groupId>com.eternalcode</groupId>
<artifactId>eternalcombat-api</artifactId>
<version>2.1.1</version>
<version>2.6.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
```
@@ -132,8 +161,8 @@ With Maven:
### Contributing
We’d love your help to make EternalCombat even better!
Check out our [contributing guide](.github/CONTRIBUTING.md) for
details on how to get involved and our [code of conduct](./.github/CODE_OF_CONDUCT.md).
Check out our [contributing guide](https://github.com/EternalCodeTeam/EternalCombat/blob/master/.github/CONTRIBUTING.md) for
details on how to get involved and our [code of conduct](https://github.com/EternalCodeTeam/EternalCombat/blob/master/.github/CODE_OF_CONDUCT.md).
### Reporting Issues
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 MiB

After

Width:  |  Height:  |  Size: 5.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

After

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 98 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

+5 -3
View File
@@ -8,10 +8,12 @@ repositories {
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.20")
implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:8.3.8")
implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:9.6.1")
implementation("com.modrinth.minotaur:com.modrinth.minotaur.gradle.plugin:2.10.0")
implementation("io.papermc.hangar-publish-plugin:io.papermc.hangar-publish-plugin.gradle.plugin:0.1.4")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.4.20")
implementation("net.minecrell:plugin-yml:0.6.0")
implementation("xyz.jpenilla:run-task:2.3.1")
implementation("xyz.jpenilla:run-task:3.1.0")
}
sourceSets {
@@ -0,0 +1,39 @@
import org.gradle.api.Project
import org.gradle.api.provider.Provider
internal val Project.isRelease: Boolean
get() = providers.environmentVariable("GITHUB_EVENT_NAME").orNull == "release"
internal val Project.releaseChannel: String
get() = if (isRelease) "Release" else "Snapshot"
internal val Project.changelogText: Provider<String>
get() = providers.environmentVariable("CHANGELOG")
.orElse(providers.exec { commandLine("git", "log", "-1", "--format=%B") }.standardOutput.asText)
internal val Project.paperVersions: List<String>
get() = property("paperVersion").toString()
.split(",")
.map { paperVersion -> paperVersion.trim() }
internal fun Project.configureSnapshotVersionFromGit() {
val isGithubWorkflow = providers.environmentVariable("GITHUB_RUN_NUMBER").isPresent
if (!isGithubWorkflow || isRelease) {
return
}
if ("-SNAPSHOT+" in version.toString()) {
return
}
val describeParts = providers.exec { commandLine("git", "describe", "--tags", "--long") }
.standardOutput.asText.get()
.trim()
.split("-")
val offset = if (describeParts.size >= 3) describeParts[describeParts.size - 2] else "0"
val baseVersion = version.toString().substringBefore("-SNAPSHOT")
version = "$baseVersion-SNAPSHOT+$offset"
}
+21 -21
View File
@@ -1,34 +1,34 @@
object Versions {
const val SPIGOT_API = "1.17.1-R0.1-SNAPSHOT"
// Keep this version for best compatibility.
const val PAPER_API = "1.19.3-R0.1-SNAPSHOT"
const val JUNIT_JUPITER_API = "5.13.1"
const val JUNIT_JUPITER_PARAMS = "5.13.1"
const val JUNIT_JUPITER_ENGINE = "5.13.1"
const val JUNIT_JUPITER_API = "6.1.3"
const val JUNIT_JUPITER_PARAMS = "6.1.3"
const val JUNIT_JUPITER_ENGINE = "6.1.3"
const val JETBRAINS_ANNOTATIONS = "26.0.2"
const val JETBRAINS_ANNOTATIONS = "26.1.0"
const val ETERNALCODE_COMMONS = "1.1.6"
const val MULTIFICATION = "1.2.1"
const val PACKETS_EVENTS = "2.8.0"
const val ETERNALCODE_COMMONS = "1.4.1"
const val MULTIFICATION = "1.2.5-SNAPSHOT"
const val PACKETS_EVENTS = "2.13.0"
const val ADVENTURE_PLATFORM_BUKKIT = "4.4.0"
const val ADVENTURE_API = "4.23.0"
const val LITE_COMMANDS = "3.11.0"
const val OKAERI_CONFIGS_SERDES_COMMONS = "5.0.13"
const val OKAERI_CONFIGS_SERDES_BUKKIT = "5.0.13"
const val LITE_COMMANDS = "3.10.0"
const val OKAERI_CONFIGS_YAML_BUKKIT = "5.0.6"
const val OKAERI_CONFIGS_SERDES_COMMONS = "5.0.6"
const val OKAERI_CONFIGS_SERDES_BUKKIT = "5.0.6"
const val XSERIES = "13.8.0"
const val GIT_CHECK = "1.0.0"
const val CAFFEINE = "3.3.0"
const val CAFFEINE = "3.2.1"
const val B_STATS_BUKKIT = "3.2.1"
const val WORLD_GUARD_BUKKIT = "7.0.17"
const val B_STATS_BUKKIT = "3.1.0"
const val WORLD_GUARD_BUKKIT = "7.0.9"
const val PLACEHOLDER_API = "2.11.6"
const val PAPERLIB = "1.0.8"
const val PLACEHOLDER_API = "2.12.3"
const val LANDS_API = "7.25.4"
const val GRIEF_PREVENTION = "16.18.7"
const val WORLDEDIT = "3ISh7ADm" //cannot use numeric version bc of duplicated version on modrinth
const val PACKETEVENTS = "2.14.0"
}
@@ -3,7 +3,7 @@ plugins {
}
dependencies {
testImplementation("org.spigotmc:spigot-api:${Versions.SPIGOT_API}")
testImplementation("io.papermc.paper:paper-api:${Versions.PAPER_API}")
testImplementation("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT_JUPITER_API}")
testImplementation("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT_JUPITER_PARAMS}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT_JUPITER_ENGINE}")
@@ -3,12 +3,12 @@ plugins {
}
group = "com.eternalcode"
version = "2.1.1"
version = "2.6.0-SNAPSHOT"
tasks.compileJava {
options.compilerArgs = listOf("-Xlint:deprecation", "-parameters")
options.encoding = "UTF-8"
options.release = 17
options.release = 21
}
java {
@@ -0,0 +1,28 @@
import io.papermc.hangarpublishplugin.model.Platforms
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
id("io.papermc.hangar-publish-plugin")
}
configureSnapshotVersionFromGit()
pluginManager.withPlugin("com.gradleup.shadow") {
val shadowJarTask = tasks.named<ShadowJar>("shadowJar")
hangarPublish {
publications.register("plugin") {
version.set(project.version.toString())
channel.set(project.releaseChannel)
changelog.set(project.changelogText)
id.set("eternalcombat")
apiKey.set(providers.environmentVariable("HANGAR_API_TOKEN"))
platforms {
register(Platforms.PAPER) {
jar.set(shadowJarTask.flatMap { shadowJar -> shadowJar.archiveFile })
platformVersions.set(project.paperVersions)
}
}
}
}
}
@@ -0,0 +1,23 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
id("com.modrinth.minotaur")
}
configureSnapshotVersionFromGit()
pluginManager.withPlugin("com.gradleup.shadow") {
val shadowJarTask = tasks.named<ShadowJar>("shadowJar")
modrinth {
token.set(providers.environmentVariable("MODRINTH_TOKEN"))
projectId.set("eternalcombat")
versionNumber.set(project.version.toString())
versionType.set(if (project.isRelease) "release" else "beta")
uploadFile.set(shadowJarTask)
gameVersions.addAll(project.paperVersions)
loaders.addAll(listOf("paper", "folia", "purpur"))
changelog.set(project.changelogText)
syncBodyFrom.set(rootProject.file("README.md").readText())
}
}
@@ -4,7 +4,7 @@ plugins {
}
group = "com.eternalcode"
version = "2.1.1"
version = "2.6.0-SNAPSHOT"
java {
withSourcesJar()
@@ -3,15 +3,17 @@ plugins {
}
repositories {
mavenLocal()
mavenCentral()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://repo.eternalcode.pl/releases")
maven("https://repo.eternalcode.pl/snapshots")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://storehouse.okaeri.eu/repository/maven-public/")
maven("https://repo.panda-lang.org/releases")
maven("https://maven.enginehub.org/repo/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
maven("https://repo.codemc.io/repository/maven-releases/")
maven("https://jitpack.io/")
maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
@@ -0,0 +1,23 @@
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.jvm.toolchain.JavaToolchainService
plugins {
id("xyz.jpenilla.run-paper")
}
tasks {
val javaToolchains = extensions.getByType<JavaToolchainService>()
runServer {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(25))
})
minecraftVersion("26.3")
downloadPlugins.modrinth("WorldEdit", "7.4.6")
downloadPlugins.modrinth("PacketEvents", "2.14.0+spigot")
downloadPlugins.modrinth("WorldGuard", "7.0.20")
downloadPlugins.modrinth("LuckPerms", "v5.5.53-bukkit")
downloadPlugins.modrinth("GriefPrevention", Versions.GRIEF_PREVENTION)
}
}
+2 -2
View File
@@ -6,7 +6,7 @@ plugins {
}
dependencies {
// Spigot api
compileOnlyApi("org.spigotmc:spigot-api:${Versions.SPIGOT_API}")
// Paper api
compileOnlyApi("io.papermc.paper:paper-api:${Versions.PAPER_API}")
api("org.jetbrains:annotations:${Versions.JETBRAINS_ANNOTATIONS}")
}
@@ -4,7 +4,7 @@ import com.eternalcode.combat.fight.drop.DropKeepInventoryService;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.drop.DropService;
import com.eternalcode.combat.fight.effect.FightEffectService;
import com.eternalcode.combat.fight.pearl.FightPearlService;
import com.eternalcode.combat.fight.pearl.PearlService;
import com.eternalcode.combat.region.RegionProvider;
import com.eternalcode.combat.fight.tagout.FightTagOutService;
@@ -14,7 +14,7 @@ public interface EternalCombatApi {
RegionProvider getRegionProvider();
FightPearlService getFightPearlService();
PearlService getFightPearlService();
FightTagOutService getFightTagOutService();
@@ -2,6 +2,9 @@ package com.eternalcode.combat.fight.event;
public enum CancelTagReason {
TAGOUT
TAGOUT,
PERMISSION_BYPASS,
ADMIN,
CREATIVE_MODE,
}
@@ -18,6 +18,27 @@ public enum CauseOfTag {
*/
COMMAND,
/**
* Crystal or anchor explosion caused the tag.
*/
CRYSTAL,
/**
* Trident usage extending combat tag.
*/
TRIDENT,
/**
* Ender pearl usage extending combat tag.
*/
ENDER_PEARL,
/**
* The player's combat tag was kept active because they were below the void combat height.
*/
VOID,
/**
* A custom cause, typically defined by external plugins or systems, applied the combat tag.
*/
@@ -5,7 +5,9 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import java.util.UUID;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* This event is triggered when a player is tagged in a fight.
@@ -15,14 +17,25 @@ public class FightTagEvent extends Event implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
private final UUID player;
private final CauseOfTag cause;
private final UUID tagger;
private boolean cancelled = false;
private CancelTagReason cancelReason;
/**
* @deprecated use {@link #FightTagEvent(UUID, CauseOfTag, UUID)} instead, which also carries the tagger.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public FightTagEvent(UUID player, CauseOfTag cause) {
this(player, cause, null);
}
public FightTagEvent(UUID player, CauseOfTag cause, @Nullable UUID tagger) {
super(false);
this.player = player;
this.cause = cause;
this.tagger = tagger;
}
/**
@@ -43,6 +56,16 @@ public class FightTagEvent extends Event implements Cancellable {
return this.cause;
}
/**
* Gets the UUID of the player who caused this tag, if any.
*
* @return The UUID of the tagger, or {@code null} if the tag was not caused by another player.
*/
@Nullable
public UUID getTagger() {
return this.tagger;
}
@Override
public boolean isCancelled() {
return this.cancelled;
@@ -1,16 +1,16 @@
package com.eternalcode.combat.fight.pearl;
import java.time.Duration;
import java.time.Instant;
import java.util.UUID;
import org.bukkit.entity.Player;
public interface FightPearlService {
public interface PearlService {
Instant getDelay(UUID uuid);
boolean shouldCancelEvent(UUID playerId);
Duration getRemainingDelay(UUID uuid);
boolean hasDelay(UUID uuid);
void markDelay(UUID uuid);
void handleDelay(Player uuid);
}
@@ -0,0 +1,11 @@
package com.eternalcode.combat.fight.spear;
import java.time.Duration;
import java.util.UUID;
public interface SpearService {
boolean isOnCooldown(UUID player);
void saveCooldown(UUID player);
Duration getRemainingCooldown(UUID player);
void removeCooldown(UUID player);
}
@@ -0,0 +1,31 @@
package com.eternalcode.combat.fight.trident;
import java.time.Duration;
import java.util.UUID;
public interface TridentService {
/**
* returns remaining delay for the player to use trident again
* @param uuid unique id of the player
* @return remaining duration left to use trident again by the player or zero
*/
Duration getRemainingDelay(UUID uuid);
/**
* checks if player still has delay left to use trident
* @param uuid unique id of the player
* @return true if user still has cooldown left to use trident
*/
boolean hasDelay(UUID uuid);
/**
* marks start of the delay for the user
* @param uuid unique id of the player
*/
void markDelay(UUID uuid);
void removeDelay(UUID playerId);
}
+79 -31
View File
@@ -1,35 +1,45 @@
import net.minecrell.pluginyml.paper.PaperPluginDescription
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
plugins {
`eternalcombat-java`
`eternalcombat-repositories`
`eternalcombat-publish-hangar`
`eternalcombat-publish-modrinth`
`eternalcombat-runserver`
id("net.minecrell.plugin-yml.bukkit")
id("de.eldoria.plugin-yml.paper") version "0.9.0"
id("com.gradleup.shadow")
id("xyz.jpenilla.run-paper")
}
configurations.all {
resolutionStrategy {
eachDependency {
if (requested.group == "com.google.code.gson" && requested.name == "gson") {
useVersion("2.11.0")
because("WorldGuard requires strictly gson 2.11.0")
}
}
}
}
dependencies {
implementation(project(":eternalcombat-api"))
// kyori
implementation("net.kyori:adventure-platform-bukkit:${Versions.ADVENTURE_PLATFORM_BUKKIT}")
implementation("net.kyori:adventure-text-minimessage:${Versions.ADVENTURE_API}")
implementation("net.kyori:adventure-api") {
version {
strictly(Versions.ADVENTURE_API)
}
}
// Paper
compileOnly("io.papermc.paper:paper-api:${Versions.PAPER_API}")
// litecommands
implementation("dev.rollczi:litecommands-bukkit:${Versions.LITE_COMMANDS}")
implementation("dev.rollczi:litecommands-folia:${Versions.LITE_COMMANDS}")
// Okaeri configs
implementation("eu.okaeri:okaeri-configs-serdes-commons:${Versions.OKAERI_CONFIGS_SERDES_COMMONS}")
implementation("eu.okaeri:okaeri-configs-serdes-bukkit:${Versions.OKAERI_CONFIGS_SERDES_BUKKIT}")
// GitCheck
implementation("com.eternalcode:gitcheck:${Versions.GIT_CHECK}")
// XSeries
implementation("com.github.cryptomorin:XSeries:${Versions.XSERIES}")
// bstats
implementation("org.bstats:bstats-bukkit:${Versions.B_STATS_BUKKIT}")
@@ -37,45 +47,81 @@ dependencies {
// caffeine
implementation("com.github.ben-manes.caffeine:caffeine:${Versions.CAFFEINE}")
implementation("com.eternalcode:eternalcode-commons-bukkit:${Versions.ETERNALCODE_COMMONS}")
implementation("com.eternalcode:eternalcode-commons-adventure:${Versions.ETERNALCODE_COMMONS}")
implementation("com.eternalcode:eternalcode-commons-bukkit:${Versions.ETERNALCODE_COMMONS}")
implementation("com.eternalcode:eternalcode-commons-shared:${Versions.ETERNALCODE_COMMONS}")
implementation("com.eternalcode:eternalcode-commons-folia:${Versions.ETERNALCODE_COMMONS}")
implementation("com.eternalcode:eternalcode-commons-updater:${Versions.ETERNALCODE_COMMONS}")
// worldguard
compileOnly("com.sk89q.worldguard:worldguard-bukkit:${Versions.WORLD_GUARD_BUKKIT}")
// PlaceholderAPI
compileOnly("me.clip:placeholderapi:${Versions.PLACEHOLDER_API}")
// Lands
compileOnly("com.github.angeschossen:LandsAPI:7.15.20")
compileOnly("com.github.angeschossen:LandsAPI:${Versions.LANDS_API}")
// GriefPrevention
compileOnly("com.github.GriefPrevention:GriefPrevention:${Versions.GRIEF_PREVENTION}") {
isTransitive = false
}
// Multification
implementation("com.eternalcode:multification-bukkit:${Versions.MULTIFICATION}")
implementation("com.eternalcode:multification-paper:${Versions.MULTIFICATION}")
implementation("com.eternalcode:multification-okaeri:${Versions.MULTIFICATION}")
compileOnly("com.github.retrooper:packetevents-spigot:${Versions.PACKETS_EVENTS}")
implementation("io.papermc:paperlib:${Versions.PAPERLIB}")
}
bukkit {
paper {
main = "com.eternalcode.combat.CombatPlugin"
author = "EternalCodeTeam"
apiVersion = "1.13"
authors = listOf("EternalCodeTeam")
apiVersion = "1.19"
prefix = "EternalCombat"
name = "EternalCombat"
generateLibrariesJson = true
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
softDepend = listOf(
"Lands"
)
depend = listOf(
"packetevents",
)
version = "${project.version}"
foliaSupported = true
serverDependencies {
register("packetevents") {
required = true
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
}
register("Lands") {
required = false
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
}
register("WorldGuard") {
required = false
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
}
register("GriefPrevention") {
required = false
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
}
register("PlaceholderAPI") {
required = false
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
}
}
}
tasks {
runServer {
minecraftVersion("1.21.4")
downloadPlugins.url("https://github.com/retrooper/packetevents/releases/download/v2.8.0/packetevents-spigot-2.8.0.jar")
named("generatePaperPluginDescription") {
notCompatibleWithConfigurationCache("The plugin-yml paper generator reads Task.project during execution.")
}
runPaper.folia.registerTask {
minecraftVersion("26.3")
downloadPlugins.modrinth("PacketEvents", "${Versions.PACKETEVENTS}+spigot")
}
}
@@ -85,17 +131,18 @@ tasks.shadowJar {
exclude(
"org/intellij/lang/annotations/**",
"org/jetbrains/annotations/**",
"net/kyori/**",
"META-INF/**",
"kotlin/**",
"javax/**",
"org/checkerframework/**",
"com/google/errorprone/**",
"com/google/gson/**"
)
val prefix = "com.eternalcode.combat.libs"
listOf(
"eu.okaeri",
"net.kyori",
"org.bstats",
"org.yaml",
"dev.rollczi.litecommands",
@@ -104,7 +151,8 @@ tasks.shadowJar {
"com.github.benmanes.caffeine",
"com.eternalcode.commons",
"com.eternalcode.multification",
"io.papermc"
"com.github.cryptomorin",
"com.cryptomorin",
).forEach { pack ->
relocate(pack, "$prefix.$pack")
}
@@ -1,60 +1,80 @@
package com.eternalcode.combat;
import com.eternalcode.combat.border.BorderTriggerController;
import com.eternalcode.combat.border.BorderService;
import com.eternalcode.combat.border.BorderServiceImpl;
import com.eternalcode.combat.border.BorderTriggerController;
import com.eternalcode.combat.border.animation.block.BorderBlockController;
import com.eternalcode.combat.border.animation.particle.ParticleController;
import com.eternalcode.combat.bridge.BridgeService;
import com.eternalcode.combat.fight.drop.DropKeepInventoryService;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.drop.DropService;
import com.eternalcode.combat.fight.effect.FightEffectService;
import com.eternalcode.combat.fight.knockback.KnockbackService;
import com.eternalcode.combat.fight.tagout.FightTagOutService;
import com.eternalcode.combat.fight.pearl.FightPearlService;
import com.eternalcode.combat.handler.InvalidUsageHandlerImpl;
import com.eternalcode.combat.handler.MissingPermissionHandlerImpl;
import com.eternalcode.combat.config.ConfigService;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.drop.DropController;
import com.eternalcode.combat.fight.drop.DropKeepInventoryServiceImpl;
import com.eternalcode.combat.fight.drop.DropServiceImpl;
import com.eternalcode.combat.fight.drop.impl.PercentDropModifier;
import com.eternalcode.combat.fight.drop.impl.PlayersHealthDropModifier;
import com.eternalcode.combat.fight.crystalpvp.EndCrystalController;
import com.eternalcode.combat.fight.crystalpvp.RespawnAnchorController;
import com.eternalcode.combat.event.EventManager;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.FightManagerImpl;
import com.eternalcode.combat.fight.FightTagCommand;
import com.eternalcode.combat.fight.controller.FightActionBlockerController;
import com.eternalcode.combat.fight.FightTask;
import com.eternalcode.combat.fight.blocker.CommandsBlocker;
import com.eternalcode.combat.fight.blocker.ElytraBlocker;
import com.eternalcode.combat.fight.blocker.ElytraEquipBlocker;
import com.eternalcode.combat.fight.blocker.FlyingBlocker;
import com.eternalcode.combat.fight.controller.FightBypassAdminController;
import com.eternalcode.combat.fight.controller.FightBypassCreativeController;
import com.eternalcode.combat.fight.controller.FightBypassPermissionController;
import com.eternalcode.combat.fight.blocker.InventoryContainersBlocker;
import com.eternalcode.combat.fight.controller.FightMessageController;
import com.eternalcode.combat.fight.controller.FightTagController;
import com.eternalcode.combat.fight.controller.FightUnTagController;
import com.eternalcode.combat.fight.death.DeathFlareController;
import com.eternalcode.combat.fight.death.DeathLightningController;
import com.eternalcode.combat.fight.drop.DropController;
import com.eternalcode.combat.fight.drop.DropKeepInventoryService;
import com.eternalcode.combat.fight.drop.DropKeepInventoryServiceImpl;
import com.eternalcode.combat.fight.drop.DropService;
import com.eternalcode.combat.fight.drop.DropServiceImpl;
import com.eternalcode.combat.fight.drop.impl.PercentDropModifier;
import com.eternalcode.combat.fight.drop.impl.PlayersHealthDropModifier;
import com.eternalcode.combat.fight.blocker.PlaceBlockBlocker;
import com.eternalcode.combat.fight.blocker.SignEditingBlocker;
import com.eternalcode.combat.fight.effect.FightEffectController;
import com.eternalcode.combat.event.EventManager;
import com.eternalcode.combat.fight.FightManagerImpl;
import com.eternalcode.combat.fight.FightTask;
import com.eternalcode.combat.fight.effect.FightEffectService;
import com.eternalcode.combat.fight.effect.FightEffectServiceImpl;
import com.eternalcode.combat.fight.firework.FireworkController;
import com.eternalcode.combat.fight.knockback.KnockbackMountController;
import com.eternalcode.combat.fight.knockback.KnockbackRegionController;
import com.eternalcode.combat.fight.knockback.KnockbackService;
import com.eternalcode.combat.fight.logout.LogoutController;
import com.eternalcode.combat.fight.logout.LogoutService;
import com.eternalcode.combat.fight.pearl.FightPearlController;
import com.eternalcode.combat.fight.pearl.FightPearlServiceImpl;
import com.eternalcode.combat.fight.tagout.FightTagOutController;
import com.eternalcode.combat.fight.tagout.FightTagOutServiceImpl;
import com.eternalcode.combat.fight.pearl.PearlController;
import com.eternalcode.combat.fight.pearl.PearlService;
import com.eternalcode.combat.fight.pearl.PearlServiceImpl;
import com.eternalcode.combat.fight.spear.SpearLungeController;
import com.eternalcode.combat.fight.spear.SpearService;
import com.eternalcode.combat.fight.spear.SpearServiceImpl;
import com.eternalcode.combat.fight.tagout.FightTagOutCommand;
import com.eternalcode.combat.fight.tagout.FightTagOutController;
import com.eternalcode.combat.fight.tagout.FightTagOutService;
import com.eternalcode.combat.fight.tagout.FightTagOutServiceImpl;
import com.eternalcode.combat.fight.trident.TridentController;
import com.eternalcode.combat.fight.trident.TridentService;
import com.eternalcode.combat.fight.trident.TridentServiceImpl;
import com.eternalcode.combat.handler.InvalidUsageHandlerImpl;
import com.eternalcode.combat.handler.MissingPermissionHandlerImpl;
import com.eternalcode.combat.notification.NoticeService;
import com.eternalcode.combat.fight.knockback.KnockbackRegionController;
import com.eternalcode.combat.region.RegionProvider;
import com.eternalcode.combat.updater.UpdaterNotificationController;
import com.eternalcode.combat.updater.UpdaterService;
import com.eternalcode.commons.adventure.AdventureLegacyColorPostProcessor;
import com.eternalcode.commons.adventure.AdventureLegacyColorPreProcessor;
import com.eternalcode.commons.bukkit.scheduler.BukkitSchedulerImpl;
import com.eternalcode.commons.scheduler.Scheduler;
import com.eternalcode.commons.bukkit.scheduler.MinecraftScheduler;
import com.eternalcode.multification.notice.Notice;
import com.google.common.base.Stopwatch;
import dev.rollczi.litecommands.LiteCommands;
import dev.rollczi.litecommands.bukkit.LiteBukkitFactory;
import dev.rollczi.litecommands.bukkit.LiteBukkitMessages;
import net.kyori.adventure.platform.AudienceProvider;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import dev.rollczi.litecommands.folia.FoliaExtension;
import java.time.Duration;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bstats.bukkit.Metrics;
import org.bukkit.Server;
@@ -73,7 +93,8 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
private static final int BSTATS_METRICS_ID = 17803;
private FightManager fightManager;
private FightPearlService fightPearlService;
private PearlService pearlService;
private TridentService tridentService;
private FightTagOutService fightTagOutService;
private FightEffectService fightEffectService;
@@ -82,8 +103,8 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
private RegionProvider regionProvider;
private AudienceProvider audienceProvider;
private LiteCommands<CommandSender> liteCommands;
private boolean apiInitialized;
@Override
@@ -96,12 +117,13 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
ConfigService configService = new ConfigService();
EventManager eventManager = new EventManager(this);
Scheduler scheduler = new BukkitSchedulerImpl(this);
PluginConfig pluginConfig = configService.create(PluginConfig.class, new File(dataFolder, "config.yml"));
MinecraftScheduler scheduler = CombatSchedulerAdapter.getAdaptiveScheduler(this);
this.fightManager = new FightManagerImpl(eventManager);
this.fightPearlService = new FightPearlServiceImpl(pluginConfig.pearl);
this.pearlService = new PearlServiceImpl(this.fightManager, pluginConfig, scheduler);
this.tridentService = new TridentServiceImpl(pluginConfig);
this.fightTagOutService = new FightTagOutServiceImpl();
this.fightEffectService = new FightEffectServiceImpl();
@@ -112,13 +134,12 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
UpdaterService updaterService = new UpdaterService(this.getDescription());
this.audienceProvider = BukkitAudiences.create(this);
MiniMessage miniMessage = MiniMessage.builder()
.postProcessor(new AdventureLegacyColorPostProcessor())
.preProcessor(new AdventureLegacyColorPreProcessor())
.build();
NoticeService noticeService = new NoticeService(this.audienceProvider, pluginConfig, miniMessage);
NoticeService noticeService = new NoticeService(pluginConfig, miniMessage);
BridgeService bridgeService = new BridgeService(
pluginConfig,
@@ -133,6 +154,8 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
BorderService borderService = new BorderServiceImpl(scheduler, server, regionProvider, eventManager, () -> pluginConfig.border);
KnockbackService knockbackService = new KnockbackService(pluginConfig, scheduler, regionProvider);
SpearService spearService = new SpearServiceImpl(pluginConfig.spear);
this.liteCommands = LiteBukkitFactory.builder(FALLBACK_PREFIX, this, server)
.message(LiteBukkitMessages.PLAYER_NOT_FOUND, pluginConfig.messagesSettings.playerNotFound)
.message(LiteBukkitMessages.PLAYER_ONLY, pluginConfig.messagesSettings.admin.onlyForPlayers)
@@ -146,6 +169,8 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
new EternalCombatReloadCommand(configService, noticeService)
)
.extension(new FoliaExtension(this))
.result(Notice.class, (invocation, result, chain) -> noticeService.create()
.viewer(invocation.sender())
.notice(result)
@@ -154,7 +179,7 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
.build();
FightTask fightTask = new FightTask(server, pluginConfig, this.fightManager, noticeService);
this.getServer().getScheduler().runTaskTimer(this, fightTask, 20L, 20L);
scheduler.timer(fightTask, Duration.ofSeconds(1), Duration.ofSeconds(1));
new Metrics(this, BSTATS_METRICS_ID);
@@ -166,18 +191,38 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
eventManager.subscribe(
new FightTagController(this.fightManager, pluginConfig),
new FightUnTagController(this.fightManager, pluginConfig, logoutService),
new FightActionBlockerController(this.fightManager, noticeService, pluginConfig, server),
new FightPearlController(pluginConfig.pearl, noticeService, this.fightManager, this.fightPearlService),
new UpdaterNotificationController(updaterService, pluginConfig, this.audienceProvider, miniMessage),
new FightBypassAdminController(server, pluginConfig),
new FightBypassPermissionController(server, pluginConfig),
new FightBypassCreativeController(server, pluginConfig),
new PlaceBlockBlocker(this.fightManager, noticeService, pluginConfig),
new PearlController(pluginConfig, this.pearlService, noticeService, fightManager),
new TridentController(pluginConfig, noticeService, this.fightManager, this.tridentService, server),
new DeathFlareController(pluginConfig, server, scheduler, this),
new DeathLightningController(pluginConfig, server),
new UpdaterNotificationController(updaterService, pluginConfig, miniMessage),
new KnockbackRegionController(noticeService, this.regionProvider, this.fightManager, knockbackService, server),
new FightEffectController(pluginConfig.effect, this.fightEffectService, this.fightManager, this.getServer()),
new FightEffectController(pluginConfig.effect, this.fightEffectService, this.fightManager, server),
new FightTagOutController(this.fightTagOutService),
new FightMessageController(this.fightManager, noticeService, pluginConfig, this.getServer()),
new BorderTriggerController(borderService, () -> pluginConfig.border, fightManager, server),
new FightMessageController(this.fightManager, noticeService, pluginConfig, server),
new BorderTriggerController(borderService, () -> pluginConfig.border, fightManager, server, scheduler),
new ParticleController(borderService, () -> pluginConfig.border.particle, scheduler, server),
new BorderBlockController(borderService, () -> pluginConfig.border.block, scheduler, server)
new BorderBlockController(borderService, () -> pluginConfig.border.block, scheduler, server),
new EndCrystalController(this, this.fightManager, pluginConfig),
new RespawnAnchorController(this, this.fightManager, pluginConfig),
new FireworkController(this.fightManager, pluginConfig, noticeService),
new InventoryContainersBlocker(this.fightManager, pluginConfig, noticeService),
new SignEditingBlocker(this.fightManager, pluginConfig),
new CommandsBlocker(this.fightManager, noticeService, pluginConfig),
new ElytraBlocker(this.fightManager, pluginConfig),
new ElytraEquipBlocker(this.fightManager, noticeService, pluginConfig, server),
new FlyingBlocker(this.fightManager, pluginConfig, server),
new PlaceBlockBlocker(this.fightManager, noticeService, pluginConfig)
);
new KnockbackMountController(noticeService, this.regionProvider, this.fightManager).register(this);
new SpearLungeController(this, fightManager, spearService, pluginConfig, noticeService);
eventManager.subscribe(
PlayerDeathEvent.class,
pluginConfig.drop.dropEventPriority,
@@ -191,6 +236,7 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
);
EternalCombatProvider.initialize(this);
this.apiInitialized = true;
long millis = started.elapsed(TimeUnit.MILLISECONDS);
this.getLogger().info("Successfully loaded EternalCombat in " + millis + "ms");
@@ -198,17 +244,18 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
@Override
public void onDisable() {
EternalCombatProvider.deinitialize();
if (this.liteCommands != null) {
this.liteCommands.unregister();
}
if (this.audienceProvider != null) {
this.audienceProvider.close();
if (this.fightManager != null) {
this.fightManager.untagAll();
}
this.fightManager.untagAll();
if (this.apiInitialized) {
EternalCombatProvider.deinitialize();
this.apiInitialized = false;
}
}
@Override
@@ -222,8 +269,8 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
}
@Override
public FightPearlService getFightPearlService() {
return this.fightPearlService;
public PearlService getFightPearlService() {
return this.pearlService;
}
@Override
@@ -0,0 +1,26 @@
package com.eternalcode.combat;
import com.eternalcode.commons.bukkit.scheduler.BukkitSchedulerImpl;
import com.eternalcode.commons.bukkit.scheduler.MinecraftScheduler;
import com.eternalcode.commons.folia.scheduler.FoliaSchedulerImpl;
import java.util.logging.Logger;
import org.bukkit.plugin.Plugin;
public final class CombatSchedulerAdapter {
private CombatSchedulerAdapter() {
throw new UnsupportedOperationException("This is an utility class and cannot be instantiated");
}
public static MinecraftScheduler getAdaptiveScheduler(Plugin plugin) {
Logger logger = plugin.getLogger();
if (FoliaChecker.isFolia()) {
logger.info("» Detected Folia environment. Using FoliaScheduler.");
return new FoliaSchedulerImpl(plugin);
}
logger.info("» Detected Bukkit/Paper environment. Using BukkitScheduler.");
return new BukkitSchedulerImpl(plugin);
}
}
@@ -2,7 +2,6 @@ package com.eternalcode.combat;
import com.eternalcode.combat.config.ConfigService;
import com.eternalcode.combat.notification.NoticeService;
import com.eternalcode.multification.bukkit.notice.BukkitNotice;
import com.eternalcode.multification.notice.Notice;
import com.google.common.base.Stopwatch;
import dev.rollczi.litecommands.annotations.async.Async;
@@ -14,10 +13,9 @@ import java.time.Duration;
import org.bukkit.command.CommandSender;
@Command(name = "combatlog", aliases = "combat")
@Permission("eternalcombat.reload")
public class EternalCombatReloadCommand {
private static final Notice RELOAD_MESSAGE = BukkitNotice.builder()
private static final Notice RELOAD_MESSAGE = Notice.builder()
.chat("<b><gradient:#8a1212:#fc6b03>EternalCombat:</gradient></b> Reloaded EternalCombat in <color:#fce303>{TIME}ms!</color>")
.build();
@@ -31,6 +29,7 @@ public class EternalCombatReloadCommand {
@Async
@Execute(name = "reload")
@Permission("eternalcombat.reload")
void execute(@Context CommandSender sender) {
Stopwatch stopwatch = Stopwatch.createStarted();
this.configService.reload();
@@ -0,0 +1,25 @@
package com.eternalcode.combat;
public final class FoliaChecker {
private static final String FOLIA_CLASS = "io.papermc.paper.threadedregions.RegionizedServer";
private static final boolean IS_FOLIA = detectFoliaEnvironment();
private FoliaChecker() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
public static boolean isFolia() {
return IS_FOLIA;
}
private static boolean detectFoliaEnvironment() {
try {
Class.forName(FOLIA_CLASS);
return true;
}
catch (ClassNotFoundException exception) {
return false;
}
}
}
@@ -2,18 +2,24 @@ package com.eternalcode.combat.border;
import org.jetbrains.annotations.Nullable;
public record BorderPoint(int x, int y, int z, @Nullable BorderPoint inclusive) {
public record BorderPoint(int x, int y, int z, @Nullable BorderPoint innerPoint) {
public BorderPoint(int x, int y, int z) {
this(x, y, z, null);
}
public BorderPoint toInclusive() {
if (inclusive == null) {
/**
* This point represents an adjusted coordinate that takes into account the block's volume (thickness)
* and is used for logical placement and grouping, especially for assigning border blocks to the
* correct chunk when they are on the very edge of a chunk boundary.
* This ensures the block is considered to be on the "inner" side of the border for chunk-based logic.
*/
@Override
public BorderPoint innerPoint() {
if (this.innerPoint == null) {
return this;
}
return inclusive;
return this.innerPoint;
}
}
@@ -4,6 +4,7 @@ import com.eternalcode.combat.border.event.BorderHideAsyncEvent;
import com.eternalcode.combat.border.event.BorderShowAsyncEvent;
import com.eternalcode.combat.event.EventManager;
import com.eternalcode.combat.region.RegionProvider;
import com.eternalcode.commons.bukkit.scheduler.MinecraftScheduler;
import com.eternalcode.commons.scheduler.Scheduler;
import dev.rollczi.litecommands.shared.Lazy;
import java.util.ArrayList;
@@ -19,7 +20,7 @@ import org.bukkit.entity.Player;
public class BorderServiceImpl implements BorderService {
private final Scheduler scheduler;
private final MinecraftScheduler scheduler;
private final EventManager eventManager;
private final Supplier<BorderSettings> settings;
@@ -27,7 +28,7 @@ public class BorderServiceImpl implements BorderService {
private final BorderTriggerIndex borderIndexes;
private final BorderActivePointsIndex activeBorderIndex = new BorderActivePointsIndex();
public BorderServiceImpl(Scheduler scheduler, Server server, RegionProvider provider, EventManager eventManager, Supplier<BorderSettings> settings) {
public BorderServiceImpl(MinecraftScheduler scheduler, Server server, RegionProvider provider, EventManager eventManager, Supplier<BorderSettings> settings) {
this.scheduler = scheduler;
this.eventManager = eventManager;
this.settings = settings;
@@ -128,8 +129,8 @@ public class BorderServiceImpl implements BorderService {
if (borderMax.y() <= realMaxY) { // Top wall
for (int currentX = realMinX; currentX <= realMaxX; currentX++) {
for (int currentZ = realMinZ; currentZ <= realMaxZ; currentZ++) {
BorderPoint inclusive = new BorderPoint(Math.max(realMinX, currentX - 1), realMaxY - 1, Math.max(realMinZ, currentZ - 1));
addPoint(points, currentX, realMaxY, currentZ, playerLocation, inclusive);
BorderPoint innerPoint = new BorderPoint(Math.max(realMinX, currentX - 1), realMaxY - 1, Math.max(realMinZ, currentZ - 1));
addPoint(points, currentX, realMaxY, currentZ, playerLocation, innerPoint);
}
}
}
@@ -145,8 +146,8 @@ public class BorderServiceImpl implements BorderService {
if (borderMax.x() <= realMaxX) { // East wall (right)
for (int currentY = realMinY; currentY <= realMaxY; currentY++) {
for (int currentZ = realMinZ; currentZ <= realMaxZ; currentZ++) {
BorderPoint inclusive = new BorderPoint(realMaxX - 1, Math.max(realMinY, currentY - 1), Math.max(realMinZ, currentZ - 1));
addPoint(points, realMaxX, currentY, currentZ, playerLocation, inclusive);
BorderPoint innerPoint = new BorderPoint(realMaxX - 1, Math.max(realMinY, currentY - 1), Math.max(realMinZ, currentZ - 1));
addPoint(points, realMaxX, currentY, currentZ, playerLocation, innerPoint);
}
}
}
@@ -162,8 +163,8 @@ public class BorderServiceImpl implements BorderService {
if (borderMax.z() <= realMaxZ) { // South wall (back)
for (int currentX = realMinX; currentX <= realMaxX; currentX++) {
for (int currentY = realMinY; currentY <= realMaxY; currentY++) {
BorderPoint inclusive = new BorderPoint(Math.max(realMinX, currentX - 1), Math.max(realMinY, currentY - 1), realMaxZ - 1);
addPoint(points, currentX, currentY, realMaxZ, playerLocation, inclusive);
BorderPoint innerPoint = new BorderPoint(Math.max(realMinX, currentX - 1), Math.max(realMinY, currentY - 1), realMaxZ - 1);
addPoint(points, currentX, currentY, realMaxZ, playerLocation, innerPoint);
}
}
}
@@ -171,9 +172,9 @@ public class BorderServiceImpl implements BorderService {
return points;
}
private void addPoint(List<BorderPoint> points, int x, int y, int z, Location playerLocation, BorderPoint inclusive) {
private void addPoint(List<BorderPoint> points, int x, int y, int z, Location playerLocation, BorderPoint innerPoint) {
if (isVisible(x, y, z, playerLocation)) {
points.add(new BorderPoint(x, y, z, inclusive));
points.add(new BorderPoint(x, y, z, innerPoint));
}
}
@@ -3,6 +3,8 @@ package com.eternalcode.combat.border;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.FightTagEvent;
import com.eternalcode.combat.fight.event.FightUntagEvent;
import com.eternalcode.commons.bukkit.scheduler.MinecraftScheduler;
import java.time.Duration;
import java.util.function.Supplier;
import org.bukkit.Location;
import org.bukkit.Server;
@@ -15,16 +17,26 @@ import org.bukkit.event.player.PlayerTeleportEvent;
public class BorderTriggerController implements Listener {
private static final long BORDER_WORK_AROUND_DELAY_MILLIS = 250;
private final BorderService borderService;
private final Supplier<BorderSettings> border;
private final FightManager fightManager;
private final Server server;
private final MinecraftScheduler scheduler;
public BorderTriggerController(BorderService borderService, Supplier<BorderSettings> border, FightManager fightManager, Server server) {
public BorderTriggerController(
BorderService borderService,
Supplier<BorderSettings> border,
FightManager fightManager,
Server server,
MinecraftScheduler scheduler
) {
this.borderService = borderService;
this.border = border;
this.fightManager = fightManager;
this.server = server;
this.scheduler = scheduler;
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
@@ -86,7 +98,11 @@ public class BorderTriggerController implements Listener {
return;
}
borderService.clearBorder(player);
// Due to race condition in PlayerMoveEvent and FightUntagEvent - border can be triggered after death and untag of player - solution delayed removal of border
this.scheduler.runLater(() -> {
if (!this.fightManager.isInCombat(player.getUniqueId())) {
this.borderService.clearBorder(player);
}
}, Duration.ofMillis(BORDER_WORK_AROUND_DELAY_MILLIS));
}
}
@@ -2,6 +2,7 @@ package com.eternalcode.combat.border;
import com.eternalcode.combat.region.Region;
import com.eternalcode.combat.region.RegionProvider;
import com.eternalcode.commons.bukkit.scheduler.MinecraftScheduler;
import com.eternalcode.commons.scheduler.Scheduler;
import java.time.Duration;
import java.util.ArrayList;
@@ -17,13 +18,13 @@ import org.bukkit.World;
class BorderTriggerIndex {
private final Server server;
private final Scheduler scheduler;
private final MinecraftScheduler scheduler;
private final RegionProvider provider;
private final Supplier<BorderSettings> settings;
private final Map<String, BorderTriggerIndexBucket> borderIndexes = new HashMap<>();
private BorderTriggerIndex(Server server, Scheduler scheduler, RegionProvider provider, Supplier<BorderSettings> settings) {
private BorderTriggerIndex(Server server, MinecraftScheduler scheduler, RegionProvider provider, Supplier<BorderSettings> settings) {
this.server = server;
this.scheduler = scheduler;
this.provider = provider;
@@ -56,7 +57,7 @@ class BorderTriggerIndex {
});
}
static BorderTriggerIndex started(Server server, Scheduler scheduler, RegionProvider provider, Supplier<BorderSettings> settings) {
static BorderTriggerIndex started(Server server, MinecraftScheduler scheduler, RegionProvider provider, Supplier<BorderSettings> settings) {
BorderTriggerIndex index = new BorderTriggerIndex(server, scheduler, provider, settings);
scheduler.timerAsync(() -> index.updateWorlds(), Duration.ZERO, settings.get().indexRefreshDelay());
return index;
@@ -15,6 +15,7 @@ import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
import com.github.retrooper.packetevents.util.Vector3i;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerMultiBlockChange;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerMultiBlockChange.EncodedBlock;
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
@@ -25,11 +26,12 @@ import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.bukkit.ChunkSnapshot;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
public class BorderBlockController implements Listener {
@@ -37,7 +39,7 @@ public class BorderBlockController implements Listener {
public static final PlayerManager PLAYER_MANAGER = PACKET_EVENTS.getPlayerManager();
public static final ClientVersion SERVER_VERSION = PACKET_EVENTS.getServerManager().getVersion().toClientVersion();
public static final int AIR_ID = WrappedBlockState.getDefaultState(SERVER_VERSION, StateTypes.AIR).getGlobalId();
public static final WrappedBlockState AIR_ID = WrappedBlockState.getDefaultState(SERVER_VERSION, StateTypes.AIR);
public static final int MINECRAFT_CHUNK_SHIFT = 4;
private final BorderService borderService;
@@ -46,6 +48,7 @@ public class BorderBlockController implements Listener {
private final Set<UUID> playersToUpdate = ConcurrentHashMap.newKeySet();
private final Map<UUID, Object> lockedPlayers = new ConcurrentHashMap<>();
private final Map<UUID, Map<BorderPoint, WrappedBlockState>> originalBlocks = new ConcurrentHashMap<>();
private final ChunkCache chunkCache;
public BorderBlockController(BorderService borderService, Supplier<BlockSettings> settings, Scheduler scheduler, Server server) {
@@ -59,37 +62,52 @@ public class BorderBlockController implements Listener {
@EventHandler
void onBorderShowAsyncEvent(BorderShowAsyncEvent event) {
if (!settings.get().enabled) {
if (!this.settings.get().enabled) {
return;
}
Player player = event.getPlayer();
Set<BorderPoint> borderPoints = this.getPointsWithoutAir(player, event.getPoints());
UUID playerId = player.getUniqueId();
event.setPoints(borderPoints);
this.showBlocks(player, borderPoints);
this.playersToUpdate.add(player.getUniqueId());
synchronized (this.getLock(playerId)) {
Set<BorderPoint> borderPoints = this.savePassablePoints(player, event.getPoints());
event.setPoints(borderPoints);
this.showBorder(player, borderPoints);
this.playersToUpdate.add(playerId);
}
}
@EventHandler
void onBorderHideAsyncEvent(BorderHideAsyncEvent event) {
if (!settings.get().enabled) {
if (!this.settings.get().enabled) {
return;
}
Object lock = lockedPlayers.computeIfAbsent(event.getPlayer().getUniqueId(), k -> new Object());
synchronized (lock) {
this.hideBlocks(event.getPlayer(), event.getPoints());
UUID playerId = event.getPlayer().getUniqueId();
synchronized (this.getLock(playerId)) {
this.hideBorder(event.getPlayer(), event.getPoints());
Set<BorderPoint> border = this.borderService.getActiveBorder(event.getPlayer());
if (border.isEmpty()) {
this.playersToUpdate.remove(event.getPlayer().getUniqueId());
this.playersToUpdate.remove(playerId);
this.originalBlocks.remove(playerId);
}
}
}
@EventHandler
void onPlayerQuit(PlayerQuitEvent event) {
UUID playerId = event.getPlayer().getUniqueId();
this.playersToUpdate.remove(playerId);
this.originalBlocks.remove(playerId);
this.lockedPlayers.remove(playerId);
}
private void updatePlayers() {
if (!settings.get().enabled) {
if (!this.settings.get().enabled) {
return;
}
@@ -105,93 +123,109 @@ public class BorderBlockController implements Listener {
}
private void updatePlayer(UUID uuid, Player player) {
Object lock = lockedPlayers.computeIfAbsent(uuid, k -> new Object());
synchronized (lock) {
synchronized (this.getLock(uuid)) {
Set<BorderPoint> border = this.borderService.getActiveBorder(player);
if (border.isEmpty()) {
this.playersToUpdate.remove(uuid);
this.originalBlocks.remove(uuid);
return;
}
this.showBlocks(player, border);
Set<BorderPoint> passablePoints = this.savePassablePoints(player, border);
this.showBorder(player, passablePoints);
}
}
private void showBlocks(Player player, Collection<BorderPoint> blocks) {
this.splitByChunks(blocks).entrySet().stream()
.map(chunkBlocks -> toMultiBlockChangePacket(chunkBlocks))
.forEach(change -> PLAYER_MANAGER.sendPacket(player, change));
private void showBorder(Player player, Collection<BorderPoint> blocks) {
this.groupByChunkPacket(blocks).forEach((chunkPos, chunkPoints) -> {
EncodedBlock[] encodedBlocks = chunkPoints.stream()
.map(point -> toBorderBlock(point))
.toArray(EncodedBlock[]::new);
PLAYER_MANAGER.sendPacket(player, new WrapperPlayServerMultiBlockChange(chunkPos, true, encodedBlocks));
});
}
private WrapperPlayServerMultiBlockChange toMultiBlockChangePacket(Entry<Vector3i, Set<BorderPoint>> chunkBlocks) {
EncodedBlock[] encodedBlocks = chunkBlocks.getValue().stream()
.map(borderPoint -> this.toEncodedBlock(borderPoint))
.toArray(value -> new EncodedBlock[value]);
private void hideBorder(Player player, Collection<BorderPoint> blocks) {
UUID playerId = player.getUniqueId();
Map<BorderPoint, WrappedBlockState> savedBlocks = this.originalBlocks.get(playerId);
return new WrapperPlayServerMultiBlockChange(chunkBlocks.getKey(), true, encodedBlocks);
this.groupByChunkPacket(blocks).forEach((chunkPosition, chunkPoints) -> {
EncodedBlock[] originalBlocks = chunkPoints.stream()
.map(point -> this.toOriginalBlock(point, savedBlocks))
.toArray(EncodedBlock[]::new);
PLAYER_MANAGER.sendPacket(player, new WrapperPlayServerMultiBlockChange(chunkPosition, true, originalBlocks));
});
if (savedBlocks != null) {
blocks.forEach(key -> savedBlocks.remove(key));
}
}
private void hideBlocks(Player player, Collection<BorderPoint> blocks) {
this.splitByChunks(blocks).entrySet().stream()
.map(chunkBlocks -> toMultiAirChangePacket(chunkBlocks))
.forEach(change -> PLAYER_MANAGER.sendPacket(player, change));
}
private Set<BorderPoint> savePassablePoints(Player player, Collection<BorderPoint> points) {
UUID playerId = player.getUniqueId();
Map<BorderPoint, WrappedBlockState> savedBlocks = this.originalBlocks.computeIfAbsent(playerId, key -> new ConcurrentHashMap<>());
private WrapperPlayServerMultiBlockChange toMultiAirChangePacket(Entry<Vector3i, Set<BorderPoint>> chunkBlocks) {
EncodedBlock[] encodedBlocks = chunkBlocks.getValue().stream()
.map(point -> new EncodedBlock(AIR_ID, point.x(), point.y(), point.z()))
.toArray(value -> new EncodedBlock[value]);
return new WrapperPlayServerMultiBlockChange(chunkBlocks.getKey(), true, encodedBlocks);
}
private Set<BorderPoint> getPointsWithoutAir(Player player, Collection<BorderPoint> blocks) {
Map<ChunkLocation, Set<BorderPoint>> chunksToProcess = blocks.stream()
.map(borderPoint -> borderPoint.toInclusive())
.collect(Collectors.groupingBy(
inclusive -> new ChunkLocation(inclusive.x() >> MINECRAFT_CHUNK_SHIFT, inclusive.z() >> MINECRAFT_CHUNK_SHIFT),
Collectors.toSet()
));
return chunksToProcess.entrySet().stream()
.flatMap(entry -> getPointsWithoutAirOnChunk(player, entry))
return this.groupByChunk(points).entrySet().stream()
.flatMap(entry -> this.savePassableBlock(player, entry, savedBlocks))
.collect(Collectors.toSet());
}
private Stream<BorderPoint> getPointsWithoutAirOnChunk(Player player, Entry<ChunkLocation, Set<BorderPoint>> entry) {
ChunkSnapshot snapshot = this.chunkCache.loadSnapshot(player, entry.getKey());
private Stream<BorderPoint> savePassableBlock(Player player, Entry<ChunkLocation, Set<BorderPoint>> entry, Map<BorderPoint, WrappedBlockState> savedBlocks) {
ChunkSnapshot snapshot = this.chunkCache.loadSnapshot(player, entry.getKey());
if (snapshot == null) {
return Stream.empty();
}
return entry.getValue().stream()
.filter(point -> isAir(entry.getKey(), point, snapshot));
ChunkLocation chunk = entry.getKey();
return entry.getValue().stream().filter(point -> this.saveBlockIfPassable(point, chunk, snapshot, savedBlocks));
}
private static boolean isAir(ChunkLocation location, BorderPoint point, ChunkSnapshot chunk) {
int xInsideChunk = point.x() - (location.x() << MINECRAFT_CHUNK_SHIFT);
int zInsideChunk = point.z() - (location.z() << MINECRAFT_CHUNK_SHIFT);
Material material = chunk.getBlockType(xInsideChunk, point.y(), zInsideChunk);
private boolean saveBlockIfPassable(BorderPoint point, ChunkLocation chunk, ChunkSnapshot snapshot, Map<BorderPoint, WrappedBlockState> savedBlocks) {
int localX = point.x() - (chunk.x() << MINECRAFT_CHUNK_SHIFT);
int localZ = point.z() - (chunk.z() << MINECRAFT_CHUNK_SHIFT);
return material.isAir();
BlockData blockData = snapshot.getBlockData(localX, point.y(), localZ);
if (blockData.getMaterial().isSolid()) {
return false;
}
savedBlocks.put(point, SpigotConversionUtil.fromBukkitBlockData(blockData));
return true;
}
private Map<Vector3i, Set<BorderPoint>> splitByChunks(Collection<BorderPoint> blocks) {
return blocks.stream().collect(Collectors.groupingBy(
block -> new Vector3i(
block.x() >> MINECRAFT_CHUNK_SHIFT,
block.y() >> MINECRAFT_CHUNK_SHIFT,
block.z() >> MINECRAFT_CHUNK_SHIFT
),
private EncodedBlock toBorderBlock(BorderPoint point) {
StateType type = this.settings.get().type.getStateType(point);
int blockId = WrappedBlockState.getDefaultState(SERVER_VERSION, type).getGlobalId();
return new EncodedBlock(blockId, point.x(), point.y(), point.z());
}
private EncodedBlock toOriginalBlock(BorderPoint point, Map<BorderPoint, WrappedBlockState> savedBlocks) {
WrappedBlockState blockId = savedBlocks != null ? savedBlocks.getOrDefault(point, AIR_ID) : AIR_ID;
return new EncodedBlock(blockId, point.x(), point.y(), point.z());
}
private Map<ChunkLocation, Set<BorderPoint>> groupByChunk(Collection<BorderPoint> points) {
return points.stream()
.map(borderPoint -> borderPoint.innerPoint())
.collect(Collectors.groupingBy(point -> new ChunkLocation(point.x() >> MINECRAFT_CHUNK_SHIFT, point.z() >> MINECRAFT_CHUNK_SHIFT),
Collectors.toSet()
));
}
private EncodedBlock toEncodedBlock(BorderPoint point) {
StateType type = settings.get().type.getStateType(point);
WrappedBlockState state = WrappedBlockState.getDefaultState(SERVER_VERSION, type);
return new EncodedBlock(state.getGlobalId(), point.x(), point.y(), point.z());
private Map<Vector3i, Set<BorderPoint>> groupByChunkPacket(Collection<BorderPoint> points) {
return points.stream().collect(Collectors.groupingBy(
point -> new Vector3i(point.x() >> MINECRAFT_CHUNK_SHIFT, point.y() >> MINECRAFT_CHUNK_SHIFT, point.z() >> MINECRAFT_CHUNK_SHIFT),
Collectors.toSet()
));
}
private Object getLock(UUID uuid) {
return this.lockedPlayers.computeIfAbsent(uuid, k -> new Object());
}
}
@@ -2,7 +2,6 @@ package com.eternalcode.combat.border.animation.block;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import io.papermc.lib.PaperLib;
import org.bukkit.ChunkSnapshot;
import org.bukkit.entity.Player;
@@ -22,7 +21,7 @@ class ChunkCache {
return snapshot;
}
ChunkSnapshot chunkSnapshot = PaperLib.getChunkAtAsync(player.getWorld(), location.x(), location.z(), false)
ChunkSnapshot chunkSnapshot = player.getWorld().getChunkAtAsync(location.x(), location.z(), false)
.thenApply(chunk -> chunk.getChunkSnapshot())
.join();
@@ -7,6 +7,7 @@ import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.region.CompositeRegionProvider;
import com.eternalcode.combat.region.bukkit.DefaultRegionProvider;
import com.eternalcode.combat.region.RegionProvider;
import com.eternalcode.combat.region.griefprevention.GriefPreventionRegionProvider;
import com.eternalcode.combat.region.worldguard.WorldGuardRegionProvider;
import java.util.ArrayList;
import java.util.List;
@@ -55,6 +56,12 @@ public class BridgeService {
() -> this.logger.warning("WorldGuard not found; skipping WorldGuardRegionProvider.")
);
this.initialize(
"GriefPrevention",
() -> providers.add(new GriefPreventionRegionProvider(this.config)),
() -> this.logger.warning("GriefPrevention not found; skipping GriefPreventionRegionProvider.")
);
if (providers.isEmpty()) {
providers.add(new DefaultRegionProvider(this.config.regions.restrictedRegionRadius));
this.logger.warning("No region plugin found; using DefaultRegionProvider.");
@@ -69,7 +76,7 @@ public class BridgeService {
initialize(
"PlaceholderAPI",
() -> new FightTagPlaceholder(this.fightManager, server, this.plugin).register(),
() -> new FightTagPlaceholder(this.config, this.fightManager, server, this.plugin).register(),
() -> this.logger.warning("PlaceholderAPI not found; skipping placeholders.")
);
}
@@ -1,5 +1,7 @@
package com.eternalcode.combat.bridge.placeholder;
import com.eternalcode.combat.config.implementation.PlaceholderSettings;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.FightTag;
import com.eternalcode.combat.util.DurationUtil;
@@ -14,23 +16,93 @@ import org.jetbrains.annotations.NotNull;
public class FightTagPlaceholder extends PlaceholderExpansion {
private static final String IDENTIFIER = "eternalcombat";
private final PlaceholderSettings placeholderSettings;
private final FightManager fightManager;
private final Server server;
private final Plugin plugin;
private static final String IDENTIFIER = "eternalcombat";
public FightTagPlaceholder(FightManager fightManager, Server server, Plugin plugin) {
public FightTagPlaceholder(PluginConfig pluginConfig, FightManager fightManager, Server server, Plugin plugin) {
this.placeholderSettings = pluginConfig.placeholders;
this.fightManager = fightManager;
this.server = server;
this.plugin = plugin;
}
@Override
public String onRequest(OfflinePlayer player, String identifier) {
return switch (identifier) {
case "remaining_millis" -> this.handleRemainingMillis(player);
case "remaining_seconds" -> this.handleRemainingSeconds(player);
case "opponent" -> this.handleOpponent(player);
case "opponent_health" -> this.handleOpponentHealth(player);
case "isInCombat" -> this.handleIsInCombat(player);
case "isInCombat_formatted" -> this.handleIsInCombatFormatted(player);
default -> null;
};
}
private String handleRemainingMillis(OfflinePlayer player) {
return this.getFightTag(player)
.map(tag -> DurationParser.TIME_UNITS.format(tag.getRemainingDuration()))
.orElse("");
}
private String handleRemainingSeconds(OfflinePlayer player) {
return this.getFightTag(player)
.map(tag -> DurationUtil.format(tag.getRemainingDuration()))
.orElse("");
}
private String handleOpponent(OfflinePlayer player) {
return this.getTagger(player)
.map(Player::getName)
.orElse("");
}
private String handleOpponentHealth(OfflinePlayer player) {
return this.getTagger(player)
.map(tagger -> String.format("%.2f", tagger.getHealth()))
.orElse("");
}
private String handleIsInCombat(OfflinePlayer player) {
return String.valueOf(this.isPlayerInCombat(player));
}
private String handleIsInCombatFormatted(OfflinePlayer player) {
return this.isPlayerInCombat(player)
? this.placeholderSettings.isInCombatFormattedTrue
: this.placeholderSettings.isInCombatFormattedFalse;
}
private boolean isPlayerInCombat(OfflinePlayer player) {
Player onlinePlayer = player.getPlayer();
return onlinePlayer != null && this.fightManager.isInCombat(onlinePlayer.getUniqueId());
}
private @NotNull Optional<Player> getTagger(OfflinePlayer player) {
return this.getFightTag(player)
.map(FightTag::getTagger)
.map(this.server::getPlayer);
}
private Optional<FightTag> getFightTag(OfflinePlayer player) {
Player onlinePlayer = player.getPlayer();
if (onlinePlayer == null || !this.fightManager.isInCombat(onlinePlayer.getUniqueId())) {
return Optional.empty();
}
return Optional.of(this.fightManager.getTag(onlinePlayer.getUniqueId()));
}
@Override
public boolean canRegister() {
return true;
}
@Override
public @NotNull String getIdentifier() {
return IDENTIFIER;
@@ -45,54 +117,4 @@ public class FightTagPlaceholder extends PlaceholderExpansion {
public @NotNull String getVersion() {
return this.plugin.getDescription().getVersion();
}
@Override
public String onRequest(OfflinePlayer player, String identifier) {
if (identifier.equals("remaining_seconds")) {
return this.getFightTag(player)
.map(fightTagInter -> DurationUtil.format(fightTagInter.getRemainingDuration()))
.orElse("");
}
if (identifier.equals("remaining_millis")) {
return this.getFightTag(player)
.map(fightTag -> DurationParser.TIME_UNITS.format(fightTag.getRemainingDuration()))
.orElse("");
}
if (identifier.equals("opponent")) {
return this.getTagger(player)
.map(tagger -> tagger.getName())
.orElse("");
}
if (identifier.equals("opponent_health")) {
return this.getTagger(player)
.map(tagger -> String.format("%.2f", tagger.getHealth()))
.orElse("");
}
return null;
}
private @NotNull Optional<Player> getTagger(OfflinePlayer player) {
return this.getFightTag(player)
.map(fightTagInter -> fightTagInter.getTagger())
.map(taggerId -> this.server.getPlayer(taggerId));
}
private Optional<FightTag> getFightTag(OfflinePlayer player) {
Player onlinePlayer = player.getPlayer();
if (onlinePlayer != null) {
if (!this.fightManager.isInCombat(onlinePlayer.getUniqueId())) {
return Optional.empty();
}
return Optional.of(this.fightManager.getTag(onlinePlayer.getUniqueId()));
}
return Optional.empty();
}
}
@@ -3,9 +3,9 @@ package com.eternalcode.combat.config;
import com.eternalcode.combat.border.animation.block.BlockTypeTransformer;
import com.eternalcode.combat.border.animation.particle.ParticleColorTransformer;
import com.eternalcode.combat.border.animation.particle.ParticleTypeTransformer;
import com.eternalcode.multification.bukkit.notice.resolver.sound.SoundBukkitResolver;
import com.eternalcode.multification.notice.resolver.NoticeResolverDefaults;
import com.eternalcode.multification.notice.resolver.NoticeResolverRegistry;
import com.eternalcode.multification.notice.resolver.sound.SoundAdventureResolver;
import com.eternalcode.multification.okaeri.MultificationSerdesPack;
import eu.okaeri.configs.ConfigManager;
import eu.okaeri.configs.OkaeriConfig;
@@ -28,7 +28,7 @@ public class ConfigService {
YamlSnakeYamlConfigurer configurer = new YamlSnakeYamlConfigurer();
NoticeResolverRegistry noticeRegistry = NoticeResolverDefaults.createRegistry()
.registerResolver(new SoundBukkitResolver());
.registerResolver(new SoundAdventureResolver());
configFile.withConfigurer(configurer,
new SerdesCommons(),
@@ -6,7 +6,6 @@ import eu.okaeri.configs.annotation.Comment;
import java.util.List;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class CombatSettings extends OkaeriConfig {
@@ -35,10 +34,18 @@ public class CombatSettings extends OkaeriConfig {
public boolean disableFlying = true;
@Comment({
"# Prevent players from opening their inventory during combat.",
"# Set to 'true' to block inventory access while in combat."
"# Forcefully unequip elytra when a player enters combat.",
"# This prevents players from abusing glide by jumping before being tagged.",
"# The elytra will be moved to the player's inventory.",
"# Recommended: true"
})
public boolean disableInventoryAccess = false;
public boolean unequipElytraOnCombat = true;
@Comment({
"# Prevent players from boosting themselves while flying with fireworks",
"# This setting blocks usage of fireworks to boost elytra flight during combat"
})
public boolean disableFireworks = true;
@Comment({
"# Enable or disable combat logging for damage caused by non-player entities.",
@@ -83,6 +90,19 @@ public class CombatSettings extends OkaeriConfig {
})
public EventPriority quitPunishmentEventPriority = EventPriority.NORMAL;
@Comment({
"# Keep a player's combat tag continuously active while they are below 'voidCombatHeight'.",
"# This prevents players from evading combat by falling into the void (e.g. in the End).",
"# Set to 'true' to keep resetting the combat timer to its full duration while below that height."
})
public boolean keepCombatActiveInVoid = false;
@Comment({
"# The Y height below which the combat timer is kept active (see 'keepCombatActiveInVoid').",
"# Default: 0, matching the void threshold in worlds such as the End."
})
public double voidCombatHeight = 0;
@Comment({
"# List of kick reasons where players will NOT be punished for combat logging.",
"# If this list is empty, players are ALWAYS punished when kicked during combat.",
@@ -0,0 +1,14 @@
package com.eternalcode.combat.config.implementation;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
public class CrystalPvpSettings extends OkaeriConfig {
@Comment({"# Should player be tagged when damaged from crystal explosion set by other player"})
public boolean tagFromCrystals = true;
@Comment({"#Should player be tagged when damaged from respawn anchor explosion set by other player"})
public boolean tagFromRespawnAnchor = true;
}
@@ -0,0 +1,38 @@
package com.eternalcode.combat.config.implementation;
public enum InventoryAccessMode {
/**
* Allow access to all inventories during combat
*/
ALLOW_ALL,
/**
* Block access to all inventories during combat
*/
BLOCK_ALL,
/**
* Only block inventories in the restricted list
*/
BLACKLIST,
/**
* Only allow inventories in the allowed list
*/
WHITELIST;
/**
* Determines if an inventory type should be blocked based on the mode and whether it's in the list
*
* @param isInList whether the inventory type is in the configured list
* @return true if the inventory should be blocked
*/
public boolean shouldBlock(boolean isInList) {
return switch (this) {
case ALLOW_ALL -> false;
case BLOCK_ALL -> true;
case BLACKLIST -> isInList;
case WHITELIST -> !isInList;
};
}
}
@@ -0,0 +1,38 @@
package com.eternalcode.combat.config.implementation;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import org.bukkit.event.inventory.InventoryType;
import java.util.List;
public class InventorySettings extends OkaeriConfig {
@Comment({
"# Inventory access restriction mode during combat",
"# ALLOW_ALL - Players can open all inventories during combat",
"# BLOCK_ALL - Players cannot open any inventories during combat",
"# BLACKLIST - Block only inventories listed in restrictedInventoryTypes",
"# WHITELIST - Allow only inventories listed in restrictedInventoryTypes"
})
public InventoryAccessMode inventoryAccessMode = InventoryAccessMode.ALLOW_ALL;
@Comment({
"# List of inventory types to restrict or allow (depending on the mode)",
"# In BLACKLIST mode: these inventories will be blocked",
"# In WHITELIST mode: only these inventories will be allowed",
"# Available types: CHEST, ENDER_CHEST, DISPENSER, DROPPER, FURNACE, WORKBENCH,",
"# CRAFTING, ENCHANTING, BREWING, MERCHANT, BEACON, ANVIL, SMITHING, HOPPER,",
"# SHULKER_BOX, BARREL, BLAST_FURNACE, LECTERN, SMOKER, LOOM, CARTOGRAPHY,",
"# GRINDSTONE, STONECUTTER, COMPOSTER, CHISELED_BOOKSHELF, JUKEBOX, SMITHING_NEW,",
"# CRAFTER, DECORATED_POT",
"# Note: PLAYER and CREATIVE inventories are never blocked to prevent game-breaking issues",
"# Full list: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryType.html"
})
public List<InventoryType> restrictedInventoryTypes = List.of(
InventoryType.CHEST,
InventoryType.ENDER_CHEST,
InventoryType.BARREL,
InventoryType.SHULKER_BOX
);
}
@@ -1,197 +1,213 @@
package com.eternalcode.combat.config.implementation;
import com.eternalcode.multification.bukkit.notice.BukkitNotice;
import com.eternalcode.multification.notice.Notice;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
public class MessagesSettings extends OkaeriConfig {
@Comment({
"# Customize messages related to admin commands and notifications.",
"# These messages are displayed to server administrators."
"# Customize messages related to admin commands and notifications.",
"# These messages are displayed to server administrators."
})
public AdminMessages admin = new AdminMessages();
@Comment({
" ",
"# Configure the combat log notification displayed to players.",
"# You can use the {TIME} variable to display the remaining combat time.",
" ",
"# BossBar progress: Set to -1.0 to show the remaining combat time as a progress bar.",
"# BossBar colors: https://javadoc.io/static/net.kyori/adventure-api/4.14.0/net/kyori/adventure/bossbar/BossBar.Color.html",
"# BossBar overlays: https://javadoc.io/static/net.kyori/adventure-api/4.14.0/net/kyori/adventure/bossbar/BossBar.Overlay.html"
" ",
"# Configure the combat log notification displayed to players.",
"# You can use the {TIME} variable to display the remaining combat time.",
"# Placeholder {OPPONENT} will be replaced with player name or 'unknownPlayerPlaceholder' variable",
" ",
})
public Notice combatNotification = BukkitNotice.builder()
.actionBar("<bold>Combat ends in: <red>{TIME}</red></bold>")
.sound(Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 2.0F, 1.0F)
.build();
public Notice combatNotification = Notice.builder()
.actionBar("Combat ends in: <red>{TIME}</red>")
.build();
@Comment({
"# Would you like to display milliseconds instead of seconds in combat notification "
"# Would you like to display milliseconds instead of seconds in combat notification "
})
public boolean withoutMillis = true;
@Comment({
"# Message displayed when a player lacks permission to execute a command.",
"# The {PERMISSION} placeholder is replaced with the required permission."
" ",
"# When player is not known this text will be used as {OPPONENT} in 'combatNotification'"
})
public String unknownPlayerPlaceholder = "Unknown";
@Comment({
"# Message displayed when a player lacks permission to execute a command.",
"# The {PERMISSION} placeholder is replaced with the required permission."
})
public Notice noPermission = Notice.chat(
"<gradient:red:dark_red>You don't have permission <dark_gray>(<gray>{PERMISSION}</gray>)</dark_gray> to perform this command!</gradient>");
"<gradient:red:dark_red>You don't have permission <dark_gray>(<gray>{PERMISSION}</gray>)</dark_gray> to perform this command!</gradient>");
@Comment({
"# Message displayed when a specified player is not found.",
"# This message is shown when a command targets a player who is not online or does not exist."
"# Message displayed when a specified player is not found.",
"# This message is shown when a command targets a player who is not online or does not exist."
})
public Notice playerNotFound =
Notice.chat("<gradient:#ff0000:#ff6b6b>The specified player could not be found!</gradient>");
public Notice playerNotFound = Notice
.chat("<gradient:#ff0000:#ff6b6b>The specified player could not be found!</gradient>");
@Comment({
"# Message displayed when a player enters combat.",
"# This message warns the player not to leave the server while in combat."
"# Message displayed when a player enters combat.",
"# This message warns the player not to leave the server while in combat.",
"# The {OPPONENT} placeholder is replaced with the name of the player who caused the tag,",
"# or the 'unknownPlayerPlaceholder' variable if the tag was not caused by a player."
})
public Notice playerTagged = Notice.chat(
"<gradient:red:yellow>⚠ <white>You are in combat!</white> <u>Do not leave the server!</gradient>");
"<gradient:red:yellow>⚠ <white>You are in combat with</white> <yellow>{OPPONENT}</yellow>! <u>Do not leave the server!</gradient>");
@Comment({
"# Message displayed when a player leaves combat.",
"# This message informs the player that they can safely leave the server."
"# Message displayed when a player leaves combat.",
"# This message informs the player that they can safely leave the server."
})
public Notice playerUntagged = Notice.chat(
"<gradient:#00ff00:#00b300>✌ <white>Combat ended!</white> You can now safely leave!</gradient>");
"<gradient:#00ff00:#00b300>✌ <white>Combat ended!</white> You can now safely leave!</gradient>");
@Comment({
"# Broadcast message displayed when a player logs out during combat.",
"# The {PLAYER} placeholder is replaced with the player's name."
"# Broadcast message displayed when a player logs out during combat.",
"# The {PLAYER} placeholder is replaced with the player's name."
})
public Notice playerLoggedOutDuringCombat =
Notice.chat("<gradient:red:dark_red>⚠ <white>{PLAYER}</white> logged off during combat!</gradient>");
public Notice playerLoggedOutDuringCombat = Notice
.chat("<gradient:red:dark_red>⚠ <white>{PLAYER}</white> logged off during combat!</gradient>");
@Comment({
"# Message displayed when a player attempts to use a disabled command during combat.",
"# This message informs the player that the command is prohibited while in combat."
"# Message displayed when a player attempts to use a disabled command during combat.",
"# This message informs the player that the command is prohibited while in combat."
})
public Notice commandDisabledDuringCombat = Notice.chat(
"<gradient:red:yellow>⚠ <white>Command blocked!</white> Cannot use this during combat!</gradient>");
"<gradient:red:yellow>⚠ <white>Command blocked!</white> Cannot use this during combat!</gradient>");
@Comment({
"# Message displayed when a player uses a command with incorrect arguments.",
"# The {USAGE} placeholder is replaced with the correct command syntax."
"# Message displayed when a player attempts to use an elytra during combat.",
"# This includes gliding, equipping, or having it forcefully removed.",
"# Informs the player that elytra usage is disabled in combat."
})
public Notice elytraDisabledDuringCombat = Notice.chat(
"<gradient:red:yellow>⚠ <white>Elytra disabled!</white> Cannot use elytra during combat!</gradient>"
);
@Comment({
"# Message displayed when a player uses a command with incorrect arguments.",
"# The {USAGE} placeholder is replaced with the correct command syntax."
})
public Notice invalidCommandUsage = Notice.chat("<gray>Usage: <gradient:gold:yellow>{USAGE}</gradient>");
@Comment({
"# Message displayed when a player attempts to open their inventory during combat.",
"# This message informs the player that inventory access is blocked while in combat."
"# Message displayed when a player attempts to open their inventory during combat.",
"# This message informs the player that inventory access is blocked while in combat."
})
public Notice inventoryBlockedDuringCombat = Notice.chat(
"<gradient:red:dark_red>⚠ <white>Inventory access</white> is restricted during combat!</gradient>");
"<gradient:red:dark_red>⚠ <white>Inventory access</white> is restricted during combat!</gradient>");
@Comment({
"# Message displayed when a player attempts to place a block during combat.",
"# The {MODE} placeholder is replaced with the block placement mode (ABOVE/BELOW).",
"# The {Y} placeholder is replaced with the Y coordinate set in the config."
"# Message displayed when a player attempts to place a block during combat.",
"# The {MODE} placeholder is replaced with the block placement mode (ABOVE/BELOW).",
"# The {Y} placeholder is replaced with the Y coordinate set in the config."
})
public Notice blockPlacingBlockedDuringCombat =
Notice.chat("<gradient:red:yellow>⚠ Block placement <white>{MODE} Y:{Y}</white> is restricted!</gradient>");
public Notice blockPlacingBlockedDuringCombat = Notice
.chat("<gradient:red:yellow>⚠ Block placement <white>{MODE} Y:{Y}</white> is restricted!</gradient>");
@Comment({
"# Message displayed when a player attempts to enter a restricted region during combat.",
"# This message informs the player that they cannot enter the region while in combat."
"# Message sent to the player using fireworks when fireworks during elytra flight are disabled"
})
public Notice fireworksDisabled = Notice
.actionbar("<gradient:red:yellow>⚠ You can't use fireworks during combat ⚠</gradient>");
@Comment({
"# Message displayed when a player attempts to enter a restricted region during combat.",
"# This message informs the player that they cannot enter the region while in combat."
})
public Notice cantEnterOnRegion = Notice.chat(
"<gradient:red:dark_red>⚠ Restricted area!</gradient> <white>Cannot enter during combat!</white>");
"<gradient:red:dark_red>⚠ Restricted area!</gradient> <white>Cannot enter during combat!</white>");
public static class AdminMessages extends OkaeriConfig {
@Comment({
"# Message displayed when the console attempts to use a player-only command.",
"# This message informs the console that the command is not available for non-players."
"# Message displayed when the console attempts to use a player-only command.",
"# This message informs the console that the command is not available for non-players."
})
public Notice onlyForPlayers =
Notice.chat("<gradient:red:dark_red>❌ This command is player-only!</gradient>");
public Notice onlyForPlayers = Notice.chat("<gradient:red:dark_red>❌ This command is player-only!</gradient>");
@Comment({
"# Message displayed to an admin when they tag a player.",
"# The {PLAYER} placeholder is replaced with the tagged player's name."
"# Message displayed to an admin when they tag a player.",
"# The {PLAYER} placeholder is replaced with the tagged player's name."
})
public Notice adminTagPlayer =
Notice.chat("<gradient:#00b3ff:#0066ff>⚔ <gray>Tagged player:</gray> <white>{PLAYER}</white></gradient>");
public Notice adminTagPlayer = Notice
.chat("<gradient:#00b3ff:#0066ff>⚔ <gray>Tagged player:</gray> <white>{PLAYER}</white></gradient>");
@Comment({
"# Message displayed when an admin tags multiple players.",
"# The {FIRST_PLAYER} and {SECOND_PLAYER} placeholders are replaced with the players' names."
"# Message displayed when an admin tags multiple players.",
"# The {FIRST_PLAYER} and {SECOND_PLAYER} placeholders are replaced with the players' names."
})
public Notice adminTagMultiplePlayers = Notice.chat(
"<gradient:#00b3ff:#0066ff>⚔ <gray>Tagged:</gray> <white>{FIRST_PLAYER}</white> <gray>and</gray> <white>{SECOND_PLAYER}</white></gradient>");
"<gradient:#00b3ff:#0066ff>⚔ <gray>Tagged:</gray> <white>{FIRST_PLAYER}</white> <gray>and</gray> <white>{SECOND_PLAYER}</white></gradient>");
@Comment({
"# Message displayed to an admin when they remove a player from combat.",
"# The {PLAYER} placeholder is replaced with the player's name."
"# Message displayed to an admin when they remove a player from combat.",
"# The {PLAYER} placeholder is replaced with the player's name."
})
public Notice adminUntagPlayer = Notice.chat(
"<gradient:#00ff88:#00b300>✌ <gray>Removed</gray> <white>{PLAYER}</white> <gray>from combat</gray></gradient>");
"<gradient:#00ff88:#00b300>✌ <gray>Removed</gray> <white>{PLAYER}</white> <gray>from combat</gray></gradient>");
@Comment({
"# Message displayed to an admin when they remove a player from combat.",
"# The {PLAYER} placeholder is replaced with the player's name."
"# Message displayed to an admin when they remove a player from combat.",
"# The {PLAYER} placeholder is replaced with the player's name."
})
public Notice adminUntagAll = Notice.chat(
"<gradient:#00ff88:#00b300>✌ <gray>Removed</gray> <white>{COUNT}</white> <gray> players from combat</gray></gradient>");
"<gradient:#00ff88:#00b300>✌ <gray>Removed</gray> <white>{COUNT}</white> <gray> players from combat</gray></gradient>");
@Comment({
"# Message displayed when an admin attempts to untag a player who is not in combat.",
"# This message informs the admin that the player is not currently in combat."
"# Message displayed when an admin attempts to untag a player who is not in combat.",
"# This message informs the admin that the player is not currently in combat."
})
public Notice adminPlayerNotInCombat =
Notice.chat("<gradient:red:dark_red>❌ <white>{PLAYER}</white> is not in combat!</gradient>");
public Notice adminPlayerNotInCombat = Notice
.chat("<gradient:red:dark_red>❌ <white>{PLAYER}</white> is not in combat!</gradient>");
@Comment({
"# Message displayed when a player is in combat.",
"# The {PLAYER} placeholder is replaced with the player's name."
"# Message displayed when a player is in combat.",
"# The {PLAYER} placeholder is replaced with the player's name."
})
public Notice playerInCombat =
Notice.chat("<gradient:#ff6666:#ff0000>⚔ <white>{PLAYER}</white> <gray>is in combat!</gray></gradient>");
public Notice playerInCombat = Notice
.chat("<gradient:#ff6666:#ff0000>⚔ <white>{PLAYER}</white> <gray>is in combat!</gray></gradient>");
@Comment({
"# Message displayed when a player is not in combat.",
"# The {PLAYER} placeholder is replaced with the player's name."
"# Message displayed when a player is not in combat.",
"# The {PLAYER} placeholder is replaced with the player's name."
})
public Notice playerNotInCombat =
Notice.chat("<gradient:#00ff00:#00b300>✌ <white>{PLAYER}</white> <gray>is safe</gray></gradient>");
public Notice playerNotInCombat = Notice
.chat("<gradient:#00ff00:#00b300>✌ <white>{PLAYER}</white> <gray>is safe</gray></gradient>");
@Comment({
"# Message displayed when an admin attempts to tag themselves.",
"# This message informs the admin that they cannot tag themselves."
"# Message displayed when an admin attempts to tag themselves.",
"# This message informs the admin that they cannot tag themselves."
})
public Notice adminCannotTagSelf = Notice.chat("<gradient:red:dark_red>❌ Cannot tag yourself!</gradient>");
@Comment({
"# Message displayed when an admin disables combat tagging for themselves.",
"# The {TIME} placeholder is replaced with the remaining fight time."
"# Message displayed when an admin disables combat tagging for themselves.",
"# The {TIME} placeholder is replaced with the remaining fight time."
})
public Notice adminTagOutSelf = Notice.chat(
"<gradient:#00b3ff:#0066ff>🛡 <gray>Self-protection active for</gray> <white>{TIME}</white></gradient>");
"<gradient:#00b3ff:#0066ff>🛡 <gray>Self-protection active for</gray> <white>{TIME}</white></gradient>");
@Comment({
"# Message displayed when an admin disables combat tagging for another player.",
"# The {PLAYER} placeholder is replaced with the player's name.",
"# The {TIME} placeholder is replaced with the remaining fight time."
"# Message displayed when an admin disables combat tagging for another player.",
"# The {PLAYER} placeholder is replaced with the player's name.",
"# The {TIME} placeholder is replaced with the remaining fight time."
})
public Notice adminTagOut = Notice.chat(
"<gradient:#00b3ff:#0066ff>🛡 <gray>Protected</gray> <white>{PLAYER}</white> <gray>for</gray> <white>{TIME}</white></gradient>");
"<gradient:#00b3ff:#0066ff>🛡 <gray>Protected</gray> <white>{PLAYER}</white> <gray>for</gray> <white>{TIME}</white></gradient>");
@Comment({
"# Message displayed to a player when their combat tagging is disabled.",
"# The {TIME} placeholder is replaced with the remaining fight time."
"# Message displayed to a player when their combat tagging is disabled.",
"# The {TIME} placeholder is replaced with the remaining fight time."
})
public Notice playerTagOut = Notice.chat(
"<gradient:#00ff88:#00b300>🛡 <gray>Protection active for</gray> <white>{TIME}</white></gradient>");
"<gradient:#00ff88:#00b300>🛡 <gray>Protection active for</gray> <white>{TIME}</white></gradient>");
@Comment({
"# Message displayed when an admin reenables combat tagging for a player.",
"# The {PLAYER} placeholder is replaced with the player's name."
"# Message displayed when an admin reenables combat tagging for a player.",
"# The {PLAYER} placeholder is replaced with the player's name."
})
public Notice adminTagOutOff = Notice.chat(
"<gradient:#00ff88:#00b300>✌ <gray>Re-enabled tagging for</gray> <white>{PLAYER}</white></gradient>");
@@ -206,7 +222,14 @@ public class MessagesSettings extends OkaeriConfig {
"# Message displayed when an admin attempts to tag a player who has tag-out enabled.",
"# This message informs the admin that the player cannot be tagged at this time."
})
public Notice adminTagOutCanceled =
Notice.chat("<gradient:red:dark_red>❌ Player has tag-out protection!</gradient>");
public Notice adminTagOutCanceled = Notice
.chat("<gradient:red:dark_red>❌ Player has tag-out protection!</gradient>");
@Comment({
"# Message displayed when an admin checks combat statistics.",
"# The {COUNT} placeholder is replaced with the number of players currently in combat."
})
public Notice combatStats = Notice
.chat("<gradient:#ff6666:#ff0000>⚔ <gray>Players in combat:</gray> <white>{COUNT}</white></gradient>");
}
}
@@ -0,0 +1,14 @@
package com.eternalcode.combat.config.implementation;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
public class PlaceholderSettings extends OkaeriConfig {
@Comment("Text returned by %eternalcombat_isInCombat_formatted% placeholder when the player is in combat")
public String isInCombatFormattedTrue = "In Combat";
@Comment("Text returned by %eternalcombat_isInCombat_formatted% placeholder when the player is out of combat")
public String isInCombatFormattedFalse = "Not In Combat";
}
@@ -1,10 +1,13 @@
package com.eternalcode.combat.config.implementation;
import com.eternalcode.combat.border.BorderSettings;
import com.eternalcode.combat.fight.death.DeathSettings;
import com.eternalcode.combat.fight.drop.DropSettings;
import com.eternalcode.combat.fight.effect.FightEffectSettings;
import com.eternalcode.combat.fight.knockback.KnockbackSettings;
import com.eternalcode.combat.fight.pearl.FightPearlSettings;
import com.eternalcode.combat.fight.pearl.PearlSettings;
import com.eternalcode.combat.fight.spear.SpearSettings;
import com.eternalcode.combat.fight.trident.TridentSettings;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import java.time.Duration;
@@ -33,7 +36,21 @@ public class PluginConfig extends OkaeriConfig {
"# Settings related to Ender Pearls.",
"# Configure cooldowns, restrictions, and other behaviors for Ender Pearls during combat."
})
public FightPearlSettings pearl = new FightPearlSettings();
public PearlSettings pearl = new PearlSettings();
@Comment({
" ",
"# Settings related to Trident",
"# Configure cooldowns, restrictions, and other behaviors for Trident during combat."
})
public TridentSettings trident = new TridentSettings();
@Comment({
" ",
"# Settings related to Spears with lunge",
"# Set cooldown for spear lunging"
})
public SpearSettings spear = new SpearSettings();
@Comment({
" ",
@@ -42,6 +59,12 @@ public class PluginConfig extends OkaeriConfig {
})
public FightEffectSettings effect = new FightEffectSettings();
@Comment({
" ",
"# This section contains effects displayed on death of the player"
})
public DeathSettings death = new DeathSettings();
@Comment({
" ",
"# Customize how items are dropped when a player dies during combat.",
@@ -70,6 +93,13 @@ public class PluginConfig extends OkaeriConfig {
})
public BlockPlacementSettings blockPlacement = new BlockPlacementSettings();
@Comment({
" ",
"# Settings related to crystal PvP.",
"# Configure behaviors, restrictions, and features specific to crystal PvP combat."
})
public CrystalPvpSettings crystalPvp = new CrystalPvpSettings();
@Comment({
" ",
"# Settings related to commands during combat.",
@@ -98,6 +128,27 @@ public class PluginConfig extends OkaeriConfig {
})
public CombatSettings combat = new CombatSettings();
@Comment({
" ",
"# Settings related to inventory access during combat.",
"# Configure which inventories players can or cannot access while in combat."
})
public InventorySettings inventory = new InventorySettings();
@Comment({
" ",
"# Settings related to sign editing during combat.",
"# Created for sign traps where opening the sign editor can block ender pearl throws."
})
public SignEditingSettings signEditing = new SignEditingSettings();
@Comment({
" ",
"# Settings related to placeholders used in the plugin.",
"# Configure default values returned by placeholders"
})
public PlaceholderSettings placeholders = new PlaceholderSettings();
@Comment({
" ",
"# Customize the messages displayed by the plugin.",
@@ -13,7 +13,8 @@ public class RegionSettings extends OkaeriConfig {
public List<String> blockedRegions = Collections.singletonList("your_region");
@Comment({
"# Prevent players from entering regions where PVP is disabled by WorldGuard.",
"# Prevent players from entering regions where PVP is disabled by the region plugin",
"# (WorldGuard PVP flag, GriefPrevention no-combat-in-claims settings).",
"# Set to 'true' to enforce this restriction, or 'false' to allow PVP in all regions."
})
public boolean preventPvpInRegions = true;
@@ -0,0 +1,13 @@
package com.eternalcode.combat.config.implementation;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
public class SignEditingSettings extends OkaeriConfig {
@Comment({
"# Prevent players from editing signs during combat.",
"# Disabled by default; created for sign traps where sign editing blocks ender pearl throws."
})
public boolean disableSignEditingDuringCombat = false;
}
@@ -55,7 +55,7 @@ public class FightManagerImpl implements FightManager {
@ApiStatus.Experimental
@Override
public FightTagEvent tag(UUID target, Duration delay, CauseOfTag causeOfTag, @Nullable UUID tagger) {
FightTagEvent event = this.eventManager.publishEvent(new FightTagEvent(target, causeOfTag));
FightTagEvent event = this.eventManager.publishEvent(new FightTagEvent(target, causeOfTag, tagger));
if (event.isCancelled()) {
return event;
@@ -16,10 +16,8 @@ import dev.rollczi.litecommands.annotations.permission.Permission;
import dev.rollczi.litecommands.annotations.priority.Priority;
import dev.rollczi.litecommands.annotations.priority.PriorityValue;
import java.time.Duration;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -49,7 +47,6 @@ public class FightTagCommand {
.placeholder("{PLAYER}", target.getName())
.viewer(sender)
.send();
}
@Execute(name = "tag")
@@ -74,7 +71,6 @@ public class FightTagCommand {
.placeholder("{PLAYER}", target.getName())
.viewer(sender)
.send();
}
@Execute(name = "tag")
@@ -122,7 +118,6 @@ public class FightTagCommand {
.placeholder("{SECOND_PLAYER}", secondTarget.getName())
.viewer(sender)
.send();
}
@Execute(name = "untag")
@@ -144,7 +139,6 @@ public class FightTagCommand {
return;
}
this.noticeService.create()
.notice(this.config.messagesSettings.admin.adminUntagPlayer)
.placeholder("{PLAYER}", target.getName())
@@ -169,13 +163,28 @@ public class FightTagCommand {
.send();
}
private void tagoutReasonHandler(CommandSender sender, CancelTagReason cancelReason, MessagesSettings messagesSettings) {
@Execute(name = "stats")
@Permission("eternalcombat.stats")
void stats(@Context CommandSender sender) {
long activeCombatPlayers = this.fightManager.getFights().stream()
.filter(fightTag -> !fightTag.isExpired())
.count();
this.noticeService.create()
.notice(this.config.messagesSettings.admin.combatStats)
.placeholder("{COUNT}", String.valueOf(activeCombatPlayers))
.viewer(sender)
.send();
}
private void tagoutReasonHandler(
CommandSender sender, CancelTagReason cancelReason,
MessagesSettings messagesSettings) {
if (cancelReason == CancelTagReason.TAGOUT) {
this.noticeService.create()
.notice(messagesSettings.admin.adminTagOutCanceled)
.viewer(sender)
.send();
}
}
}
@@ -1,9 +1,12 @@
package com.eternalcode.combat.fight;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.event.CauseOfTag;
import com.eternalcode.combat.fight.event.CauseOfUnTag;
import com.eternalcode.combat.fight.event.FightTagEvent;
import com.eternalcode.combat.notification.NoticeService;
import com.eternalcode.combat.util.DurationUtil;
import java.util.Optional;
import org.bukkit.Server;
import org.bukkit.entity.Player;
@@ -17,7 +20,7 @@ public class FightTask implements Runnable {
private final FightManager fightManager;
private final NoticeService noticeService;
public FightTask(Server server, PluginConfig config, FightManager fightManager, NoticeService noticeService) {
public FightTask(Server server, PluginConfig config, FightManager fightManager, NoticeService noticeService) {
this.server = server;
this.config = config;
this.fightManager = fightManager;
@@ -40,12 +43,29 @@ public class FightTask implements Runnable {
return;
}
if (this.config.combat.keepCombatActiveInVoid
&& player.getLocation().getY() < this.config.combat.voidCombatHeight
&& !this.config.settings.ignoredWorlds.contains(player.getWorld().getName())) {
FightTagEvent tagEvent = this.fightManager.tag(playerUniqueId, this.config.settings.combatTimerDuration, CauseOfTag.VOID, fightTag.getTagger());
if (!tagEvent.isCancelled()) {
fightTag = this.fightManager.getTag(playerUniqueId);
}
}
Duration remaining = fightTag.getRemainingDuration();
String opponent = Optional.ofNullable(fightTag.getTagger())
.filter(uuid -> !uuid.equals(playerUniqueId))
.map(this.server::getPlayer)
.map(Player::getName)
.orElse(this.config.messagesSettings.unknownPlayerPlaceholder);
this.noticeService.create()
.player(player.getUniqueId())
.notice(this.config.messagesSettings.combatNotification)
.placeholder("{TIME}", DurationUtil.format(remaining, this.config.messagesSettings.withoutMillis))
.placeholder("{OPPONENT}", opponent)
.send();
}
@@ -0,0 +1,54 @@
package com.eternalcode.combat.fight.blocker;
import com.eternalcode.combat.WhitelistBlacklistMode;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.notification.NoticeService;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.util.StringUtil;
public class CommandsBlocker implements Listener {
private final FightManager fightManager;
private final NoticeService noticeService;
private final PluginConfig config;
public CommandsBlocker(FightManager fightManager, NoticeService noticeService, PluginConfig config) {
this.fightManager = fightManager;
this.noticeService = noticeService;
this.config = config;
}
@EventHandler
void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
UUID playerUniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(playerUniqueId)) {
return;
}
String command = event.getMessage().substring(1);
boolean isAnyMatch = this.config.commands.restrictedCommands.stream()
.anyMatch(restrictedCommand -> StringUtil.startsWithIgnoreCase(command, restrictedCommand));
WhitelistBlacklistMode mode = this.config.commands.commandRestrictionMode;
boolean shouldCancel = mode.shouldBlock(isAnyMatch);
if (shouldCancel) {
event.setCancelled(true);
this.noticeService.create()
.player(playerUniqueId)
.notice(this.config.messagesSettings.commandDisabledDuringCombat)
.send();
}
}
}
@@ -0,0 +1,105 @@
package com.eternalcode.combat.fight.blocker;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import java.time.Duration;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityToggleGlideEvent;
import org.bukkit.event.player.PlayerMoveEvent;
public class ElytraBlocker implements Listener {
private final FightManager fightManager;
private final PluginConfig config;
private final Cache<UUID, Boolean> fallProtection = Caffeine.newBuilder()
.expireAfterWrite(Duration.ofSeconds(10))
.build();
public ElytraBlocker(FightManager fightManager, PluginConfig config) {
this.fightManager = fightManager;
this.config = config;
}
@EventHandler
void onToggleGlide(EntityToggleGlideEvent event) {
if (!this.config.combat.disableElytraUsage) {
return;
}
if (!(event.getEntity() instanceof Player player)) {
return;
}
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
if (event.isGliding()) {
event.setCancelled(true);
player.setGliding(false);
}
}
@EventHandler
void onMoveWhileGliding(PlayerMoveEvent event) {
if (!this.config.combat.disableElytraUsage) {
return;
}
Player player = event.getPlayer();
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
if (player.isGliding()) {
player.setGliding(false);
player.setVelocity(player.getVelocity().setY(-10));
player.setFallDistance(0f);
fallProtection.put(uniqueId, true);
}
}
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player player)) {
return;
}
if (event.getCause() != EntityDamageEvent.DamageCause.FALL) {
return;
}
if (fallProtection.get(player.getUniqueId(), key -> false)) {
event.setCancelled(true);
}
}
@EventHandler
void onDamage(EntityDamageEvent event) {
if (!this.config.combat.disableElytraOnDamage) {
return;
}
if (!(event.getEntity() instanceof Player player)) {
return;
}
UUID uniqueId = player.getUniqueId();
if (this.fightManager.isInCombat(uniqueId) && player.isGliding()) {
player.setGliding(false);
}
}
}
@@ -0,0 +1,132 @@
package com.eternalcode.combat.fight.blocker;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.FightTagEvent;
import com.eternalcode.combat.notification.NoticeService;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class ElytraEquipBlocker implements Listener {
private final FightManager fightManager;
private final NoticeService noticeService;
private final PluginConfig config;
private final Server server;
public ElytraEquipBlocker(FightManager fightManager, NoticeService noticeService, PluginConfig config, Server server) {
this.fightManager = fightManager;
this.noticeService = noticeService;
this.config = config;
this.server = server;
}
@EventHandler
void onInventoryClick(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player player)) {
return;
}
if (!this.config.combat.unequipElytraOnCombat) {
return;
}
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
if (event.getCurrentItem() == null) {
return;
}
if (event.getCurrentItem().getType() == Material.ELYTRA) {
event.setCancelled(true);
this.noticeService.create()
.player(uniqueId)
.notice(this.config.messagesSettings.elytraDisabledDuringCombat)
.send();
}
}
@EventHandler
void onTag(FightTagEvent event) {
UUID uniqueId = event.getPlayer();
Player player = this.server.getPlayer(uniqueId);
if (player == null) {
return;
}
if (this.config.combat.unequipElytraOnCombat) {
ItemStack chest = player.getInventory().getChestplate();
if (chest != null && chest.getType() == Material.ELYTRA) {
removeChestplateIfElytra(player);
this.noticeService.create()
.player(uniqueId)
.notice(this.config.messagesSettings.elytraDisabledDuringCombat)
.send();
}
}
}
private void removeChestplateIfElytra(Player player) {
ItemStack chestplate = player.getInventory().getChestplate();
if (chestplate != null && chestplate.getType() == Material.ELYTRA) {
player.getInventory().setChestplate(null);
HashMap<Integer, ItemStack> leftover = player.getInventory().addItem(chestplate);
leftover.values().forEach(item ->
player.getWorld().dropItemNaturally(player.getLocation(), item)
);
}
}
@EventHandler
void onInteract(PlayerInteractEvent event) {
if (!this.config.combat.unequipElytraOnCombat) {
return;
}
if (event.getItem() == null) {
return;
}
if (event.getItem().getType() != Material.ELYTRA) {
return;
}
Player player = event.getPlayer();
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
switch (event.getAction()) {
case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> {
event.setCancelled(true);
this.noticeService.create()
.player(uniqueId)
.notice(this.config.messagesSettings.elytraDisabledDuringCombat)
.send();
}
}
}
}
@@ -0,0 +1,86 @@
package com.eternalcode.combat.fight.blocker;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.FightTagEvent;
import com.eternalcode.combat.fight.event.FightUntagEvent;
import java.util.UUID;
import org.bukkit.GameMode;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerToggleFlightEvent;
public class FlyingBlocker implements Listener {
private final FightManager fightManager;
private final PluginConfig config;
private final Server server;
public FlyingBlocker(FightManager fightManager, PluginConfig config, Server server) {
this.fightManager = fightManager;
this.config = config;
this.server = server;
}
@EventHandler
void onFly(PlayerToggleFlightEvent event) {
if (!this.config.combat.disableFlying) {
return;
}
Player player = event.getPlayer();
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
if (event.isFlying()) {
player.setAllowFlight(false);
event.setCancelled(true);
}
}
@EventHandler
void onTag(FightTagEvent event) {
UUID uniqueId = event.getPlayer();
Player player = this.server.getPlayer(uniqueId);
if (player == null) {
return;
}
if (this.config.combat.disableFlying) {
GameMode gameMode = player.getGameMode();
if (gameMode != GameMode.CREATIVE && gameMode != GameMode.SPECTATOR) {
player.setAllowFlight(false);
player.setFlying(false);
}
}
}
@EventHandler
void onUnTag(FightUntagEvent event) {
if (!this.config.combat.disableFlying) {
return;
}
UUID uniqueId = event.getPlayer();
Player player = this.server.getPlayer(uniqueId);
if (player == null) {
return;
}
GameMode playerGameMode = player.getGameMode();
if (playerGameMode == GameMode.CREATIVE || playerGameMode == GameMode.SPECTATOR) {
player.setAllowFlight(true);
}
}
}
@@ -0,0 +1,49 @@
package com.eternalcode.combat.fight.blocker;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.notification.NoticeService;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
public class InventoryContainersBlocker implements Listener {
private final FightManager fightManager;
private final PluginConfig config;
private final NoticeService noticeService;
public InventoryContainersBlocker(FightManager fightManager, PluginConfig config, NoticeService noticeService) {
this.fightManager = fightManager;
this.config = config;
this.noticeService = noticeService;
}
@EventHandler
void onOpenInventory(InventoryOpenEvent event) {
Player player = (Player) event.getPlayer();
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
InventoryType inventoryType = event.getInventory().getType();
boolean isInRestrictedList = this.config.inventory.restrictedInventoryTypes.contains(inventoryType);
boolean shouldBlock = this.config.inventory.inventoryAccessMode.shouldBlock(isInRestrictedList);
if (shouldBlock) {
event.setCancelled(true);
this.noticeService.create()
.player(uniqueId)
.notice(this.config.messagesSettings.inventoryBlockedDuringCombat)
.send();
}
}
}
@@ -0,0 +1,81 @@
package com.eternalcode.combat.fight.blocker;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.config.implementation.BlockPlacementSettings;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.notification.NoticeService;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import java.util.List;
import java.util.UUID;
public class PlaceBlockBlocker implements Listener {
private final FightManager fightManager;
private final NoticeService noticeService;
private final PluginConfig config;
public PlaceBlockBlocker(FightManager fightManager, NoticeService noticeService, PluginConfig config) {
this.fightManager = fightManager;
this.noticeService = noticeService;
this.config = config;
}
@EventHandler
void onPlace(BlockPlaceEvent event) {
if (!this.config.blockPlacement.disableBlockPlacing) {
return;
}
Player player = event.getPlayer();
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
Block block = event.getBlock();
int level = block.getY();
List<Material> specificBlocksToPreventPlacing = this.config.blockPlacement.restrictedBlockTypes;
boolean isPlacementBlocked = this.isPlacementBlocked(level);
if (isPlacementBlocked && specificBlocksToPreventPlacing.isEmpty()) {
event.setCancelled(true);
this.noticeService.create()
.player(uniqueId)
.notice(this.config.messagesSettings.blockPlacingBlockedDuringCombat)
.placeholder("{Y}", String.valueOf(this.config.blockPlacement.blockPlacementYCoordinate))
.placeholder("{MODE}", this.config.blockPlacement.blockPlacementModeDisplayName)
.send();
}
Material blockMaterial = block.getType();
boolean isBlockInDisabledList = specificBlocksToPreventPlacing.contains(blockMaterial);
if (isPlacementBlocked && isBlockInDisabledList) {
event.setCancelled(true);
this.noticeService.create()
.player(uniqueId)
.notice(this.config.messagesSettings.blockPlacingBlockedDuringCombat)
.placeholder("{Y}", String.valueOf(this.config.blockPlacement.blockPlacementYCoordinate))
.placeholder("{MODE}", this.config.blockPlacement.blockPlacementModeDisplayName)
.send();
}
}
private boolean isPlacementBlocked(int level) {
return this.config.blockPlacement.blockPlacementMode == BlockPlacementSettings.BlockPlacingMode.ABOVE
? level > this.config.blockPlacement.blockPlacementYCoordinate
: level < this.config.blockPlacement.blockPlacementYCoordinate;
}
}
@@ -0,0 +1,63 @@
package com.eternalcode.combat.fight.blocker;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Event.Result;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class SignEditingBlocker implements Listener {
private final FightManager fightManager;
private final PluginConfig config;
public SignEditingBlocker(FightManager fightManager, PluginConfig config) {
this.fightManager = fightManager;
this.config = config;
}
@EventHandler(ignoreCancelled = true)
void onInteract(PlayerInteractEvent event) {
if (!this.config.signEditing.disableSignEditingDuringCombat) {
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
Block clickedBlock = event.getClickedBlock();
if (clickedBlock == null || !isSign(clickedBlock.getType())) {
return;
}
Player player = event.getPlayer();
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
event.setUseInteractedBlock(Result.DENY);
ItemStack item = event.getItem();
if (item != null && isEnderPearl(item.getType()) && event.useItemInHand() != Result.DENY) {
event.setUseItemInHand(Result.ALLOW);
}
}
static boolean isSign(Material material) {
return material.name().endsWith("_SIGN");
}
static boolean isEnderPearl(Material material) {
return material == Material.ENDER_PEARL;
}
}
@@ -1,237 +0,0 @@
package com.eternalcode.combat.fight.controller;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.WhitelistBlacklistMode;
import com.eternalcode.combat.config.implementation.BlockPlacementSettings;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.FightUntagEvent;
import com.eternalcode.combat.notification.NoticeService;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityToggleGlideEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import java.util.List;
import java.util.UUID;
import org.bukkit.util.StringUtil;
public class FightActionBlockerController implements Listener {
private final FightManager fightManager;
private final NoticeService noticeService;
private final PluginConfig config;
private final Server server;
public FightActionBlockerController(FightManager fightManager, NoticeService noticeService, PluginConfig config, Server server) {
this.fightManager = fightManager;
this.noticeService = noticeService;
this.config = config;
this.server = server;
}
@EventHandler
void onPlace(BlockPlaceEvent event) {
if (!this.config.blockPlacement.disableBlockPlacing) {
return;
}
Player player = event.getPlayer();
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
Block block = event.getBlock();
int level = block.getY();
List<Material> specificBlocksToPreventPlacing = this.config.blockPlacement.restrictedBlockTypes;
boolean isPlacementBlocked = this.isPlacementBlocked(level);
if (isPlacementBlocked && specificBlocksToPreventPlacing.isEmpty()) {
event.setCancelled(true);
this.noticeService.create()
.player(uniqueId)
.notice(this.config.messagesSettings.blockPlacingBlockedDuringCombat)
.placeholder("{Y}", String.valueOf(this.config.blockPlacement.blockPlacementYCoordinate))
.placeholder("{MODE}", this.config.blockPlacement.blockPlacementModeDisplayName)
.send();
}
Material blockMaterial = block.getType();
boolean isBlockInDisabledList = specificBlocksToPreventPlacing.contains(blockMaterial);
if (isPlacementBlocked && isBlockInDisabledList) {
event.setCancelled(true);
this.noticeService.create()
.player(uniqueId)
.notice(this.config.messagesSettings.blockPlacingBlockedDuringCombat)
.placeholder("{Y}", String.valueOf(this.config.blockPlacement.blockPlacementYCoordinate))
.placeholder("{MODE}", this.config.blockPlacement.blockPlacementModeDisplayName)
.send();
}
}
private boolean isPlacementBlocked(int level) {
return this.config.blockPlacement.blockPlacementMode == BlockPlacementSettings.BlockPlacingMode.ABOVE
? level > this.config.blockPlacement.blockPlacementYCoordinate
: level < this.config.blockPlacement.blockPlacementYCoordinate;
}
@EventHandler
void onToggleGlide(EntityToggleGlideEvent event) {
if (!this.config.combat.disableElytraUsage) {
return;
}
if (!(event.getEntity() instanceof Player player)) {
return;
}
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
if (event.isGliding()) {
event.setCancelled(true);
}
}
@EventHandler
void onMoveWhileGliding(PlayerMoveEvent event) {
if (!this.config.combat.disableElytraUsage) {
return;
}
Player player = event.getPlayer();
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
if (player.isGliding()) {
player.setGliding(false);
}
}
@EventHandler
void onFly(PlayerToggleFlightEvent event) {
if (!this.config.combat.disableFlying) {
return;
}
Player player = event.getPlayer();
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
if (event.isFlying()) {
player.setAllowFlight(false);
event.setCancelled(true);
}
}
@EventHandler
void onUnTag(FightUntagEvent event) {
if (!this.config.combat.disableFlying) {
return;
}
UUID uniqueId = event.getPlayer();
Player player = this.server.getPlayer(uniqueId);
if (player == null) {
return;
}
GameMode playerGameMode = player.getGameMode();
if (playerGameMode == GameMode.CREATIVE || playerGameMode == GameMode.SPECTATOR) {
player.setAllowFlight(true);
}
}
@EventHandler
void onDamage(EntityDamageEvent event) {
if (!this.config.combat.disableElytraOnDamage) {
return;
}
if (!(event.getEntity() instanceof Player player)) {
return;
}
UUID uniqueId = player.getUniqueId();
if (this.fightManager.isInCombat(uniqueId) && player.isGliding()) {
player.setGliding(false);
}
}
@EventHandler
void onOpenInventory(InventoryOpenEvent event) {
if (!this.config.combat.disableInventoryAccess) {
return;
}
Player player = (Player) event.getPlayer();
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
event.setCancelled(true);
this.noticeService.create()
.player(uniqueId)
.notice(this.config.messagesSettings.inventoryBlockedDuringCombat)
.send();
}
@EventHandler
void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
UUID playerUniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(playerUniqueId)) {
return;
}
String command = event.getMessage().substring(1);
boolean isAnyMatch = this.config.commands.restrictedCommands.stream()
.anyMatch(restrictedCommand -> StringUtil.startsWithIgnoreCase(command, restrictedCommand));
WhitelistBlacklistMode mode = this.config.commands.commandRestrictionMode;
boolean shouldCancel = mode.shouldBlock(isAnyMatch);
if (shouldCancel) {
event.setCancelled(true);
this.noticeService.create()
.player(playerUniqueId)
.notice(this.config.messagesSettings.commandDisabledDuringCombat)
.send();
}
}
}
@@ -0,0 +1,37 @@
package com.eternalcode.combat.fight.controller;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.event.CancelTagReason;
import com.eternalcode.combat.fight.event.FightTagEvent;
import java.util.UUID;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class FightBypassAdminController implements Listener {
private final Server server;
private final PluginConfig config;
public FightBypassAdminController(Server server, PluginConfig config) {
this.server = server;
this.config = config;
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
void onFightTagEvent(FightTagEvent event) {
UUID uniqueId = event.getPlayer();
Player player = this.server.getPlayer(uniqueId);
if (player == null) {
return;
}
if (this.config.admin.excludeAdminsFromCombat && player.isOp()) {
event.setCancelReason(CancelTagReason.ADMIN);
event.setCancelled(true);
}
}
}
@@ -0,0 +1,39 @@
package com.eternalcode.combat.fight.controller;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.event.CancelTagReason;
import com.eternalcode.combat.fight.event.FightTagEvent;
import java.util.UUID;
import org.bukkit.GameMode;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class FightBypassCreativeController implements Listener {
private final Server server;
private final PluginConfig config;
public FightBypassCreativeController(Server server, PluginConfig config) {
this.server = server;
this.config = config;
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
void onFightTagEvent(FightTagEvent event) {
UUID uniqueId = event.getPlayer();
Player player = this.server.getPlayer(uniqueId);
if (player == null) {
return;
}
if (this.config.admin.excludeCreativePlayersFromCombat && player.getGameMode() == GameMode.CREATIVE) {
event.setCancelReason(CancelTagReason.CREATIVE_MODE);
event.setCancelled(true);
}
}
}
@@ -0,0 +1,39 @@
package com.eternalcode.combat.fight.controller;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.event.CancelTagReason;
import com.eternalcode.combat.fight.event.FightTagEvent;
import java.util.UUID;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class FightBypassPermissionController implements Listener {
private static final String BYPASS_PERMISSION = "eternalcombat.bypass";
private final Server server;
private final PluginConfig config;
public FightBypassPermissionController(Server server, PluginConfig config) {
this.server = server;
this.config = config;
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
void onFightTagEvent(FightTagEvent event) {
UUID uniqueId = event.getPlayer();
Player player = this.server.getPlayer(uniqueId);
if (player == null) {
return;
}
if (player.hasPermission(BYPASS_PERMISSION) && this.config.admin.excludeAdminsFromCombat) {
event.setCancelReason(CancelTagReason.PERMISSION_BYPASS);
event.setCancelled(true);
}
}
}
@@ -5,6 +5,8 @@ import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.FightTagEvent;
import com.eternalcode.combat.fight.event.FightUntagEvent;
import com.eternalcode.combat.notification.NoticeService;
import java.util.Optional;
import java.util.UUID;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -37,12 +39,23 @@ public class FightMessageController implements Listener {
return;
}
String opponent = this.resolveOpponentName(event.getTagger(), player.getUniqueId());
this.noticeService.create()
.player(player.getUniqueId())
.notice(this.config.messagesSettings.playerTagged)
.placeholder("{OPPONENT}", opponent)
.send();
}
private String resolveOpponentName(UUID tagger, UUID taggedPlayer) {
return Optional.ofNullable(tagger)
.filter(uuid -> !uuid.equals(taggedPlayer))
.map(this.server::getPlayer)
.map(Player::getName)
.orElse(this.config.messagesSettings.unknownPlayerPlaceholder);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
void onUnTag(FightUntagEvent event) {
Player player = this.server.getPlayer(event.getPlayer());
@@ -1,10 +1,10 @@
package com.eternalcode.combat.fight.controller;
import com.eternalcode.combat.FoliaChecker;
import com.eternalcode.combat.WhitelistBlacklistMode;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.CauseOfTag;
import org.bukkit.GameMode;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
@@ -56,11 +56,13 @@ public class FightTagController implements Listener {
return;
}
if (this.cannotBeTagged(attacker)) {
return;
}
UUID targetId = attackedPlayerByPerson.getUniqueId();
UUID attackerId = attacker.getUniqueId();
if (this.cannotBeTagged(attackedPlayerByPerson)) {
if (
targetId.equals(attackerId)
&& FoliaChecker.isFolia()
) {
return;
}
@@ -77,11 +79,9 @@ public class FightTagController implements Listener {
}
Duration combatTime = this.config.settings.combatTimerDuration;
UUID attackedUniqueId = attackedPlayerByPerson.getUniqueId();
UUID attackerUniqueId = attacker.getUniqueId();
this.fightManager.tag(attackedUniqueId, combatTime, CauseOfTag.PLAYER, attackerUniqueId);
this.fightManager.tag(attackerUniqueId, combatTime, CauseOfTag.PLAYER, attackedUniqueId);
this.fightManager.tag(targetId, combatTime, CauseOfTag.PLAYER, attackerId);
this.fightManager.tag(attackerId, combatTime, CauseOfTag.PLAYER, targetId);
}
@@ -99,15 +99,6 @@ public class FightTagController implements Listener {
return;
}
if (this.cannotBeTagged(player)) {
return;
}
boolean hasBypass = player.hasPermission("eternalcombat.bypass");
if (hasBypass) {
return;
}
Duration combatTime = this.config.settings.combatTimerDuration;
UUID uuid = player.getUniqueId();
@@ -145,18 +136,6 @@ public class FightTagController implements Listener {
return this.config.settings.ignoredWorlds.contains(worldName);
}
private boolean cannotBeTagged(Player player) {
if (this.config.admin.excludeAdminsFromCombat && player.hasPermission("eternalcombat.bypass")) {
return true;
}
if (this.config.admin.excludeAdminsFromCombat && player.isOp()) {
return true;
}
return this.config.admin.excludeCreativePlayersFromCombat && player.getGameMode() == GameMode.CREATIVE;
}
}
@@ -1,12 +1,18 @@
package com.eternalcode.combat.fight.controller;
import com.eternalcode.combat.fight.crystalpvp.CrystalPvpConstants;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.CauseOfUnTag;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.logout.LogoutService;
import java.util.Optional;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
public class FightUnTagController implements Listener {
@@ -26,33 +32,55 @@ public class FightUnTagController implements Listener {
Player player = event.getEntity();
Player killer = player.getKiller();
UUID playerUniqueId = player.getUniqueId();
Optional<UUID> optionalKiller;
if (killer != null) {
optionalKiller = Optional.of(killer.getUniqueId());
} else {
optionalKiller = this.getCrystalKiller(player);
}
if (!this.fightManager.isInCombat(player.getUniqueId())) {
return;
}
CauseOfUnTag cause = this.getDeathCause(player, killer);
CauseOfUnTag cause = this.getDeathCause(playerUniqueId, optionalKiller.orElse(null));
this.fightManager.untag(player.getUniqueId(), cause);
if (killer != null && this.config.combat.releaseAttackerOnVictimDeath) {
this.fightManager.untag(killer.getUniqueId(), CauseOfUnTag.ATTACKER_RELEASE);
if (optionalKiller.isPresent() && this.config.combat.releaseAttackerOnVictimDeath) {
this.fightManager.untag(optionalKiller.get(), CauseOfUnTag.ATTACKER_RELEASE);
}
}
private CauseOfUnTag getDeathCause(Player player, Player killer) {
if (this.logoutService.hasLoggedOut(player.getUniqueId())) {
private CauseOfUnTag getDeathCause(UUID playerUniqueId, UUID killerUniqueId) {
if (this.logoutService.hasLoggedOut(playerUniqueId)) {
return CauseOfUnTag.LOGOUT;
}
if (killer == null) {
if (killerUniqueId == null) {
return CauseOfUnTag.DEATH;
}
if (this.fightManager.isInCombat(killer.getUniqueId())) {
if (this.fightManager.isInCombat(killerUniqueId)) {
return CauseOfUnTag.DEATH_BY_PLAYER;
}
return CauseOfUnTag.DEATH;
}
private Optional<UUID> getCrystalKiller(Player player) {
EntityDamageEvent lastDamageCause = player.getLastDamageCause();
if (lastDamageCause instanceof EntityDamageByBlockEvent damageByBlockEvent) {
return CrystalPvpConstants.getDamagerUniqueIdFromRespawnAnchor(damageByBlockEvent);
}
if (lastDamageCause instanceof EntityDamageByEntityEvent damageByEntityEvent) {
return CrystalPvpConstants.getDamagerUniqueIdFromEndCrystal(damageByEntityEvent);
}
return Optional.empty();
}
}
@@ -0,0 +1,33 @@
package com.eternalcode.combat.fight.crystalpvp;
import java.util.Optional;
import java.util.UUID;
import org.bukkit.metadata.MetadataValueAdapter;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class CrystalMetadata extends MetadataValueAdapter {
private UUID damager;
protected CrystalMetadata(@NotNull Plugin owningPlugin, UUID damager) {
super(owningPlugin);
this.damager = damager;
}
Optional<UUID> getDamager() {
return Optional.ofNullable(this.damager);
}
@Override
public @Nullable UUID value() {
return this.damager;
}
@Override
public void invalidate() {
this.damager = null;
}
}
@@ -0,0 +1,81 @@
package com.eternalcode.combat.fight.crystalpvp;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.CauseOfTag;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.EnderCrystal;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.metadata.MetadataValue;
public class CrystalPvpConstants {
private CrystalPvpConstants() {
}
public static final String CRYSTAL_METADATA = "eternalcombat:crystal";
public static final String ANCHOR_METADATA = "eternalcombat:anchor";
public static Optional<UUID> getDamagerUniqueIdFromEndCrystal(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof EnderCrystal enderCrystal) {
List<MetadataValue> metadataValues = enderCrystal.getMetadata(CRYSTAL_METADATA);
return metadataValues
.stream()
.filter(source -> source instanceof CrystalMetadata)
.map(meta -> (CrystalMetadata) meta)
.findFirst()
.flatMap(CrystalMetadata::getDamager);
}
return Optional.empty();
}
public static Optional<UUID> getDamagerUniqueIdFromRespawnAnchor(EntityDamageByBlockEvent event) {
Block damager = event.getDamager();
if (damager == null) {
return Optional.empty();
}
if (damager.getType() != Material.RESPAWN_ANCHOR) {
return Optional.empty();
}
return damager.getMetadata(ANCHOR_METADATA).stream()
.filter(source -> source instanceof CrystalMetadata)
.map(meta -> (CrystalMetadata) meta)
.findFirst()
.flatMap(metadata -> metadata.getDamager());
}
static void handleCombatTag(
Optional<UUID> optionalDamagerUUID,
Player player,
FightManager fightManager,
PluginConfig pluginConfig
) {
UUID victimUniqueId = player.getUniqueId();
if (optionalDamagerUUID.isPresent()) {
UUID damagerUniqueId = optionalDamagerUUID.get();
if (!damagerUniqueId.equals(victimUniqueId)) {
fightManager.tag(
damagerUniqueId,
pluginConfig.settings.combatTimerDuration,
CauseOfTag.CRYSTAL,
victimUniqueId
);
fightManager.tag(
victimUniqueId,
pluginConfig.settings.combatTimerDuration,
CauseOfTag.CRYSTAL,
damagerUniqueId
);
}
}
}
}
@@ -0,0 +1,70 @@
package com.eternalcode.combat.fight.crystalpvp;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import java.util.Optional;
import java.util.UUID;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EnderCrystal;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.plugin.Plugin;
import static com.eternalcode.combat.fight.crystalpvp.CrystalPvpConstants.CRYSTAL_METADATA;
public class EndCrystalController implements Listener {
private final Plugin plugin;
private final FightManager fightManager;
private final PluginConfig pluginConfig;
public EndCrystalController(Plugin plugin, FightManager fightManager, PluginConfig pluginConfig) {
this.plugin = plugin;
this.fightManager = fightManager;
this.pluginConfig = pluginConfig;
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
void onPlayerDamageCrystal(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof EnderCrystal enderCrystal) {
if (event.getDamager() instanceof Arrow arrow && arrow.getShooter() instanceof Player player) {
enderCrystal.setMetadata(CRYSTAL_METADATA, new CrystalMetadata(this.plugin, player.getUniqueId()));
}
if (!(event.getDamager() instanceof Player player)) {
return;
}
enderCrystal.setMetadata(CRYSTAL_METADATA, new CrystalMetadata(this.plugin, player.getUniqueId()));
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
void onDamage(EntityDamageByEntityEvent event) {
if (!this.pluginConfig.crystalPvp.tagFromCrystals) {
return;
}
if (pluginConfig.settings.ignoredWorlds.contains(event.getEntity().getWorld().getName())) {
return;
}
Optional<UUID> optionalDamagerUUID = CrystalPvpConstants.getDamagerUniqueIdFromEndCrystal(event);
if (optionalDamagerUUID.isEmpty()) {
return;
}
if (event.getEntity() instanceof Player player) {
CrystalPvpConstants.handleCombatTag(
optionalDamagerUUID,
player,
this.fightManager,
this.pluginConfig
);
}
}
}
@@ -0,0 +1,89 @@
package com.eternalcode.combat.fight.crystalpvp;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import java.util.Optional;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.type.RespawnAnchor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import static com.eternalcode.combat.fight.crystalpvp.CrystalPvpConstants.ANCHOR_METADATA;
public class RespawnAnchorController implements Listener {
private final Plugin plugin;
private final FightManager fightManager;
private final PluginConfig pluginConfig;
public RespawnAnchorController(Plugin plugin, FightManager fightManager, PluginConfig pluginConfig) {
this.plugin = plugin;
this.fightManager = fightManager;
this.pluginConfig = pluginConfig;
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
void onAnchorInteract(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
if (block == null || block.getType() != Material.RESPAWN_ANCHOR) {
return;
}
if (!(block.getBlockData() instanceof RespawnAnchor respawnAnchor)) {
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
int charges = respawnAnchor.getCharges();
ItemStack item = event.getItem();
boolean isGlowstone = item != null && item.getType() == Material.GLOWSTONE;
if ((charges > 0 && !isGlowstone) || charges == respawnAnchor.getMaximumCharges()) {
addMetaData(event, block);
}
}
private void addMetaData(PlayerInteractEvent event, Block block) {
block.setMetadata(
ANCHOR_METADATA,
new CrystalMetadata(this.plugin, event.getPlayer().getUniqueId())
);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
void onAnchorExplosion(EntityDamageByBlockEvent event) {
if (!this.pluginConfig.crystalPvp.tagFromRespawnAnchor) {
return;
}
if (pluginConfig.settings.ignoredWorlds.contains(event.getEntity().getWorld().getName())) {
return;
}
if (!(event.getEntity() instanceof Player player)) {
return;
}
Optional<UUID> optionalDamagerUniqueId = CrystalPvpConstants.getDamagerUniqueIdFromRespawnAnchor(event);
if (optionalDamagerUniqueId.isEmpty()) {
return;
}
CrystalPvpConstants.handleCombatTag(optionalDamagerUniqueId, player, this.fightManager, this.pluginConfig);
}
}
@@ -0,0 +1,152 @@
package com.eternalcode.combat.fight.death;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.event.CauseOfUnTag;
import com.eternalcode.combat.fight.event.FightUntagEvent;
import com.eternalcode.commons.scheduler.Scheduler;
import java.time.Duration;
import java.util.UUID;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.Plugin;
public class DeathFlareController implements Listener {
private final PluginConfig pluginConfig;
private final Server server;
private final Scheduler scheduler;
private final NamespacedKey key;
public DeathFlareController(PluginConfig pluginConfig, Server server, Scheduler scheduler, Plugin plugin) {
this.pluginConfig = pluginConfig;
this.server = server;
this.scheduler = scheduler;
this.key = NamespacedKey.fromString("eternalcombat_firework", plugin);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFightUntagEvent(FightUntagEvent event) {
CauseOfUnTag cause = event.getCause();
if (cause != CauseOfUnTag.DEATH && cause != CauseOfUnTag.DEATH_BY_PLAYER) {
return;
}
UUID uniqueId = event.getPlayer();
Player player = this.server.getPlayer(uniqueId);
if (player == null) {
return;
}
if (this.pluginConfig.death.firework.inCombat && !this.pluginConfig.death.firework.afterEveryDeath) {
this.spawnFlare(player);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerDeathEventFlare(PlayerDeathEvent event) {
Player player = event.getEntity();
if (this.pluginConfig.death.firework.afterEveryDeath) {
this.spawnFlare(player);
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Firework firework && firework.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
event.setCancelled(true);
}
}
private void spawnFlare(Player player) {
Location deathLocation = player.getLocation();
World world = deathLocation.getWorld();
Firework flare = world.spawn(deathLocation, Firework.class);
flare.getPersistentDataContainer().set(key, PersistentDataType.STRING, "true");
FireworkMeta meta = flare.getFireworkMeta();
Color primaryColor = this.decodeColor(this.pluginConfig.death.firework.primaryColor, "primary");
Color fadeColor = this.decodeColor(this.pluginConfig.death.firework.fadeColor, "fade");
FireworkEffect effect = FireworkEffect.builder()
.with(this.pluginConfig.death.firework.fireworkType)
.withColor(primaryColor)
.withFade(fadeColor)
.trail(true)
.flicker(true)
.build();
meta.addEffect(effect);
meta.setPower(this.pluginConfig.death.firework.power);
flare.setFireworkMeta(meta);
if (this.pluginConfig.death.firework.particlesEnabled) {
scheduleParticles(flare, world);
}
}
private void scheduleParticles(Firework flare, World world) {
this.scheduler.runLaterAsync(
() -> {
if (flare.isDead() || !flare.isValid()) {
return;
}
this.spawnParticles(world, flare);
this.scheduleParticles(flare, world);
}, Duration.ofMillis(50)
);
}
private Color decodeColor(String firework, String name) {
try {
return Color.fromRGB(Integer.decode(firework));
}
catch (NumberFormatException exception) {
throw new IllegalArgumentException(
"Invalid " + name + " format in plugin configuration" + firework,
exception
);
}
}
private void spawnParticles(World world, Firework flare) {
Location location = flare.getLocation();
world.spawnParticle(
this.pluginConfig.death.firework.mainParticle.get(),
location,
this.pluginConfig.death.firework.mainParticleCount,
0.05,
0.05,
0.05,
0.01
);
world.spawnParticle(
this.pluginConfig.death.firework.secondaryParticle.get(),
location,
this.pluginConfig.death.firework.secondaryParticleCount,
0.1,
0.1,
0.1,
0.01
);
}
}
@@ -0,0 +1,56 @@
package com.eternalcode.combat.fight.death;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.event.CauseOfUnTag;
import com.eternalcode.combat.fight.event.FightUntagEvent;
import java.util.UUID;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
public class DeathLightningController implements Listener {
private final PluginConfig pluginConfig;
private final Server server;
public DeathLightningController(PluginConfig pluginConfig, Server server) {
this.pluginConfig = pluginConfig;
this.server = server;
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFightUntagEvent(FightUntagEvent event) {
CauseOfUnTag cause = event.getCause();
if (cause != CauseOfUnTag.DEATH && cause != CauseOfUnTag.DEATH_BY_PLAYER) {
return;
}
UUID uniqueId = event.getPlayer();
Player player = this.server.getPlayer(uniqueId);
if (player == null) {
return;
}
if (this.pluginConfig.death.lightning.inCombat && !this.pluginConfig.death.lightning.afterEveryDeath) {
this.lightningStrike(player);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerDeathEventLightning(PlayerDeathEvent event) {
Player player = event.getEntity();
if (this.pluginConfig.death.lightning.afterEveryDeath) {
lightningStrike(player);
}
}
private void lightningStrike(Player player) {
player.getWorld().strikeLightningEffect(player.getLocation());
}
}
@@ -0,0 +1,77 @@
package com.eternalcode.combat.fight.death;
import com.cryptomorin.xseries.particles.XParticle;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import org.bukkit.FireworkEffect;
public class DeathSettings extends OkaeriConfig {
@Comment({
"Settings related to lightning effect upon death",
"Setting both afterEveryDeath and inCombat to false will disable this feature completely"
})
public LightningSettings lightning = new LightningSettings();
public static class LightningSettings extends OkaeriConfig {
@Comment("Should lightning spawn on every death?")
public boolean afterEveryDeath = false;
@Comment("Should lightning spawn on ONLY deaths in combat?")
public boolean inCombat = true;
}
@Comment({
"Settings for the Arc Raiders style flare (firework)",
"Setting both afterEveryDeath and inCombat to false will disable this feature completely"
})
public FlareSettings firework = new FlareSettings();
public static class FlareSettings extends OkaeriConfig {
@Comment("Should firework (flare) spawn on every death?")
public boolean afterEveryDeath = false;
@Comment("Should firework (flare) spawn on ONLY deaths in combat?")
public boolean inCombat = false;
@Comment("Power of firework - how long till explosion (please enter positive number)")
public int power = 2;
@Comment({
"The firework (flare) effect type (BALL, BALL_LARGE, STAR, BURST, CREEPER)",
"Reference: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/FireworkEffect.Type.html"
})
public FireworkEffect.Type fireworkType = FireworkEffect.Type.BALL;
@Comment("Hex color for the firework (flare)")
public String primaryColor = "#a80022";
@Comment("Hex color for the fade of firework (flare)")
public String fadeColor = "#0a0a0a";
@Comment("Toggle on/off additional particles spawned in the firework (flare) path")
public boolean particlesEnabled = true;
@Comment({
"The main trail particle (e.g., CAMPFIRE_COSY_SMOKE, SMOKE_LARGE)",
"Reference: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html"
})
public XParticle mainParticle = XParticle.CAMPFIRE_COSY_SMOKE;
@Comment("Count of main particles spawned on each tick")
public int mainParticleCount = 3;
@Comment({
"The secondary trail particle (e.g., CAMPFIRE_COSY_SMOKE, SMOKE_LARGE)",
"Reference: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.html"
})
public XParticle secondaryParticle = XParticle.SMALL_FLAME;
@Comment("Count of secondary particles spawned on each tick")
public int secondaryParticleCount = 3;
}
}
@@ -4,7 +4,6 @@ import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.CauseOfUnTag;
import com.eternalcode.combat.fight.event.FightTagEvent;
import com.eternalcode.combat.fight.event.FightUntagEvent;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -50,9 +49,11 @@ public class FightEffectController implements Listener {
}
if (event.getCause() == CauseOfUnTag.LOGOUT) {
Player player = Bukkit.getPlayer(event.getPlayer());
Player player = this.server.getPlayer(event.getPlayer());
if (player == null) {
return;
}
assert player != null;
this.effectService.clearStoredEffects(player);
}
}
@@ -80,9 +81,11 @@ public class FightEffectController implements Listener {
return;
}
if (event.getCause() == CauseOfUnTag.DEATH_BY_PLAYER || event.getCause() == CauseOfUnTag.DEATH) {
Player player = Bukkit.getPlayer(event.getPlayer());
Player player = this.server.getPlayer(event.getPlayer());
if (player == null) {
return;
}
assert player != null;
this.effectService.clearStoredEffects(player);
}
}
@@ -1,11 +1,10 @@
package com.eternalcode.combat.fight.effect;
import com.cryptomorin.xseries.XPotion;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import org.bukkit.potion.PotionEffectType;
import java.util.Map;
import org.bukkit.potion.PotionEffectType;
public class FightEffectSettings extends OkaeriConfig {
@@ -16,11 +15,20 @@ public class FightEffectSettings extends OkaeriConfig {
"# If the option above is set to true, you can add effects to players in combat below",
"# You can find a list of all potion effects here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionEffectType.html",
"# Correct format: 'EFFECT_TYPE:AMPLIFIER' Amplifier strength starts from 0, so level 1 gives effect strength 2",
"# Example: SPEED:1, DAMAGE_RESISTANCE:0",
"# Example: SPEED:1, RESISTANCE:0",
})
public Map<PotionEffectType, Integer> customEffects = Map.of(
PotionEffectType.SPEED, 1,
PotionEffectType.DAMAGE_RESISTANCE, 0
requirePotionEffectType(XPotion.SPEED), 1,
requirePotionEffectType(XPotion.RESISTANCE), 0
);
private static PotionEffectType requirePotionEffectType(XPotion potion) {
PotionEffectType potionEffectType = potion.get();
if (potionEffectType == null) {
throw new IllegalStateException("Potion effect " + potion.name() + " is not supported by this server version");
}
return potionEffectType;
}
}
@@ -0,0 +1,55 @@
package com.eternalcode.combat.fight.firework;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.notification.NoticeService;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import java.util.UUID;
public class FireworkController implements Listener {
private final FightManager fightManager;
private final PluginConfig pluginConfig;
private final NoticeService noticeService;
public FireworkController(FightManager fightManager, PluginConfig pluginConfig, NoticeService noticeService) {
this.fightManager = fightManager;
this.pluginConfig = pluginConfig;
this.noticeService = noticeService;
}
@EventHandler
public void onPlayerUseFirework(PlayerInteractEvent event) {
if (!this.pluginConfig.combat.disableFireworks) {
return;
}
Player player = event.getPlayer();
UUID uniqueId = player.getUniqueId();
if (!this.fightManager.isInCombat(uniqueId)) {
return;
}
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
if (!player.isGliding()) {
return;
}
ItemStack item = event.getItem();
if (item != null && item.getType() == Material.FIREWORK_ROCKET) {
event.setCancelled(true);
this.noticeService.player(uniqueId, config -> this.pluginConfig.messagesSettings.fireworksDisabled);
}
}
}
@@ -0,0 +1,129 @@
package com.eternalcode.combat.fight.knockback;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.notification.NoticeService;
import com.eternalcode.combat.region.RegionProvider;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Method;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityEvent;
import org.bukkit.plugin.Plugin;
// EntityMountEvent moved between org.spigotmc, io.papermc.paper and org.bukkit across versions,
// so we resolve it at runtime to stay compatible without bumping the compile API.
public final class KnockbackMountController implements Listener {
private static final String[] EVENT_CLASS_CANDIDATES = {
"org.bukkit.event.entity.EntityMountEvent",
"io.papermc.paper.event.entity.EntityMountEvent",
"org.spigotmc.event.entity.EntityMountEvent",
};
private final NoticeService noticeService;
private final RegionProvider regionProvider;
private final FightManager fightManager;
private final AtomicBoolean mountFailureLogged = new AtomicBoolean();
public KnockbackMountController(NoticeService noticeService, RegionProvider regionProvider, FightManager fightManager) {
this.noticeService = noticeService;
this.regionProvider = regionProvider;
this.fightManager = fightManager;
}
public void register(Plugin plugin) {
Class<? extends Event> eventClass = null;
for (String candidate : EVENT_CLASS_CANDIDATES) {
try {
eventClass = Class.forName(candidate).asSubclass(Event.class);
break;
} catch (ClassNotFoundException | ClassCastException ignored) {
}
}
if (eventClass == null) {
plugin.getLogger().warning("Could not find any EntityMountEvent class; mount protection in regions is disabled.");
return;
}
MethodHandle getMountHandle;
try {
getMountHandle = this.resolveGetMountHandle(eventClass);
} catch (NoSuchMethodException | IllegalAccessException exception) {
plugin.getLogger().log(Level.WARNING, "EntityMountEvent has incompatible getMount() method; mount protection in regions is disabled.", exception);
return;
}
plugin.getServer().getPluginManager().registerEvent(
eventClass,
this,
EventPriority.HIGHEST,
(listener, event) -> this.handle(event, getMountHandle, plugin),
plugin,
true
);
}
private MethodHandle resolveGetMountHandle(Class<? extends Event> eventClass) throws NoSuchMethodException, IllegalAccessException {
if (!EntityEvent.class.isAssignableFrom(eventClass) || !Cancellable.class.isAssignableFrom(eventClass)) {
throw new NoSuchMethodException(eventClass.getName() + " is not a cancellable entity event");
}
Method getMount = eventClass.getMethod("getMount");
if (!Entity.class.isAssignableFrom(getMount.getReturnType())) {
throw new NoSuchMethodException(eventClass.getName() + "#getMount() does not return Entity");
}
return MethodHandles.publicLookup()
.unreflect(getMount)
.asType(MethodType.methodType(Entity.class, Event.class));
}
private void handle(Event event, MethodHandle getMountHandle, Plugin plugin) {
if (!(event instanceof EntityEvent entityEvent) || !(event instanceof Cancellable cancellable)) {
return;
}
if (!(entityEvent.getEntity() instanceof Player player)) {
return;
}
if (!this.fightManager.isInCombat(player.getUniqueId())) {
return;
}
Entity mount;
try {
mount = (Entity) getMountHandle.invokeExact(event);
} catch (Throwable exception) {
this.logMountFailure(plugin, exception);
return;
}
if (mount == null || !this.regionProvider.isInRegion(mount.getLocation())) {
return;
}
cancellable.setCancelled(true);
this.noticeService.create()
.player(player.getUniqueId())
.notice(config -> config.messagesSettings.cantEnterOnRegion)
.send();
}
private void logMountFailure(Plugin plugin, Throwable exception) {
if (!this.mountFailureLogged.compareAndSet(false, true)) {
return;
}
plugin.getLogger().log(Level.WARNING, "Could not read EntityMountEvent mount; mount protection in regions is skipped.", exception);
}
}
@@ -3,53 +3,21 @@ package com.eternalcode.combat.fight.knockback;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
import java.util.function.Function;
import org.bukkit.Location;
class KnockbackOutsideRegionGenerator {
static Location generate(Point2D min, Point2D max, Location playerLocation) {
NavigableMap<Double, List<Point2D>> points = generatePoints(min, max, Point2D.from(playerLocation));
NavigableMap<Double, Double> distances = new TreeMap<>();
double totalWeight = 0;
Double maxDistance = points.lastKey();
for (double distance : points.keySet()) {
double weight = createWeight(distance, maxDistance);
distances.put(distance, weight);
totalWeight += weight;
}
double rand = Math.random() * totalWeight;
double cumulativeWeight = 0;
for (Map.Entry<Double, Double> entry : distances.entrySet()) {
double distance = entry.getKey();
double weight = entry.getValue();
cumulativeWeight += weight;
if (rand <= cumulativeWeight) {
return getRandom(points.get(distance))
.toLocation(playerLocation);
}
}
return getRandom(points.firstEntry().getValue())
.toLocation(playerLocation);
}
private static Point2D getRandom(List<Point2D> points) {
return points.get((int) (Math.random() * points.size()));
}
private static double createWeight(double distance, double maxDistance) {
double last = Math.log(maxDistance);
double weight = last - Math.log(distance);
return Math.pow(weight, 10);
static Optional<Location> generate(Point2D min, Point2D max, Location playerLocation, Function<Location, Optional<Location>> safeMapper) {
return generatePoints(min, max, Point2D.from(playerLocation)).entrySet().stream()
.flatMap(entry -> entry.getValue().stream())
.map(point2D -> point2D.toLocation(playerLocation))
.flatMap(safeMapper.andThen(validPoint -> validPoint.stream()))
.findFirst();
}
private static NavigableMap<Double, List<Point2D>> generatePoints(Point2D min, Point2D max, Point2D location) {
@@ -78,5 +46,4 @@ class KnockbackOutsideRegionGenerator {
return Math.sqrt(Math.pow(p2.x() - p1.x(), 2) + Math.pow(p2.z() - p1.z(), 2));
}
}
@@ -9,12 +9,14 @@ import java.time.Duration;
import java.util.Optional;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.vehicle.VehicleMoveEvent;
public class KnockbackRegionController implements Listener {
@@ -89,6 +91,46 @@ public class KnockbackRegionController implements Listener {
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
void onVehicleMove(VehicleMoveEvent event) {
Location locationTo = event.getTo();
Location locationFrom = event.getFrom();
if (locationTo.getBlockX() == locationFrom.getBlockX()
&& locationTo.getBlockY() == locationFrom.getBlockY()
&& locationTo.getBlockZ() == locationFrom.getBlockZ()) {
return;
}
for (Entity passenger : event.getVehicle().getPassengers()) {
if (!(passenger instanceof Player player)) {
continue;
}
if (!this.fightManager.isInCombat(player.getUniqueId())) {
continue;
}
Optional<Region> regionOptional = this.regionProvider.getRegion(locationTo);
if (regionOptional.isEmpty()) {
return;
}
Region region = regionOptional.get();
if (region.contains(locationFrom)) {
this.knockbackService.knockback(region, player);
this.knockbackService.forceKnockbackLater(player, region);
} else {
this.knockbackService.knockbackLater(region, player, Duration.ofMillis(50));
}
this.noticeService.create()
.player(player.getUniqueId())
.notice(config -> config.messagesSettings.cantEnterOnRegion)
.send();
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
void onTag(FightTagEvent event) {
Player player = this.server.getPlayer(event.getPlayer());
@@ -1,77 +1,177 @@
package com.eternalcode.combat.fight.knockback;
import com.cryptomorin.xseries.XMaterial;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.region.Point;
import com.eternalcode.combat.region.Region;
import com.eternalcode.combat.region.RegionProvider;
import com.eternalcode.commons.scheduler.Scheduler;
import com.eternalcode.commons.bukkit.scheduler.MinecraftScheduler;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.util.Vector;
public final class KnockbackService {
private static final int FORCE_TELEPORT_MAX_ATTEMPTS = 10;
private static final double KNOCKBACK_DAMPEN_FACTOR = 0.8;
public static final int DEPTH_OF_SEARCHING = 10;
private final PluginConfig config;
private final Scheduler scheduler;
private final MinecraftScheduler scheduler;
private final RegionProvider regionProvider;
private final Map<UUID, Region> insideRegion = new HashMap<>();
public KnockbackService(PluginConfig config, Scheduler scheduler, RegionProvider regionProvider) {
public KnockbackService(PluginConfig config, MinecraftScheduler scheduler, RegionProvider regionProvider) {
this.config = config;
this.scheduler = scheduler;
this.regionProvider = regionProvider;
}
public void knockbackLater(Region region, Player player, Duration duration) {
this.scheduler.runLater(() -> this.knockback(region, player), duration);
scheduler.runLater(() -> this.knockback(region, player), duration);
}
public void knockback(Region region, Player player) {
if (player.isInsideVehicle()) {
player.leaveVehicle();
}
Location currentLocation = player.getLocation();
Vector shortestDirection = getShortestDirectionToEdge(region, currentLocation);
// Reduces player's current velocity BEFORE applying knockback. Helps create a smoother and more consistent knockback.
player.setVelocity(player.getVelocity().multiply(KNOCKBACK_DAMPEN_FACTOR));
double y = Math.min(player.getVelocity().getY(), config.knockback.vertical);
Vector velocity = shortestDirection.multiply(config.knockback.multiplier).setY(y);
player.setFallDistance(0);
player.setVelocity(velocity);
}
private Vector getShortestDirectionToEdge(Region region, Location current) {
double directionToBottomEdge = current.getX() - region.getMin().getX();
double directionToTopEdge = region.getMax().getX() - current.getX();
double directionToLeftEdge = current.getZ() - region.getMin().getZ();
double directionToRightEdge = region.getMax().getZ() - current.getZ();
double shortestDirection = Math.min(
Math.min(directionToBottomEdge, directionToTopEdge),
Math.min(directionToLeftEdge, directionToRightEdge)
);
if (shortestDirection == directionToBottomEdge)
return new Vector(-1, 0, 0);
if (shortestDirection == directionToTopEdge)
return new Vector(1, 0, 0);
if (shortestDirection == directionToLeftEdge)
return new Vector(0, 0, -1);
if (shortestDirection == directionToRightEdge)
return new Vector(0, 0, 1);
throw new IllegalStateException("Failed to determine direction to edge");
}
public void forceKnockbackLater(Player player, Region region) {
if (insideRegion.containsKey(player.getUniqueId())) {
UUID playerId = player.getUniqueId();
if (insideRegion.containsKey(playerId)) {
return;
}
insideRegion.put(player.getUniqueId(), region);
scheduler.runLater(() -> {
insideRegion.remove(player.getUniqueId());
insideRegion.put(playerId, region);
scheduler.runLater(player.getLocation(), () -> {
insideRegion.remove(playerId);
Location playerLocation = player.getLocation();
if (!region.contains(playerLocation) && !regionProvider.isInRegion(playerLocation)) {
return;
}
Location location = generate(playerLocation, Point2D.from(region.getMin()), Point2D.from(region.getMax()));
if (player.isInsideVehicle()) {
player.leaveVehicle();
}
player.teleport(location, PlayerTeleportEvent.TeleportCause.PLUGIN);
}, this.config.knockback.forceDelay);
generate(playerLocation, Point2D.from(region.getMin()), Point2D.from(region.getMax()), 0)
.ifPresent(location -> player.teleportAsync(location, TeleportCause.PLUGIN));
}, config.knockback.forceTeleport.delay);
}
private Location generate(Location playerLocation, Point2D minX, Point2D maxX) {
Location location = KnockbackOutsideRegionGenerator.generate(minX, maxX, playerLocation);
Optional<Region> otherRegion = regionProvider.getRegion(location);
if (otherRegion.isPresent()) {
Region region = otherRegion.get();
return generate(playerLocation, minX.min(region.getMin()), maxX.max(region.getMax()));
private Optional<Location> generate(Location playerLocation, Point2D min, Point2D max, int attempts) {
if (attempts >= FORCE_TELEPORT_MAX_ATTEMPTS) {
return Optional.of(playerLocation);
}
return location;
Optional<Location> location = KnockbackOutsideRegionGenerator.generate(min, max, playerLocation, candidate -> makeSafe(candidate));
if (location.isEmpty()) {
int expand = (attempts + 1) * (attempts + 1);
return generate(playerLocation, min.expandMin(expand, expand), max.expandMax(expand, expand), attempts + 1);
}
Optional<Region> otherRegion = regionProvider.getRegion(location.get());
if (otherRegion.isPresent()) {
Region region = otherRegion.get();
return generate(playerLocation, min.min(region.getMin()), max.max(region.getMax()), attempts + 1);
}
return location.map(loc -> loc.add(0.5, 0, 0.5));
}
public void knockback(Region region, Player player) {
Point point = region.getCenter();
Location subtract = player.getLocation().subtract(point.x(), 0, point.z());
private Optional<Location> makeSafe(Location random) {
Location maybeSafe = random.clone();
int minY = maybeSafe.getBlockY() - DEPTH_OF_SEARCHING;
Vector knockbackVector = new Vector(subtract.getX(), 0, subtract.getZ()).normalize();
double multiplier = this.config.knockback.multiplier;
Vector configuredVector = new Vector(multiplier, 0.5, multiplier);
CachedPillarOfBlocks pillar = new CachedPillarOfBlocks(maybeSafe.getBlockX(), maybeSafe.getBlockZ(), maybeSafe.getWorld());
player.setVelocity(knockbackVector.multiply(configuredVector));
for (int y = maybeSafe.getBlockY(); y > minY; y--) {
maybeSafe.setY(y);
Material ground = pillar.get(maybeSafe.getBlockY() - 1);
Material legs = pillar.get(maybeSafe.getBlockY());
Material head = pillar.get(maybeSafe.getBlockY() + 1);
if (ground.isSolid()
&& !containsMaterial(config.knockback.forceTeleport.unsafeGroundBlocks, ground)
&& containsMaterial(config.knockback.forceTeleport.airBlocks, legs)
&& containsMaterial(config.knockback.forceTeleport.airBlocks, head)
) {
return Optional.of(maybeSafe);
}
}
return Optional.empty();
}
private boolean containsMaterial(Set<XMaterial> materials, Material material) {
return materials.contains(XMaterial.matchXMaterial(material));
}
private static class CachedPillarOfBlocks {
private final int x;
private final int z;
private final World world;
private final Map<Integer, Material> blocksTypes = new HashMap<>();
private CachedPillarOfBlocks(int x, int z, World world) {
this.x = x;
this.z = z;
this.world = world;
}
public Material get(int y) {
return this.blocksTypes.computeIfAbsent(y, __ -> world.getType(x, y, z));
}
}
}
@@ -1,19 +1,138 @@
package com.eternalcode.combat.fight.knockback;
import com.cryptomorin.xseries.XMaterial;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import java.time.Duration;
import java.util.EnumSet;
import java.util.Set;
public class KnockbackSettings extends OkaeriConfig {
@Comment({
"# Adjust the knockback multiplier for restricted regions.",
"# Higher values increase the knockback distance. Avoid using negative values.",
"# A value of 1.0 typically knocks players 2-4 blocks away."
"# Horizontal knockback strength multiplier.",
"# This controls how far the player is pushed horizontally.",
"#",
"# Applied in: direction.multiply(multiplier)",
"# Example: 1.0 ≈ 2–4 blocks push"
})
public double multiplier = 1;
public double multiplier = 1.0;
@Comment({
"# Vertical velocity applied when the player is considered on ground.",
"#",
"# Used when Y velocity is near zero (< 0.08).",
"# Higher values = more upward knockback.",
"# Recommended: 0.15 - 0.3"
})
public double vertical = 0.2;
@Comment({
"# Force teleport settings for players that fail to be knocked back outside the region.",
"# If a player cannot be knocked back outside the region after multiple attempts,",
"# they will be teleported to a safe location outside the region after a short delay.",
"# This ensures players don't get stuck inside the region due to knockback failures."
})
public ForceTeleport forceTeleport = new ForceTeleport();
public static class ForceTeleport extends OkaeriConfig {
@Comment({
"# Delay before force teleport is applied after entering a region.",
"# Recommended: 1-3 seconds to allow knockback attempts before teleporting.",
})
public Duration delay = Duration.ofSeconds(1);
@Comment({
"# Blocks that are considered unsafe to stand on when searching for ground.",
"# These blocks will be ignored during safe ground detection.",
"#",
"# Used in findSafeGround():",
"# - Skips these blocks even if they are solid",
"# - Prevents teleporting onto dangerous or invalid blocks",
"#",
"# Examples:",
"# - BARRIER (invisible collision)",
"# - LAVA / WATER (damage / movement issues)",
"# - CACTUS / MAGMA (damage blocks)",
})
public Set<XMaterial> unsafeGroundBlocks = EnumSet.of(
XMaterial.BARRIER,
XMaterial.LAVA,
XMaterial.WATER,
XMaterial.CACTUS,
XMaterial.MAGMA_BLOCK,
XMaterial.FIRE,
XMaterial.SOUL_FIRE,
XMaterial.COBWEB,
XMaterial.SWEET_BERRY_BUSH,
XMaterial.BEDROCK,
XMaterial.TNT,
XMaterial.SEAGRASS,
XMaterial.TALL_SEAGRASS,
XMaterial.BUBBLE_COLUMN,
XMaterial.POWDER_SNOW,
XMaterial.WITHER_ROSE
);
@Comment({
"# Safe blocks that players can be teleported into",
"# These blocks don't cause damage and allow free movement",
"# Players can safely spawn in these blocks or pass through them",
"# Includes air, grass, flowers, and other non-solid blocks"
})
public Set<XMaterial> airBlocks = EnumSet.of(
XMaterial.AIR,
XMaterial.CAVE_AIR,
XMaterial.VOID_AIR,
XMaterial.TALL_SEAGRASS,
XMaterial.SEAGRASS,
XMaterial.SHORT_GRASS,
XMaterial.TALL_GRASS,
XMaterial.VINE,
XMaterial.STRUCTURE_VOID,
XMaterial.DEAD_BUSH,
XMaterial.DANDELION,
XMaterial.POPPY,
XMaterial.BLUE_ORCHID,
XMaterial.ALLIUM,
XMaterial.AZURE_BLUET,
XMaterial.RED_TULIP,
XMaterial.ORANGE_TULIP,
XMaterial.WHITE_TULIP,
XMaterial.PINK_TULIP,
XMaterial.OXEYE_DAISY,
XMaterial.CORNFLOWER,
XMaterial.LILY_OF_THE_VALLEY,
XMaterial.SUNFLOWER,
XMaterial.LILAC,
XMaterial.ROSE_BUSH,
XMaterial.PEONY,
XMaterial.WITHER_ROSE,
XMaterial.LARGE_FERN,
XMaterial.RAIL,
XMaterial.POWERED_RAIL,
XMaterial.DETECTOR_RAIL,
XMaterial.ACTIVATOR_RAIL,
XMaterial.REDSTONE_WIRE,
XMaterial.COMPARATOR,
XMaterial.REPEATER,
XMaterial.LEVER,
XMaterial.STRING,
XMaterial.SNOW,
XMaterial.CRIMSON_ROOTS,
XMaterial.WARPED_ROOTS,
XMaterial.CRIMSON_FUNGUS,
XMaterial.WARPED_FUNGUS,
XMaterial.TORCH,
XMaterial.WALL_TORCH,
XMaterial.REDSTONE_TORCH,
XMaterial.REDSTONE_WALL_TORCH,
XMaterial.SOUL_TORCH,
XMaterial.SOUL_WALL_TORCH
);
}
@Comment({ "# Time after which the player will be force knocked back outside the safe zone" })
public Duration forceDelay = Duration.ofSeconds(1);
}
@@ -5,11 +5,13 @@ import org.bukkit.World;
record Point2D(int x, int z) {
Location toLocation(Location location) {
World world = location.getWorld();
int y = world.getHighestBlockYAt(x, z) + 1;
Location toLocation(Location playerLocation) {
World world = playerLocation.getWorld();
int y = world.getEnvironment() == World.Environment.NETHER
? playerLocation.getBlockY() + 1
: world.getHighestBlockYAt(x, z) + 1;
return new Location(world, x, y, z, location.getYaw(), location.getPitch());
return new Location(world, x, y, z, playerLocation.getYaw(), playerLocation.getPitch());
}
static Point2D from(Location location) {
@@ -24,4 +26,12 @@ record Point2D(int x, int z) {
return new Point2D(Math.max(this.x, max.getBlockX()), Math.max(this.z, max.getBlockZ()));
}
public Point2D expandMax(int x, int z) {
return new Point2D(this.x + x, this.z + z);
}
public Point2D expandMin(int x, int z) {
return new Point2D(this.x - x, this.z - z);
}
}
@@ -1,50 +0,0 @@
package com.eternalcode.combat.fight.pearl;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import java.time.Duration;
import java.time.Instant;
import java.util.UUID;
public class FightPearlServiceImpl implements FightPearlService {
private final FightPearlSettings pearlSettings;
private final Cache<UUID, Instant> pearlStartTimes;
public FightPearlServiceImpl(FightPearlSettings pearlSettings) {
this.pearlSettings = pearlSettings;
this.pearlStartTimes = Caffeine.newBuilder()
.expireAfterWrite(pearlSettings.pearlThrowDelay)
.build();
}
@Override
public void markDelay(UUID uuid) {
this.pearlStartTimes.put(uuid, Instant.now());
}
@Override
public boolean hasDelay(UUID uuid) {
return this.pearlStartTimes.getIfPresent(uuid) != null;
}
@Override
public Duration getRemainingDelay(UUID uuid) {
Instant startTime = this.pearlStartTimes.getIfPresent(uuid);
if (startTime == null) {
return Duration.ZERO;
}
Duration elapsed = Duration.between(startTime, Instant.now());
Duration remaining = this.pearlSettings.pearlThrowDelay.minus(elapsed);
return remaining.isNegative() ? Duration.ZERO : remaining;
}
@Override
public Instant getDelay(UUID uuid) {
Instant startTime = this.pearlStartTimes.getIfPresent(uuid);
return startTime != null ? startTime.plus(this.pearlSettings.pearlThrowDelay) : Instant.MIN;
}
}
@@ -1,11 +1,11 @@
package com.eternalcode.combat.fight.pearl;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.notification.NoticeService;
import com.eternalcode.combat.util.DurationUtil;
import java.time.Duration;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -14,28 +14,26 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.event.player.PlayerTeleportEvent;
public class FightPearlController implements Listener {
public class PearlController implements Listener {
private final FightPearlSettings settings;
private final PluginConfig pluginConfig;
private final PearlService pearlService;
private final NoticeService noticeService;
private final FightManager fightManager;
private final FightPearlService fightPearlService;
public FightPearlController(
FightPearlSettings settings,
NoticeService noticeService,
FightManager fightManager,
FightPearlService fightPearlService
public PearlController(
PluginConfig pluginConfig,
PearlService pearlService, NoticeService noticeService, FightManager fightManager
) {
this.settings = settings;
this.pluginConfig = pluginConfig;
this.pearlService = pearlService;
this.noticeService = noticeService;
this.fightManager = fightManager;
this.fightPearlService = fightPearlService;
}
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPearlThrow(ProjectileLaunchEvent event) {
if (!(event.getEntity() instanceof EnderPearl)) {
return;
@@ -47,58 +45,68 @@ public class FightPearlController implements Listener {
UUID playerId = player.getUniqueId();
if (!this.fightManager.isInCombat(playerId)) {
return;
}
if (this.settings.pearlThrowDisabledDuringCombat) {
if (this.pearlService.shouldCancelEvent(playerId)) {
event.setCancelled(true);
if (this.pluginConfig.pearl.pearlThrowDisabledDuringCombat) {
this.noticeService.create()
.player(playerId)
.notice(this.pluginConfig.pearl.pearlThrowBlockedDuringCombat)
.send();
return;
}
Duration remainingDelay = this.pearlService.getRemainingDelay(playerId);
this.noticeService.create()
.player(playerId)
.notice(this.settings.pearlThrowBlockedDuringCombat)
.notice(this.pluginConfig.pearl.pearlThrowBlockedDelayDuringCombat)
.placeholder("{TIME}", DurationUtil.format(remainingDelay))
.send();
return;
}
if (this.settings.pearlCooldownEnabled) {
handlePearlCooldown(event, player, playerId);
}
this.pearlService.handleDelay(player);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPearlDamage(EntityDamageByEntityEvent event) {
if (this.settings.pearlThrowDamageEnabled) {
if (this.pluginConfig.pearl.pearlThrowDamageEnabled) {
return;
}
if (!(event.getEntity() instanceof Player) ||
!(event.getDamager() instanceof EnderPearl) ||
event.getCause() != EntityDamageEvent.DamageCause.FALL) {
event.getCause() != EntityDamageEvent.DamageCause.PROJECTILE) {
return;
}
event.setDamage(0.0);
}
private void handlePearlCooldown(ProjectileLaunchEvent event, Player player, UUID playerId) {
if (this.settings.pearlThrowDelay.isZero()) {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPearlTeleport(PlayerTeleportEvent event) {
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
return;
}
if (this.fightPearlService.hasDelay(playerId)) {
event.setCancelled(true);
Duration remainingDelay = this.fightPearlService.getRemainingDelay(playerId);
this.noticeService.create()
.player(playerId)
.notice(this.settings.pearlThrowBlockedDelayDuringCombat)
.placeholder("{TIME}", DurationUtil.format(remainingDelay))
.send();
if (!this.pluginConfig.pearl.pearlThrowDisabledDuringCombat) {
return;
}
this.fightPearlService.markDelay(playerId);
int cooldownTicks = (int) (this.settings.pearlThrowDelay.toMillis() / 50);
player.setCooldown(Material.ENDER_PEARL, cooldownTicks);
Player player = event.getPlayer();
UUID playerId = player.getUniqueId();
if (!this.fightManager.isInCombat(playerId)) {
return;
}
event.setCancelled(true);
this.noticeService.create()
.player(playerId)
.notice(this.pluginConfig.pearl.pearlThrowBlockedDuringCombat)
.send();
}
}
@@ -0,0 +1,81 @@
package com.eternalcode.combat.fight.pearl;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.event.CauseOfTag;
import com.eternalcode.commons.delay.Delay;
import com.eternalcode.commons.scheduler.Scheduler;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.time.Duration;
import java.util.UUID;
public class PearlServiceImpl implements PearlService {
private final FightManager fightManager;
private final PluginConfig pluginConfig;
private final Scheduler scheduler;
private final Delay<UUID> pearlStartTimes;
public PearlServiceImpl(FightManager fightManager, PluginConfig pluginConfig, Scheduler scheduler) {
this.fightManager = fightManager;
this.pluginConfig = pluginConfig;
this.pearlStartTimes = Delay.withDefault(() -> pluginConfig.pearl.pearlThrowDelay);
this.scheduler = scheduler;
}
@Override
public boolean shouldCancelEvent(UUID playerId) {
if (fightManager.isInCombat(playerId)) {
if (this.pluginConfig.pearl.pearlCooldownEnabled) {
return this.pearlStartTimes.hasDelay(playerId);
}
return pluginConfig.pearl.pearlThrowDisabledDuringCombat;
}
return false;
}
@Override
public void handleDelay(Player player) {
UUID uniqueId = player.getUniqueId();
if (this.hasDelay(uniqueId)) {
return;
}
if (this.fightManager.isInCombat(uniqueId)) {
if (this.pluginConfig.pearl.pearlExtendsCombatTag) {
Duration combatTime = this.pluginConfig.settings.combatTimerDuration;
this.fightManager.tag(uniqueId, combatTime, CauseOfTag.ENDER_PEARL);
}
if (this.pluginConfig.pearl.pearlCooldownEnabled && !this.pluginConfig.pearl.pearlThrowDelay.isZero()) {
this.pearlStartTimes.markDelay(uniqueId);
this.scheduler.runLater(
() -> player.setCooldown(
Material.ENDER_PEARL,
(int) this.pluginConfig.pearl.pearlThrowDelay.toMillis() / 50
), Duration.ofMillis(50)
);
}
}
}
@Override
public boolean hasDelay(UUID uuid) {
return this.pearlStartTimes.hasDelay(uuid);
}
@Override
public Duration getRemainingDelay(UUID uuid) {
return this.pearlStartTimes.getRemaining(uuid);
}
}
@@ -1,13 +1,12 @@
package com.eternalcode.combat.fight.pearl;
import com.eternalcode.multification.bukkit.notice.BukkitNotice;
import com.eternalcode.multification.notice.Notice;
import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import java.time.Duration;
public class FightPearlSettings extends OkaeriConfig {
public class PearlSettings extends OkaeriConfig {
@Comment({ "# Is pearl damage to be enabled?", "# This will work globally" })
public boolean pearlThrowDamageEnabled = true;
@@ -21,6 +20,9 @@ public class FightPearlSettings extends OkaeriConfig {
@Comment("# Set true, If you want add cooldown to pearls")
public boolean pearlCooldownEnabled = false;
@Comment("# Set true, If you want to reset timer when player throws ender pearl")
public boolean pearlExtendsCombatTag = false;
@Comment({
"# Block throwing pearls with delay?",
"# If you set this to for example 3s, player will have to wait 3 seconds before throwing another pearl"
@@ -28,12 +30,12 @@ public class FightPearlSettings extends OkaeriConfig {
public Duration pearlThrowDelay = Duration.ofSeconds(3);
@Comment("# Message sent when player tries to throw ender pearl, but are disabled")
public Notice pearlThrowBlockedDuringCombat = BukkitNotice.builder()
public Notice pearlThrowBlockedDuringCombat = Notice.builder()
.chat("<red>Throwing ender pearls is prohibited during combat!")
.build();
@Comment("# Message sent when player tries to throw ender pearl, but has delay")
public Notice pearlThrowBlockedDelayDuringCombat = BukkitNotice.builder()
public Notice pearlThrowBlockedDelayDuringCombat = Notice.builder()
.chat("<red>You must wait {TIME} before next throw!")
.build();
@@ -0,0 +1,93 @@
package com.eternalcode.combat.fight.spear;
import com.eternalcode.combat.config.implementation.PluginConfig;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.notification.NoticeService;
import com.eternalcode.combat.util.DurationUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.UUID;
public class SpearLungeController implements Listener {
private final SpearService spearService;
public SpearLungeController(
Plugin plugin,
FightManager fightManager,
SpearService spearService,
PluginConfig config,
NoticeService noticeService
) {
this.spearService = spearService;
try {
Class<? extends Event> lungeEventClass = Class.forName("io.papermc.paper.event.entity.EntityLungeEvent").asSubclass(Event.class);
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle getEntityHandle = lookup.findVirtual(lungeEventClass, "getEntity", MethodType.methodType(Entity.class));
MethodHandle setCancelledHandle = lookup.findVirtual(lungeEventClass, "setCancelled", MethodType.methodType(void.class, boolean.class));
Bukkit.getPluginManager().registerEvent(
lungeEventClass,
this,
EventPriority.NORMAL,
(listener, event) -> {
if (!config.spear.lungeCooldown || !lungeEventClass.isInstance(event)) {
return;
}
try {
Entity entity = (Entity) getEntityHandle.invoke(event);
if (!(entity instanceof Player player)) {
return;
}
UUID playerId = player.getUniqueId();
if (config.spear.onlyForFight && !fightManager.isInCombat(playerId)) {
return;
}
if (this.spearService.isOnCooldown(playerId)) {
setCancelledHandle.invoke(event, true);
noticeService.create()
.player(playerId)
.notice(config.spear.lungeOnCooldown)
.placeholder("{TIME}", DurationUtil.format(spearService.getRemainingCooldown(playerId), !config.spear.useMillis))
.send();
return;
}
spearService.saveCooldown(playerId);
} catch (Throwable e) {
plugin.getLogger().warning("Failed to handle EntityLungeEvent: " + e.getMessage());
}
},
plugin
);
} catch (ClassNotFoundException e) {
// Silently ignore: Server version is too old to have EntityLungeEvent
} catch (Throwable e) {
plugin.getLogger().warning("Failed to hook EntityLungeEvent: " + e.getMessage());
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
this.spearService.removeCooldown(event.getPlayer().getUniqueId());
}
}
Loaded 100 of 120 files, more files were not shown because too many files have changed in this diff. Show more