Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c0d738f4a | ||
|
|
786d480a11 | ||
|
|
6546694c7c | ||
|
|
e3508f3be6 | ||
|
|
fdd5147f18 | ||
|
|
2265b66dfc | ||
|
|
07821a62f0 | ||
|
|
78db24b23f | ||
|
|
9ea261517a | ||
|
|
7363d57b0e | ||
|
|
0951ef3b97 | ||
|
|
8a48eb55bf | ||
|
|
dd1688af28 | ||
|
|
fbce3c2c0b | ||
|
|
2de95627d5 | ||
|
|
f31a459c13 | ||
|
|
9fe7a1d067 | ||
|
|
b5c289c2b1 | ||
|
|
5b4f9d1911 | ||
|
|
e024b2fae9 | ||
|
|
b2776936ed | ||
|
|
d2aa5dfa84 | ||
|
|
5c88af692d | ||
|
|
390195edb2 | ||
|
|
8808331f0a | ||
|
|
99b3a5aa27 | ||
|
|
9d1716d9db | ||
|
|
7b94ab4b7a | ||
|
|
daee189865 | ||
|
|
1aef1e6f1d | ||
|
|
788a2a668c | ||
|
|
93d7ffdd0f | ||
|
|
fb6db7a008 | ||
|
|
7d8a01b7d7 | ||
|
|
08c7482cee | ||
|
|
7e24e5afa6 | ||
|
|
bb130ae10e | ||
|
|
2c5b007d02 | ||
|
|
51b365df1b | ||
|
|
4f23105ba1 | ||
|
|
d0c221c184 | ||
|
|
bf529dce32 | ||
|
|
74ec795581 | ||
|
|
b3550110c8 | ||
|
|
326f7363f1 | ||
|
|
5645f0473b | ||
|
|
d0336441ce | ||
|
|
bc6df07609 | ||
|
|
440f77e387 | ||
|
|
3dc115c1f6 | ||
|
|
591ba20221 | ||
|
|
4d2d2222aa | ||
|
|
62975caf58 | ||
|
|
d7c7ac2916 | ||
|
|
d250a6a720 | ||
|
|
5c6ac79579 | ||
|
|
59f0612405 | ||
|
|
84d1d5aeb6 | ||
|
|
e73864923f | ||
|
|
195e45ed34 | ||
|
|
459ff06f18 | ||
|
|
4a153d5557 | ||
|
|
3e5b060923 | ||
|
|
03768ccd8d | ||
|
|
ba59d85996 | ||
|
|
1c432cbcb3 | ||
|
|
de6b76526c | ||
|
|
7de452ac15 | ||
|
|
7e578d63f7 | ||
|
|
e5f86c53a2 | ||
|
|
22260e87d0 | ||
|
|
fe73466cfb | ||
|
|
c299aed434 | ||
|
|
8dbaf9ae98 | ||
|
|
db4ab96377 | ||
|
|
0dca7e7d42 | ||
|
|
bb080b5ce9 | ||
|
|
9f4ae311a7 | ||
|
|
96deb783b7 | ||
|
|
bee80d22aa | ||
|
|
4202e86eaa | ||
|
|
e109b38705 | ||
|
|
9bba5bd418 | ||
|
|
77940ca7b6 | ||
|
|
a4cc6d0e8b | ||
|
|
2028c5eafd | ||
|
|
042c5848df | ||
|
|
c30860070f | ||
|
|
20c3515082 | ||
|
|
07b22a1141 | ||
|
|
2fc9bc580b | ||
|
|
7730956dbc | ||
|
|
48ef3e5d0a | ||
|
|
abd097401f | ||
|
|
1d0d182cc8 | ||
|
|
60b4e6ee9c | ||
|
|
b096cb5d6f | ||
|
|
d596202278 | ||
|
|
b879497840 | ||
|
|
ccad96ae96 | ||
|
|
0e782a0cf5 | ||
|
|
0979d449c6 | ||
|
|
dee65e5f59 | ||
|
|
01d3491d44 | ||
|
|
9896069577 | ||
|
|
f682508172 | ||
|
|
a988abcd17 | ||
|
|
b0fa197e99 | ||
|
|
5300b5a007 | ||
|
|
c1f282832c | ||
|
|
972fc52e69 | ||
|
|
b79ed28edf | ||
|
|
025f49685c | ||
|
|
4d957d2c8a | ||
|
|
d7a04ef0c2 | ||
|
|
0bd9911df3 | ||
|
|
3062378c66 | ||
|
|
0799081813 | ||
|
|
16a2df1a08 | ||
|
|
cd3681f8f6 | ||
|
|
885f514e17 | ||
|
|
5b84881b94 | ||
|
|
e69a42ba0f | ||
|
|
9783d7a025 | ||
|
|
99a93ce249 | ||
|
|
1c2797225a | ||
|
|
1af5710ac9 | ||
|
|
1938ae409d | ||
|
|
88fa996202 | ||
|
|
e3c4f2c26d | ||
|
|
e87060d2b9 | ||
|
|
dfe70a65d7 | ||
|
|
fbade09087 | ||
|
|
660b8b5519 | ||
|
|
13eb6dead2 | ||
|
|
eafb4c9318 | ||
|
|
bfc632d518 | ||
|
|
02d5a2f46d | ||
|
|
9e3f28ee10 | ||
|
|
e5fb0d4b32 | ||
|
|
3325a2f8d3 | ||
|
|
a0bd8494f8 | ||
|
|
08cfe7c0c4 | ||
|
|
ed30d43736 | ||
|
|
b6347517b6 | ||
|
|
3f729beffe | ||
|
|
337eb7d765 | ||
|
|
b02231bc0c | ||
|
|
ee6f5aecd3 | ||
|
|
6eb89607bf | ||
|
|
9f33de088b | ||
|
|
815b63c7bf | ||
|
|
410289a2b8 | ||
|
|
e40a37e2ff | ||
|
|
1bae5c547d | ||
|
|
986895d5a4 | ||
|
|
4776714893 | ||
|
|
6154f26977 | ||
|
|
2f010ee978 | ||
|
|
7d5d074811 | ||
|
|
8315e198b3 | ||
|
|
b0cbdc04c8 | ||
|
|
f46f9ca268 | ||
|
|
d789d3b47e | ||
|
|
dd7eaf2de8 | ||
|
|
a985774272 | ||
|
|
fa000b4a3a | ||
|
|
80edd3b425 | ||
|
|
fc4a6c28a3 | ||
|
|
e4eb847b56 | ||
|
|
f5884119d6 | ||
|
|
0cd9d50086 | ||
|
|
7043d7baff | ||
|
|
26d3f5b1ce | ||
|
|
455b66e136 | ||
|
|
881d9b633a | ||
|
|
ac80f1bb0c | ||
|
|
cd36abae37 | ||
|
|
817b907170 | ||
|
|
b9dfb293e4 | ||
|
|
11bfddfc9f | ||
|
|
74d0f487c3 | ||
|
|
f4cc51e9a1 | ||
|
|
e579ca4a22 | ||
|
|
4c13a61752 | ||
|
|
dad09ba196 | ||
|
|
690678c1ea | ||
|
|
40cac29eb0 | ||
|
|
b9c625cdd6 | ||
|
|
861aad1852 | ||
|
|
4c30b7dad6 | ||
|
|
7a152e0624 | ||
|
|
487fc971bc | ||
|
|
ba5fa97e1e | ||
|
|
f2ab289794 | ||
|
|
241898d62a | ||
|
|
9e914d6166 | ||
|
|
f9bc56bf33 | ||
|
|
d6bf4e628c | ||
|
|
b87e64090a | ||
|
|
7ce6d8bd95 | ||
|
|
2dc6cbf40c | ||
|
|
411e78dda0 | ||
|
|
31d41c900f | ||
|
|
a8b48b8804 | ||
|
|
312d8e08e6 | ||
|
|
7f30d79301 | ||
|
|
05095857ca | ||
|
|
d9f98d3aa2 | ||
|
|
bae1b805a7 | ||
|
|
0b119a28c9 | ||
|
|
a235b799e5 | ||
|
|
9b8b0a8513 | ||
|
|
0da9208323 | ||
|
|
64e366ccd3 | ||
|
|
0540e39af2 | ||
|
|
824313c6ec | ||
|
|
4cd83670a9 | ||
|
|
7f130493f7 | ||
|
|
8c5038e3a4 | ||
|
|
bd4fd131c5 | ||
|
|
f338fc4109 | ||
|
|
da555c65e9 | ||
|
|
726f1aa78c | ||
|
|
0539e69236 | ||
|
|
d54bff5516 | ||
|
|
5c099d2de4 | ||
|
|
5042241e94 | ||
|
|
b63e2584ac | ||
|
|
a6984e2694 | ||
|
|
c7f93d9b25 | ||
|
|
c8483e51e9 | ||
|
|
dfc825cd98 | ||
|
|
bd5a6a4351 | ||
|
|
97fd32a7af | ||
|
|
9203309def | ||
|
|
381007a735 | ||
|
|
534e2cf857 | ||
|
|
20a4e4a2f5 | ||
|
|
fe2569918a | ||
|
|
e17effa4cd | ||
|
|
c63df3ab38 | ||
|
|
24fade593b | ||
|
|
4b12968a7b | ||
|
|
9ad0063aa5 | ||
|
|
7f6c6341f1 | ||
|
|
0620f7fb92 | ||
|
|
d18b2f013a | ||
|
|
7b89dfdcfc | ||
|
|
595370f6a4 | ||
|
|
e732bdf842 | ||
|
|
6b6329c4a6 | ||
|
|
7a6707b20e | ||
|
|
7a10e268bb | ||
|
|
adce4729f0 | ||
|
|
8560f17bac | ||
|
|
d2d7a4f02c | ||
|
|
cf33b23720 | ||
|
|
e261e06635 | ||
|
|
2856ababff | ||
|
|
f061e1738e | ||
|
|
4118983479 | ||
|
|
988859ddbe | ||
|
|
305ab9e299 | ||
|
|
5aaf8a4f08 | ||
|
|
153657c554 | ||
|
|
5123176cb3 | ||
|
|
1665f39151 | ||
|
|
94113ea326 | ||
|
|
7f581dbaac | ||
|
|
2dd25cc27e | ||
|
|
3ca562f515 | ||
|
|
383c405198 | ||
|
|
c522f7c078 | ||
|
|
fb6efa0646 | ||
|
|
ad7899f10e | ||
|
|
ab5e6a7cf3 | ||
|
|
42ae17bf8d | ||
|
|
20d342d0ca | ||
|
|
c4adeb1aed | ||
|
|
d2d0c5b608 | ||
|
|
eb1febab85 | ||
|
|
8153ba55ab | ||
|
|
89784f3412 | ||
|
|
49e82385d4 | ||
|
|
190034f5aa | ||
|
|
1db744c4ec | ||
|
|
94d7baf791 | ||
|
|
c25af3f6d3 | ||
|
|
3b38c82b47 | ||
|
|
526f831fcb | ||
|
|
e4151cbbe0 | ||
|
|
47d9fed823 | ||
|
|
0890b2abbd | ||
|
|
be99a8646d | ||
|
|
b58266c868 | ||
|
|
eaa02a4166 | ||
|
|
08e99ded13 | ||
|
|
e867e7e697 |
No files matched your search
@@ -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 messages 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).
|
||||
@@ -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.
|
||||
@@ -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
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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)
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": [
|
||||
"local>EternalCodeTeam/.github:renovate-config"
|
||||
]
|
||||
}
|
||||
@@ -4,40 +4,45 @@ on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v6
|
||||
with:
|
||||
java-version: '17'
|
||||
java-version: '25'
|
||||
distribution: 'temurin'
|
||||
- name: Cache Gradle
|
||||
uses: actions/cache@v3.3.1
|
||||
|
||||
- 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@e3426b1f20c7262e0fed7b855aae1325633af3b4
|
||||
run: ./gradlew shadowJar
|
||||
|
||||
- name: Upload build artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
arguments: shadowJar
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
with:
|
||||
name: 'Successfully build EternalCombat'
|
||||
path: build/libs/*.jar
|
||||
name: ${{ env.FULL_ARTIFACT_NAME }}
|
||||
path: eternalcombat-plugin/build/libs/*.jar
|
||||
archive: false
|
||||
@@ -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@v6
|
||||
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 }}
|
||||
@@ -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@v6
|
||||
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 }}
|
||||
@@ -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@v3
|
||||
uses: actions/setup-java@v6
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
java-version: 25
|
||||
cache: 'gradle'
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
.classpath
|
||||
.idea
|
||||
.gradle
|
||||
.kotlin
|
||||
.project
|
||||
.settings
|
||||
bin
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"scanSettings": {
|
||||
"baseBranches": []
|
||||
},
|
||||
"checkRunSettings": {
|
||||
"vulnerableCheckRunConclusionLevel": "failure",
|
||||
"displayMode": "diff",
|
||||
"useMendCheckNames": true
|
||||
},
|
||||
"issueSettings": {
|
||||
"minSeverityLevel": "LOW",
|
||||
"issueType": "DEPENDENCY"
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,174 @@
|
||||
<div align="center">
|
||||
|
||||

|
||||

|
||||
|
||||
[](https://papermc.io)
|
||||
[](https://spigotmc.org)
|
||||
[](https://www.spigotmc.org/resources/eternalcombat-%E2%9C%94%EF%B8%8F-enchance-your-combat-system-with-eternalcombat.109056/)
|
||||
[](https://modrinth.com/plugin/eternalcombat)
|
||||
[](https://hangar.papermc.io/EternalCodeTeam/eternalcombat)
|
||||
|
||||
[](https://www.patreon.com/eternalcode)
|
||||
[](https://eternalcode.pl/)
|
||||
[](https://discord.gg/FQ7jmGBd6c)
|
||||
[](https://discord.com/invite/FQ7jmGBd6c)
|
||||
[](https://docs.eternalcode.pl/eternalcombat/introduction)
|
||||
[](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>
|
||||
|
||||
[](https://gradle.org/)
|
||||
[](https://www.java.com/)
|
||||
</div>
|
||||
|
||||
### Information
|
||||
|
||||
EternalCombat has been tested on Minecraft versions 1.17.1 to 1.20.1, but it should work on most other versions. If you
|
||||
encounter any compatibility issues, please report them in the
|
||||
[Issues tab](https://github.com/EternalCodeTeam/EternalCombat/issues). The plugin requires Java 17 or later, so please
|
||||
make sure it is installed on your server.
|
||||
## EternalCombat requires PacketEvents plugin to work.
|
||||
You can download it from [here](https://modrinth.com/plugin/packetevents)
|
||||
|
||||
## Building
|
||||
Build EternalCombat using:
|
||||
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 21 or later**, so
|
||||
ensure your server is ready.
|
||||
Ready for action?
|
||||
Install EternalCombat and dive in now!
|
||||
|
||||
`./gradlew shadowJar`
|
||||
### How Does EternalCombat Work?
|
||||
|
||||
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:
|
||||
<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:
|
||||
<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
|
||||
defeated players, you’re in control. Here’s what you can tweak:
|
||||
|
||||
| Feature | Description |
|
||||
|----------------------|-----------------------------------------------------------------|
|
||||
| Elytra & Inventory | Disable elytra or inventory access during combat. |
|
||||
| Commands | Whitelist or blacklist specific commands in combat. |
|
||||
| Damage & Projectiles | Customize damage causes and projectile tagging settings. |
|
||||
| Ender Pearls | Add cooldowns to pearl usage in fights. |
|
||||
| Block Placement | Enable or disable block placement during combat. |
|
||||
| Drop Rates | Set a percentage of items dropped by defeated players. |
|
||||
| Temporary Effects | Apply special effects to players in combat for added intensity. |
|
||||
| And More! | Dive into the config for even more fine-tuning options! |
|
||||
|
||||
Curious for more? Check out our quick and exciting YouTube presentation [here](https://youtu.be/5pELO5B0Hhk) to see
|
||||
EternalCombat in full swing and learn why it’s a game-changer for your server!
|
||||
|
||||
### Permissions for EternalCombat
|
||||
|
||||
- `eternalcombat.status` - Allows to check if the player is in combat `/combatlog status <player>`
|
||||
- `eternalcombat.tag` - Allows to create fights between two
|
||||
players `/combatlog tag <first_player> <optional_second_player>`
|
||||
- `eternalcombat.untag` - Allows to remove player from fight `/combatlog untag <player>`
|
||||
- `eternalcombat.reload` - Allows to reload plugin `/combatlog reload`
|
||||
- `eternalcombat.receiveupdates` - Allows you to receive notifications about the new version of the plugin when
|
||||
attaching
|
||||
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.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
|
||||
|
||||
EternalCombat 2.0 fully supports **PlaceholderAPI**, letting you integrate placeholders into other compatible plugins.
|
||||
Follow the [PlaceholderAPI instructions](https://wiki.placeholderapi.com/users/) to get started.
|
||||
Here are the available
|
||||
placeholders:
|
||||
|
||||
| Placeholder | Description |
|
||||
|-------------------------------------|---------------------------------------------------------------|
|
||||
| `%eternalcombat_opponent%` | Returns the name of the player you’re fighting. |
|
||||
| `%eternalcombat_opponent_health%` | Returns the opponent’s health in `00.00` format. |
|
||||
| `%eternalcombat_remaining_seconds%` | Returns seconds remaining until the player exits combat. |
|
||||
| `%eternalcombat_remaining_millis%` | Returns milliseconds remaining until the player exits combat. |
|
||||
|
||||
If a player isn’t in combat, placeholders return an empty string.
|
||||
If combat wasn’t triggered by another player,
|
||||
opponent-related placeholders will also return empty.
|
||||
|
||||
### Developer API
|
||||
|
||||
#### 1. Add repository:
|
||||
|
||||
With Gradle:
|
||||
|
||||
```kts
|
||||
maven {
|
||||
url = uri("https://repo.eternalcode.pl/releases")
|
||||
}
|
||||
```
|
||||
|
||||
With Maven:
|
||||
|
||||
```xml
|
||||
|
||||
<repository>
|
||||
<id>eternalcode-reposilite-releases</id>
|
||||
<name>EternalCode Repository</name>
|
||||
<url>https://repo.eternalcode.pl/releases</url>
|
||||
</repository>
|
||||
```
|
||||
|
||||
#### 2. Add dependency:
|
||||
|
||||
With Gradle:
|
||||
|
||||
```kts
|
||||
compileOnly("com.eternalcode:eternalcombat-api:2.6.0-SNAPSHOT")
|
||||
```
|
||||
|
||||
With Maven:
|
||||
|
||||
```xml
|
||||
|
||||
<dependency>
|
||||
<groupId>com.eternalcode</groupId>
|
||||
<artifactId>eternalcombat-api</artifactId>
|
||||
<version>2.6.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### Contributing
|
||||
|
||||
We welcome all contributions to the EternalCombat project! Please check out [contributing](.github/CONTRIBUTING.md) for
|
||||
more information on how to contribute and our [code of conduct](./.github/CODE_OF_CONDUCT.md)
|
||||
We’d love your help to make EternalCombat even better!
|
||||
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
|
||||
|
||||
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 messages or logs
|
||||
Found a bug?
|
||||
Report it in the [Issues tab](https://github.com/eternalcodeteam/eternalcombat/issues).
|
||||
Please include as much detail as possible, like your Minecraft and plugin
|
||||
versions, along with any error messages or logs.
|
||||
Ready to transform your server’s combat experience?
|
||||
Download EternalCombat 2.0 now and let the battles begin!
|
||||
|
After Width: | Height: | Size: 5.2 MiB |
|
After Width: | Height: | Size: 2.6 MiB |
|
After Width: | Height: | Size: 752 KiB |
|
After Width: | Height: | Size: 5.4 MiB |
|
After Width: | Height: | Size: 2.7 MiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 98 KiB |
|
After Width: | Height: | Size: 4.1 MiB |
@@ -0,0 +1,31 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
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:3.1.0")
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java.setSrcDirs(emptyList<String>())
|
||||
groovy.setSrcDirs(emptyList<String>())
|
||||
resources.setSrcDirs(emptyList<String>())
|
||||
}
|
||||
test {
|
||||
java.setSrcDirs(emptyList<String>())
|
||||
kotlin.setSrcDirs(emptyList<String>())
|
||||
groovy.setSrcDirs(emptyList<String>())
|
||||
resources.setSrcDirs(emptyList<String>())
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
object Versions {
|
||||
|
||||
// Keep this version for best compatibility.
|
||||
const val PAPER_API = "1.19.3-R0.1-SNAPSHOT"
|
||||
|
||||
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.1.0"
|
||||
|
||||
const val ETERNALCODE_COMMONS = "1.4.1"
|
||||
const val MULTIFICATION = "1.2.5-SNAPSHOT"
|
||||
const val PACKETS_EVENTS = "2.13.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 XSERIES = "13.8.0"
|
||||
|
||||
const val CAFFEINE = "3.3.0"
|
||||
|
||||
const val B_STATS_BUKKIT = "3.2.1"
|
||||
const val WORLD_GUARD_BUKKIT = "7.0.17"
|
||||
|
||||
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"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
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}")
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
sourceSets.test {
|
||||
java.setSrcDirs(listOf("test"))
|
||||
resources.setSrcDirs(emptyList<String>())
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
group = "com.eternalcode"
|
||||
version = "2.6.0-SNAPSHOT"
|
||||
|
||||
tasks.compileJava {
|
||||
options.compilerArgs = listOf("-Xlint:deprecation", "-parameters")
|
||||
options.encoding = "UTF-8"
|
||||
options.release = 21
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
group = "com.eternalcode"
|
||||
version = "2.6.0-SNAPSHOT"
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
artifactId = "eternalcombat-api"
|
||||
from(project.components["java"])
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = "eternalcodeReleases"
|
||||
url = uri("https://repo.eternalcode.pl/releases")
|
||||
credentials {
|
||||
username = System.getenv("ETERNAL_CODE_MAVEN_USERNAME")
|
||||
password = System.getenv("ETERNAL_CODE_MAVEN_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -1,109 +1,12 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
checkstyle
|
||||
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
group = "com.eternalcode"
|
||||
version = "1.1.1"
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "10.12.2"
|
||||
|
||||
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
|
||||
|
||||
maxErrors = 0
|
||||
maxWarnings = 0
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
|
||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.eternalcode.pl/releases") }
|
||||
maven { url = uri("https://storehouse.okaeri.eu/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.panda-lang.org/releases") }
|
||||
maven { url = uri("https://maven.enginehub.org/repo/") }
|
||||
`eternalcombat-java`
|
||||
`eternalcombat-repositories`
|
||||
`eternalcombat-publish`
|
||||
`eternalcombat-java-unit-test`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Spigot api
|
||||
compileOnlyApi("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")
|
||||
|
||||
// kyori
|
||||
api("net.kyori:adventure-platform-bukkit:4.3.0")
|
||||
api("net.kyori:adventure-text-minimessage:4.14.0")
|
||||
|
||||
// litecommands
|
||||
api("dev.rollczi.litecommands:bukkit-adventure:2.8.9")
|
||||
|
||||
// Okaeri configs
|
||||
api("eu.okaeri:okaeri-configs-yaml-bukkit:5.0.0-beta.5")
|
||||
api("eu.okaeri:okaeri-configs-serdes-commons:5.0.0-beta.5")
|
||||
api("eu.okaeri:okaeri-configs-serdes-bukkit:5.0.0-beta.5")
|
||||
|
||||
// Panda utilities
|
||||
api("org.panda-lang:panda-utilities:0.5.2-alpha")
|
||||
|
||||
// GitCheck
|
||||
api("com.eternalcode:gitcheck:1.0.0")
|
||||
|
||||
// commons
|
||||
api("commons-io:commons-io:2.13.0")
|
||||
|
||||
// bstats
|
||||
api("org.bstats:bstats-bukkit:3.0.2")
|
||||
|
||||
// worldguard
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.9")
|
||||
|
||||
// tests
|
||||
testImplementation("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-params:5.10.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0")
|
||||
// Paper api
|
||||
compileOnlyApi("io.papermc.paper:paper-api:${Versions.PAPER_API}")
|
||||
api("org.jetbrains:annotations:${Versions.JETBRAINS_ANNOTATIONS}")
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
tasks.getByName<Test>("test") {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
// Publish
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
artifactId = "eternalcombat-api"
|
||||
from(project.components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
||||
maven {
|
||||
name = "eternalcodeReleases"
|
||||
url = uri("https://repo.eternalcode.pl/releases")
|
||||
|
||||
credentials {
|
||||
username = System.getenv("ETERNAL_CODE_MAVEN_USERNAME")
|
||||
password = System.getenv("ETERNAL_CODE_MAVEN_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
package com.eternalcode.combat;
|
||||
|
||||
import com.eternalcode.combat.config.ConfigService;
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
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.fight.event.FightUntagEvent;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
import dev.rollczi.litecommands.argument.Arg;
|
||||
import dev.rollczi.litecommands.command.async.Async;
|
||||
import dev.rollczi.litecommands.command.execute.Execute;
|
||||
import dev.rollczi.litecommands.command.permission.Permission;
|
||||
import dev.rollczi.litecommands.command.route.Route;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import panda.utilities.text.Formatter;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.UUID;
|
||||
|
||||
@Route(name = "combatlog", aliases = "combat")
|
||||
public class CombatCommand {
|
||||
|
||||
private final FightManager fightManager;
|
||||
private final ConfigService configService;
|
||||
private final NotificationAnnouncer announcer;
|
||||
private final PluginConfig config;
|
||||
|
||||
public CombatCommand(FightManager fightManager, ConfigService configService, NotificationAnnouncer announcer, PluginConfig config) {
|
||||
this.fightManager = fightManager;
|
||||
this.configService = configService;
|
||||
this.announcer = announcer;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Execute(route = "status", required = 1)
|
||||
@Permission("eternalcombat.status")
|
||||
void status(CommandSender sender, @Arg Player target) {
|
||||
UUID targetUniqueId = target.getUniqueId();
|
||||
PluginConfig.Messages messages = this.config.messages;
|
||||
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{PLAYER}", target.getName());
|
||||
|
||||
this.announcer.sendMessage(sender, this.fightManager.isInCombat(targetUniqueId)
|
||||
? formatter.format(messages.admin.playerInCombat)
|
||||
: formatter.format(messages.admin.playerNotInCombat));
|
||||
}
|
||||
|
||||
@Execute(route = "tag", required = 1)
|
||||
@Permission("eternalcombat.tag")
|
||||
void tag(CommandSender sender, @Arg Player target) {
|
||||
UUID targetUniqueId = target.getUniqueId();
|
||||
Duration time = this.config.settings.combatDuration;
|
||||
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{PLAYER}", target.getName());
|
||||
|
||||
FightTagEvent event = this.fightManager.tag(targetUniqueId, time, CauseOfTag.COMMAND);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
this.announcer.sendMessage(sender, event.getCancelMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
String format = formatter.format(this.config.messages.admin.adminTagPlayer);
|
||||
this.announcer.sendMessage(sender, format);
|
||||
}
|
||||
|
||||
@Execute(route = "tag", required = 2)
|
||||
@Permission("eternalcombat.tag")
|
||||
void tagMultiple(CommandSender sender, @Arg Player firstTarget, @Arg Player secondTarget) {
|
||||
Duration combatTime = this.config.settings.combatDuration;
|
||||
PluginConfig.Messages messages = this.config.messages;
|
||||
|
||||
if (sender.equals(firstTarget) || sender.equals(secondTarget)) {
|
||||
this.announcer.sendMessage(sender, messages.admin.adminCannotTagSelf);
|
||||
return;
|
||||
}
|
||||
|
||||
FightTagEvent firstTagEvent = this.fightManager.tag(firstTarget.getUniqueId(), combatTime, CauseOfTag.COMMAND);
|
||||
FightTagEvent secondTagEvent = this.fightManager.tag(secondTarget.getUniqueId(), combatTime, CauseOfTag.COMMAND);
|
||||
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{FIRST_PLAYER}", firstTarget.getName())
|
||||
.register("{SECOND_PLAYER}", secondTarget.getName());
|
||||
|
||||
String format = formatter.format(messages.admin.adminTagMultiplePlayers);
|
||||
|
||||
if (firstTagEvent.isCancelled()) {
|
||||
this.announcer.sendMessage(sender, firstTagEvent.getCancelMessage());
|
||||
}
|
||||
|
||||
if (secondTagEvent.isCancelled()) {
|
||||
this.announcer.sendMessage(sender, firstTagEvent.getCancelMessage());
|
||||
}
|
||||
|
||||
if (firstTagEvent.isCancelled() && secondTagEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.announcer.sendMessage(sender, format);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Execute(route = "reload")
|
||||
@Permission("eternalcombat.reload")
|
||||
void execute(CommandSender player) {
|
||||
this.configService.reload();
|
||||
this.announcer.sendMessage(player, this.config.messages.admin.reload);
|
||||
}
|
||||
|
||||
@Execute(route = "untag", required = 1)
|
||||
@Permission("eternalcombat.untag")
|
||||
void untag(Player sender, @Arg Player target) {
|
||||
UUID targetUniqueId = target.getUniqueId();
|
||||
|
||||
if (!this.fightManager.isInCombat(targetUniqueId)) {
|
||||
this.announcer.sendMessage(sender, this.config.messages.admin.adminPlayerNotInCombat);
|
||||
return;
|
||||
}
|
||||
|
||||
FightUntagEvent event = this.fightManager.untag(targetUniqueId, CauseOfUnTag.COMMAND);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{PLAYER}", target.getName());
|
||||
|
||||
String format = formatter.format(this.config.messages.admin.adminUntagPlayer);
|
||||
|
||||
this.announcer.sendMessage(sender, format);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.eternalcode.combat;
|
||||
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.drop.DropKeepInventoryManager;
|
||||
import com.eternalcode.combat.drop.DropManager;
|
||||
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.FightPearlManager;
|
||||
import com.eternalcode.combat.fight.tagout.FightTagOutService;
|
||||
import com.eternalcode.combat.fight.pearl.PearlService;
|
||||
import com.eternalcode.combat.region.RegionProvider;
|
||||
import com.eternalcode.combat.fight.tagout.FightTagOutService;
|
||||
|
||||
public interface EternalCombatApi {
|
||||
|
||||
@@ -15,16 +14,14 @@ public interface EternalCombatApi {
|
||||
|
||||
RegionProvider getRegionProvider();
|
||||
|
||||
FightPearlManager getFightPearlManager();
|
||||
PearlService getFightPearlService();
|
||||
|
||||
FightTagOutService getFightTagOutService();
|
||||
|
||||
FightEffectService getFightEffectService();
|
||||
|
||||
DropManager getDropManager();
|
||||
DropService getDropService();
|
||||
|
||||
DropKeepInventoryManager getDropKeepInventoryManager();
|
||||
|
||||
PluginConfig getPluginConfig();
|
||||
DropKeepInventoryService getDropKeepInventoryService();
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.eternalcode.combat.bridge;
|
||||
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.region.DefaultRegionProvider;
|
||||
import com.eternalcode.combat.region.RegionProvider;
|
||||
import com.eternalcode.combat.region.WorldGuardRegionProvider;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class BridgeService {
|
||||
|
||||
private final PluginConfig pluginConfig;
|
||||
private final PluginManager pluginManager;
|
||||
private final Logger logger;
|
||||
|
||||
private RegionProvider regionProvider;
|
||||
|
||||
public BridgeService(PluginConfig pluginConfig, PluginManager pluginManager, Logger logger) {
|
||||
this.pluginConfig = pluginConfig;
|
||||
this.pluginManager = pluginManager;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
this.initialize("WorldGuard",
|
||||
() -> this.regionProvider = new WorldGuardRegionProvider(this.pluginConfig.settings.blockedRegions),
|
||||
() -> {
|
||||
this.regionProvider = new DefaultRegionProvider(this.pluginConfig.settings.blockedRegionRadius);
|
||||
|
||||
this.logger.warning("WorldGuard is not installed, set to default region provider.");
|
||||
});
|
||||
}
|
||||
|
||||
private void initialize(String pluginName, BridgeInitializer initializer, Runnable runnable) {
|
||||
if (this.pluginManager.isPluginEnabled(pluginName)) {
|
||||
initializer.initialize();
|
||||
|
||||
this.logger.info("Successfully initialized " + pluginName + " bridge.");
|
||||
}
|
||||
else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
public RegionProvider getRegionProvider() {
|
||||
return this.regionProvider;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.eternalcode.combat.command;
|
||||
|
||||
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
import dev.rollczi.litecommands.command.LiteInvocation;
|
||||
import dev.rollczi.litecommands.handle.InvalidUsageHandler;
|
||||
import dev.rollczi.litecommands.schematic.Schematic;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import panda.utilities.text.Formatter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InvalidUsage implements InvalidUsageHandler<CommandSender> {
|
||||
|
||||
private final PluginConfig config;
|
||||
private final NotificationAnnouncer announcer;
|
||||
|
||||
public InvalidUsage(PluginConfig config, NotificationAnnouncer announcer) {
|
||||
this.config = config;
|
||||
this.announcer = announcer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(CommandSender commandSender, LiteInvocation invocation, Schematic scheme) {
|
||||
List<String> schematics = scheme.getSchematics();
|
||||
|
||||
for (String schematic : schematics) {
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{USAGE}", schematic);
|
||||
|
||||
this.announcer.sendMessage(commandSender, formatter.format(this.config.messages.invalidCommandUsage));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.eternalcode.combat.command;
|
||||
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
import dev.rollczi.litecommands.command.LiteInvocation;
|
||||
import dev.rollczi.litecommands.command.permission.RequiredPermissions;
|
||||
import dev.rollczi.litecommands.handle.PermissionHandler;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import panda.utilities.text.Formatter;
|
||||
import panda.utilities.text.Joiner;
|
||||
|
||||
public class PermissionMessage implements PermissionHandler<CommandSender> {
|
||||
|
||||
private final PluginConfig config;
|
||||
private final NotificationAnnouncer announcer;
|
||||
|
||||
public PermissionMessage(PluginConfig config, NotificationAnnouncer announcer) {
|
||||
this.config = config;
|
||||
this.announcer = announcer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(CommandSender commandSender, LiteInvocation invocation, RequiredPermissions requiredPermissions) {
|
||||
String value = Joiner.on(", ")
|
||||
.join(requiredPermissions.getPermissions())
|
||||
.toString();
|
||||
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{PERMISSION}", value);
|
||||
|
||||
this.announcer.sendMessage(commandSender, formatter.format(this.config.messages.noPermission));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
package com.eternalcode.combat.config;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
public class ConfigBackupService {
|
||||
|
||||
private static final String BACKUP_FOLDER_NAME = "backup";
|
||||
private static final String BACKUP_FILE_EXTENSION = ".bak";
|
||||
private final File dataFolder;
|
||||
|
||||
public ConfigBackupService(File dataFolder) {
|
||||
this.dataFolder = dataFolder;
|
||||
}
|
||||
|
||||
public void createBackup() {
|
||||
File backupFolder = new File(this.dataFolder, BACKUP_FOLDER_NAME);
|
||||
|
||||
if (!backupFolder.exists()) {
|
||||
backupFolder.mkdirs();
|
||||
}
|
||||
|
||||
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||
String backupFolderName = BACKUP_FOLDER_NAME + "_" + currentDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm"));
|
||||
File currentBackupFolder = new File(backupFolder, backupFolderName);
|
||||
if (!currentBackupFolder.exists()) {
|
||||
currentBackupFolder.mkdirs();
|
||||
}
|
||||
|
||||
this.copyFolderContents(this.dataFolder, currentBackupFolder);
|
||||
this.deleteIfOlderDirectory(backupFolder);
|
||||
}
|
||||
|
||||
private void copyFolderContents(File sourceFolder, File targetFolder) {
|
||||
if (!sourceFolder.exists() || !sourceFolder.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!targetFolder.exists()) {
|
||||
boolean targetFolderCreated = targetFolder.mkdirs();
|
||||
|
||||
if (!targetFolderCreated) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File[] filesToBackup = sourceFolder.listFiles();
|
||||
if (filesToBackup == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (File file : filesToBackup) {
|
||||
if (file.isDirectory() && !file.getName().equals(BACKUP_FOLDER_NAME)) {
|
||||
File subFolder = new File(targetFolder, file.getName());
|
||||
this.copyFolderContents(file, subFolder);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file.isFile() && !file.getName().endsWith(BACKUP_FILE_EXTENSION)) {
|
||||
File backupFile = new File(targetFolder, file.getName() + BACKUP_FILE_EXTENSION);
|
||||
|
||||
this.copyToBackupFile(file, backupFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void copyToBackupFile(File targetFolder, File path) {
|
||||
try {
|
||||
Files.copy(targetFolder.toPath(), path.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// delete backup folders older than X days
|
||||
private void deleteIfOlderDirectory(File backupFolder) {
|
||||
File[] backupFolders = backupFolder.listFiles(File::isDirectory);
|
||||
|
||||
if (backupFolders == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (File folder : backupFolders) {
|
||||
String folderName = folder.getName();
|
||||
if (!folderName.startsWith(BACKUP_FOLDER_NAME)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
LocalDate folderDate = LocalDate.parse(folderName.substring(BACKUP_FOLDER_NAME.length() + 1, folderName.lastIndexOf("_")));
|
||||
LocalTime folderTime = LocalTime.parse(folderName.substring(folderName.lastIndexOf("_") + 1).replace("-", ":"));
|
||||
LocalDateTime folderDateTime = LocalDateTime.of(folderDate, folderTime);
|
||||
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||
|
||||
long hours = ChronoUnit.HOURS.between(folderDateTime, currentDateTime);
|
||||
|
||||
if (hours > 72) {
|
||||
FileUtils.deleteDirectory(folder);
|
||||
}
|
||||
}
|
||||
catch (DateTimeParseException | IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.eternalcode.combat.config;
|
||||
|
||||
import com.eternalcode.combat.notification.serializer.NotificationSerializer;
|
||||
import eu.okaeri.configs.ConfigManager;
|
||||
import eu.okaeri.configs.OkaeriConfig;
|
||||
import eu.okaeri.configs.serdes.commons.SerdesCommons;
|
||||
import eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer;
|
||||
import eu.okaeri.configs.yaml.bukkit.serdes.SerdesBukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ConfigService {
|
||||
|
||||
private final ConfigBackupService backupService;
|
||||
|
||||
private final Set<OkaeriConfig> configs = new HashSet<>();
|
||||
|
||||
public ConfigService(ConfigBackupService backupService) {
|
||||
this.backupService = backupService;
|
||||
}
|
||||
|
||||
public <T extends OkaeriConfig> T create(Class<T> config, File file) {
|
||||
this.backupService.createBackup();
|
||||
|
||||
T configFile = ConfigManager.create(config);
|
||||
|
||||
configFile.withConfigurer(new YamlBukkitConfigurer(), new SerdesCommons(), new SerdesBukkit());
|
||||
configFile.withSerdesPack(registry -> {
|
||||
registry.register(new NotificationSerializer());
|
||||
});
|
||||
|
||||
configFile.withBindFile(file);
|
||||
configFile.withRemoveOrphans(true);
|
||||
configFile.saveDefaults();
|
||||
configFile.load(true);
|
||||
|
||||
this.configs.add(configFile);
|
||||
|
||||
return configFile;
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
for (OkaeriConfig config : this.configs) {
|
||||
config.load();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
package com.eternalcode.combat.config.implementation;
|
||||
|
||||
import com.eternalcode.combat.WhitelistBlacklistMode;
|
||||
import com.eternalcode.combat.drop.DropSettings;
|
||||
import com.eternalcode.combat.fight.effect.FightEffectSettings;
|
||||
import com.eternalcode.combat.fight.pearl.FightPearlSettings;
|
||||
import com.eternalcode.combat.notification.Notification;
|
||||
import com.eternalcode.combat.notification.implementation.ActionBarNotification;
|
||||
import eu.okaeri.configs.OkaeriConfig;
|
||||
import eu.okaeri.configs.annotation.Comment;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PluginConfig extends OkaeriConfig {
|
||||
|
||||
@Comment("# Do you want to change the plugin settings?")
|
||||
public Settings settings = new Settings();
|
||||
|
||||
@Comment({" ", "# Ender pearl settings"})
|
||||
public FightPearlSettings pearl = new FightPearlSettings();
|
||||
|
||||
@Comment({" ", "# Custom effects settings"})
|
||||
public FightEffectSettings effect = new FightEffectSettings();
|
||||
|
||||
@Comment({" ", "# Set a custom way for a player's items to drop on death (if in combat)"})
|
||||
public DropSettings dropSettings = new DropSettings();
|
||||
|
||||
public static class Settings extends OkaeriConfig {
|
||||
|
||||
@Comment("# Whether the player should receive information about new plugin updates upon joining the server")
|
||||
public boolean shouldReceivePluginUpdates = true;
|
||||
|
||||
@Comment("# The duration of combat in seconds")
|
||||
public Duration combatDuration = Duration.ofSeconds(20);
|
||||
|
||||
@Comment("# List of worlds to ignore")
|
||||
public List<String> worldsToIgnore = List.of(
|
||||
"your_world"
|
||||
);
|
||||
|
||||
@Comment("# List of regions to block")
|
||||
public List<String> blockedRegions = Collections.singletonList("your_region");
|
||||
|
||||
@Comment("# Set the knock multiplier for the blocked region")
|
||||
public double blockedRegionKnockMultiplier = 1.2;
|
||||
|
||||
@Comment("# Set the radius of the blocked region if you aren't using WorldGuard basen on default spawn region!")
|
||||
public int blockedRegionRadius = 10;
|
||||
|
||||
@Comment("# Release attacker after victim dies?")
|
||||
public boolean shouldReleaseAttacker = true;
|
||||
|
||||
@Comment("# Command blocking mode, available modes: WHITELIST, BLACKLIST")
|
||||
public WhitelistBlacklistMode commandBlockingMode = WhitelistBlacklistMode.BLACKLIST;
|
||||
|
||||
@Comment({
|
||||
"# List of commands based on the mode above",
|
||||
"# Based on BLACKLIST mode, all commands in the list are blocked, and all others are allowed",
|
||||
"# Based on WHITELIST mode, all commands in the list are allowed, and all others are blocked",
|
||||
})
|
||||
public List<String> blockedCommands = List.of(
|
||||
"gamemode",
|
||||
"spawn",
|
||||
"tp"
|
||||
);
|
||||
|
||||
@Comment("# Block the use of elytra?")
|
||||
public boolean shouldPreventElytraUsage = true;
|
||||
|
||||
@Comment("# Disable the use of elytra on damage?")
|
||||
public boolean shouldElytraDisableOnDamage = true;
|
||||
|
||||
@Comment("# Block the opening of inventory?")
|
||||
public boolean shouldPreventInventoryOpening = true;
|
||||
|
||||
@Comment("# Whether to block the placement of blocks?")
|
||||
public boolean shouldPreventBlockPlacing = true;
|
||||
|
||||
@Comment("# The minimum Y level at which block placing is blocked")
|
||||
public int minBlockPlacingLevel = 40;
|
||||
|
||||
@Comment({
|
||||
"# Disable placing specific blocks?",
|
||||
"# If you want to block all blocks, enable shouldPreventBlockPlacing and make this list empty",
|
||||
"# If you want to disable placing only specific blocks, enable shouldPreventBlockPlacing and add blocks to this list above",
|
||||
"# If you want to disable this feature completely, disable shouldPreventBlockPlacing option above",
|
||||
})
|
||||
public List<Material> specificBlocksToPreventPlacing = List.of();
|
||||
|
||||
@Comment("# Do You want to enable combat log for non-player causes of damage? - Set to false to disable")
|
||||
public boolean shouldEnableDamageCauses = false;
|
||||
|
||||
@Comment("# Select the mode for damage causes, available modes: WHITELIST, BLACKLIST")
|
||||
public WhitelistBlacklistMode damageCausesMode = WhitelistBlacklistMode.WHITELIST;
|
||||
|
||||
@Comment({
|
||||
"# After selecting the mode above, select the causes of damage to be logged",
|
||||
"# You can find a list of all causes here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityDamageEvent.DamageCause.html",
|
||||
"# While using Whitelist mode the player will get a combat log after the damage from the list below",
|
||||
"# While using Blacklist mode the player will get a combat log after any damage non-listed below",
|
||||
})
|
||||
public List<EntityDamageEvent.DamageCause> damageCausesToLog = List.of(
|
||||
EntityDamageEvent.DamageCause.LAVA,
|
||||
EntityDamageEvent.DamageCause.CONTACT,
|
||||
EntityDamageEvent.DamageCause.FIRE,
|
||||
EntityDamageEvent.DamageCause.FIRE_TICK
|
||||
);
|
||||
|
||||
@Comment({
|
||||
"# After what type of projectile entity should not tag the player as fighter?",
|
||||
"# You can find a list of all entity types here: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html"
|
||||
})
|
||||
public List<EntityType> disabledProjectileEntities = List.of(
|
||||
EntityType.ENDER_PEARL
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Comment({" ", "# Do you want to change the plugin messages?"})
|
||||
public Messages messages = new Messages();
|
||||
|
||||
public static class Messages extends OkaeriConfig {
|
||||
|
||||
@Comment("# Do you want to change the admin messages?")
|
||||
public AdminMessages admin = new AdminMessages();
|
||||
|
||||
@Comment({
|
||||
" ",
|
||||
"# Combat log notification",
|
||||
"# You can use {TIME} variable to display the time left in combat",
|
||||
"# Notification types: CHAT, ACTION_BAR, TITLE, SUB_TITLE, BOSS_BAR",
|
||||
" ",
|
||||
"# BossBar progress: This is the value of the progress bar. Set it to -1.0 to show the remaining combat time",
|
||||
"# 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"
|
||||
})
|
||||
public Notification combatNotification = new ActionBarNotification("&dCombat ends in: &f{TIME}");
|
||||
|
||||
@Comment("# Message sent when the player does not have permission to perform a command")
|
||||
public String noPermission = "&cYou don't have permission to perform this command!";
|
||||
|
||||
@Comment("# Message sent when the specified player could not be found")
|
||||
public String playerNotFound = "&cThe specified player could not be found!";
|
||||
|
||||
@Comment("# Message sent when the player enters combat")
|
||||
public String playerTagged = "&cYou are in combat, do not leave the server!";
|
||||
|
||||
@Comment("# Message sent when the player leaves combat")
|
||||
public String playerUntagged = "&aYou are no longer in combat! You can safely leave the server.";
|
||||
|
||||
@Comment("# This is broadcast when the player is in combat and logs out")
|
||||
public String playerLoggedOutDuringCombat = "&c{PLAYER} logged off during the fight!";
|
||||
|
||||
@Comment({
|
||||
"# Message sent when the player is in combat and tries to use a disabled command",
|
||||
"# you can configure the list of disabled commands in the blockedCommands section of the config.yml file"
|
||||
})
|
||||
public String commandDisabledDuringCombat = "&cUsing this command during combat is prohibited!";
|
||||
|
||||
@Comment("# Message sent when player tries to use a command with invalid arguments")
|
||||
public String invalidCommandUsage = "&7Correct usage: &e{USAGE}";
|
||||
|
||||
@Comment("# Message sent when player tries to open inventory, but the inventory open is blocked")
|
||||
public String inventoryBlockedDuringCombat = "&cYou cannot open this inventory during combat!";
|
||||
|
||||
@Comment("# Message sent when player tries to place a block, but the block place is blocked")
|
||||
public String blockPlacingBlockedDuringCombat = "&cYou cannot place above 40Y coordinate during combat!";
|
||||
|
||||
@Comment("# Message sent when player tries to enter a region")
|
||||
public String cantEnterOnRegion = "&cYou can't enter on this region during combat!";
|
||||
|
||||
public static class AdminMessages extends OkaeriConfig {
|
||||
@Comment("# Message sent when the configuration is reloaded")
|
||||
public String reload = "&aConfiguration has been successfully reloaded!";
|
||||
|
||||
@Comment("# Message sent when console tries to use a command that is only for players")
|
||||
public String onlyForPlayers = "&cThis command is only available to players!";
|
||||
|
||||
@Comment("# Message sent to admin when they tag a player")
|
||||
public String adminTagPlayer = "&7You have tagged &e{PLAYER}";
|
||||
|
||||
@Comment("# Message sent when a player is tagged by an admin")
|
||||
public String adminTagMultiplePlayers = "&7You have tagged &e{FIRST_PLAYER}&7 and &e{SECOND_PLAYER}&7.";
|
||||
|
||||
@Comment("# Message sent to admin when they remove a player from combat")
|
||||
public String adminUntagPlayer = "&7You have removed &e{PLAYER}&7 from the fight.";
|
||||
|
||||
@Comment("# Message sent when the player is not in combat")
|
||||
public String adminPlayerNotInCombat = "&cThis player is not in combat!";
|
||||
|
||||
@Comment("# Message sent when the player is in combat")
|
||||
public String playerInCombat = "&c{PLAYER} is currently in combat!";
|
||||
|
||||
@Comment("# Message sent when a player is not in combat")
|
||||
public String playerNotInCombat = "&a{PLAYER} is not currently in combat.";
|
||||
|
||||
@Comment("# Message sent when an admin tries to tag themselves")
|
||||
public String adminCannotTagSelf = "&cYou cannot tag yourself!";
|
||||
|
||||
@Comment("# Message sent when an admin disables the ability to get tagged for some time")
|
||||
public String adminTagOutSelf = "&7Successfully disabled tag for Yourself! You will be taggable after &e{TIME} ";
|
||||
|
||||
@Comment("# Message sent when an admin disables the ability to get tagged for some time for other player")
|
||||
public String adminTagOut = "&7Successfully disabled tag for &e{PLAYER}! They will be taggable after &e{TIME} ";
|
||||
|
||||
@Comment("# Message sent to the player whom the ability to get tagged for some time has been disabled")
|
||||
public String playerTagOut = "&7You will be taggable in &e{TIME} !";
|
||||
|
||||
@Comment("# Message sent when an admin reenables the ability to get tagged for the player")
|
||||
public String adminTagOutOff = "&7Successfully enabled tag for &e{PLAYER}!";
|
||||
|
||||
@Comment("# Message sent to the player whom the ability to get tagged has been reenabled")
|
||||
public String playerTagOutOff = "&7You are now taggable!";
|
||||
|
||||
@Comment("# Message sent when player cannot be tagged because they have enabled tag-out")
|
||||
public String adminTagOutCanceled = "&cCannot tag this player due to tag-out!";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package com.eternalcode.combat.drop;
|
||||
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.fight.FightTag;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DropController implements Listener {
|
||||
|
||||
private final DropManager dropManager;
|
||||
private final DropKeepInventoryManager keepInventoryManager;
|
||||
private final DropSettings dropSettings;
|
||||
private final FightManager fightManager;
|
||||
|
||||
public DropController(DropManager dropManager, DropKeepInventoryManager keepInventoryManager, DropSettings dropSettings, FightManager fightManager) {
|
||||
this.dropManager = dropManager;
|
||||
this.keepInventoryManager = keepInventoryManager;
|
||||
this.dropSettings = dropSettings;
|
||||
this.fightManager = fightManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity();
|
||||
|
||||
DropType dropType = this.dropSettings.dropType;
|
||||
|
||||
if (dropType == DropType.UNCHANGED || !this.fightManager.isInCombat(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
FightTag fightTag = this.fightManager.getTag(player.getUniqueId());
|
||||
|
||||
List<ItemStack> drops = event.getDrops();
|
||||
|
||||
Drop drop = Drop.builder()
|
||||
.player(player)
|
||||
.killer(player.getKiller())
|
||||
.fightTag(fightTag)
|
||||
.deathCause(fightTag.getDeathCause())
|
||||
.droppedItems(drops)
|
||||
.droppedExp(player.getTotalExperience())
|
||||
.build();
|
||||
|
||||
DropResult result = this.dropManager.modify(dropType, drop);
|
||||
|
||||
drops.clear();
|
||||
drops.addAll(result.droppedItems());
|
||||
|
||||
this.keepInventoryManager.addItems(player.getUniqueId(), result.removedItems());
|
||||
|
||||
if (this.dropSettings.affectExperience) {
|
||||
event.setDroppedExp(drop.getDroppedExp());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
UUID playerUniqueId = player.getUniqueId();
|
||||
|
||||
if (this.keepInventoryManager.hasItems(playerUniqueId)) {
|
||||
PlayerInventory playerInventory = player.getInventory();
|
||||
|
||||
ItemStack[] itemsToGive = this.keepInventoryManager.nextItems(playerUniqueId)
|
||||
.toArray(new ItemStack[0]);
|
||||
|
||||
playerInventory.addItem(itemsToGive);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.eternalcode.combat.drop;
|
||||
|
||||
import eu.okaeri.configs.OkaeriConfig;
|
||||
import eu.okaeri.configs.annotation.Comment;
|
||||
|
||||
public class DropSettings extends OkaeriConfig {
|
||||
|
||||
@Comment({
|
||||
"# UNCHANGED - The default way of item drop defined by the engine",
|
||||
"# PERCENT - Drops a fixed percentage of items",
|
||||
"# PLAYERS_HEALTH - Drops inverted percentage of the player's health (i.e. if the player has, for example, 80% HP, he will drop 20% of items. Only works when the player escapes from combat by quiting game)"
|
||||
})
|
||||
public DropType dropType = DropType.UNCHANGED;
|
||||
|
||||
@Comment("# What percentage of items should drop from the player? (Only if Drop Type is set to PERCENT)")
|
||||
public int dropItemPercent = 100;
|
||||
|
||||
@Comment("# This option is responsible for the lowest percentage of the player that can drop (i.e. if the player leaves the game while he has 100% of his HP, the percentage of items that is set in this option will drop, if you set this option to 0, then nothing will drop from such a player)")
|
||||
public int playersHealthPercentClamp = 20;
|
||||
|
||||
@Comment("# Does the drop modification affect the experience drop?")
|
||||
public boolean affectExperience = false;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.eternalcode.combat.event;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public class EventCaller {
|
||||
|
||||
private final Server server;
|
||||
|
||||
public EventCaller(Server server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public <T extends Event> T publishEvent(T event) {
|
||||
this.server.getPluginManager().callEvent(event);
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.eternalcode.combat.fight;
|
||||
|
||||
public enum FightDeathCause {
|
||||
|
||||
UNKNOWN,
|
||||
ESCAPE,
|
||||
KILLED_BY_PLAYER,
|
||||
KILLED_BY_ENTITY
|
||||
|
||||
}
|
||||
@@ -4,69 +4,26 @@ 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.fight.event.FightUntagEvent;
|
||||
import com.eternalcode.combat.event.EventCaller;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FightManager {
|
||||
public interface FightManager {
|
||||
|
||||
private final Map<UUID, FightTag> fights = new ConcurrentHashMap<>();
|
||||
private final EventCaller eventCaller;
|
||||
boolean isInCombat(UUID player);
|
||||
|
||||
public FightManager(EventCaller eventCaller) {
|
||||
this.eventCaller = eventCaller;
|
||||
}
|
||||
FightTag getTag(UUID target);
|
||||
|
||||
public boolean isInCombat(UUID player) {
|
||||
if (!this.fights.containsKey(player)) {
|
||||
return false;
|
||||
}
|
||||
Collection<FightTag> getFights();
|
||||
|
||||
FightTag fightTag = this.fights.get(player);
|
||||
@ApiStatus.Experimental
|
||||
FightTagEvent tag(UUID target, Duration delay, CauseOfTag causeOfTag, @Nullable UUID tagger);
|
||||
|
||||
return !fightTag.isExpired();
|
||||
}
|
||||
FightTagEvent tag(UUID target, Duration delay, CauseOfTag causeOfTag);
|
||||
|
||||
public FightUntagEvent untag(UUID player, CauseOfUnTag causeOfUnTag) {
|
||||
FightUntagEvent event = this.eventCaller.publishEvent(new FightUntagEvent(player, causeOfUnTag));
|
||||
if (event.isCancelled()) {
|
||||
return event;
|
||||
}
|
||||
FightUntagEvent untag(UUID player, CauseOfUnTag causeOfUnTag);
|
||||
|
||||
this.fights.remove(player);
|
||||
return event;
|
||||
}
|
||||
|
||||
public FightTagEvent tag(UUID target, Duration delay, CauseOfTag causeOfTag) {
|
||||
FightTagEvent event = this.eventCaller.publishEvent(new FightTagEvent(target, causeOfTag));
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return event;
|
||||
}
|
||||
Instant now = Instant.now();
|
||||
Instant endOfCombatLog = now.plus(delay);
|
||||
|
||||
FightTag fightTag = new FightTag(target, endOfCombatLog);
|
||||
|
||||
this.fights.put(target, fightTag);
|
||||
return event;
|
||||
}
|
||||
|
||||
public Collection<FightTag> getFights() {
|
||||
return Collections.unmodifiableCollection(this.fights.values());
|
||||
}
|
||||
|
||||
public FightTag getTag(UUID target) {
|
||||
return this.fights.get(target);
|
||||
}
|
||||
|
||||
public void untagAll() {
|
||||
this.fights.clear();
|
||||
}
|
||||
void untagAll();
|
||||
}
|
||||
@@ -3,58 +3,20 @@ package com.eternalcode.combat.fight;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FightTag {
|
||||
public interface FightTag {
|
||||
|
||||
private final UUID taggedPlayer;
|
||||
private final Instant endOfCombatLog;
|
||||
@Nullable
|
||||
@ApiStatus.Experimental
|
||||
UUID getTagger();
|
||||
|
||||
private double healthBeforeDeath;
|
||||
private FightDeathCause deathCause;
|
||||
Duration getRemainingDuration();
|
||||
|
||||
FightTag(UUID personToAddCombat, Instant endOfCombatLog) {
|
||||
this.taggedPlayer = personToAddCombat;
|
||||
this.endOfCombatLog = endOfCombatLog;
|
||||
boolean isExpired();
|
||||
|
||||
this.healthBeforeDeath = 0;
|
||||
this.deathCause = FightDeathCause.UNKNOWN;
|
||||
}
|
||||
Instant getEndOfCombatLog();
|
||||
|
||||
public UUID getTaggedPlayer() {
|
||||
return this.taggedPlayer;
|
||||
}
|
||||
|
||||
public Instant getEndOfCombatLog() {
|
||||
return this.endOfCombatLog;
|
||||
}
|
||||
|
||||
public boolean isExpired() {
|
||||
return Instant.now().isAfter(this.endOfCombatLog);
|
||||
}
|
||||
|
||||
public Duration getRemainingDuration() {
|
||||
Duration between = Duration.between(Instant.now(), this.endOfCombatLog);
|
||||
|
||||
if (between.isNegative()) {
|
||||
return Duration.ZERO;
|
||||
}
|
||||
|
||||
return between;
|
||||
}
|
||||
|
||||
public double getHealthBeforeDeath() {
|
||||
return this.healthBeforeDeath;
|
||||
}
|
||||
|
||||
public void setHealthBeforeDeath(double health) {
|
||||
this.healthBeforeDeath = health;
|
||||
}
|
||||
|
||||
public FightDeathCause getDeathCause() {
|
||||
return this.deathCause;
|
||||
}
|
||||
|
||||
public void setDeathCause(FightDeathCause deathCause) {
|
||||
this.deathCause = deathCause;
|
||||
}
|
||||
UUID getTaggedPlayer();
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.eternalcode.combat.fight;
|
||||
|
||||
import com.eternalcode.combat.fight.event.CauseOfUnTag;
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.fight.bossbar.FightBossBarService;
|
||||
import com.eternalcode.combat.notification.Notification;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
import com.eternalcode.combat.notification.implementation.BossBarNotification;
|
||||
import com.eternalcode.combat.util.DurationUtil;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import panda.utilities.text.Formatter;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FightTask implements Runnable {
|
||||
|
||||
private final Server server;
|
||||
private final PluginConfig config;
|
||||
private final FightManager fightManager;
|
||||
private final FightBossBarService bossBarService;
|
||||
private final NotificationAnnouncer announcer;
|
||||
|
||||
public FightTask(Server server, PluginConfig config, FightManager fightManager, FightBossBarService bossBarService, NotificationAnnouncer announcer) {
|
||||
this.server = server;
|
||||
this.config = config;
|
||||
this.fightManager = fightManager;
|
||||
this.bossBarService = bossBarService;
|
||||
this.announcer = announcer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (FightTag fightTag : this.fightManager.getFights()) {
|
||||
Player player = this.server.getPlayer(fightTag.getTaggedPlayer());
|
||||
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
UUID playerUniqueId = player.getUniqueId();
|
||||
|
||||
if (fightTag.isExpired()) {
|
||||
this.fightManager.untag(playerUniqueId, CauseOfUnTag.TIME_EXPIRED);
|
||||
return;
|
||||
}
|
||||
|
||||
Duration remaining = fightTag.getRemainingDuration();
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{TIME}", DurationUtil.format(remaining));
|
||||
|
||||
Notification combatNotification = this.config.messages.combatNotification;
|
||||
|
||||
this.sendFightNotification(player, fightTag, combatNotification, formatter);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendFightNotification(Player player, FightTag fightTag, Notification notification, Formatter formatter) {
|
||||
if (notification instanceof BossBarNotification bossBarNotification) {
|
||||
this.bossBarService.send(player, fightTag, bossBarNotification, formatter);
|
||||
return;
|
||||
}
|
||||
|
||||
this.announcer.send(player, notification, formatter);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.eternalcode.combat.fight.bossbar;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public record FightBossBar(Audience audience, BossBar bossBar, float progress, Duration combatDuration) {
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.eternalcode.combat.fight.bossbar;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
class FightBossBarRegistry {
|
||||
|
||||
private final Map<UUID, FightBossBar> fightBossBars = new ConcurrentHashMap<>();
|
||||
|
||||
void add(UUID uuid, FightBossBar fightBossBar) {
|
||||
this.fightBossBars.put(uuid, fightBossBar);
|
||||
}
|
||||
|
||||
void remove(UUID uuid) {
|
||||
this.fightBossBars.remove(uuid);
|
||||
}
|
||||
|
||||
boolean hasFightBossBar(UUID uuid) {
|
||||
return this.fightBossBars.containsKey(uuid);
|
||||
}
|
||||
|
||||
Optional<FightBossBar> getFightBossBar(UUID uuid) {
|
||||
return Optional.ofNullable(this.fightBossBars.get(uuid));
|
||||
}
|
||||
}
|
||||
@@ -1,119 +0,0 @@
|
||||
package com.eternalcode.combat.fight.bossbar;
|
||||
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.fight.FightTag;
|
||||
import com.eternalcode.combat.notification.implementation.BossBarNotification;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.platform.AudienceProvider;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.entity.Player;
|
||||
import panda.utilities.text.Formatter;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FightBossBarService {
|
||||
|
||||
private final PluginConfig pluginConfig;
|
||||
private final FightBossBarRegistry bossBarRegistry = new FightBossBarRegistry();
|
||||
private final AudienceProvider audienceProvider;
|
||||
private final MiniMessage miniMessage;
|
||||
|
||||
public FightBossBarService(PluginConfig pluginConfig, AudienceProvider audienceProvider, MiniMessage miniMessage) {
|
||||
this.pluginConfig = pluginConfig;
|
||||
this.audienceProvider = audienceProvider;
|
||||
this.miniMessage = miniMessage;
|
||||
}
|
||||
|
||||
public void hide(FightTag fightTag, FightBossBar fightBossBar) {
|
||||
Audience audience = fightBossBar.audience();
|
||||
BossBar bossBar = fightBossBar.bossBar();
|
||||
UUID taggedPlayer = fightTag.getTaggedPlayer();
|
||||
|
||||
audience.hideBossBar(bossBar);
|
||||
this.bossBarRegistry.remove(taggedPlayer);
|
||||
}
|
||||
|
||||
public void hide(UUID playerUuid) {
|
||||
Optional<FightBossBar> bossBar = this.bossBarRegistry.getFightBossBar(playerUuid);
|
||||
|
||||
if (bossBar.isPresent()) {
|
||||
FightBossBar fightBossBar = bossBar.get();
|
||||
Audience audience = fightBossBar.audience();
|
||||
BossBar bar = fightBossBar.bossBar();
|
||||
|
||||
audience.hideBossBar(bar);
|
||||
this.bossBarRegistry.remove(playerUuid);
|
||||
}
|
||||
}
|
||||
|
||||
public void send(Player player, FightTag fightTag, BossBarNotification bossBarNotification, Formatter formatter) {
|
||||
UUID playerUniqueId = player.getUniqueId();
|
||||
|
||||
FightBossBar fightBossBar = this.bossBarRegistry.getFightBossBar(playerUniqueId)
|
||||
.orElseGet(() -> this.create(player, bossBarNotification, formatter));
|
||||
|
||||
if (!this.bossBarRegistry.hasFightBossBar(playerUniqueId)) {
|
||||
this.show(player, fightBossBar);
|
||||
return;
|
||||
}
|
||||
|
||||
String message = formatter.format(bossBarNotification.message());
|
||||
|
||||
this.update(fightTag, fightBossBar, message);
|
||||
}
|
||||
|
||||
private void update(FightTag fightTag, FightBossBar fightBossBar, String message) {
|
||||
if (fightTag.isExpired()) {
|
||||
this.hide(fightTag, fightBossBar);
|
||||
return;
|
||||
}
|
||||
|
||||
BossBar bossBar = fightBossBar.bossBar();
|
||||
float fightBossBarProgress = fightBossBar.progress();
|
||||
|
||||
if (fightBossBarProgress < 0.0F) {
|
||||
Instant now = Instant.now();
|
||||
|
||||
Instant endOfCombatLog = fightTag.getEndOfCombatLog();
|
||||
|
||||
Duration between = Duration.between(now, endOfCombatLog);
|
||||
Duration combatDuration = fightBossBar.combatDuration();
|
||||
|
||||
float difference = (float) between.toMillis() / combatDuration.toMillis();
|
||||
float progress = Math.max(0.0F, Math.min(1.0F, difference));
|
||||
|
||||
bossBar.progress(progress);
|
||||
}
|
||||
|
||||
Component name = this.miniMessage.deserialize(message);
|
||||
|
||||
bossBar.name(name);
|
||||
}
|
||||
|
||||
private void show(Player player, FightBossBar fightBossBar) {
|
||||
UUID playerUniqueId = player.getUniqueId();
|
||||
|
||||
Audience audience = this.audienceProvider.player(playerUniqueId);
|
||||
BossBar bossBar = fightBossBar.bossBar();
|
||||
|
||||
audience.showBossBar(bossBar);
|
||||
this.bossBarRegistry.add(playerUniqueId, fightBossBar);
|
||||
}
|
||||
|
||||
private FightBossBar create(Player player, BossBarNotification bossBarNotification, Formatter formatter) {
|
||||
Audience audience = this.audienceProvider.player(player.getUniqueId());
|
||||
|
||||
Component name = this.miniMessage.deserialize(formatter.format(bossBarNotification.message()));
|
||||
BossBar bossBar = bossBarNotification.create(name);
|
||||
|
||||
float progress = bossBarNotification.progress();
|
||||
Duration combatDuration = this.pluginConfig.settings.combatDuration;
|
||||
|
||||
return new FightBossBar(audience, bossBar, progress, combatDuration);
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
package com.eternalcode.combat.fight.controller;
|
||||
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.WhitelistBlacklistMode;
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
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 org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityToggleGlideEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FightActionBlockerController implements Listener {
|
||||
|
||||
private final FightManager fightManager;
|
||||
private final NotificationAnnouncer announcer;
|
||||
private final PluginConfig config;
|
||||
|
||||
public FightActionBlockerController(FightManager fightManager, NotificationAnnouncer announcer, PluginConfig config) {
|
||||
this.fightManager = fightManager;
|
||||
this.announcer = announcer;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlace(BlockPlaceEvent event) {
|
||||
if (!this.config.settings.shouldPreventBlockPlacing) {
|
||||
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.settings.specificBlocksToPreventPlacing;
|
||||
|
||||
boolean isBlockPlaceLevel = level > this.config.settings.minBlockPlacingLevel;
|
||||
if (isBlockPlaceLevel && specificBlocksToPreventPlacing.isEmpty()) {
|
||||
event.setCancelled(true);
|
||||
this.announcer.sendMessage(player, this.config.messages.blockPlacingBlockedDuringCombat);
|
||||
}
|
||||
|
||||
Material blockMaterial = block.getType();
|
||||
boolean isBlockInDisabledList = specificBlocksToPreventPlacing.contains(blockMaterial);
|
||||
if (isBlockPlaceLevel && isBlockInDisabledList) {
|
||||
event.setCancelled(true);
|
||||
this.announcer.sendMessage(player, this.config.messages.blockPlacingBlockedDuringCombat);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onToggleGlide(EntityToggleGlideEvent event) {
|
||||
if (!this.config.settings.shouldPreventElytraUsage) {
|
||||
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
|
||||
public void onDamage(EntityDamageEvent event) {
|
||||
if (!this.config.settings.shouldElytraDisableOnDamage) {
|
||||
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.settings.shouldPreventInventoryOpening) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getPlayer();
|
||||
UUID uniqueId = player.getUniqueId();
|
||||
|
||||
if (!this.fightManager.isInCombat(uniqueId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
this.announcer.sendMessage(player, this.config.messages.inventoryBlockedDuringCombat);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
UUID playerUniqueId = player.getUniqueId();
|
||||
|
||||
if (!this.fightManager.isInCombat(playerUniqueId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String command = event.getMessage().split(" ")[0].substring(1).toLowerCase();
|
||||
|
||||
boolean isMatchCommand = this.config.settings.blockedCommands.stream()
|
||||
.anyMatch(command::startsWith);
|
||||
|
||||
WhitelistBlacklistMode mode = this.config.settings.commandBlockingMode;
|
||||
|
||||
boolean shouldCancel = mode.shouldBlock(isMatchCommand);
|
||||
|
||||
if (shouldCancel) {
|
||||
event.setCancelled(true);
|
||||
this.announcer.sendMessage(player, this.config.messages.commandDisabledDuringCombat);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.eternalcode.combat.fight.controller;
|
||||
|
||||
import com.eternalcode.combat.fight.FightDeathCause;
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.fight.FightTag;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class FightDeathCauseController implements Listener {
|
||||
|
||||
private final FightManager fightManager;
|
||||
|
||||
public FightDeathCauseController(FightManager fightManager) {
|
||||
this.fightManager = fightManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event) {
|
||||
Entity victimEntity = event.getEntity();
|
||||
Entity damagerEntity = event.getDamager();
|
||||
|
||||
if (!(victimEntity instanceof Player victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.fightManager.isInCombat(victim.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (victim.getHealth() > event.getFinalDamage()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FightTag fightTag = this.fightManager.getTag(damagerEntity.getUniqueId());
|
||||
|
||||
if (damagerEntity instanceof Player) {
|
||||
fightTag.setDeathCause(FightDeathCause.KILLED_BY_PLAYER);
|
||||
return;
|
||||
}
|
||||
|
||||
fightTag.setDeathCause(FightDeathCause.KILLED_BY_ENTITY);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!this.fightManager.isInCombat(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
FightTag fightTag = this.fightManager.getTag(player.getUniqueId());
|
||||
fightTag.setDeathCause(FightDeathCause.ESCAPE);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.eternalcode.combat.fight.controller;
|
||||
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.fight.FightTag;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import panda.utilities.text.Formatter;
|
||||
|
||||
public class FightEscapeController implements Listener {
|
||||
|
||||
private final FightManager fightManager;
|
||||
private final PluginConfig config;
|
||||
private final NotificationAnnouncer announcer;
|
||||
|
||||
public FightEscapeController(FightManager fightManager, PluginConfig config, NotificationAnnouncer announcer) {
|
||||
this.fightManager = fightManager;
|
||||
this.config = config;
|
||||
this.announcer = announcer;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!this.fightManager.isInCombat(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{PLAYER}", player.getName());
|
||||
|
||||
String format = formatter.format(this.config.messages.playerLoggedOutDuringCombat);
|
||||
|
||||
this.announcer.broadcast(format);
|
||||
|
||||
FightTag fightTag = this.fightManager.getTag(player.getUniqueId());
|
||||
fightTag.setHealthBeforeDeath(player.getHealth());
|
||||
|
||||
player.setHealth(0.0); // Untagged in PlayerDeathEvent
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.eternalcode.combat.fight.controller;
|
||||
|
||||
import com.eternalcode.combat.fight.event.CauseOfUnTag;
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
public class FightUnTagController implements Listener {
|
||||
|
||||
private final FightManager fightManager;
|
||||
private final PluginConfig config;
|
||||
|
||||
public FightUnTagController(FightManager fightManager, PluginConfig config) {
|
||||
this.fightManager = fightManager;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity();
|
||||
Player killer = player.getKiller();
|
||||
|
||||
if (!this.fightManager.isInCombat(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
CauseOfUnTag causeOfUnTag = (killer == null ? CauseOfUnTag.DEATH_BY_PLAYER : CauseOfUnTag.DEATH);
|
||||
|
||||
this.fightManager.untag(player.getUniqueId(), causeOfUnTag);
|
||||
|
||||
if (killer != null && this.config.settings.shouldReleaseAttacker) {
|
||||
this.fightManager.untag(killer.getUniqueId(), CauseOfUnTag.ATTACKER_RELEASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.eternalcode.combat.drop;
|
||||
package com.eternalcode.combat.fight.drop;
|
||||
|
||||
import com.eternalcode.combat.fight.FightDeathCause;
|
||||
import com.eternalcode.combat.fight.FightTag;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -15,18 +13,13 @@ public class Drop {
|
||||
|
||||
private final Player player;
|
||||
private final Player killer;
|
||||
private final FightTag fightTag;
|
||||
private final FightDeathCause deathCause;
|
||||
|
||||
private final List<ItemStack> droppedItems;
|
||||
private final int droppedExp;
|
||||
|
||||
private Drop(Player player, Player killer, FightTag fightTag, FightDeathCause deathCause, List<ItemStack> droppedItems, int droppedExp) {
|
||||
private Drop(Player player, Player killer, List<ItemStack> droppedItems, int droppedExp) {
|
||||
this.player = player;
|
||||
this.killer = killer;
|
||||
this.fightTag = fightTag;
|
||||
this.deathCause = deathCause;
|
||||
|
||||
this.droppedItems = droppedItems;
|
||||
this.droppedExp = droppedExp;
|
||||
}
|
||||
@@ -43,14 +36,6 @@ public class Drop {
|
||||
return this.killer;
|
||||
}
|
||||
|
||||
public FightTag getFightTag() {
|
||||
return this.fightTag;
|
||||
}
|
||||
|
||||
public FightDeathCause getDeathCause() {
|
||||
return this.deathCause;
|
||||
}
|
||||
|
||||
public boolean hasKiller() {
|
||||
return this.killer != null;
|
||||
}
|
||||
@@ -67,8 +52,6 @@ public class Drop {
|
||||
|
||||
private Player player;
|
||||
private Player killer;
|
||||
private FightTag fightTag;
|
||||
private FightDeathCause deathCause;
|
||||
private List<ItemStack> droppedItems;
|
||||
private int droppedExp;
|
||||
|
||||
@@ -82,16 +65,6 @@ public class Drop {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder fightTag(@NotNull FightTag fightTag) {
|
||||
this.fightTag = fightTag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder deathCause(@NotNull FightDeathCause deathCause) {
|
||||
this.deathCause = deathCause;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder droppedItems(@NotNull List<ItemStack> droppedItems) {
|
||||
this.droppedItems = new ArrayList<>(droppedItems);
|
||||
return this;
|
||||
@@ -106,8 +79,6 @@ public class Drop {
|
||||
return new Drop(
|
||||
this.player,
|
||||
this.killer,
|
||||
this.fightTag,
|
||||
this.deathCause,
|
||||
this.droppedItems,
|
||||
this.droppedExp
|
||||
);
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.eternalcode.combat.fight.drop;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface DropKeepInventoryService {
|
||||
|
||||
List<ItemStack> nextItems(UUID uuid);
|
||||
|
||||
boolean hasItems(UUID uuid);
|
||||
|
||||
void addItems(UUID uuid, List<ItemStack> item);
|
||||
|
||||
void addItem(UUID uuid, ItemStack item);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.eternalcode.combat.drop;
|
||||
package com.eternalcode.combat.fight.drop;
|
||||
|
||||
public interface DropModifier {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.eternalcode.combat.drop;
|
||||
package com.eternalcode.combat.fight.drop;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.eternalcode.combat.fight.drop;
|
||||
|
||||
public interface DropService {
|
||||
|
||||
DropResult modify(DropType dropType, Drop drop);
|
||||
|
||||
void registerModifier(DropModifier dropModifier);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.eternalcode.combat.drop;
|
||||
package com.eternalcode.combat.fight.drop;
|
||||
|
||||
public enum DropType {
|
||||
|
||||
@@ -1,75 +1,25 @@
|
||||
package com.eternalcode.combat.fight.effect;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
/**
|
||||
* Manages custom potion effects on players during combat.
|
||||
* Active effects before combat are stored and restored after combat ends.
|
||||
*/
|
||||
public interface FightEffectService {
|
||||
|
||||
public class FightEffectService {
|
||||
void removeCustomEffect(Player player, PotionEffectType type, Integer amplifier);
|
||||
|
||||
private final Map<UUID, List<PotionEffect>> activeEffects = new HashMap<>();
|
||||
private static final int INFINITE_DURATION = -1;
|
||||
void applyCustomEffect(Player player, PotionEffectType type, Integer amplifier);
|
||||
|
||||
public void storeActiveEffect(Player player, PotionEffect effect) {
|
||||
List<PotionEffect> effects = this.activeEffects.computeIfAbsent(player.getUniqueId(), k -> new ArrayList<>());
|
||||
List<PotionEffect> getCurrentEffects(Player player);
|
||||
|
||||
effects.add(effect);
|
||||
}
|
||||
void clearStoredEffects(Player player);
|
||||
|
||||
public void restoreActiveEffects(Player player) {
|
||||
List<PotionEffect> currentEffects = this.getCurrentEffects(player);
|
||||
void restoreActiveEffects(Player player);
|
||||
|
||||
for (PotionEffect effect : currentEffects) {
|
||||
player.addPotionEffect(effect);
|
||||
}
|
||||
|
||||
this.clearStoredEffects(player);
|
||||
}
|
||||
|
||||
public void clearStoredEffects(Player player) {
|
||||
this.activeEffects.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public List<PotionEffect> getCurrentEffects(Player player) {
|
||||
return this.activeEffects.getOrDefault(player.getUniqueId(), new ArrayList<>());
|
||||
}
|
||||
|
||||
public void applyCustomEffect(Player player, PotionEffectType type, Integer amplifier) {
|
||||
PotionEffect activeEffect = player.getPotionEffect(type);
|
||||
|
||||
if (activeEffect == null) {
|
||||
player.addPotionEffect(new PotionEffect(type, INFINITE_DURATION, amplifier));
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeEffect.getAmplifier() > amplifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeEffect.getDuration() == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.storeActiveEffect(player, activeEffect);
|
||||
player.addPotionEffect(new PotionEffect(type, INFINITE_DURATION, amplifier));
|
||||
}
|
||||
|
||||
public void removeCustomEffect(Player player, PotionEffectType type, Integer amplifier) {
|
||||
PotionEffect activeEffect = player.getPotionEffect(type);
|
||||
|
||||
if (activeEffect == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeEffect.getAmplifier() != amplifier) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.removePotionEffect(type);
|
||||
}
|
||||
void storeActiveEffect(Player player, PotionEffect effect);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.eternalcode.combat.fight.event;
|
||||
|
||||
public enum CancelTagReason {
|
||||
|
||||
TAGOUT,
|
||||
PERMISSION_BYPASS,
|
||||
ADMIN,
|
||||
CREATIVE_MODE,
|
||||
|
||||
}
|
||||
@@ -1,7 +1,46 @@
|
||||
package com.eternalcode.combat.fight.event;
|
||||
|
||||
public enum CauseOfTag {
|
||||
|
||||
/**
|
||||
* The player was tagged in combat as a result of an attack by another player.
|
||||
*/
|
||||
PLAYER,
|
||||
|
||||
/**
|
||||
* The player was tagged in combat due to an interaction with a non-player entity
|
||||
* (e.g., mobs or environmental damage).
|
||||
*/
|
||||
NON_PLAYER,
|
||||
COMMAND
|
||||
|
||||
/**
|
||||
* A command was executed to apply a combat tag to the player.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
CUSTOM
|
||||
}
|
||||
@@ -1,10 +1,38 @@
|
||||
package com.eternalcode.combat.fight.event;
|
||||
|
||||
public enum CauseOfUnTag {
|
||||
/**
|
||||
* The combat tag expired after a set duration.
|
||||
*/
|
||||
TIME_EXPIRED,
|
||||
|
||||
/**
|
||||
* The player died, which resulted in the removal of the combat tag.
|
||||
*/
|
||||
DEATH,
|
||||
|
||||
/**
|
||||
* The player was killed by another player, causing the combat tag to be removed.
|
||||
*/
|
||||
DEATH_BY_PLAYER,
|
||||
|
||||
/**
|
||||
* The player logged out, triggering the removal of the combat tag.
|
||||
*/
|
||||
LOGOUT,
|
||||
|
||||
/**
|
||||
* A command was executed to remove the player's combat tag.
|
||||
*/
|
||||
COMMAND,
|
||||
ATTACKER_RELEASE
|
||||
|
||||
/**
|
||||
* The attacker released the player, ending the combat and removing the tag.
|
||||
*/
|
||||
ATTACKER_RELEASE,
|
||||
|
||||
/**
|
||||
* A custom cause, typically defined by external plugins or systems.
|
||||
*/
|
||||
CUSTOM
|
||||
}
|
||||
@@ -5,59 +5,103 @@ 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.
|
||||
*/
|
||||
public class FightTagEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private final UUID player;
|
||||
private final CauseOfTag cause;
|
||||
private boolean isCancelled = false;
|
||||
private String cancelMessage = "";
|
||||
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 = player;
|
||||
this.cause = 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UUID of the player who was tagged.
|
||||
*
|
||||
* @return The UUID of the tagged player.
|
||||
*/
|
||||
public UUID getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the reason why the player was tagged.
|
||||
*
|
||||
* @return The cause of the combat tag as a {@link CauseOfTag}.
|
||||
*/
|
||||
public CauseOfTag getCause() {
|
||||
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.isCancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
throw new UnsupportedOperationException("Use #cancel(String) instead");
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public void cancel(String cancelMessage) {
|
||||
this.isCancelled = true;
|
||||
this.cancelMessage = cancelMessage;
|
||||
/**
|
||||
* Gets the reason why the event was cancelled.
|
||||
*
|
||||
* @return The cancel reason.
|
||||
*/
|
||||
public CancelTagReason getCancelReason() {
|
||||
return this.cancelReason;
|
||||
}
|
||||
|
||||
public void allow() {
|
||||
this.isCancelled = false;
|
||||
this.cancelMessage = "";
|
||||
}
|
||||
|
||||
public String getCancelMessage() {
|
||||
return this.cancelMessage;
|
||||
/**
|
||||
* Sets the reason why the event was cancelled.
|
||||
*
|
||||
* @param cancelReason The cancel reason.
|
||||
*/
|
||||
public void setCancelReason(CancelTagReason cancelReason) {
|
||||
this.cancelReason = cancelReason;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,43 +5,61 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This event is triggered when a player is untagged during a fight.
|
||||
*/
|
||||
public class FightUntagEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final UUID player;
|
||||
private final CauseOfUnTag cause;
|
||||
private boolean isCancelled = false;
|
||||
private boolean cancelled;
|
||||
|
||||
public FightUntagEvent(UUID player, CauseOfUnTag cause) {
|
||||
super(false);
|
||||
|
||||
this.player = player;
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the UUID of the player who was untagged.
|
||||
*
|
||||
* @return The UUID of the untagged player.
|
||||
*/
|
||||
public UUID getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the reason for why the player was untagged.
|
||||
*
|
||||
* @return The cause of untagging as a {@link CauseOfUnTag}.
|
||||
*/
|
||||
public CauseOfUnTag getCause() {
|
||||
return this.cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.isCancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.isCancelled = cancelled;
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.eternalcode.combat.fight.pearl;
|
||||
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
import com.eternalcode.combat.util.DurationUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
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.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import panda.utilities.text.Formatter;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FightPearlController implements Listener {
|
||||
|
||||
private final FightPearlSettings settings;
|
||||
private final NotificationAnnouncer announcer;
|
||||
private final FightManager fightManager;
|
||||
private final FightPearlManager fightPearlManager;
|
||||
|
||||
public FightPearlController(FightPearlSettings settings, NotificationAnnouncer announcer, FightManager fightManager, FightPearlManager fightPearlManager) {
|
||||
this.settings = settings;
|
||||
this.announcer = announcer;
|
||||
this.fightManager = fightManager;
|
||||
this.fightPearlManager = fightPearlManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
UUID uniqueId = player.getUniqueId();
|
||||
|
||||
if (!this.settings.pearlThrowBlocked) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.fightManager.isInCombat(uniqueId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = event.getItem();
|
||||
if (item == null || item.getType() != Material.ENDER_PEARL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Action action = event.getAction();
|
||||
if (action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.settings.pearlThrowDelay.isZero()) {
|
||||
event.setCancelled(true);
|
||||
this.announcer.sendMessage(player, this.settings.pearlThrowBlockedDuringCombat);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.fightPearlManager.hasDelay(uniqueId)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
Duration remainingPearlDelay = this.fightPearlManager.getRemainingDelay(uniqueId);
|
||||
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{TIME}", DurationUtil.format(remainingPearlDelay));
|
||||
|
||||
String format = formatter.format(this.settings.pearlThrowBlockedDelayDuringCombat);
|
||||
this.announcer.sendMessage(player, format);
|
||||
return;
|
||||
}
|
||||
|
||||
this.fightPearlManager.markDelay(uniqueId);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
void onEntityDamage(EntityDamageByEntityEvent event) {
|
||||
if (this.settings.pearlThrowDamageEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.getDamager() instanceof EnderPearl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getCause() != EntityDamageEvent.DamageCause.FALL) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setDamage(0.0D);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.eternalcode.combat.fight.pearl;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FightPearlManager {
|
||||
|
||||
private final FightPearlSettings pearlSettings;
|
||||
private final Cache<UUID, Instant> pearlDelays;
|
||||
|
||||
public FightPearlManager(FightPearlSettings pearlSettings) {
|
||||
this.pearlSettings = pearlSettings;
|
||||
this.pearlDelays = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(pearlSettings.pearlThrowDelay)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void markDelay(UUID uuid) {
|
||||
this.pearlDelays.put(uuid, Instant.now().plus(this.pearlSettings.pearlThrowDelay));
|
||||
}
|
||||
|
||||
public boolean hasDelay(UUID uuid) {
|
||||
return Instant.now().isBefore(this.getDelay(uuid));
|
||||
}
|
||||
|
||||
public Duration getRemainingDelay(UUID uuid) {
|
||||
return Duration.between(Instant.now(), this.getDelay(uuid));
|
||||
}
|
||||
|
||||
public Instant getDelay(UUID uuid) {
|
||||
return this.pearlDelays.asMap().getOrDefault(uuid, Instant.MIN);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.eternalcode.combat.fight.pearl;
|
||||
|
||||
import eu.okaeri.configs.OkaeriConfig;
|
||||
import eu.okaeri.configs.annotation.Comment;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class FightPearlSettings extends OkaeriConfig {
|
||||
|
||||
@Comment({ "# Is pearl damage to be enabled?", "# This will work globally" })
|
||||
public boolean pearlThrowDamageEnabled = true;
|
||||
|
||||
@Comment("# Set true, If you want to lock pearls during the combat")
|
||||
public boolean pearlThrowBlocked = 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",
|
||||
"# Set to 0 to disable"
|
||||
})
|
||||
public Duration pearlThrowDelay = Duration.ofSeconds(3);
|
||||
|
||||
@Comment("# Message sent when player tries to throw ender pearl, but are disabled")
|
||||
public String pearlThrowBlockedDuringCombat = "&cThrowing ender pearls is prohibited during combat!";
|
||||
|
||||
@Comment("# Message sent when player tries to throw ender pearl, but has delay")
|
||||
public String pearlThrowBlockedDelayDuringCombat = "&cYou must wait {TIME} before next throw!";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.eternalcode.combat.fight.pearl;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface PearlService {
|
||||
|
||||
boolean shouldCancelEvent(UUID playerId);
|
||||
|
||||
Duration getRemainingDelay(UUID uuid);
|
||||
|
||||
boolean hasDelay(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);
|
||||
}
|
||||
@@ -1,34 +1,13 @@
|
||||
package com.eternalcode.combat.fight.tagout;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FightTagOutService {
|
||||
public interface FightTagOutService {
|
||||
|
||||
private final Map<UUID, Instant> tagOuts = new HashMap<>();
|
||||
boolean isTaggedOut(UUID player);
|
||||
|
||||
public void tagOut(UUID player, Duration duration) {
|
||||
Instant endTime = Instant.now().plus(duration);
|
||||
|
||||
this.tagOuts.put(player, endTime);
|
||||
}
|
||||
|
||||
public void unTagOut(UUID player) {
|
||||
this.tagOuts.remove(player);
|
||||
}
|
||||
|
||||
public boolean isTaggedOut(UUID player) {
|
||||
Instant endTime = this.tagOuts.get(player);
|
||||
|
||||
if (endTime == null) {
|
||||
return false;
|
||||
}
|
||||
Instant now = Instant.now();
|
||||
|
||||
return now.isBefore(endTime);
|
||||
}
|
||||
void unTagOut(UUID player);
|
||||
|
||||
void tagOut(UUID player, Duration duration);
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package com.eternalcode.combat.fight.tagout;
|
||||
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
import com.eternalcode.combat.util.DurationUtil;
|
||||
import dev.rollczi.litecommands.argument.Arg;
|
||||
import dev.rollczi.litecommands.command.execute.Execute;
|
||||
import dev.rollczi.litecommands.command.permission.Permission;
|
||||
import dev.rollczi.litecommands.command.route.Route;
|
||||
import org.bukkit.entity.Player;
|
||||
import panda.utilities.text.Formatter;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
|
||||
@Route(name = "tagout", aliases = "tagimmunity")
|
||||
public class TagOutCommand {
|
||||
|
||||
private final FightTagOutService fightTagOutService;
|
||||
private final NotificationAnnouncer announcer;
|
||||
private final PluginConfig config;
|
||||
|
||||
public TagOutCommand(FightTagOutService fightTagOutService, NotificationAnnouncer announcer, PluginConfig config) {
|
||||
this.fightTagOutService = fightTagOutService;
|
||||
this.announcer = announcer;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Execute(required = 1)
|
||||
@Permission("eternalcombat.tagout")
|
||||
void tagout(Player sender, @Arg Duration time) {
|
||||
UUID targetUniqueId = sender.getUniqueId();
|
||||
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{PLAYER}", sender.getName())
|
||||
.register("{TIME}", DurationUtil.format(time));
|
||||
|
||||
this.fightTagOutService.tagOut(targetUniqueId, time);
|
||||
|
||||
String format = formatter.format(this.config.messages.admin.adminTagOutSelf);
|
||||
this.announcer.sendMessage(sender, format);
|
||||
}
|
||||
|
||||
@Execute(required = 2)
|
||||
@Permission("eternalcombat.tagout")
|
||||
void tagout(Player sender, @Arg Player target, @Arg Duration time) {
|
||||
UUID targetUniqueId = target.getUniqueId();
|
||||
|
||||
Instant now = Instant.now();
|
||||
Duration remaining = Duration.between(now, now.plus(time));
|
||||
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{PLAYER}", target.getName())
|
||||
.register("{TIME}", DurationUtil.format(remaining));
|
||||
|
||||
this.fightTagOutService.tagOut(targetUniqueId, time);
|
||||
|
||||
String adminTagOutFormat = formatter.format(this.config.messages.admin.adminTagOut);
|
||||
this.announcer.sendMessage(sender, adminTagOutFormat);
|
||||
|
||||
String playerTagOutFormat = formatter.format(this.config.messages.admin.playerTagOut);
|
||||
this.announcer.sendMessage(target, playerTagOutFormat);
|
||||
}
|
||||
|
||||
@Execute(route = "remove", required = 1)
|
||||
@Permission("eternalcombat.tagout")
|
||||
void untagout(Player sender, @Arg Player target) {
|
||||
UUID targetUniqueId = target.getUniqueId();
|
||||
|
||||
this.fightTagOutService.unTagOut(targetUniqueId);
|
||||
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{PLAYER}", target.getName());
|
||||
|
||||
if (!targetUniqueId.equals(sender.getUniqueId())) {
|
||||
String adminUnTagOutFormat = formatter.format(this.config.messages.admin.adminTagOutOff);
|
||||
this.announcer.sendMessage(sender, adminUnTagOutFormat);
|
||||
}
|
||||
|
||||
this.announcer.sendMessage(target, this.config.messages.admin.playerTagOutOff);
|
||||
}
|
||||
|
||||
@Execute(route = "remove", required = 0)
|
||||
@Permission("eternalcombat.tagout")
|
||||
void untagout(Player sender) {
|
||||
UUID senderUniqueId = sender.getUniqueId();
|
||||
|
||||
this.fightTagOutService.unTagOut(senderUniqueId);
|
||||
|
||||
this.announcer.sendMessage(sender, this.config.messages.admin.playerTagOutOff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.eternalcode.combat.notification;
|
||||
|
||||
public interface Notification {
|
||||
|
||||
String message();
|
||||
|
||||
NotificationType type();
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.eternalcode.combat.notification;
|
||||
|
||||
import com.eternalcode.combat.notification.implementation.BossBarNotification;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.platform.AudienceProvider;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import panda.utilities.text.Formatter;
|
||||
|
||||
public final class NotificationAnnouncer {
|
||||
|
||||
private final AudienceProvider audienceProvider;
|
||||
private final MiniMessage miniMessage;
|
||||
|
||||
public NotificationAnnouncer(AudienceProvider audienceProvider, MiniMessage miniMessage) {
|
||||
this.audienceProvider = audienceProvider;
|
||||
this.miniMessage = miniMessage;
|
||||
}
|
||||
|
||||
public void send(CommandSender sender, Notification notification, Formatter formatter) {
|
||||
Audience audience = this.audience(sender);
|
||||
Component message = this.miniMessage.deserialize(formatter.format(notification.message()));
|
||||
|
||||
NotificationType type = notification.type();
|
||||
|
||||
switch (type) {
|
||||
case CHAT -> audience.sendMessage(message);
|
||||
case ACTION_BAR -> audience.sendActionBar(message);
|
||||
|
||||
case TITLE -> {
|
||||
Title title = Title.title(message, Component.empty());
|
||||
|
||||
audience.showTitle(title);
|
||||
}
|
||||
|
||||
case SUB_TITLE -> {
|
||||
Title subTitle = Title.title(Component.empty(), message);
|
||||
|
||||
audience.showTitle(subTitle);
|
||||
}
|
||||
|
||||
case BOSS_BAR -> {
|
||||
BossBarNotification bossBarNotification = (BossBarNotification) notification;
|
||||
|
||||
BossBar bossBar = bossBarNotification.create(message);
|
||||
|
||||
audience.showBossBar(bossBar);
|
||||
}
|
||||
|
||||
default -> throw new IllegalStateException("Unknown notification type: " + type);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessage(CommandSender commandSender, String text) {
|
||||
Audience audience = this.audience(commandSender);
|
||||
Component message = this.miniMessage.deserialize(text);
|
||||
|
||||
audience.sendMessage(message);
|
||||
}
|
||||
|
||||
public void broadcast(String text) {
|
||||
Audience audience = this.audienceProvider.all();
|
||||
Component message = this.miniMessage.deserialize(text);
|
||||
|
||||
audience.sendMessage(message);
|
||||
}
|
||||
|
||||
private Audience audience(CommandSender sender) {
|
||||
if (sender instanceof Player player) {
|
||||
return this.audienceProvider.player(player.getUniqueId());
|
||||
}
|
||||
|
||||
return this.audienceProvider.console();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.eternalcode.combat.notification;
|
||||
|
||||
public enum NotificationType {
|
||||
CHAT,
|
||||
ACTION_BAR,
|
||||
TITLE,
|
||||
SUB_TITLE,
|
||||
BOSS_BAR
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.eternalcode.combat.notification.implementation;
|
||||
|
||||
import com.eternalcode.combat.notification.Notification;
|
||||
import com.eternalcode.combat.notification.NotificationType;
|
||||
|
||||
public record ActionBarNotification(String message) implements Notification {
|
||||
|
||||
@Override
|
||||
public NotificationType type() {
|
||||
return NotificationType.ACTION_BAR;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.eternalcode.combat.notification.implementation;
|
||||
|
||||
import com.eternalcode.combat.notification.Notification;
|
||||
import com.eternalcode.combat.notification.NotificationType;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public record BossBarNotification(String message, float progress, BossBar.Color color, BossBar.Overlay overlay) implements Notification {
|
||||
|
||||
public BossBar create(Component name) {
|
||||
float replacedProgress = this.progress < 0.0F ? BossBar.MAX_PROGRESS : this.progress;
|
||||
|
||||
return BossBar.bossBar(name, replacedProgress, this.color, this.overlay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationType type() {
|
||||
return NotificationType.BOSS_BAR;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.eternalcode.combat.notification.implementation;
|
||||
|
||||
import com.eternalcode.combat.notification.Notification;
|
||||
import com.eternalcode.combat.notification.NotificationType;
|
||||
|
||||
public record ChatNotification(String message) implements Notification {
|
||||
|
||||
@Override
|
||||
public NotificationType type() {
|
||||
return NotificationType.CHAT;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.eternalcode.combat.notification.implementation;
|
||||
|
||||
import com.eternalcode.combat.notification.Notification;
|
||||
import com.eternalcode.combat.notification.NotificationType;
|
||||
|
||||
public record SubTitleNotification(String message) implements Notification {
|
||||
|
||||
@Override
|
||||
public NotificationType type() {
|
||||
return NotificationType.SUB_TITLE;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.eternalcode.combat.notification.implementation;
|
||||
|
||||
import com.eternalcode.combat.notification.Notification;
|
||||
import com.eternalcode.combat.notification.NotificationType;
|
||||
|
||||
public record TitleNotification(String message) implements Notification {
|
||||
|
||||
@Override
|
||||
public NotificationType type() {
|
||||
return NotificationType.TITLE;
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.eternalcode.combat.notification.serializer;
|
||||
|
||||
import com.eternalcode.combat.notification.Notification;
|
||||
import com.eternalcode.combat.notification.NotificationType;
|
||||
import com.eternalcode.combat.notification.implementation.ActionBarNotification;
|
||||
import com.eternalcode.combat.notification.implementation.BossBarNotification;
|
||||
import com.eternalcode.combat.notification.implementation.ChatNotification;
|
||||
import com.eternalcode.combat.notification.implementation.SubTitleNotification;
|
||||
import com.eternalcode.combat.notification.implementation.TitleNotification;
|
||||
import eu.okaeri.configs.schema.GenericsDeclaration;
|
||||
import eu.okaeri.configs.serdes.DeserializationData;
|
||||
import eu.okaeri.configs.serdes.ObjectSerializer;
|
||||
import eu.okaeri.configs.serdes.SerializationData;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class NotificationSerializer implements ObjectSerializer<Notification> {
|
||||
|
||||
@Override
|
||||
public boolean supports(@NonNull Class<? super Notification> type) {
|
||||
return Notification.class.isAssignableFrom(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@NonNull Notification notification, @NonNull SerializationData data, @NonNull GenericsDeclaration generics) {
|
||||
data.add("type", notification.type(), NotificationType.class);
|
||||
data.add("message", notification.message(), String.class);
|
||||
|
||||
if (notification instanceof BossBarNotification bossBarNotification) {
|
||||
data.add("progress", bossBarNotification.progress(), float.class);
|
||||
data.add("color", bossBarNotification.color(), BossBar.Color.class);
|
||||
data.add("overlay", bossBarNotification.overlay(), BossBar.Overlay.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Notification deserialize(@NonNull DeserializationData data, @NonNull GenericsDeclaration generics) {
|
||||
NotificationType type = data.get("type", NotificationType.class);
|
||||
String message = data.get("message", String.class);
|
||||
|
||||
return switch (type) {
|
||||
case CHAT -> new ChatNotification(message);
|
||||
case ACTION_BAR -> new ActionBarNotification(message);
|
||||
|
||||
case TITLE -> new TitleNotification(message);
|
||||
case SUB_TITLE -> new SubTitleNotification(message);
|
||||
|
||||
case BOSS_BAR -> {
|
||||
float progress = Optional.ofNullable(data.get("progress", float.class))
|
||||
.orElse(BossBar.MAX_PROGRESS);
|
||||
|
||||
BossBar.Color color = Optional.ofNullable(data.get("color", BossBar.Color.class))
|
||||
.orElse(BossBar.Color.RED);
|
||||
|
||||
BossBar.Overlay overlay = Optional.ofNullable(data.get("overlay", BossBar.Overlay.class))
|
||||
.orElse(BossBar.Overlay.PROGRESS);
|
||||
|
||||
yield new BossBarNotification(message, progress, color, overlay);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.eternalcode.combat.region;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class DefaultRegionProvider implements RegionProvider {
|
||||
|
||||
private final int radius;
|
||||
|
||||
public DefaultRegionProvider(int radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInRegion(Location location) {
|
||||
Location spawnLocation = location.getWorld().getSpawnLocation();
|
||||
double x = spawnLocation.getX();
|
||||
double z = spawnLocation.getZ();
|
||||
|
||||
Point min = new Point(x - this.radius, z - this.radius);
|
||||
Point max = new Point(x + this.radius, z + this.radius);
|
||||
|
||||
return this.contains(min, max, location.getX(), location.getZ());
|
||||
}
|
||||
|
||||
public boolean contains(Point min, Point max, double x, double z) {
|
||||
return x >= min.x() && x < max.x()
|
||||
&& z >= min.z() && z < max.z();
|
||||
}
|
||||
|
||||
public record Point(double x, double z) {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.eternalcode.combat.region;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
public record Point(World world, double x, double z) {
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.eternalcode.combat.region;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public interface Region {
|
||||
|
||||
Point getCenter();
|
||||
|
||||
Location getMin();
|
||||
|
||||
Location getMax();
|
||||
|
||||
default boolean contains(Location location) {
|
||||
return this.contains(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
default boolean contains(double x, double y, double z) {
|
||||
Location min = this.getMin();
|
||||
Location max = this.getMax();
|
||||
return x >= min.getX() && x < max.getX()
|
||||
&& y >= min.getY() && y < max.getY()
|
||||
&& z >= min.getZ() && z < max.getZ();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.eternalcode.combat.region;
|
||||
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class RegionController implements Listener {
|
||||
|
||||
private final NotificationAnnouncer announcer;
|
||||
private final RegionProvider regionProvider;
|
||||
private final FightManager fightManager;
|
||||
private final PluginConfig pluginConfig;
|
||||
|
||||
public RegionController(NotificationAnnouncer announcer, RegionProvider regionProvider, FightManager fightManager, PluginConfig pluginConfig) {
|
||||
this.announcer = announcer;
|
||||
this.regionProvider = regionProvider;
|
||||
this.fightManager = fightManager;
|
||||
this.pluginConfig = pluginConfig;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!this.fightManager.isInCombat(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location locationTo = event.getTo();
|
||||
int xTo = locationTo.getBlockX();
|
||||
int yTo = locationTo.getBlockY();
|
||||
int zTo = locationTo.getBlockZ();
|
||||
|
||||
Location locationFrom = event.getFrom();
|
||||
int xFrom = locationFrom.getBlockX();
|
||||
int yFrom = locationFrom.getBlockY();
|
||||
int zFrom = locationFrom.getBlockZ();
|
||||
|
||||
if (xTo != xFrom || yTo != yFrom || zTo != zFrom) {
|
||||
if (!this.regionProvider.isInRegion(locationTo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location playerLocation = player.getLocation().subtract(player.getWorld().getSpawnLocation());
|
||||
double distance = playerLocation.distance(player.getWorld().getSpawnLocation());
|
||||
Vector knockback = new Vector(0, 3, 0).multiply(this.pluginConfig.settings.blockedRegionKnockMultiplier / distance);
|
||||
Vector vector = playerLocation.toVector().add(knockback);
|
||||
|
||||
player.setVelocity(vector);
|
||||
|
||||
this.announcer.sendMessage(player, this.pluginConfig.messages.cantEnterOnRegion);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,18 @@
|
||||
package com.eternalcode.combat.region;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface RegionProvider {
|
||||
|
||||
boolean isInRegion(Location location);
|
||||
Optional<Region> getRegion(Location location);
|
||||
|
||||
default boolean isInRegion(Location location) {
|
||||
return this.getRegion(location).isPresent();
|
||||
}
|
||||
|
||||
Collection<Region> getRegions(World world);
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.eternalcode.combat.region;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WorldGuardRegionProvider implements RegionProvider {
|
||||
|
||||
private final List<String> regions;
|
||||
|
||||
public WorldGuardRegionProvider(List<String> regions) {
|
||||
this.regions = regions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInRegion(Location location) {
|
||||
return this.regions.stream().anyMatch(region -> this.isInCombatRegion(location, region));
|
||||
}
|
||||
|
||||
private boolean isInCombatRegion(Location location, String regionName) {
|
||||
RegionContainer regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionQuery regionQuery = regionContainer.createQuery();
|
||||
ApplicableRegionSet applicableRegions = regionQuery.getApplicableRegions(BukkitAdapter.adapt(location));
|
||||
|
||||
return applicableRegions.getRegions().stream().anyMatch(region -> region.getId().equalsIgnoreCase(regionName));
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.eternalcode.combat.updater;
|
||||
|
||||
import com.eternalcode.gitcheck.GitCheck;
|
||||
import com.eternalcode.gitcheck.GitCheckResult;
|
||||
import com.eternalcode.gitcheck.git.GitRepository;
|
||||
import com.eternalcode.gitcheck.git.GitTag;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import panda.std.Lazy;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class UpdaterService {
|
||||
|
||||
private static final GitRepository GIT_REPOSITORY = GitRepository.of("EternalCodeTeam", "EternalCombat");
|
||||
|
||||
private final GitCheck gitCheck = new GitCheck();
|
||||
private final Lazy<GitCheckResult> gitCheckResult;
|
||||
|
||||
public UpdaterService(PluginDescriptionFile descriptionFile) {
|
||||
this.gitCheckResult = new Lazy<>(() -> {
|
||||
String version = descriptionFile.getVersion();
|
||||
|
||||
return this.gitCheck.checkRelease(GIT_REPOSITORY, GitTag.of("v" + version));
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Boolean> isUpToDate() {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
GitCheckResult result = this.gitCheckResult.get();
|
||||
|
||||
return result.isUpToDate();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.eternalcode.combat.util;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public final class DurationUtil {
|
||||
|
||||
private DurationUtil() {
|
||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||
}
|
||||
|
||||
public static String format(Duration duration) {
|
||||
return format(duration, true);
|
||||
}
|
||||
|
||||
public static String format(Duration duration, boolean removeMillis) {
|
||||
if (removeMillis) {
|
||||
duration = Duration.ofSeconds(duration.toSeconds());
|
||||
}
|
||||
|
||||
return duration.toString()
|
||||
.substring(2)
|
||||
.replaceAll("(\\d[HMS])(?!$)", "$1 ")
|
||||
.toLowerCase();
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.eternalcode.combat.util;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.function.ToIntFunction;
|
||||
|
||||
public class InventoryUtil {
|
||||
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
private InventoryUtil() {
|
||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||
}
|
||||
|
||||
public static <T> int calculateItemsToDelete(int percent, Collection<T> objectList, ToIntFunction<? super T> mapper) {
|
||||
return MathUtil.getRoundedCountFromPercentage(percent, MathUtil.sum(objectList, mapper));
|
||||
}
|
||||
|
||||
public static RemoveItemResult removeRandomItems(List<ItemStack> list, int itemsToDelete) {
|
||||
List<ItemStack> restItems = new ArrayList<>(list);
|
||||
Map<Integer, ItemStack> removedItems = new HashMap<>();
|
||||
|
||||
for (int i = 0; i < itemsToDelete; i++) {
|
||||
if (restItems.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
int randomIndex = RANDOM.nextInt(restItems.size());
|
||||
|
||||
ItemStack item = restItems.get(randomIndex);
|
||||
int newAmount = item.getAmount() - 1;
|
||||
|
||||
if (newAmount <= 0) {
|
||||
restItems.remove(randomIndex);
|
||||
incrementItem(removedItems, randomIndex, item);
|
||||
continue;
|
||||
}
|
||||
|
||||
item.setAmount(newAmount);
|
||||
incrementItem(removedItems, randomIndex, item);
|
||||
}
|
||||
|
||||
return new RemoveItemResult(restItems, new ArrayList<>(removedItems.values()));
|
||||
}
|
||||
|
||||
// TODO: kinda shitty, but no time for a proper solution now
|
||||
private static void incrementItem(Map<Integer, ItemStack> items, int index, ItemStack itemStack) {
|
||||
ItemStack itemInList = items.get(index);
|
||||
|
||||
if (itemInList == null) {
|
||||
ItemStack cloned = itemStack.clone();
|
||||
|
||||
cloned.setAmount(1);
|
||||
items.put(index, cloned);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemInList.isSimilar(itemStack)) {
|
||||
throw new IllegalStateException("Items are not similar!");
|
||||
}
|
||||
|
||||
itemInList.setAmount(itemInList.getAmount() + 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.eternalcode.combat.util.legacy;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public final class Legacy {
|
||||
|
||||
private static final LegacyComponentSerializer AMPERSAND_SERIALIZER = LegacyComponentSerializer.builder()
|
||||
.character('&')
|
||||
.hexColors()
|
||||
.useUnusualXRepeatedCharacterHexFormat()
|
||||
.build();
|
||||
|
||||
public static Component component(String text) {
|
||||
return AMPERSAND_SERIALIZER.deserialize(text);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.eternalcode.combat.util.legacy;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class LegacyColorProcessor implements UnaryOperator<Component> {
|
||||
|
||||
@Override
|
||||
public Component apply(Component component) {
|
||||
return component.replaceText(builder -> builder.match(Pattern.compile(".*"))
|
||||
.replacement((matchResult, builder1) -> Legacy.component(matchResult.group())));
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.eternalcode.combat.util;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
class DurationUtilTest {
|
||||
|
||||
private static Collection<Object[]> data() {
|
||||
return Arrays.asList(new Object[][]{
|
||||
{ "3m 30s", true, Duration.ofMinutes(3).plusSeconds(30).plusMillis(500) },
|
||||
{ "3m 30.5s", false, Duration.ofMinutes(3).plusSeconds(30).plusMillis(500) },
|
||||
|
||||
{ "59m 59s", true, Duration.ofMinutes(59).plusSeconds(59) },
|
||||
{ "1h 1m", true, Duration.ofHours(1).plusMinutes(1).plusMillis(1) },
|
||||
|
||||
|
||||
{ "0s", true, Duration.ofMillis(500) },
|
||||
{ "0.5s", false, Duration.ofMillis(500) },
|
||||
{ "0s", true, Duration.ofMillis(500) },
|
||||
{ "0s", false, Duration.ZERO },
|
||||
|
||||
|
||||
{ "30s", true, Duration.ofSeconds(30) },
|
||||
{ "30s", false, Duration.ofSeconds(30) },
|
||||
{ "30s", true, Duration.ofSeconds(30).plusMillis(500) },
|
||||
{ "30.5s", false, Duration.ofSeconds(30).plusMillis(500) },
|
||||
|
||||
{ "1h 30m 30s", true, Duration.ofHours(1).plusMinutes(30).plusSeconds(30).plusMillis(500) },
|
||||
{ "1h 30m 30.5s", false, Duration.ofHours(1).plusMinutes(30).plusSeconds(30).plusMillis(500) },
|
||||
{ "1h 1m 1s", true, Duration.ofHours(1).plusMinutes(1).plusSeconds(1) },
|
||||
{ "23h 59m 59s", true, Duration.ofHours(23).plusMinutes(59).plusSeconds(59) },
|
||||
{ "23h 59m 59s", true, Duration.ofHours(23).plusMinutes(59).plusSeconds(59).plusMillis(999) },
|
||||
{ "26h 3m 4s", true, Duration.ofDays(1).plusHours(2).plusMinutes(3).plusSeconds(4).plusMillis(500) },
|
||||
{ "1h 1m 1s", true, Duration.ofHours(1).plusMinutes(1).plusSeconds(1).plusMillis(1) },
|
||||
|
||||
{ "1h 1s", true, Duration.ofHours(1).plusSeconds(1) },
|
||||
{ "1m", true, Duration.ofMinutes(1).plusMillis(1) },
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
void testFormat(String expected, boolean removeMillis, Duration duration) {
|
||||
String actual = DurationUtil.format(duration, removeMillis);
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
@@ -1,92 +1,158 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
import net.minecrell.pluginyml.paper.PaperPluginDescription
|
||||
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
checkstyle
|
||||
`eternalcombat-java`
|
||||
`eternalcombat-repositories`
|
||||
`eternalcombat-publish-hangar`
|
||||
`eternalcombat-publish-modrinth`
|
||||
`eternalcombat-runserver`
|
||||
|
||||
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
id("xyz.jpenilla.run-paper") version "2.1.0"
|
||||
id("de.eldoria.plugin-yml.paper") version "0.9.0"
|
||||
id("com.gradleup.shadow")
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "10.12.2"
|
||||
|
||||
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
|
||||
|
||||
maxErrors = 0
|
||||
maxWarnings = 0
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
|
||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.eternalcode.pl/releases") }
|
||||
maven { url = uri("https://storehouse.okaeri.eu/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.panda-lang.org/releases") }
|
||||
maven { url = uri("https://maven.enginehub.org/repo/") }
|
||||
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"))
|
||||
|
||||
// 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}")
|
||||
|
||||
// XSeries
|
||||
implementation("com.github.cryptomorin:XSeries:${Versions.XSERIES}")
|
||||
|
||||
// bstats
|
||||
implementation("org.bstats:bstats-bukkit:${Versions.B_STATS_BUKKIT}")
|
||||
|
||||
// caffeine
|
||||
implementation("com.github.ben-manes.caffeine:caffeine:${Versions.CAFFEINE}")
|
||||
|
||||
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:${Versions.LANDS_API}")
|
||||
|
||||
// GriefPrevention
|
||||
compileOnly("com.github.GriefPrevention:GriefPrevention:${Versions.GRIEF_PREVENTION}") {
|
||||
isTransitive = false
|
||||
}
|
||||
|
||||
// Multification
|
||||
implementation("com.eternalcode:multification-paper:${Versions.MULTIFICATION}")
|
||||
implementation("com.eternalcode:multification-okaeri:${Versions.MULTIFICATION}")
|
||||
compileOnly("com.github.retrooper:packetevents-spigot:${Versions.PACKETS_EVENTS}")
|
||||
}
|
||||
|
||||
bukkit {
|
||||
paper {
|
||||
main = "com.eternalcode.combat.CombatPlugin"
|
||||
author = "EternalCodeTeam"
|
||||
apiVersion = "1.13"
|
||||
authors = listOf("EternalCodeTeam")
|
||||
apiVersion = "1.19"
|
||||
prefix = "EternalCombat"
|
||||
name = "EternalCombat"
|
||||
softDepend = listOf("WorldGuard")
|
||||
generateLibrariesJson = true
|
||||
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD
|
||||
version = "${project.version}"
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
foliaSupported = true
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.compilerArgs = listOf("-Xlint:deprecation", "-parameters")
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
serverDependencies {
|
||||
register("packetevents") {
|
||||
required = true
|
||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||
}
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
minecraftVersion("1.19.4")
|
||||
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.withType<ShadowJar> {
|
||||
archiveFileName.set("EternalCombat v${project.version}.jar")
|
||||
tasks {
|
||||
named("generatePaperPluginDescription") {
|
||||
notCompatibleWithConfigurationCache("The plugin-yml paper generator reads Task.project during execution.")
|
||||
}
|
||||
|
||||
dependsOn("checkstyleMain")
|
||||
dependsOn("checkstyleTest")
|
||||
dependsOn("test")
|
||||
runPaper.folia.registerTask {
|
||||
minecraftVersion("26.3")
|
||||
|
||||
downloadPlugins.modrinth("PacketEvents", "${Versions.PACKETEVENTS}+spigot")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
archiveFileName.set("EternalCombat v${project.version}.jar")
|
||||
|
||||
exclude(
|
||||
"org/intellij/lang/annotations/**",
|
||||
"org/jetbrains/annotations/**",
|
||||
"net/kyori/**",
|
||||
"META-INF/**",
|
||||
"kotlin/**",
|
||||
"javax/**"
|
||||
"javax/**",
|
||||
"org/checkerframework/**",
|
||||
"com/google/errorprone/**",
|
||||
"com/google/gson/**"
|
||||
)
|
||||
|
||||
val prefix = "com.eternalcode.combat.libs"
|
||||
listOf(
|
||||
"panda.std",
|
||||
"panda.utilities",
|
||||
"org.panda-lang",
|
||||
"eu.okaeri",
|
||||
"net.kyori",
|
||||
"org.bstats",
|
||||
"org.yaml",
|
||||
"dev.rollczi.litecommands",
|
||||
"com.eternalcode.gitcheck",
|
||||
"org.json.simple",
|
||||
"org.apache.commons",
|
||||
"javassist"
|
||||
"com.github.benmanes.caffeine",
|
||||
"com.eternalcode.commons",
|
||||
"com.eternalcode.multification",
|
||||
"com.github.cryptomorin",
|
||||
"com.cryptomorin",
|
||||
).forEach { pack ->
|
||||
relocate(pack, "$prefix.$pack")
|
||||
}
|
||||
|
||||
@@ -1,51 +1,86 @@
|
||||
package com.eternalcode.combat;
|
||||
|
||||
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.command.InvalidUsage;
|
||||
import com.eternalcode.combat.command.PermissionMessage;
|
||||
import com.eternalcode.combat.config.ConfigBackupService;
|
||||
import com.eternalcode.combat.config.ConfigService;
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.drop.DropController;
|
||||
import com.eternalcode.combat.drop.DropKeepInventoryManager;
|
||||
import com.eternalcode.combat.drop.DropManager;
|
||||
import com.eternalcode.combat.drop.impl.PercentDropModifier;
|
||||
import com.eternalcode.combat.drop.impl.PlayersHealthDropModifier;
|
||||
import com.eternalcode.combat.fight.controller.FightActionBlockerController;
|
||||
import com.eternalcode.combat.fight.controller.FightDeathCauseController;
|
||||
import com.eternalcode.combat.fight.controller.FightEscapeController;
|
||||
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.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.EventCaller;
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.fight.FightTask;
|
||||
import com.eternalcode.combat.fight.bossbar.FightBossBarService;
|
||||
import com.eternalcode.combat.fight.effect.FightEffectService;
|
||||
import com.eternalcode.combat.fight.pearl.FightPearlController;
|
||||
import com.eternalcode.combat.fight.pearl.FightPearlManager;
|
||||
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.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.TagOutCommand;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
import com.eternalcode.combat.region.RegionController;
|
||||
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.region.RegionProvider;
|
||||
import com.eternalcode.combat.updater.UpdaterNotificationController;
|
||||
import com.eternalcode.combat.updater.UpdaterService;
|
||||
import com.eternalcode.combat.util.legacy.LegacyColorProcessor;
|
||||
import com.eternalcode.commons.adventure.AdventureLegacyColorPostProcessor;
|
||||
import com.eternalcode.commons.adventure.AdventureLegacyColorPreProcessor;
|
||||
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.adventure.platform.LiteBukkitAdventurePlatformFactory;
|
||||
import dev.rollczi.litecommands.bukkit.tools.BukkitOnlyPlayerContextual;
|
||||
import dev.rollczi.litecommands.bukkit.tools.BukkitPlayerArgument;
|
||||
import net.kyori.adventure.platform.AudienceProvider;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import dev.rollczi.litecommands.bukkit.LiteBukkitFactory;
|
||||
import dev.rollczi.litecommands.bukkit.LiteBukkitMessages;
|
||||
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;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
@@ -54,18 +89,23 @@ import java.util.stream.Stream;
|
||||
|
||||
public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
|
||||
private static final String FALLBACK_PREFIX = "eternalcombat";
|
||||
private static final int BSTATS_METRICS_ID = 17803;
|
||||
|
||||
private FightManager fightManager;
|
||||
private FightPearlManager fightPearlManager;
|
||||
private PearlService pearlService;
|
||||
private TridentService tridentService;
|
||||
private FightTagOutService fightTagOutService;
|
||||
private FightEffectService fightEffectService;
|
||||
private DropManager dropManager;
|
||||
private DropKeepInventoryManager dropKeepInventoryManager;
|
||||
|
||||
private DropService dropService;
|
||||
private DropKeepInventoryService dropKeepInventoryService;
|
||||
|
||||
private RegionProvider regionProvider;
|
||||
|
||||
private PluginConfig pluginConfig;
|
||||
|
||||
private AudienceProvider audienceProvider;
|
||||
private LiteCommands<CommandSender> liteCommands;
|
||||
private boolean apiInitialized;
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@@ -74,73 +114,129 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
|
||||
File dataFolder = this.getDataFolder();
|
||||
|
||||
ConfigBackupService backupService = new ConfigBackupService(dataFolder);
|
||||
ConfigService configService = new ConfigService(backupService);
|
||||
ConfigService configService = new ConfigService();
|
||||
|
||||
EventCaller eventCaller = new EventCaller(server);
|
||||
EventManager eventManager = new EventManager(this);
|
||||
PluginConfig pluginConfig = configService.create(PluginConfig.class, new File(dataFolder, "config.yml"));
|
||||
|
||||
this.pluginConfig = configService.create(PluginConfig.class, new File(dataFolder, "config.yml"));
|
||||
MinecraftScheduler scheduler = CombatSchedulerAdapter.getAdaptiveScheduler(this);
|
||||
|
||||
this.fightManager = new FightManager(eventCaller);
|
||||
this.fightPearlManager = new FightPearlManager(this.pluginConfig.pearl);
|
||||
this.fightTagOutService = new FightTagOutService();
|
||||
this.fightEffectService = new FightEffectService();
|
||||
this.dropManager = new DropManager();
|
||||
this.dropKeepInventoryManager = new DropKeepInventoryManager();
|
||||
this.fightManager = new FightManagerImpl(eventManager);
|
||||
this.pearlService = new PearlServiceImpl(this.fightManager, pluginConfig, scheduler);
|
||||
this.tridentService = new TridentServiceImpl(pluginConfig);
|
||||
this.fightTagOutService = new FightTagOutServiceImpl();
|
||||
this.fightEffectService = new FightEffectServiceImpl();
|
||||
|
||||
LogoutService logoutService = new LogoutService();
|
||||
|
||||
this.dropService = new DropServiceImpl();
|
||||
this.dropKeepInventoryService = new DropKeepInventoryServiceImpl();
|
||||
|
||||
UpdaterService updaterService = new UpdaterService(this.getDescription());
|
||||
|
||||
this.audienceProvider = BukkitAudiences.create(this);
|
||||
MiniMessage miniMessage = MiniMessage.builder()
|
||||
.postProcessor(new LegacyColorProcessor())
|
||||
.postProcessor(new AdventureLegacyColorPostProcessor())
|
||||
.preProcessor(new AdventureLegacyColorPreProcessor())
|
||||
.build();
|
||||
|
||||
FightBossBarService fightBossBarService = new FightBossBarService(this.pluginConfig, this.audienceProvider, miniMessage);
|
||||
NoticeService noticeService = new NoticeService(pluginConfig, miniMessage);
|
||||
|
||||
BridgeService bridgeService = new BridgeService(
|
||||
pluginConfig,
|
||||
server.getPluginManager(),
|
||||
this.getLogger(),
|
||||
this,
|
||||
this.fightManager
|
||||
);
|
||||
bridgeService.init(server);
|
||||
|
||||
BridgeService bridgeService = new BridgeService(this.pluginConfig, server.getPluginManager(), this.getLogger());
|
||||
bridgeService.init();
|
||||
this.regionProvider = bridgeService.getRegionProvider();
|
||||
BorderService borderService = new BorderServiceImpl(scheduler, server, regionProvider, eventManager, () -> pluginConfig.border);
|
||||
KnockbackService knockbackService = new KnockbackService(pluginConfig, scheduler, regionProvider);
|
||||
|
||||
NotificationAnnouncer notificationAnnouncer = new NotificationAnnouncer(this.audienceProvider, miniMessage);
|
||||
SpearService spearService = new SpearServiceImpl(pluginConfig.spear);
|
||||
|
||||
this.liteCommands = LiteBukkitAdventurePlatformFactory.builder(server, "eternalcombat", this.audienceProvider)
|
||||
.argument(Player.class, new BukkitPlayerArgument<>(this.getServer(), this.pluginConfig.messages.playerNotFound))
|
||||
.contextualBind(Player.class, new BukkitOnlyPlayerContextual<>(this.pluginConfig.messages.admin.onlyForPlayers))
|
||||
this.liteCommands = LiteBukkitFactory.builder(FALLBACK_PREFIX, this, server)
|
||||
.message(LiteBukkitMessages.PLAYER_NOT_FOUND, pluginConfig.messagesSettings.playerNotFound)
|
||||
.message(LiteBukkitMessages.PLAYER_ONLY, pluginConfig.messagesSettings.admin.onlyForPlayers)
|
||||
|
||||
.invalidUsageHandler(new InvalidUsage(this.pluginConfig, notificationAnnouncer))
|
||||
.permissionHandler(new PermissionMessage(this.pluginConfig, notificationAnnouncer))
|
||||
.invalidUsage(new InvalidUsageHandlerImpl(pluginConfig, noticeService))
|
||||
.missingPermission(new MissingPermissionHandlerImpl(pluginConfig, noticeService))
|
||||
|
||||
.commandInstance(new CombatCommand(this.fightManager, configService, notificationAnnouncer, this.pluginConfig))
|
||||
.commandInstance(new TagOutCommand(this.fightTagOutService, notificationAnnouncer, this.pluginConfig))
|
||||
.commands(
|
||||
new FightTagCommand(this.fightManager, noticeService, pluginConfig),
|
||||
new FightTagOutCommand(this.fightTagOutService, noticeService, pluginConfig),
|
||||
new EternalCombatReloadCommand(configService, noticeService)
|
||||
)
|
||||
|
||||
.register();
|
||||
.extension(new FoliaExtension(this))
|
||||
|
||||
FightTask fightTask = new FightTask(server, this.pluginConfig, this.fightManager, fightBossBarService, notificationAnnouncer);
|
||||
this.getServer().getScheduler().runTaskTimer(this, fightTask, 20L, 20L);
|
||||
.result(Notice.class, (invocation, result, chain) -> noticeService.create()
|
||||
.viewer(invocation.sender())
|
||||
.notice(result)
|
||||
.send())
|
||||
|
||||
new Metrics(this, 17803);
|
||||
.build();
|
||||
|
||||
FightTask fightTask = new FightTask(server, pluginConfig, this.fightManager, noticeService);
|
||||
scheduler.timer(fightTask, Duration.ofSeconds(1), Duration.ofSeconds(1));
|
||||
|
||||
new Metrics(this, BSTATS_METRICS_ID);
|
||||
|
||||
Stream.of(
|
||||
new PercentDropModifier(this.pluginConfig.dropSettings),
|
||||
new PlayersHealthDropModifier(this.pluginConfig.dropSettings)
|
||||
).forEach(this.dropManager::registerModifier);
|
||||
new PercentDropModifier(pluginConfig.drop),
|
||||
new PlayersHealthDropModifier(pluginConfig.drop, logoutService)
|
||||
).forEach(this.dropService::registerModifier);
|
||||
|
||||
Stream.of(
|
||||
new FightDeathCauseController(this.fightManager),
|
||||
new DropController(this.dropManager, this.dropKeepInventoryManager, this.pluginConfig.dropSettings, this.fightManager),
|
||||
new FightTagController(this.fightManager, this.pluginConfig, notificationAnnouncer),
|
||||
new FightUnTagController(this.fightManager, this.pluginConfig),
|
||||
new FightEscapeController(this.fightManager, this.pluginConfig, notificationAnnouncer),
|
||||
new FightActionBlockerController(this.fightManager, notificationAnnouncer, this.pluginConfig),
|
||||
new FightPearlController(this.pluginConfig.pearl, notificationAnnouncer, this.fightManager, this.fightPearlManager),
|
||||
new UpdaterNotificationController(updaterService, this.pluginConfig, this.audienceProvider, miniMessage),
|
||||
new RegionController(notificationAnnouncer, this.regionProvider, this.fightManager, this.pluginConfig),
|
||||
new FightEffectController(this.pluginConfig.effect, this.fightEffectService, this.fightManager, this.getServer()),
|
||||
new FightTagOutController(this.fightTagOutService, this.pluginConfig),
|
||||
new FightMessageController(this.fightManager, notificationAnnouncer, fightBossBarService, this.pluginConfig, this.getServer())
|
||||
).forEach(listener -> this.getServer().getPluginManager().registerEvents(listener, this));
|
||||
eventManager.subscribe(
|
||||
new FightTagController(this.fightManager, pluginConfig),
|
||||
new FightUnTagController(this.fightManager, pluginConfig, logoutService),
|
||||
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, server),
|
||||
new FightTagOutController(this.fightTagOutService),
|
||||
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 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,
|
||||
new DropController(dropService, dropKeepInventoryService, pluginConfig.drop, fightManager, miniMessage)
|
||||
);
|
||||
|
||||
eventManager.subscribe(
|
||||
PlayerQuitEvent.class,
|
||||
pluginConfig.combat.quitPunishmentEventPriority,
|
||||
new LogoutController(this.fightManager, logoutService, noticeService, pluginConfig)
|
||||
);
|
||||
|
||||
EternalCombatProvider.initialize(this);
|
||||
this.apiInitialized = true;
|
||||
|
||||
long millis = started.elapsed(TimeUnit.MILLISECONDS);
|
||||
this.getLogger().info("Successfully loaded EternalCombat in " + millis + "ms");
|
||||
@@ -148,17 +244,18 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
EternalCombatProvider.deinitialize();
|
||||
|
||||
if (this.liteCommands != null) {
|
||||
this.liteCommands.getPlatform().unregisterAll();
|
||||
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
|
||||
@@ -172,8 +269,8 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FightPearlManager getFightPearlManager() {
|
||||
return this.fightPearlManager;
|
||||
public PearlService getFightPearlService() {
|
||||
return this.pearlService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,17 +284,12 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropManager getDropManager() {
|
||||
return this.dropManager;
|
||||
public DropService getDropService() {
|
||||
return this.dropService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DropKeepInventoryManager getDropKeepInventoryManager() {
|
||||
return this.dropKeepInventoryManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginConfig getPluginConfig() {
|
||||
return this.pluginConfig;
|
||||
public DropKeepInventoryService getDropKeepInventoryService() {
|
||||
return this.dropKeepInventoryService;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.eternalcode.combat;
|
||||
|
||||
import com.eternalcode.combat.config.ConfigService;
|
||||
import com.eternalcode.combat.notification.NoticeService;
|
||||
import com.eternalcode.multification.notice.Notice;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import dev.rollczi.litecommands.annotations.async.Async;
|
||||
import dev.rollczi.litecommands.annotations.command.Command;
|
||||
import dev.rollczi.litecommands.annotations.context.Context;
|
||||
import dev.rollczi.litecommands.annotations.execute.Execute;
|
||||
import dev.rollczi.litecommands.annotations.permission.Permission;
|
||||
import java.time.Duration;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@Command(name = "combatlog", aliases = "combat")
|
||||
public class EternalCombatReloadCommand {
|
||||
|
||||
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();
|
||||
|
||||
private final ConfigService configService;
|
||||
private final NoticeService noticeService;
|
||||
|
||||
public EternalCombatReloadCommand(ConfigService configService, NoticeService noticeService) {
|
||||
this.configService = configService;
|
||||
this.noticeService = noticeService;
|
||||
}
|
||||
|
||||
@Async
|
||||
@Execute(name = "reload")
|
||||
@Permission("eternalcombat.reload")
|
||||
void execute(@Context CommandSender sender) {
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
this.configService.reload();
|
||||
|
||||
Duration elapsed = stopwatch.elapsed();
|
||||
this.noticeService.create()
|
||||
.viewer(sender)
|
||||
.notice(RELOAD_MESSAGE)
|
||||
.placeholder("{TIME}", String.valueOf(elapsed.toMillis()))
|
||||
.send();
|
||||
|
||||
}
|
||||
}
|
||||