geforkt von Mirrors/Paper
Merge remote-tracking branch 'upstream/master' into 1.21-2
Dieser Commit ist enthalten in:
Commit
191d74a113
@ -4,6 +4,10 @@ end_of_line=lf
|
|||||||
insert_final_newline=true
|
insert_final_newline=true
|
||||||
indent_style=space
|
indent_style=space
|
||||||
indent_size=4
|
indent_size=4
|
||||||
|
ij_any_block_comment_add_space = false
|
||||||
|
ij_any_block_comment_at_first_column = false
|
||||||
|
ij_any_line_comment_at_first_column = false
|
||||||
|
ij_any_line_comment_add_space = true
|
||||||
|
|
||||||
[*.tiny]
|
[*.tiny]
|
||||||
indent_style=tab
|
indent_style=tab
|
||||||
@ -16,3 +20,23 @@ indent_size=2
|
|||||||
|
|
||||||
[*.patch]
|
[*.patch]
|
||||||
trim_trailing_whitespace=false
|
trim_trailing_whitespace=false
|
||||||
|
|
||||||
|
[*.java]
|
||||||
|
ij_continuation_indent_size = 4
|
||||||
|
ij_java_class_count_to_use_import_on_demand = 999999
|
||||||
|
ij_java_insert_inner_class_imports = false
|
||||||
|
ij_java_names_count_to_use_import_on_demand = 999999
|
||||||
|
ij_java_imports_layout = *,|,$*
|
||||||
|
ij_java_generate_final_locals = true
|
||||||
|
ij_java_generate_final_parameters = true
|
||||||
|
ij_java_method_parameters_new_line_after_left_paren = true
|
||||||
|
ij_java_method_parameters_right_paren_on_new_line = true
|
||||||
|
|
||||||
|
[test-plugin/**/*.java]
|
||||||
|
ij_java_use_fq_class_names = false
|
||||||
|
|
||||||
|
[Paper-Server/src/main/resources/data/**/*.json]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[paper-api-generator/generated/**/*.java]
|
||||||
|
ij_java_imports_layout = $*,|,*
|
||||||
|
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1,4 +1,4 @@
|
|||||||
* text=auto
|
* text=auto eol=lf
|
||||||
|
|
||||||
*.sh text eol=lf
|
*.sh text eol=lf
|
||||||
gradlew text eol=lf
|
gradlew text eol=lf
|
||||||
|
42
.github/DISCUSSION_TEMPLATE/ideas.yml
vendored
Normale Datei
42
.github/DISCUSSION_TEMPLATE/ideas.yml
vendored
Normale Datei
@ -0,0 +1,42 @@
|
|||||||
|
labels: ["status: needs triage"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thank you for filling out a feature request for Paper! Please be as detailed as possible so that we may consider and review the request easier.
|
||||||
|
We ask that you search all the issues to avoid a duplicate feature request. If one exists, please reply if you have anything to add.
|
||||||
|
Before requesting a new feature, please make sure you are using the latest version and that the feature you are requesting is not already in Paper.
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Is your feature request related to a problem?
|
||||||
|
description: Please give some context for this request. Why do you want it added?
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Describe the solution you'd like.
|
||||||
|
description: A clear and concise description of what you want.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Describe alternatives you've considered.
|
||||||
|
description: List any alternatives you might have tried to get the feature you want.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Other
|
||||||
|
description: Add any other context or screenshots about the feature request below.
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Before submitting this feature request, please search our issue tracker to ensure your feature has not
|
||||||
|
already been requested.
|
@ -44,10 +44,10 @@ body:
|
|||||||
|
|
||||||
```
|
```
|
||||||
> version
|
> version
|
||||||
[20:34:42 INFO]: This server is running Paper version git-Paper-540 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
|
|
||||||
[20:34:42 INFO]: Checking version, please wait...
|
[20:34:42 INFO]: Checking version, please wait...
|
||||||
[20:34:42 INFO]: Previous version: git-Paper-538 (MC: 1.16.5)
|
[20:34:42 INFO]: This server is running Paper version 1.21-105-master@7e91a2c (2024-07-20T21:04:31Z) (Implementing API version 1.21-R0.1-SNAPSHOT)
|
||||||
[20:34:42 INFO]: You are running the latest version
|
[20:34:42 INFO]: You are running the latest version
|
||||||
|
[20:34:42 INFO]: Previous version: 1.21-103-aa3b356 (MC: 1.21)
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
5
.github/ISSUE_TEMPLATE/config.yml
vendored
5
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -1,8 +1,11 @@
|
|||||||
blank_issues_enabled: false
|
blank_issues_enabled: false
|
||||||
contact_links:
|
contact_links:
|
||||||
|
- name: Feature Request
|
||||||
|
url: https://github.com/PaperMC/Paper/discussions/new?category=ideas
|
||||||
|
about: Suggest an idea for Paper
|
||||||
- name: PaperMC Discord
|
- name: PaperMC Discord
|
||||||
url: https://discord.gg/papermc
|
url: https://discord.gg/papermc
|
||||||
about: If you are having issues with timings or have other minor issues, come ask us on our Discord server!
|
about: If you are having issues with spark or have other minor issues, come ask us on our Discord server!
|
||||||
- name: Exploit Report
|
- name: Exploit Report
|
||||||
url: https://discord.gg/papermc
|
url: https://discord.gg/papermc
|
||||||
about: |
|
about: |
|
||||||
|
44
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
44
.github/ISSUE_TEMPLATE/feature-request.yml
vendored
@ -1,44 +0,0 @@
|
|||||||
name: Feature Request
|
|
||||||
description: Suggest an idea for Paper
|
|
||||||
labels: [ "status: needs triage", "type: feature" ]
|
|
||||||
body:
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Thank you for filling out a feature request for Paper! Please be as detailed as possible so that we may consider and review the request easier.
|
|
||||||
We ask that you search all the issues to avoid a duplicate feature request. If one exists, please reply if you have anything to add.
|
|
||||||
Before requesting a new feature, please make sure you are using the latest version and that the feature you are requesting is not already in Paper.
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Is your feature request related to a problem?
|
|
||||||
description: Please give some context for this request. Why do you want it added?
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Describe the solution you'd like.
|
|
||||||
description: A clear and concise description of what you want.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Describe alternatives you've considered.
|
|
||||||
description: List any alternatives you might have tried to get the feature you want.
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
|
|
||||||
- type: textarea
|
|
||||||
attributes:
|
|
||||||
label: Other
|
|
||||||
description: Add any other context or screenshots about the feature request below.
|
|
||||||
validations:
|
|
||||||
required: false
|
|
||||||
|
|
||||||
- type: markdown
|
|
||||||
attributes:
|
|
||||||
value: |
|
|
||||||
Before submitting this feature request, please search our issue tracker to ensure your feature has not
|
|
||||||
already been requested.
|
|
10
.github/ISSUE_TEMPLATE/performance-problem.yml
vendored
10
.github/ISSUE_TEMPLATE/performance-problem.yml
vendored
@ -10,9 +10,9 @@ body:
|
|||||||
|
|
||||||
- type: input
|
- type: input
|
||||||
attributes:
|
attributes:
|
||||||
label: Timings or Profile link
|
label: Profile link
|
||||||
description: We ask that all timings/profiles are a link, not a screenshot. Screenshots inhibit our ability to figure out the real cause of the issue.
|
description: We ask that all profiles are a link, not a screenshot. Screenshots inhibit our ability to figure out the real cause of the issue.
|
||||||
placeholder: "Example: https://timings.aikar.co/?id=6b48586fbbdd48e585ca0ebb07c59dd0"
|
placeholder: "Example: https://spark.lucko.me/XsN0hxGfsi"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
@ -56,10 +56,10 @@ body:
|
|||||||
|
|
||||||
```
|
```
|
||||||
> version
|
> version
|
||||||
[20:34:42 INFO]: This server is running Paper version git-Paper-540 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
|
|
||||||
[20:34:42 INFO]: Checking version, please wait...
|
[20:34:42 INFO]: Checking version, please wait...
|
||||||
[20:34:42 INFO]: Previous version: git-Paper-538 (MC: 1.16.5)
|
[20:34:42 INFO]: This server is running Paper version 1.21-105-master@7e91a2c (2024-07-20T21:04:31Z) (Implementing API version 1.21-R0.1-SNAPSHOT)
|
||||||
[20:34:42 INFO]: You are running the latest version
|
[20:34:42 INFO]: You are running the latest version
|
||||||
|
[20:34:42 INFO]: Previous version: 1.21-103-aa3b356 (MC: 1.21)
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
@ -44,10 +44,10 @@ body:
|
|||||||
|
|
||||||
```
|
```
|
||||||
> version
|
> version
|
||||||
[20:34:42 INFO]: This server is running Paper version git-Paper-540 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
|
|
||||||
[20:34:42 INFO]: Checking version, please wait...
|
[20:34:42 INFO]: Checking version, please wait...
|
||||||
[20:34:42 INFO]: Previous version: git-Paper-538 (MC: 1.16.5)
|
[20:34:42 INFO]: This server is running Paper version 1.21-105-master@7e91a2c (2024-07-20T21:04:31Z) (Implementing API version 1.21-R0.1-SNAPSHOT)
|
||||||
[20:34:42 INFO]: You are running the latest version
|
[20:34:42 INFO]: You are running the latest version
|
||||||
|
[20:34:42 INFO]: Previous version: 1.21-103-aa3b356 (MC: 1.21)
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
54
.github/workflows/build.yml
vendored
54
.github/workflows/build.yml
vendored
@ -21,31 +21,36 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java: [17]
|
java: [21]
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: JDK ${{ matrix.java }}
|
- name: JDK ${{ matrix.java }}
|
||||||
uses: actions/setup-java@v3.11.0
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
distribution: 'temurin'
|
distribution: 'zulu'
|
||||||
|
|
||||||
- name: Validate Gradle wrapper
|
- name: Validate Gradle wrapper
|
||||||
uses: gradle/wrapper-validation-action@v1
|
uses: gradle/wrapper-validation-action@v2
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/gradle-build-action@v2
|
uses: gradle/actions/setup-gradle@v3
|
||||||
|
|
||||||
- name: Configure Build
|
- name: Configure Build
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v7
|
||||||
id: determine
|
id: determine
|
||||||
|
env:
|
||||||
|
REF_NAME: "${{ github.ref_name }}"
|
||||||
|
REF_TYPE: "${{ github.ref_type }}"
|
||||||
|
EVENT: "${{ toJSON(github.event) }}"
|
||||||
|
EVENT_TYPE: "${{ github.event_name }}"
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const {owner, repo} = context.repo;
|
const {owner, repo} = context.repo;
|
||||||
const event_name = "${{ github.event_name }}";
|
const event_name = `${process.env.EVENT_TYPE}`;
|
||||||
const event = ${{ toJSON(github.event) }};
|
const event = JSON.parse(`${process.env.EVENT}`);
|
||||||
const ref_type = "${{ github.ref_type }}";
|
const ref_type = `${process.env.REF_TYPE}`;
|
||||||
const ref_name = "${{ github.ref_name }}";
|
const ref_name = `${process.env.REF_NAME}`;
|
||||||
const result = {
|
const result = {
|
||||||
action: "build"
|
action: "build"
|
||||||
};
|
};
|
||||||
@ -71,19 +76,38 @@ jobs:
|
|||||||
- name: Apply Patches
|
- name: Apply Patches
|
||||||
run: |
|
run: |
|
||||||
git config --global user.email "no-reply@github.com"
|
git config --global user.email "no-reply@github.com"
|
||||||
git config --global user.name "Github Actions"
|
git config --global user.name "GitHub Actions"
|
||||||
./gradlew applyPatches --stacktrace
|
./gradlew applyPatches --stacktrace
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: ./gradlew build --stacktrace
|
run: ./gradlew build --stacktrace
|
||||||
|
|
||||||
|
- name: Upload Test Results
|
||||||
|
if: always()
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: Test Results (${{ matrix.java }})
|
||||||
|
path: |
|
||||||
|
**/build/test-results/test/TEST-*.xml
|
||||||
|
|
||||||
- name: Create Paperclip Jar
|
- name: Create Paperclip Jar
|
||||||
if: fromJSON(steps.determine.outputs.result).action == 'paperclip'
|
if: fromJSON(steps.determine.outputs.result).action == 'paperclip'
|
||||||
run: ./gradlew createReobfPaperclipJar --stacktrace
|
run: ./gradlew createMojmapPaperclipJar --stacktrace
|
||||||
|
|
||||||
- name: Upload Paperclip Jar
|
- name: Upload Paperclip Jar
|
||||||
if: fromJSON(steps.determine.outputs.result).action == 'paperclip'
|
if: fromJSON(steps.determine.outputs.result).action == 'paperclip'
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: paper-${{ fromJSON(steps.determine.outputs.result).pr }}
|
name: paper-${{ fromJSON(steps.determine.outputs.result).pr }}
|
||||||
path: build/libs/paper-paperclip-*-reobf.jar
|
path: build/libs/paper-paperclip-*-mojmap.jar
|
||||||
|
event_file:
|
||||||
|
name: "Event File"
|
||||||
|
# Only run on PRs if the source branch is on someone else's repo
|
||||||
|
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Upload
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: Event File
|
||||||
|
path: ${{ github.event_path }}
|
||||||
|
15
.github/workflows/close_invalid_prs.yml
vendored
15
.github/workflows/close_invalid_prs.yml
vendored
@ -6,9 +6,22 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
run:
|
||||||
if: ${{ github.repository != github.event.pull_request.head.repo.full_name && github.head_ref == 'master' }}
|
if: |
|
||||||
|
github.repository != github.event.pull_request.head.repo.full_name &&
|
||||||
|
(
|
||||||
|
github.head_ref == 'master' ||
|
||||||
|
github.event.pull_request.head.repo.owner.type != 'User'
|
||||||
|
)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: superbrothers/close-pull-request@v3
|
- uses: superbrothers/close-pull-request@v3
|
||||||
|
id: "master_branch"
|
||||||
|
if: github.head_ref == 'master'
|
||||||
with:
|
with:
|
||||||
comment: "Please do not open pull requests from the `master` branch, create a new branch instead."
|
comment: "Please do not open pull requests from the `master` branch, create a new branch instead."
|
||||||
|
|
||||||
|
- uses: superbrothers/close-pull-request@v3
|
||||||
|
id: "org_account"
|
||||||
|
if: github.event.pull_request.head.repo.owner.type != 'User' && steps.master_branch.outcome == 'skipped'
|
||||||
|
with:
|
||||||
|
comment: "Please do not open pull requests from non-user accounts like organizations. Create a fork on a user account instead."
|
||||||
|
24
.github/workflows/pr_comment.yml
vendored
24
.github/workflows/pr_comment.yml
vendored
@ -17,7 +17,15 @@ jobs:
|
|||||||
if: github.event.workflow_run.conclusion == 'success'
|
if: github.event.workflow_run.conclusion == 'success'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@v6
|
- uses: actions/github-script@v7
|
||||||
|
env:
|
||||||
|
BRANCH_NAME: "${{ github.event.workflow_run.head_branch }}"
|
||||||
|
PR_OWNER: "${{ github.event.workflow_run.head_repository.owner.login }}"
|
||||||
|
PR_SHA: "${{ github.event.workflow_run.head_sha }}"
|
||||||
|
RUN_ID: "${{ github.event.workflow_run.id }}"
|
||||||
|
REPO_ID: "${{ github.event.repository.id }}"
|
||||||
|
EVENT_TYPE: "${{ github.event.workflow_run.event}}"
|
||||||
|
PULL_REQUESTS: "${{ toJSON(github.event.workflow_run.pull_requests) }}"
|
||||||
with:
|
with:
|
||||||
# This snippet is public-domain, taken from
|
# This snippet is public-domain, taken from
|
||||||
# https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
|
# https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
|
||||||
@ -37,17 +45,17 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { owner, repo } = context.repo;
|
const { owner, repo } = context.repo;
|
||||||
const run_id = ${{ github.event.workflow_run.id }};
|
const run_id = `${process.env.RUN_ID}`;
|
||||||
const repo_id = ${{ github.event.repository.id }};
|
const repo_id = `${process.env.REPO_ID}`;
|
||||||
|
|
||||||
let pulls = [];
|
let pulls = [];
|
||||||
const event_type = "${{ github.event.workflow_run.event}}";
|
const event_type = `${process.env.EVENT_TYPE}`;
|
||||||
if (event_type === "push") { // if push, it's from the same repo which means `pull_requests` is populated
|
if (event_type === "push") { // if push, it's from the same repo which means `pull_requests` is populated
|
||||||
pulls = ${{ toJSON(github.event.workflow_run.pull_requests) }};
|
pulls = JSON.parse(`${process.env.PULL_REQUESTS}`);
|
||||||
} else {
|
} else {
|
||||||
const pr_branch = "${{ github.event.workflow_run.head_branch }}";
|
const pr_branch = `${process.env.BRANCH_NAME}`;
|
||||||
const pr_sha = "${{ github.event.workflow_run.head_sha }}";
|
const pr_sha = `${process.env.PR_SHA}`;
|
||||||
const pr_owner = "${{ github.event.workflow_run.head_repository.owner.login }}";
|
const pr_owner = `${process.env.PR_OWNER}`;
|
||||||
const { data } = await github.rest.pulls.list({ owner, repo, head: `${pr_owner}:${pr_branch}`, state: "open" });
|
const { data } = await github.rest.pulls.list({ owner, repo, head: `${pr_owner}:${pr_branch}`, state: "open" });
|
||||||
core.debug(JSON.stringify(data, null, 2));
|
core.debug(JSON.stringify(data, null, 2));
|
||||||
pulls = data.filter((pr) => pr.head.sha === pr_sha && pr.labels.find((l) => l.name === "build-pr-jar"));
|
pulls = data.filter((pr) => pr.head.sha === pr_sha && pr.labels.find((l) => l.name === "build-pr-jar"));
|
||||||
|
44
.github/workflows/projects.yml
vendored
44
.github/workflows/projects.yml
vendored
@ -33,25 +33,23 @@ jobs:
|
|||||||
column-field: Status
|
column-field: Status
|
||||||
label-to-column-map: |
|
label-to-column-map: |
|
||||||
{
|
{
|
||||||
"status: needs triage": "🕑 Needs Triage",
|
"resolution: awaiting response": "⌛ Awaiting Response",
|
||||||
|
"resolution: cannot reproduce": "Invalid",
|
||||||
|
"resolution: duplicate": "Invalid",
|
||||||
|
"resolution: incomplete": "Invalid",
|
||||||
|
"resolution: invalid": "Invalid",
|
||||||
|
"resolution: superseded": "Invalid",
|
||||||
|
"resolution: unsupported": "Invalid",
|
||||||
|
"resolution: won't fix": "Invalid",
|
||||||
|
"resolution: works as intended": "Invalid",
|
||||||
"status: accepted": "✅ Accepted",
|
"status: accepted": "✅ Accepted",
|
||||||
"status: unlikely": "✅ Accepted",
|
|
||||||
"status: in progress": "Needs Work",
|
|
||||||
"status: rebase required": "Needs Work",
|
|
||||||
"status: blocked": "Needs Work",
|
"status: blocked": "Needs Work",
|
||||||
"status: defer upstream": "Needs Work",
|
"status: defer upstream": "Needs Work",
|
||||||
|
"status: in progress": "Needs Work",
|
||||||
"status: input wanted": "Needs Work",
|
"status: input wanted": "Needs Work",
|
||||||
"we must go deeper": "Needs Work",
|
"status: needs triage": "🕑 Needs Triage",
|
||||||
"has rough edges": "Needs Work",
|
"status: rebase required": "Needs Work",
|
||||||
"status: waiting on reporter": "⌛ Waiting for Reporter",
|
"status: unlikely": "✅ Accepted"
|
||||||
"resolution: works-as-intended": "Invalid",
|
|
||||||
"resolution: invalid": "Invalid",
|
|
||||||
"resolution: wontfix": "Invalid",
|
|
||||||
"resolution: duplicate": "Invalid",
|
|
||||||
"resolution: cannot reproduce": "Invalid",
|
|
||||||
"resolution: unsupported": "Invalid",
|
|
||||||
"resolution: incomplete": "Invalid",
|
|
||||||
"resolution: superseded": "Invalid"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- uses: PaperMC/update-projects-action@v0.2.0
|
- uses: PaperMC/update-projects-action@v0.2.0
|
||||||
@ -65,14 +63,14 @@ jobs:
|
|||||||
# include "status: needs triage" below to catch any closed issues without setting a resolution
|
# include "status: needs triage" below to catch any closed issues without setting a resolution
|
||||||
label-to-column-map: |
|
label-to-column-map: |
|
||||||
{
|
{
|
||||||
"status: accepted": "Done",
|
|
||||||
"status: needs triage": "Invalid",
|
|
||||||
"resolution: works-as-intended": "Invalid",
|
|
||||||
"resolution: invalid": "Invalid",
|
|
||||||
"resolution: wontfix": "Invalid",
|
|
||||||
"resolution: duplicate": "Invalid",
|
|
||||||
"resolution: cannot reproduce": "Invalid",
|
"resolution: cannot reproduce": "Invalid",
|
||||||
"resolution: unsupported": "Invalid",
|
"resolution: duplicate": "Invalid",
|
||||||
"resolution: incomplete": "Invalid",
|
"resolution: incomplete": "Invalid",
|
||||||
"resolution: superseded": "Invalid"
|
"resolution: invalid": "Invalid",
|
||||||
|
"resolution: superseded": "Invalid",
|
||||||
|
"resolution: unsupported": "Invalid",
|
||||||
|
"resolution: won't fix": "Invalid",
|
||||||
|
"resolution: works as intended": "Invalid",
|
||||||
|
"status: accepted": "Done",
|
||||||
|
"status: needs triage": "Invalid"
|
||||||
}
|
}
|
||||||
|
32
.github/workflows/test_results.yml
vendored
Normale Datei
32
.github/workflows/test_results.yml
vendored
Normale Datei
@ -0,0 +1,32 @@
|
|||||||
|
name: Test Results
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_run:
|
||||||
|
workflows: [ "Build Paper" ]
|
||||||
|
types:
|
||||||
|
- completed
|
||||||
|
permissions: { }
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-results:
|
||||||
|
name: Test Results
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event.workflow_run.conclusion != 'skipped'
|
||||||
|
permissions:
|
||||||
|
checks: write
|
||||||
|
# for downloading test result artifacts
|
||||||
|
actions: read
|
||||||
|
steps:
|
||||||
|
- name: Download and Extract Artifacts
|
||||||
|
uses: dawidd6/action-download-artifact@v3
|
||||||
|
with:
|
||||||
|
run_id: ${{ github.event.workflow_run.id }}
|
||||||
|
path: artifacts
|
||||||
|
- name: Publish Test Results
|
||||||
|
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||||
|
with:
|
||||||
|
commit: ${{ github.event.workflow_run.head_sha }}
|
||||||
|
event_file: artifacts/Event File/event.json
|
||||||
|
event_name: ${{ github.event.workflow_run.event }}
|
||||||
|
files: "artifacts/**/*.xml"
|
||||||
|
comment_mode: off
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -61,6 +61,7 @@ out/
|
|||||||
|
|
||||||
# other stuff
|
# other stuff
|
||||||
run/
|
run/
|
||||||
|
logs/
|
||||||
|
|
||||||
Paper-Server
|
Paper-Server
|
||||||
Paper-API
|
Paper-API
|
||||||
@ -72,3 +73,4 @@ paperclip.properties
|
|||||||
!gradle/wrapper/gradle-wrapper.jar
|
!gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
test-plugin.settings.gradle.kts
|
test-plugin.settings.gradle.kts
|
||||||
|
paper-api-generator.settings.gradle.kts
|
||||||
|
@ -27,12 +27,12 @@ which can be obtained in (most) package managers such as `apt` (Debian / Ubuntu;
|
|||||||
you will most likely use this for WSL), `homebrew` (macOS / Linux), and more:
|
you will most likely use this for WSL), `homebrew` (macOS / Linux), and more:
|
||||||
|
|
||||||
- `git` (package `git` everywhere);
|
- `git` (package `git` everywhere);
|
||||||
- A Java 17 or later JDK (packages vary, use Google/DuckDuckGo/etc.).
|
- A Java 21 or later JDK (packages vary, use Google/DuckDuckGo/etc.).
|
||||||
- [Adoptium](https://adoptium.net/) has builds for most operating systems.
|
- [Adoptium](https://adoptium.net/) has builds for most operating systems.
|
||||||
- Paper requires JDK 17 to build, however, makes use of Gradle's
|
- Paper requires JDK 21 to build, however, makes use of Gradle's
|
||||||
[Toolchains](https://docs.gradle.org/current/userguide/toolchains.html)
|
[Toolchains](https://docs.gradle.org/current/userguide/toolchains.html)
|
||||||
feature to allow building with only JRE 11 or later installed. (Gradle will
|
feature to allow building with only JRE 11 or later installed. (Gradle will
|
||||||
automatically provision JDK 17 for compilation if it cannot find an existing
|
automatically provision JDK 21 for compilation if it cannot find an existing
|
||||||
install).
|
install).
|
||||||
|
|
||||||
If you're on Windows, check
|
If you're on Windows, check
|
||||||
@ -42,11 +42,11 @@ If you're compiling with Docker, you can use Adoptium's
|
|||||||
[`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin/) images like so:
|
[`eclipse-temurin`](https://hub.docker.com/_/eclipse-temurin/) images like so:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
# docker run -it -v "$(pwd)":/data --rm eclipse-temurin:17.0.1_12-jdk bash
|
# docker run -it -v "$(pwd)":/data --rm eclipse-temurin:21.0.3_9-jdk bash
|
||||||
Pulling image...
|
Pulling image...
|
||||||
|
|
||||||
root@abcdefg1234:/# javac -version
|
root@abcdefg1234:/# javac -version
|
||||||
javac 17.0.1
|
javac 21.0.3
|
||||||
```
|
```
|
||||||
|
|
||||||
## Understanding Patches
|
## Understanding Patches
|
||||||
@ -67,7 +67,7 @@ Assuming you have already forked the repository:
|
|||||||
|
|
||||||
1. Clone your fork to your local machine;
|
1. Clone your fork to your local machine;
|
||||||
2. Type `./gradlew applyPatches` in a terminal to apply the changes from upstream.
|
2. Type `./gradlew applyPatches` in a terminal to apply the changes from upstream.
|
||||||
On Windows, leave out the `./` at the beginning for all `gradlew` commands;
|
On Windows, replace the `./` with `.\` at the beginning for all `gradlew` commands;
|
||||||
3. cd into `Paper-Server` for server changes, and `Paper-API` for API changes.
|
3. cd into `Paper-Server` for server changes, and `Paper-API` for API changes.
|
||||||
<!--You can also run `./paper server` or `./paper api` for these same directories
|
<!--You can also run `./paper server` or `./paper api` for these same directories
|
||||||
respectively.
|
respectively.
|
||||||
@ -204,29 +204,31 @@ when making and submitting changes.
|
|||||||
|
|
||||||
## Formatting
|
## Formatting
|
||||||
|
|
||||||
All modifications to non-Paper files should be marked.
|
All modifications to non-Paper files should be marked. The one exception to this is
|
||||||
|
when modifying javadoc comments, which should not have these markers.
|
||||||
|
|
||||||
- Multi-line changes start with `// Paper start` and end with `// Paper end`;
|
- You need to add a comment with a short and identifiable description of the patch:
|
||||||
- You can put a comment with an explanation if it isn't obvious, like this:
|
`// Paper start - <COMMIT DESCRIPTION>`
|
||||||
`// Paper start - reason`.
|
- The comments should generally be about the reason the change was made, what
|
||||||
- The comments should generally be about the reason the change was made, what
|
it was before, or what the change is.
|
||||||
it was before, or what the change is.
|
- After the general commit description, you can add additional information either
|
||||||
- Multi-line messages should start with `// Paper start` and use `/* Multi
|
after a `;` or in the next line.
|
||||||
line message here */` for the message itself.
|
- Multi-line changes start with `// Paper start - <COMMIT DESCRIPTION>` and end
|
||||||
- One-line changes should have `// Paper` or `// Paper - reason`.
|
with `// Paper end - <COMMIT DESCRIPTION>`.
|
||||||
|
- One-line changes should have `// Paper - <COMMIT DESCRIPTION>` at the end of the line.
|
||||||
|
|
||||||
Here's an example of how to mark changes by Paper:
|
Here's an example of how to mark changes by Paper:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
entity.getWorld().dontbeStupid(); // Paper - was beStupid() which is bad
|
entity.getWorld().dontBeStupid(); // Paper - Was beStupid(), which is bad
|
||||||
entity.getFriends().forEach(Entity::explode);
|
entity.getFriends().forEach(Entity::explode);
|
||||||
entity.a();
|
entity.updateFriends();
|
||||||
entity.b();
|
|
||||||
// Paper start - use plugin-set spawn
|
// Paper start - Use plugin-set spawn
|
||||||
// entity.getWorld().explode(entity.getWorld().getSpawn());
|
// entity.getWorld().explode(entity.getWorld().getSpawn());
|
||||||
Location spawnLocation = ((CraftWorld)entity.getWorld()).getSpawnLocation();
|
Location spawnLocation = ((CraftWorld)entity.getWorld()).getSpawnLocation();
|
||||||
entity.getWorld().explode(new BlockPosition(spawnLocation.getX(), spawnLocation.getY(), spawnLocation.getZ()));
|
entity.getWorld().explode(new BlockPosition(spawnLocation.getX(), spawnLocation.getY(), spawnLocation.getZ()));
|
||||||
// Paper end
|
// Paper end - Use plugin-set spawn
|
||||||
```
|
```
|
||||||
|
|
||||||
We generally follow the usual Java style (aka. Oracle style), or what is programmed
|
We generally follow the usual Java style (aka. Oracle style), or what is programmed
|
||||||
@ -235,6 +237,25 @@ into most IDEs and formatters by default. There are a few notes, however:
|
|||||||
There are exceptions, especially in Spigot-related files
|
There are exceptions, especially in Spigot-related files
|
||||||
- When in doubt or the code around your change is in a clearly different style,
|
- When in doubt or the code around your change is in a clearly different style,
|
||||||
use the same style as the surrounding code.
|
use the same style as the surrounding code.
|
||||||
|
- Usage of the `var` keyword is heavily discouraged, as it makes reading patch files
|
||||||
|
a lot harder and can lead to confusion during updates due to changed return types.
|
||||||
|
The only exception to this is if a line would otherwise be way too long/filled with
|
||||||
|
hard to parse generics in a case where the base type itself is already obvious
|
||||||
|
|
||||||
|
### Imports
|
||||||
|
When adding new imports to a class in a file not created by the current patch, use the fully qualified class name
|
||||||
|
instead of adding a new import to the top of the file. If you are using a type a significant number of times, you
|
||||||
|
can add an import with a comment. However, if its only used a couple of times, the FQN is preferred to prevent future
|
||||||
|
patch conflicts in the import section of the file.
|
||||||
|
|
||||||
|
```java
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
// don't add import here, use FQN like below
|
||||||
|
|
||||||
|
public class SomeEvent extends Event {
|
||||||
|
public final org.bukkit.Location newLocation; // Paper - add location
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Access Transformers
|
## Access Transformers
|
||||||
Sometimes, vanilla or CraftBukkit code already contains a field, method, or type you want to access
|
Sometimes, vanilla or CraftBukkit code already contains a field, method, or type you want to access
|
||||||
@ -302,7 +323,7 @@ Subject: [PATCH] revert serverside behavior of keepalives
|
|||||||
This patch intends to bump up the time that a client has to reply to the
|
This patch intends to bump up the time that a client has to reply to the
|
||||||
server back to 30 seconds as per pre 1.12.2, which allowed clients
|
server back to 30 seconds as per pre 1.12.2, which allowed clients
|
||||||
more than enough time to reply potentially allowing them to be less
|
more than enough time to reply potentially allowing them to be less
|
||||||
tempermental due to lag spikes on the network thread, e.g. that caused
|
temperamental due to lag spikes on the network thread, e.g. that caused
|
||||||
by plugins that are interacting with netty.
|
by plugins that are interacting with netty.
|
||||||
|
|
||||||
We also add a system property to allow people to tweak how long the server
|
We also add a system property to allow people to tweak how long the server
|
||||||
@ -478,4 +499,4 @@ everything like usual.
|
|||||||
> in Windows like described here:
|
> in Windows like described here:
|
||||||
> <https://docs.microsoft.com/en-us/windows/wsl/filesystems#view-your-current-directory-in-windows-file-explorer>
|
> <https://docs.microsoft.com/en-us/windows/wsl/filesystems#view-your-current-directory-in-windows-file-explorer>
|
||||||
|
|
||||||
[MappingViewer]: https://nms.screamingsandals.org/
|
[MappingViewer]: https://mappings.cephx.dev/
|
||||||
|
@ -61,4 +61,7 @@ Emily <emilia.lopezf.1999@gmail.com>
|
|||||||
dawon <dawon@dawon.eu>
|
dawon <dawon@dawon.eu>
|
||||||
Ollie <69084614+olijeffers0n@users.noreply.github.com>
|
Ollie <69084614+olijeffers0n@users.noreply.github.com>
|
||||||
Oliwier Miodun <naczs@blueflow.pl>
|
Oliwier Miodun <naczs@blueflow.pl>
|
||||||
|
aerulion <aerulion@gmail.com>
|
||||||
|
Lukas Planz <lukas.planz@web.de>
|
||||||
|
granny <contact@granny.dev>
|
||||||
```
|
```
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
plugins {
|
|
||||||
`java-library`
|
|
||||||
`maven-publish`
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
|
||||||
withSourcesJar()
|
|
||||||
withJavadocJar()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(project(":paper-api"))
|
|
||||||
api("com.mojang:brigadier:1.0.18")
|
|
||||||
|
|
||||||
compileOnly("it.unimi.dsi:fastutil:8.5.6")
|
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
|
||||||
|
|
||||||
testImplementation("junit:junit:4.13.2")
|
|
||||||
testImplementation("org.hamcrest:hamcrest-library:1.3")
|
|
||||||
testImplementation("org.ow2.asm:asm-tree:9.2")
|
|
||||||
}
|
|
||||||
|
|
||||||
configure<PublishingExtension> {
|
|
||||||
publications.create<MavenPublication>("maven") {
|
|
||||||
from(components["java"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) {
|
|
||||||
badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;")
|
|
||||||
jarToScan.set(tasks.jar.flatMap { it.archiveFile })
|
|
||||||
classpath.from(configurations.compileClasspath)
|
|
||||||
}
|
|
||||||
tasks.check {
|
|
||||||
dependsOn(scanJar)
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package com.destroystokyo.paper.brigadier;
|
|
||||||
|
|
||||||
import com.mojang.brigadier.Command;
|
|
||||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Brigadier {@link Command}, {@link SuggestionProvider}, and permission checker for Bukkit {@link Command}s.
|
|
||||||
*
|
|
||||||
* @param <S> command source type
|
|
||||||
*/
|
|
||||||
public interface BukkitBrigadierCommand <S extends BukkitBrigadierCommandSource> extends Command<S>, Predicate<S>, SuggestionProvider<S> {
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package com.destroystokyo.paper.brigadier;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public interface BukkitBrigadierCommandSource {
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
Entity getBukkitEntity();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
World getBukkitWorld();
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
Location getBukkitLocation();
|
|
||||||
|
|
||||||
CommandSender getBukkitSender();
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
package com.destroystokyo.paper.event.brigadier;
|
|
||||||
|
|
||||||
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
|
||||||
import com.mojang.brigadier.tree.RootCommandNode;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fired any time a Brigadier RootCommandNode is generated for a player to inform the client of commands.
|
|
||||||
* You may manipulate this CommandNode to change what the client sees.
|
|
||||||
*
|
|
||||||
* <p>This event may fire on login, world change, and permission rebuilds, by plugin request, and potentially future means.</p>
|
|
||||||
*
|
|
||||||
* <p>This event will fire before {@link org.bukkit.event.player.PlayerCommandSendEvent}, so no filtering has been done by
|
|
||||||
* other plugins yet.</p>
|
|
||||||
*
|
|
||||||
* <p>WARNING: This event will potentially (and most likely) fire twice! Once for Async, and once again for Sync.
|
|
||||||
* It is important that you check event.isAsynchronous() and event.hasFiredAsync() to ensure you only act once.
|
|
||||||
* If for some reason we are unable to send this asynchronously in the future, only the sync method will fire.</p>
|
|
||||||
*
|
|
||||||
* <p>Your logic should look like this:
|
|
||||||
* {@code if (event.isAsynchronous() || !event.hasFiredAsync()) { // do stuff }}</p>
|
|
||||||
*
|
|
||||||
* <p>If your logic is not safe to run asynchronously, only react to the synchronous version.</p>
|
|
||||||
*
|
|
||||||
* <p>This is a draft/experimental API and is subject to change.</p>
|
|
||||||
*/
|
|
||||||
@ApiStatus.Experimental
|
|
||||||
public class AsyncPlayerSendCommandsEvent <S extends BukkitBrigadierCommandSource> extends PlayerEvent {
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private final RootCommandNode<S> node;
|
|
||||||
private final boolean hasFiredAsync;
|
|
||||||
|
|
||||||
public AsyncPlayerSendCommandsEvent(Player player, RootCommandNode<S> node, boolean hasFiredAsync) {
|
|
||||||
super(player, !Bukkit.isPrimaryThread());
|
|
||||||
this.node = node;
|
|
||||||
this.hasFiredAsync = hasFiredAsync;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the full Root Command Node being sent to the client, which is mutable.
|
|
||||||
*
|
|
||||||
* @return the root command node
|
|
||||||
*/
|
|
||||||
public RootCommandNode<S> getCommandNode() {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets if this event has already fired asynchronously.
|
|
||||||
*
|
|
||||||
* @return whether this event has already fired asynchronously
|
|
||||||
*/
|
|
||||||
public boolean hasFiredAsync() {
|
|
||||||
return hasFiredAsync;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
package com.destroystokyo.paper.event.brigadier;
|
|
||||||
|
|
||||||
import com.mojang.brigadier.suggestion.Suggestions;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when sending {@link Suggestions} to the client. Will be called asynchronously if a plugin
|
|
||||||
* marks the {@link com.destroystokyo.paper.event.server.AsyncTabCompleteEvent} event handled asynchronously,
|
|
||||||
* otherwise called synchronously.
|
|
||||||
*/
|
|
||||||
public class AsyncPlayerSendSuggestionsEvent extends PlayerEvent implements Cancellable {
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private boolean cancelled = false;
|
|
||||||
|
|
||||||
private Suggestions suggestions;
|
|
||||||
private final String buffer;
|
|
||||||
|
|
||||||
public AsyncPlayerSendSuggestionsEvent(Player player, Suggestions suggestions, String buffer) {
|
|
||||||
super(player, !Bukkit.isPrimaryThread());
|
|
||||||
this.suggestions = suggestions;
|
|
||||||
this.buffer = buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the input buffer sent to request these suggestions.
|
|
||||||
*
|
|
||||||
* @return the input buffer
|
|
||||||
*/
|
|
||||||
public String getBuffer() {
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the suggestions to be sent to client.
|
|
||||||
*
|
|
||||||
* @return the suggestions
|
|
||||||
*/
|
|
||||||
public Suggestions getSuggestions() {
|
|
||||||
return suggestions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the suggestions to be sent to client.
|
|
||||||
*
|
|
||||||
* @param suggestions suggestions
|
|
||||||
*/
|
|
||||||
public void setSuggestions(Suggestions suggestions) {
|
|
||||||
this.suggestions = suggestions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return this.cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancels sending suggestions to the client.
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
this.cancelled = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,168 +0,0 @@
|
|||||||
package com.destroystokyo.paper.event.brigadier;
|
|
||||||
|
|
||||||
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommand;
|
|
||||||
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
|
||||||
import com.mojang.brigadier.tree.ArgumentCommandNode;
|
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
|
||||||
import com.mojang.brigadier.tree.RootCommandNode;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.server.ServerEvent;
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fired anytime the server synchronizes Bukkit commands to Brigadier.
|
|
||||||
*
|
|
||||||
* <p>Allows a plugin to control the command node structure for its commands.
|
|
||||||
* This is done at Plugin Enable time after commands have been registered, but may also
|
|
||||||
* run at a later point in the server lifetime due to plugins, a server reload, etc.</p>
|
|
||||||
*
|
|
||||||
* <p>This is a draft/experimental API and is subject to change.</p>
|
|
||||||
*/
|
|
||||||
@ApiStatus.Experimental
|
|
||||||
public class CommandRegisteredEvent<S extends BukkitBrigadierCommandSource> extends ServerEvent implements Cancellable {
|
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private final String commandLabel;
|
|
||||||
private final Command command;
|
|
||||||
private final BukkitBrigadierCommand<S> brigadierCommand;
|
|
||||||
private final RootCommandNode<S> root;
|
|
||||||
private final ArgumentCommandNode<S, String> defaultArgs;
|
|
||||||
private LiteralCommandNode<S> literal;
|
|
||||||
private boolean rawCommand = false;
|
|
||||||
private boolean cancelled = false;
|
|
||||||
|
|
||||||
public CommandRegisteredEvent(String commandLabel, BukkitBrigadierCommand<S> brigadierCommand, Command command, RootCommandNode<S> root, LiteralCommandNode<S> literal, ArgumentCommandNode<S, String> defaultArgs) {
|
|
||||||
this.commandLabel = commandLabel;
|
|
||||||
this.brigadierCommand = brigadierCommand;
|
|
||||||
this.command = command;
|
|
||||||
this.root = root;
|
|
||||||
this.literal = literal;
|
|
||||||
this.defaultArgs = defaultArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the command label of the {@link Command} being registered.
|
|
||||||
*
|
|
||||||
* @return the command label
|
|
||||||
*/
|
|
||||||
public String getCommandLabel() {
|
|
||||||
return this.commandLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the {@link BukkitBrigadierCommand} for the {@link Command} being registered. This can be used
|
|
||||||
* as the {@link com.mojang.brigadier.Command command executor} or
|
|
||||||
* {@link com.mojang.brigadier.suggestion.SuggestionProvider} of a {@link com.mojang.brigadier.tree.CommandNode}
|
|
||||||
* to delegate to the {@link Command} being registered.
|
|
||||||
*
|
|
||||||
* @return the {@link BukkitBrigadierCommand}
|
|
||||||
*/
|
|
||||||
public BukkitBrigadierCommand<S> getBrigadierCommand() {
|
|
||||||
return this.brigadierCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the {@link Command} being registered.
|
|
||||||
*
|
|
||||||
* @return the {@link Command}
|
|
||||||
*/
|
|
||||||
public Command getCommand() {
|
|
||||||
return this.command;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the {@link RootCommandNode} which is being registered to.
|
|
||||||
*
|
|
||||||
* @return the {@link RootCommandNode}
|
|
||||||
*/
|
|
||||||
public RootCommandNode<S> getRoot() {
|
|
||||||
return this.root;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Bukkit APIs default arguments node (greedy string), for if
|
|
||||||
* you wish to reuse it.
|
|
||||||
*
|
|
||||||
* @return default arguments node
|
|
||||||
*/
|
|
||||||
public ArgumentCommandNode<S, String> getDefaultArgs() {
|
|
||||||
return this.defaultArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the {@link LiteralCommandNode} to be registered for the {@link Command}.
|
|
||||||
*
|
|
||||||
* @return the {@link LiteralCommandNode}
|
|
||||||
*/
|
|
||||||
public LiteralCommandNode<S> getLiteral() {
|
|
||||||
return this.literal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the {@link LiteralCommandNode} used to register this command. The default literal is mutable, so
|
|
||||||
* this is primarily if you want to completely replace the object.
|
|
||||||
*
|
|
||||||
* @param literal new node
|
|
||||||
*/
|
|
||||||
public void setLiteral(LiteralCommandNode<S> literal) {
|
|
||||||
this.literal = literal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets whether this command should is treated as "raw".
|
|
||||||
*
|
|
||||||
* @see #setRawCommand(boolean)
|
|
||||||
* @return whether this command is treated as "raw"
|
|
||||||
*/
|
|
||||||
public boolean isRawCommand() {
|
|
||||||
return this.rawCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets whether this command should be treated as "raw".
|
|
||||||
*
|
|
||||||
* <p>A "raw" command will only use the node provided by this event for
|
|
||||||
* sending the command tree to the client. For execution purposes, the default
|
|
||||||
* greedy string execution of a standard Bukkit {@link Command} is used.</p>
|
|
||||||
*
|
|
||||||
* <p>On older versions of Paper, this was the default and only behavior of this
|
|
||||||
* event.</p>
|
|
||||||
*
|
|
||||||
* @param rawCommand whether this command should be treated as "raw"
|
|
||||||
*/
|
|
||||||
public void setRawCommand(final boolean rawCommand) {
|
|
||||||
this.rawCommand = rawCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return this.cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancels registering this command to Brigadier, but will remain in Bukkit Command Map. Can be used to hide a
|
|
||||||
* command from all players.
|
|
||||||
*
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
this.cancelled = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package io.papermc.paper.brigadier;
|
|
||||||
|
|
||||||
import com.mojang.brigadier.Message;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
|
||||||
import net.kyori.adventure.text.TextComponent;
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper methods to bridge the gaps between Brigadier and Paper-MojangAPI.
|
|
||||||
*/
|
|
||||||
public final class PaperBrigadier {
|
|
||||||
private PaperBrigadier() {
|
|
||||||
throw new RuntimeException("PaperBrigadier is not to be instantiated!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new Brigadier {@link Message} from a {@link ComponentLike}.
|
|
||||||
*
|
|
||||||
* <p>Mostly useful for creating rich suggestion tooltips in combination with other Paper-MojangAPI APIs.</p>
|
|
||||||
*
|
|
||||||
* @param componentLike The {@link ComponentLike} to use for the {@link Message} contents
|
|
||||||
* @return A new Brigadier {@link Message}
|
|
||||||
*/
|
|
||||||
public static @NonNull Message message(final @NonNull ComponentLike componentLike) {
|
|
||||||
return PaperBrigadierProvider.instance().message(componentLike);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new {@link Component} from a Brigadier {@link Message}.
|
|
||||||
*
|
|
||||||
* <p>If the {@link Message} was created from a {@link Component}, it will simply be
|
|
||||||
* converted back, otherwise a new {@link TextComponent} will be created with the
|
|
||||||
* content of {@link Message#getString()}</p>
|
|
||||||
*
|
|
||||||
* @param message The {@link Message} to create a {@link Component} from
|
|
||||||
* @return The created {@link Component}
|
|
||||||
*/
|
|
||||||
public static @NonNull Component componentFromMessage(final @NonNull Message message) {
|
|
||||||
return PaperBrigadierProvider.instance().componentFromMessage(message);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package io.papermc.paper.brigadier;
|
|
||||||
|
|
||||||
import com.mojang.brigadier.Message;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
|
|
||||||
import static java.util.Objects.requireNonNull;
|
|
||||||
|
|
||||||
interface PaperBrigadierProvider {
|
|
||||||
final class Holder {
|
|
||||||
private static @MonotonicNonNull PaperBrigadierProvider INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static @NonNull PaperBrigadierProvider instance() {
|
|
||||||
return requireNonNull(Holder.INSTANCE, "PaperBrigadierProvider has not yet been initialized!");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void initialize(final @NonNull PaperBrigadierProvider instance) {
|
|
||||||
if (Holder.INSTANCE != null) {
|
|
||||||
throw new IllegalStateException("PaperBrigadierProvider has already been initialized!");
|
|
||||||
}
|
|
||||||
Holder.INSTANCE = instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull Message message(@NonNull ComponentLike componentLike);
|
|
||||||
|
|
||||||
@NonNull Component componentFromMessage(@NonNull Message message);
|
|
||||||
}
|
|
12
README.md
12
README.md
@ -8,7 +8,7 @@ The most widely used, high-performance Minecraft server that aims to fix gamepla
|
|||||||
|
|
||||||
|
|
||||||
**Support and Project Discussion:**
|
**Support and Project Discussion:**
|
||||||
- [Our forums](https://forums.papermc.io/), [Discord](https://discord.gg/papermc), or [IRC](https://webchat.esper.net/?channels=paper)
|
- [Our forums](https://forums.papermc.io/) or [Discord](https://discord.gg/papermc)
|
||||||
|
|
||||||
How To (Server Admins)
|
How To (Server Admins)
|
||||||
------
|
------
|
||||||
@ -40,7 +40,7 @@ How To (Plugin Developers)
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc.paper</groupId>
|
<groupId>io.papermc.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.20.1-R0.1-SNAPSHOT</version>
|
<version>1.21-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
@ -53,19 +53,19 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
How To (Compiling Jar From Source)
|
How To (Compiling Jar From Source)
|
||||||
------
|
------
|
||||||
To compile Paper, you need JDK 17 and an internet connection.
|
To compile Paper, you need JDK 21 and an internet connection.
|
||||||
|
|
||||||
Clone this repo, run `./gradlew applyPatches`, then `./gradlew createReobfBundlerJar` from your terminal. You can find the compiled jar in the project root's `build/libs` directory.
|
Clone this repo, run `./gradlew applyPatches`, then `./gradlew createMojmapBundlerJar` from your terminal. You can find the compiled jar in the project root's `build/libs` directory.
|
||||||
|
|
||||||
To get a full list of tasks, run `./gradlew tasks`.
|
To get a full list of tasks, run `./gradlew tasks`.
|
||||||
|
|
||||||
|
@ -8,4 +8,8 @@
|
|||||||
# To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId:
|
# To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId:
|
||||||
# minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter
|
# minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter
|
||||||
# minecraft net/minecraft/world/level/entity/LevelEntityGetter.java
|
# minecraft net/minecraft/world/level/entity/LevelEntityGetter.java
|
||||||
|
# To import minecraft data files, like the default chat type, use `mc_data` as the prefix:
|
||||||
|
# mc_data chat_type/chat.json
|
||||||
|
# mc_data dimension_type/overworld.json
|
||||||
|
#
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ c net/minecraft/world/level/chunk/LevelChunk net/minecraft/world/level/chunk/Chu
|
|||||||
|
|
||||||
# See mappings-patch.tiny
|
# See mappings-patch.tiny
|
||||||
c net/minecraft/server/level/ChunkMap net/minecraft/server/level/PlayerChunkMap
|
c net/minecraft/server/level/ChunkMap net/minecraft/server/level/PlayerChunkMap
|
||||||
f Lnet/minecraft/server/level/ChunkMap$ChunkDistanceManager; distanceManager F
|
f Lnet/minecraft/server/level/ChunkMap$ChunkDistanceManager; distanceManager G
|
||||||
|
|
||||||
# Paper changes type
|
# The method is made public by Spigot, which then causes accidental overrides
|
||||||
c net/minecraft/core/MappedRegistry net/minecraft/core/RegistryMaterials
|
c net/minecraft/world/entity/Entity net/minecraft/world/entity/Entity
|
||||||
f Lit/unimi/dsi/fastutil/objects/Reference2IntOpenHashMap; toId e
|
m ()Z isInRain isInRain0
|
||||||
|
201
build.gradle.kts
201
build.gradle.kts
@ -1,11 +1,17 @@
|
|||||||
|
import io.papermc.paperweight.PaperweightException
|
||||||
|
import io.papermc.paperweight.tasks.BaseTask
|
||||||
|
import io.papermc.paperweight.util.*
|
||||||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.nio.file.Path
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
import kotlin.io.path.*
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
|
id("io.papermc.paperweight.core") version "1.7.1"
|
||||||
id("io.papermc.paperweight.core") version "1.5.5"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
@ -14,7 +20,7 @@ allprojects {
|
|||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
languageVersion.set(JavaLanguageVersion.of(17))
|
languageVersion = JavaLanguageVersion.of(21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -24,7 +30,7 @@ val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
|||||||
subprojects {
|
subprojects {
|
||||||
tasks.withType<JavaCompile> {
|
tasks.withType<JavaCompile> {
|
||||||
options.encoding = Charsets.UTF_8.name()
|
options.encoding = Charsets.UTF_8.name()
|
||||||
options.release.set(17)
|
options.release = 21
|
||||||
}
|
}
|
||||||
tasks.withType<Javadoc> {
|
tasks.withType<Javadoc> {
|
||||||
options.encoding = Charsets.UTF_8.name()
|
options.encoding = Charsets.UTF_8.name()
|
||||||
@ -61,31 +67,31 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
paramMappings("net.fabricmc:yarn:1.20.1+build.1:mergedv2")
|
paramMappings("net.fabricmc:yarn:1.21+build.1:mergedv2")
|
||||||
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
remapper("net.fabricmc:tiny-remapper:0.10.3:fat")
|
||||||
decompiler("net.minecraftforge:forgeflower:2.0.627.2")
|
decompiler("org.vineflower:vineflower:1.10.1")
|
||||||
spigotDecompiler("io.papermc:patched-spigot-fernflower:0.1+build.6")
|
spigotDecompiler("io.papermc:patched-spigot-fernflower:0.1+build.13")
|
||||||
paperclip("io.papermc:paperclip:3.0.3")
|
paperclip("io.papermc:paperclip:3.0.3")
|
||||||
}
|
}
|
||||||
|
|
||||||
paperweight {
|
paperweight {
|
||||||
minecraftVersion.set(providers.gradleProperty("mcVersion"))
|
minecraftVersion = providers.gradleProperty("mcVersion")
|
||||||
serverProject.set(project(":paper-server"))
|
serverProject = project(":paper-server")
|
||||||
|
|
||||||
paramMappingsRepo.set(paperMavenPublicUrl)
|
paramMappingsRepo = paperMavenPublicUrl
|
||||||
remapRepo.set(paperMavenPublicUrl)
|
remapRepo = paperMavenPublicUrl
|
||||||
decompileRepo.set(paperMavenPublicUrl)
|
decompileRepo = paperMavenPublicUrl
|
||||||
|
|
||||||
craftBukkit {
|
craftBukkit {
|
||||||
fernFlowerJar.set(layout.file(spigotDecompiler.elements.map { it.single().asFile }))
|
fernFlowerJar = layout.file(spigotDecompiler.elements.map { it.single().asFile })
|
||||||
}
|
}
|
||||||
|
|
||||||
paper {
|
paper {
|
||||||
spigotApiPatchDir.set(layout.projectDirectory.dir("patches/api"))
|
spigotApiPatchDir = layout.projectDirectory.dir("patches/api")
|
||||||
spigotServerPatchDir.set(layout.projectDirectory.dir("patches/server"))
|
spigotServerPatchDir = layout.projectDirectory.dir("patches/server")
|
||||||
|
|
||||||
mappingsPatch.set(layout.projectDirectory.file("build-data/mappings-patch.tiny"))
|
mappingsPatch = layout.projectDirectory.file("build-data/mappings-patch.tiny")
|
||||||
reobfMappingsPatch.set(layout.projectDirectory.file("build-data/reobf-mappings-patch.tiny"))
|
reobfMappingsPatch = layout.projectDirectory.file("build-data/reobf-mappings-patch.tiny")
|
||||||
|
|
||||||
reobfPackagesToFix.addAll(
|
reobfPackagesToFix.addAll(
|
||||||
"co.aikar.timings",
|
"co.aikar.timings",
|
||||||
@ -102,8 +108,7 @@ paperweight {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.generateDevelopmentBundle {
|
tasks.generateDevelopmentBundle {
|
||||||
apiCoordinates.set("io.papermc.paper:paper-api")
|
apiCoordinates = "io.papermc.paper:paper-api"
|
||||||
mojangApiCoordinates.set("io.papermc.paper:paper-mojangapi")
|
|
||||||
libraryRepositories.addAll(
|
libraryRepositories.addAll(
|
||||||
"https://repo.maven.apache.org/maven2/",
|
"https://repo.maven.apache.org/maven2/",
|
||||||
paperMavenPublicUrl,
|
paperMavenPublicUrl,
|
||||||
@ -131,16 +136,6 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.collectAtsFromPatches {
|
|
||||||
// Uncomment while updating for a new Minecraft version
|
|
||||||
// extraPatchDir.set(layout.projectDirectory.dir("patches/unapplied/server"))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Uncomment while updating for a new Minecraft version
|
|
||||||
// tasks.withType<io.papermc.paperweight.tasks.RebuildGitPatches> {
|
|
||||||
// filterPatches.set(false)
|
|
||||||
// }
|
|
||||||
|
|
||||||
tasks.register("printMinecraftVersion") {
|
tasks.register("printMinecraftVersion") {
|
||||||
doLast {
|
doLast {
|
||||||
println(providers.gradleProperty("mcVersion").get().trim())
|
println(providers.gradleProperty("mcVersion").get().trim())
|
||||||
@ -152,3 +147,149 @@ tasks.register("printPaperVersion") {
|
|||||||
println(project.version)
|
println(project.version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// see gradle.properties
|
||||||
|
if (providers.gradleProperty("updatingMinecraft").getOrElse("false").toBoolean()) {
|
||||||
|
tasks.collectAtsFromPatches {
|
||||||
|
val dir = layout.projectDirectory.dir("patches/unapplied/server")
|
||||||
|
if (dir.path.isDirectory()) {
|
||||||
|
extraPatchDir = dir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tasks.withType<io.papermc.paperweight.tasks.RebuildGitPatches>().configureEach {
|
||||||
|
filterPatches = false
|
||||||
|
}
|
||||||
|
tasks.register("continueServerUpdate", RebasePatches::class) {
|
||||||
|
description = "Moves the next X patches from unapplied to applied, and applies them. X being the number of patches that apply cleanly, plus the terminal failure if any."
|
||||||
|
projectDir = project.projectDir
|
||||||
|
appliedPatches = file("patches/server")
|
||||||
|
unappliedPatches = file("patches/unapplied/server")
|
||||||
|
applyTaskName = "applyServerPatches"
|
||||||
|
patchedDir = "Paper-Server"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@UntrackedTask(because = "Does not make sense to track state")
|
||||||
|
abstract class RebasePatches : BaseTask() {
|
||||||
|
@get:Internal
|
||||||
|
abstract val projectDir: DirectoryProperty
|
||||||
|
|
||||||
|
@get:InputFiles
|
||||||
|
abstract val appliedPatches: DirectoryProperty
|
||||||
|
|
||||||
|
@get:InputFiles
|
||||||
|
abstract val unappliedPatches: DirectoryProperty
|
||||||
|
|
||||||
|
@get:Input
|
||||||
|
abstract val applyTaskName: Property<String>
|
||||||
|
|
||||||
|
@get:Input
|
||||||
|
abstract val patchedDir: Property<String>
|
||||||
|
|
||||||
|
private fun unapplied(): List<Path> =
|
||||||
|
unappliedPatches.path.listDirectoryEntries("*.patch").sortedBy { it.name }
|
||||||
|
|
||||||
|
private fun appliedLoc(patch: Path): Path = appliedPatches.path.resolve(unappliedPatches.path.relativize(patch))
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val regex = Pattern.compile("Patch failed at ([0-9]{4}) (.*)")
|
||||||
|
val continuationRegex = Pattern.compile("^\\s{1}.+\$")
|
||||||
|
const val subjectPrefix = "Subject: [PATCH] "
|
||||||
|
}
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
fun run() {
|
||||||
|
val patchedDirPath = projectDir.path.resolve(patchedDir.get())
|
||||||
|
if (patchedDirPath.isDirectory()) {
|
||||||
|
val status = Git(patchedDirPath)("status").getText()
|
||||||
|
if (status.contains("You are in the middle of an am session.")) {
|
||||||
|
throw PaperweightException("Cannot continue update when $patchedDirPath is in the middle of an am session.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val unapplied = unapplied()
|
||||||
|
for (patch in unapplied) {
|
||||||
|
patch.copyTo(appliedLoc(patch))
|
||||||
|
}
|
||||||
|
|
||||||
|
val out = ByteArrayOutputStream()
|
||||||
|
val proc = ProcessBuilder()
|
||||||
|
.directory(projectDir.path)
|
||||||
|
.command("./gradlew", applyTaskName.get())
|
||||||
|
.redirectErrorStream(true)
|
||||||
|
.start()
|
||||||
|
|
||||||
|
val f = redirect(proc.inputStream, out)
|
||||||
|
|
||||||
|
val exit = proc.waitFor()
|
||||||
|
f.get()
|
||||||
|
|
||||||
|
if (exit != 0) {
|
||||||
|
val outStr = String(out.toByteArray())
|
||||||
|
val matcher = regex.matcher(outStr)
|
||||||
|
if (!matcher.find()) error("Could not determine failure point")
|
||||||
|
val failedSubjectFragment = matcher.group(2)
|
||||||
|
val failed = unapplied.single { p ->
|
||||||
|
p.useLines { lines ->
|
||||||
|
val collect = mutableListOf<String>()
|
||||||
|
for (line in lines) {
|
||||||
|
if (line.startsWith(subjectPrefix)) {
|
||||||
|
collect += line
|
||||||
|
} else if (collect.size == 1) {
|
||||||
|
if (continuationRegex.matcher(line).matches()) {
|
||||||
|
collect += line
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val subjectLine = collect.joinToString("").substringAfter(subjectPrefix)
|
||||||
|
subjectLine.startsWith(failedSubjectFragment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete successful & failure point from unapplied patches dir
|
||||||
|
for (path in unapplied) {
|
||||||
|
path.deleteIfExists()
|
||||||
|
if (path == failed) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete failed from patches dir
|
||||||
|
var started = false
|
||||||
|
for (path in unapplied) {
|
||||||
|
if (path == failed) {
|
||||||
|
started = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (started) {
|
||||||
|
appliedLoc(path).deleteIfExists()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the build file before resetting the AM session in case it has compilation errors
|
||||||
|
patchedDirPath.resolve("build.gradle.kts").deleteIfExists()
|
||||||
|
// Apply again to reset the am session (so it ends on the failed patch, to allow us to rebuild after fixing it)
|
||||||
|
val apply2 = ProcessBuilder()
|
||||||
|
.directory(projectDir.path)
|
||||||
|
.command("./gradlew", applyTaskName.get())
|
||||||
|
.redirectErrorStream(true)
|
||||||
|
.start()
|
||||||
|
|
||||||
|
val f1 = redirect(apply2.inputStream, System.out)
|
||||||
|
apply2.waitFor()
|
||||||
|
f1.get()
|
||||||
|
|
||||||
|
logger.lifecycle(outStr)
|
||||||
|
logger.lifecycle("Patch failed at $failed; See Git output above.")
|
||||||
|
} else {
|
||||||
|
unapplied.forEach { it.deleteIfExists() }
|
||||||
|
logger.lifecycle("All patches applied!")
|
||||||
|
}
|
||||||
|
|
||||||
|
val git = Git(projectDir.path)
|
||||||
|
git("add", appliedPatches.path.toString() + "/*").runSilently()
|
||||||
|
git("add", unappliedPatches.path.toString() + "/*").runSilently()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
group=io.papermc.paper
|
group=io.papermc.paper
|
||||||
version=1.20.1-R0.1-SNAPSHOT
|
version=1.21-R0.1-SNAPSHOT
|
||||||
mcVersion=1.20.1
|
mcVersion=1.21
|
||||||
|
|
||||||
|
# Set to true while updating Minecraft version
|
||||||
|
updatingMinecraft=false
|
||||||
|
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binäre Datei nicht angezeigt.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
31
gradlew
vendored
31
gradlew
vendored
@ -55,7 +55,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@ -83,10 +83,8 @@ done
|
|||||||
# This is normally unused
|
# This is normally unused
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@ -133,10 +131,13 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC3045
|
# shellcheck disable=SC2039,SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
# shellcheck disable=SC3045
|
# shellcheck disable=SC2039,SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
20
gradlew.bat
vendored
20
gradlew.bat
vendored
@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
|
|||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
35
paper-api-generator/build.gradle.kts
Normale Datei
35
paper-api-generator/build.gradle.kts
Normale Datei
@ -0,0 +1,35 @@
|
|||||||
|
import io.papermc.paperweight.PaperweightSourceGeneratorHelper
|
||||||
|
import io.papermc.paperweight.extension.PaperweightSourceGeneratorExt
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
java
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins.apply(PaperweightSourceGeneratorHelper::class)
|
||||||
|
|
||||||
|
extensions.configure(PaperweightSourceGeneratorExt::class) {
|
||||||
|
atFile.set(projectDir.toPath().resolve("wideners.at").toFile())
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("com.squareup:javapoet:1.13.0")
|
||||||
|
implementation(project(":paper-api"))
|
||||||
|
implementation("io.github.classgraph:classgraph:4.8.47")
|
||||||
|
implementation("org.jetbrains:annotations:24.0.1")
|
||||||
|
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
|
||||||
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<JavaExec>("generate") {
|
||||||
|
dependsOn(tasks.check)
|
||||||
|
mainClass.set("io.papermc.generator.Main")
|
||||||
|
classpath(sourceSets.main.map { it.runtimeClasspath })
|
||||||
|
args(projectDir.toPath().resolve("generated").toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "io.papermc.paper"
|
||||||
|
version = "1.0-SNAPSHOT"
|
@ -0,0 +1,443 @@
|
|||||||
|
package com.destroystokyo.paper.entity.ai;
|
||||||
|
|
||||||
|
import com.destroystokyo.paper.entity.RangedEntity;
|
||||||
|
import io.papermc.paper.entity.SchoolableFish;
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.entity.AbstractHorse;
|
||||||
|
import org.bukkit.entity.AbstractSkeleton;
|
||||||
|
import org.bukkit.entity.AbstractVillager;
|
||||||
|
import org.bukkit.entity.Animals;
|
||||||
|
import org.bukkit.entity.Bee;
|
||||||
|
import org.bukkit.entity.Blaze;
|
||||||
|
import org.bukkit.entity.Cat;
|
||||||
|
import org.bukkit.entity.Creature;
|
||||||
|
import org.bukkit.entity.Creeper;
|
||||||
|
import org.bukkit.entity.Dolphin;
|
||||||
|
import org.bukkit.entity.Drowned;
|
||||||
|
import org.bukkit.entity.Enderman;
|
||||||
|
import org.bukkit.entity.Evoker;
|
||||||
|
import org.bukkit.entity.Fish;
|
||||||
|
import org.bukkit.entity.Fox;
|
||||||
|
import org.bukkit.entity.Ghast;
|
||||||
|
import org.bukkit.entity.Guardian;
|
||||||
|
import org.bukkit.entity.Illager;
|
||||||
|
import org.bukkit.entity.Illusioner;
|
||||||
|
import org.bukkit.entity.IronGolem;
|
||||||
|
import org.bukkit.entity.Llama;
|
||||||
|
import org.bukkit.entity.Mob;
|
||||||
|
import org.bukkit.entity.Monster;
|
||||||
|
import org.bukkit.entity.Ocelot;
|
||||||
|
import org.bukkit.entity.Panda;
|
||||||
|
import org.bukkit.entity.Parrot;
|
||||||
|
import org.bukkit.entity.Phantom;
|
||||||
|
import org.bukkit.entity.PolarBear;
|
||||||
|
import org.bukkit.entity.PufferFish;
|
||||||
|
import org.bukkit.entity.Rabbit;
|
||||||
|
import org.bukkit.entity.Raider;
|
||||||
|
import org.bukkit.entity.Shulker;
|
||||||
|
import org.bukkit.entity.Silverfish;
|
||||||
|
import org.bukkit.entity.SkeletonHorse;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
|
import org.bukkit.entity.Spellcaster;
|
||||||
|
import org.bukkit.entity.Spider;
|
||||||
|
import org.bukkit.entity.Squid;
|
||||||
|
import org.bukkit.entity.Strider;
|
||||||
|
import org.bukkit.entity.Tameable;
|
||||||
|
import org.bukkit.entity.Turtle;
|
||||||
|
import org.bukkit.entity.Vex;
|
||||||
|
import org.bukkit.entity.Vindicator;
|
||||||
|
import org.bukkit.entity.WanderingTrader;
|
||||||
|
import org.bukkit.entity.Wither;
|
||||||
|
import org.bukkit.entity.Wolf;
|
||||||
|
import org.bukkit.entity.Zombie;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for Mob Goals.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
public interface VanillaGoal<T extends Mob> extends Goal<T> {
|
||||||
|
GoalKey<AbstractHorse> RANDOM_STAND = create("random_stand", AbstractHorse.class);
|
||||||
|
|
||||||
|
GoalKey<AbstractHorse> RUN_AROUND_LIKE_CRAZY = create("run_around_like_crazy", AbstractHorse.class);
|
||||||
|
|
||||||
|
GoalKey<AbstractSkeleton> ABSTRACT_SKELETON_MELEE = create("abstract_skeleton_melee", AbstractSkeleton.class);
|
||||||
|
|
||||||
|
GoalKey<AbstractVillager> LOOK_AT_TRADING_PLAYER = create("look_at_trading_player", AbstractVillager.class);
|
||||||
|
|
||||||
|
GoalKey<AbstractVillager> TRADE_WITH_PLAYER = create("trade_with_player", AbstractVillager.class);
|
||||||
|
|
||||||
|
GoalKey<Animals> BREED = create("breed", Animals.class);
|
||||||
|
|
||||||
|
GoalKey<Animals> FOLLOW_PARENT = create("follow_parent", Animals.class);
|
||||||
|
|
||||||
|
GoalKey<Bee> BEE_ATTACK = create("bee_attack", Bee.class);
|
||||||
|
|
||||||
|
GoalKey<Bee> BEE_BECOME_ANGRY = create("bee_become_angry", Bee.class);
|
||||||
|
|
||||||
|
GoalKey<Bee> BEE_ENTER_HIVE = create("bee_enter_hive", Bee.class);
|
||||||
|
|
||||||
|
GoalKey<Bee> BEE_GO_TO_HIVE = create("bee_go_to_hive", Bee.class);
|
||||||
|
|
||||||
|
GoalKey<Bee> BEE_GO_TO_KNOWN_FLOWER = create("bee_go_to_known_flower", Bee.class);
|
||||||
|
|
||||||
|
GoalKey<Bee> BEE_GROW_CROP = create("bee_grow_crop", Bee.class);
|
||||||
|
|
||||||
|
GoalKey<Bee> BEE_HURT_BY_OTHER = create("bee_hurt_by_other", Bee.class);
|
||||||
|
|
||||||
|
GoalKey<Bee> BEE_LOCATE_HIVE = create("bee_locate_hive", Bee.class);
|
||||||
|
|
||||||
|
GoalKey<Bee> BEE_POLLINATE = create("bee_pollinate", Bee.class);
|
||||||
|
|
||||||
|
GoalKey<Bee> BEE_WANDER = create("bee_wander", Bee.class);
|
||||||
|
|
||||||
|
GoalKey<Blaze> BLAZE_ATTACK = create("blaze_attack", Blaze.class);
|
||||||
|
|
||||||
|
GoalKey<Cat> CAT_AVOID_ENTITY = create("cat_avoid_entity", Cat.class);
|
||||||
|
|
||||||
|
GoalKey<Cat> CAT_LIE_ON_BED = create("cat_lie_on_bed", Cat.class);
|
||||||
|
|
||||||
|
GoalKey<Cat> CAT_RELAX_ON_OWNER = create("cat_relax_on_owner", Cat.class);
|
||||||
|
|
||||||
|
GoalKey<Cat> CAT_SIT_ON_BLOCK = create("cat_sit_on_block", Cat.class);
|
||||||
|
|
||||||
|
GoalKey<Cat> CAT_TEMPT = create("cat_tempt", Cat.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> AVOID_ENTITY = create("avoid_entity", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> BREATH_AIR = create("breath_air", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> DROWNED_GO_TO_WATER = create("drowned_go_to_water", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> FLEE_SUN = create("flee_sun", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> FOLLOW_BOAT = create("follow_boat", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> GOLEM_RANDOM_STROLL_IN_VILLAGE = create("golem_random_stroll_in_village", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> HURT_BY = create("hurt_by", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> MELEE_ATTACK = create("melee_attack", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> MOVE_BACK_TO_VILLAGE = create("move_back_to_village", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> MOVE_THROUGH_VILLAGE = create("move_through_village", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> MOVE_TOWARDS = create("move_towards", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> MOVE_TOWARDS_RESTRICTION = create("move_towards_restriction", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> PANIC = create("panic", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> PARROT_WANDER = create("parrot_wander", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> RANDOM_STROLL = create("random_stroll", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> RANDOM_SWIMMING = create("random_swimming", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> REMOVE_BLOCK = create("remove_block", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> RESTRICT_SUN = create("restrict_sun", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> STROLL_THROUGH_VILLAGE = create("stroll_through_village", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> TEMPT = create("tempt", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> TRY_FIND_WATER = create("try_find_water", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> WATER_AVOIDING_RANDOM_FLYING = create("water_avoiding_random_flying", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creature> WATER_AVOIDING_RANDOM_STROLL = create("water_avoiding_random_stroll", Creature.class);
|
||||||
|
|
||||||
|
GoalKey<Creeper> SWELL = create("swell", Creeper.class);
|
||||||
|
|
||||||
|
GoalKey<Dolphin> DOLPHIN_JUMP = create("dolphin_jump", Dolphin.class);
|
||||||
|
|
||||||
|
GoalKey<Dolphin> DOLPHIN_SWIM_TO_TREASURE = create("dolphin_swim_to_treasure", Dolphin.class);
|
||||||
|
|
||||||
|
GoalKey<Dolphin> DOLPHIN_SWIM_WITH_PLAYER = create("dolphin_swim_with_player", Dolphin.class);
|
||||||
|
|
||||||
|
GoalKey<Dolphin> PLAY_WITH_ITEMS = create("play_with_items", Dolphin.class);
|
||||||
|
|
||||||
|
GoalKey<Drowned> DROWNED_ATTACK = create("drowned_attack", Drowned.class);
|
||||||
|
|
||||||
|
GoalKey<Drowned> DROWNED_GO_TO_BEACH = create("drowned_go_to_beach", Drowned.class);
|
||||||
|
|
||||||
|
GoalKey<Drowned> DROWNED_SWIM_UP = create("drowned_swim_up", Drowned.class);
|
||||||
|
|
||||||
|
GoalKey<Enderman> ENDERMAN_FREEZE_WHEN_LOOKED_AT = create("enderman_freeze_when_looked_at", Enderman.class);
|
||||||
|
|
||||||
|
GoalKey<Enderman> ENDERMAN_LEAVE_BLOCK = create("enderman_leave_block", Enderman.class);
|
||||||
|
|
||||||
|
GoalKey<Enderman> ENDERMAN_LOOK_FOR_PLAYER = create("enderman_look_for_player", Enderman.class);
|
||||||
|
|
||||||
|
GoalKey<Enderman> ENDERMAN_TAKE_BLOCK = create("enderman_take_block", Enderman.class);
|
||||||
|
|
||||||
|
GoalKey<Evoker> EVOKER_ATTACK_SPELL = create("evoker_attack_spell", Evoker.class);
|
||||||
|
|
||||||
|
GoalKey<Evoker> EVOKER_CASTING_SPELL = create("evoker_casting_spell", Evoker.class);
|
||||||
|
|
||||||
|
GoalKey<Evoker> EVOKER_SUMMON_SPELL = create("evoker_summon_spell", Evoker.class);
|
||||||
|
|
||||||
|
GoalKey<Evoker> EVOKER_WOLOLO_SPELL = create("evoker_wololo_spell", Evoker.class);
|
||||||
|
|
||||||
|
GoalKey<Fish> FISH_SWIM = create("fish_swim", Fish.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> DEFEND_TRUSTED = create("defend_trusted", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> FACEPLANT = create("faceplant", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> FOX_BREED = create("fox_breed", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> FOX_EAT_BERRIES = create("fox_eat_berries", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> FOX_FLOAT = create("fox_float", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> FOX_FOLLOW_PARENT = create("fox_follow_parent", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> FOX_LOOK_AT_PLAYER = create("fox_look_at_player", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> FOX_MELEE_ATTACK = create("fox_melee_attack", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> FOX_PANIC = create("fox_panic", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> FOX_POUNCE = create("fox_pounce", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> FOX_SEARCH_FOR_ITEMS = create("fox_search_for_items", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> FOX_STROLL_THROUGH_VILLAGE = create("fox_stroll_through_village", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> PERCH_AND_SEARCH = create("perch_and_search", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> SEEK_SHELTER = create("seek_shelter", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> SLEEP = create("sleep", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Fox> STALK_PREY = create("stalk_prey", Fox.class);
|
||||||
|
|
||||||
|
GoalKey<Ghast> GHAST_LOOK = create("ghast_look", Ghast.class);
|
||||||
|
|
||||||
|
GoalKey<Ghast> GHAST_SHOOT_FIREBALL = create("ghast_shoot_fireball", Ghast.class);
|
||||||
|
|
||||||
|
GoalKey<Ghast> RANDOM_FLOAT_AROUND = create("random_float_around", Ghast.class);
|
||||||
|
|
||||||
|
GoalKey<Guardian> GUARDIAN_ATTACK = create("guardian_attack", Guardian.class);
|
||||||
|
|
||||||
|
GoalKey<Illager> RAIDER_OPEN_DOOR = create("raider_open_door", Illager.class);
|
||||||
|
|
||||||
|
GoalKey<Illusioner> ILLUSIONER_BLINDNESS_SPELL = create("illusioner_blindness_spell", Illusioner.class);
|
||||||
|
|
||||||
|
GoalKey<Illusioner> ILLUSIONER_MIRROR_SPELL = create("illusioner_mirror_spell", Illusioner.class);
|
||||||
|
|
||||||
|
GoalKey<IronGolem> DEFEND_VILLAGE = create("defend_village", IronGolem.class);
|
||||||
|
|
||||||
|
GoalKey<IronGolem> OFFER_FLOWER = create("offer_flower", IronGolem.class);
|
||||||
|
|
||||||
|
GoalKey<Llama> LLAMA_ATTACK_WOLF = create("llama_attack_wolf", Llama.class);
|
||||||
|
|
||||||
|
GoalKey<Llama> LLAMA_FOLLOW_CARAVAN = create("llama_follow_caravan", Llama.class);
|
||||||
|
|
||||||
|
GoalKey<Llama> LLAMA_HURT_BY = create("llama_hurt_by", Llama.class);
|
||||||
|
|
||||||
|
GoalKey<Llama> TRADER_LLAMA_DEFEND_WANDERING_TRADER = create("trader_llama_defend_wandering_trader", Llama.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> BREAK_DOOR = create("break_door", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> CLIMB_ON_TOP_OF_POWDER_SNOW = create("climb_on_top_of_powder_snow", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> EAT_BLOCK = create("eat_block", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> FLOAT = create("float", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> FOLLOW_MOB = create("follow_mob", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> INTERACT = create("interact", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> LEAP_AT = create("leap_at", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> LOOK_AT_PLAYER = create("look_at_player", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> NEAREST_ATTACKABLE = create("nearest_attackable", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> OCELOT_ATTACK = create("ocelot_attack", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> OPEN_DOOR = create("open_door", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> RANDOM_LOOK_AROUND = create("random_look_around", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> RESET_UNIVERSAL_ANGER = create("reset_universal_anger", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> USE_ITEM = create("use_item", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Mob> VINDICATOR_BREAK_DOOR = create("vindicator_break_door", Mob.class);
|
||||||
|
|
||||||
|
GoalKey<Monster> RANGED_BOW_ATTACK = create("ranged_bow_attack", Monster.class);
|
||||||
|
|
||||||
|
GoalKey<Monster> RANGED_CROSSBOW_ATTACK = create("ranged_crossbow_attack", Monster.class);
|
||||||
|
|
||||||
|
GoalKey<Ocelot> OCELOT_AVOID_ENTITY = create("ocelot_avoid_entity", Ocelot.class);
|
||||||
|
|
||||||
|
GoalKey<Ocelot> OCELOT_TEMPT = create("ocelot_tempt", Ocelot.class);
|
||||||
|
|
||||||
|
GoalKey<Panda> PANDA_ATTACK = create("panda_attack", Panda.class);
|
||||||
|
|
||||||
|
GoalKey<Panda> PANDA_AVOID = create("panda_avoid", Panda.class);
|
||||||
|
|
||||||
|
GoalKey<Panda> PANDA_BREED = create("panda_breed", Panda.class);
|
||||||
|
|
||||||
|
GoalKey<Panda> PANDA_HURT_BY = create("panda_hurt_by", Panda.class);
|
||||||
|
|
||||||
|
GoalKey<Panda> PANDA_LIE_ON_BACK = create("panda_lie_on_back", Panda.class);
|
||||||
|
|
||||||
|
GoalKey<Panda> PANDA_LOOK_AT_PLAYER = create("panda_look_at_player", Panda.class);
|
||||||
|
|
||||||
|
GoalKey<Panda> PANDA_PANIC = create("panda_panic", Panda.class);
|
||||||
|
|
||||||
|
GoalKey<Panda> PANDA_ROLL = create("panda_roll", Panda.class);
|
||||||
|
|
||||||
|
GoalKey<Panda> PANDA_SIT = create("panda_sit", Panda.class);
|
||||||
|
|
||||||
|
GoalKey<Panda> PANDA_SNEEZE = create("panda_sneeze", Panda.class);
|
||||||
|
|
||||||
|
GoalKey<Parrot> LAND_ON_OWNERS_SHOULDER = create("land_on_owners_shoulder", Parrot.class);
|
||||||
|
|
||||||
|
GoalKey<Phantom> PHANTOM_ATTACK_PLAYER = create("phantom_attack_player", Phantom.class);
|
||||||
|
|
||||||
|
GoalKey<Phantom> PHANTOM_ATTACK_STRATEGY = create("phantom_attack_strategy", Phantom.class);
|
||||||
|
|
||||||
|
GoalKey<Phantom> PHANTOM_CIRCLE_AROUND_ANCHOR = create("phantom_circle_around_anchor", Phantom.class);
|
||||||
|
|
||||||
|
GoalKey<Phantom> PHANTOM_SWEEP_ATTACK = create("phantom_sweep_attack", Phantom.class);
|
||||||
|
|
||||||
|
GoalKey<PolarBear> POLAR_BEAR_ATTACK_PLAYERS = create("polar_bear_attack_players", PolarBear.class);
|
||||||
|
|
||||||
|
GoalKey<PolarBear> POLAR_BEAR_HURT_BY = create("polar_bear_hurt_by", PolarBear.class);
|
||||||
|
|
||||||
|
GoalKey<PolarBear> POLAR_BEAR_MELEE_ATTACK = create("polar_bear_melee_attack", PolarBear.class);
|
||||||
|
|
||||||
|
GoalKey<PufferFish> PUFFERFISH_PUFF = create("pufferfish_puff", PufferFish.class);
|
||||||
|
|
||||||
|
GoalKey<Rabbit> RABBIT_AVOID_ENTITY = create("rabbit_avoid_entity", Rabbit.class);
|
||||||
|
|
||||||
|
GoalKey<Rabbit> RABBIT_PANIC = create("rabbit_panic", Rabbit.class);
|
||||||
|
|
||||||
|
GoalKey<Rabbit> RAID_GARDEN = create("raid_garden", Rabbit.class);
|
||||||
|
|
||||||
|
GoalKey<Raider> HOLD_GROUND_ATTACK = create("hold_ground_attack", Raider.class);
|
||||||
|
|
||||||
|
GoalKey<Raider> LONG_DISTANCE_PATROL = create("long_distance_patrol", Raider.class);
|
||||||
|
|
||||||
|
GoalKey<Raider> NEAREST_ATTACKABLE_WITCH = create("nearest_attackable_witch", Raider.class);
|
||||||
|
|
||||||
|
GoalKey<Raider> NEAREST_HEALABLE_RAIDER = create("nearest_healable_raider", Raider.class);
|
||||||
|
|
||||||
|
GoalKey<Raider> OBTAIN_RAID_LEADER_BANNER = create("obtain_raid_leader_banner", Raider.class);
|
||||||
|
|
||||||
|
GoalKey<Raider> PATHFIND_TO_RAID = create("pathfind_to_raid", Raider.class);
|
||||||
|
|
||||||
|
GoalKey<Raider> RAIDER_CELEBRATION = create("raider_celebration", Raider.class);
|
||||||
|
|
||||||
|
GoalKey<Raider> RAIDER_MOVE_THROUGH_VILLAGE = create("raider_move_through_village", Raider.class);
|
||||||
|
|
||||||
|
GoalKey<RangedEntity> DROWNED_TRIDENT_ATTACK = create("drowned_trident_attack", RangedEntity.class);
|
||||||
|
|
||||||
|
GoalKey<RangedEntity> RANGED_ATTACK = create("ranged_attack", RangedEntity.class);
|
||||||
|
|
||||||
|
GoalKey<SchoolableFish> FOLLOW_FLOCK_LEADER = create("follow_flock_leader", SchoolableFish.class);
|
||||||
|
|
||||||
|
GoalKey<Shulker> SHULKER_ATTACK = create("shulker_attack", Shulker.class);
|
||||||
|
|
||||||
|
GoalKey<Shulker> SHULKER_DEFENSE_ATTACK = create("shulker_defense_attack", Shulker.class);
|
||||||
|
|
||||||
|
GoalKey<Shulker> SHULKER_NEAREST_ATTACK = create("shulker_nearest_attack", Shulker.class);
|
||||||
|
|
||||||
|
GoalKey<Shulker> SHULKER_PEEK = create("shulker_peek", Shulker.class);
|
||||||
|
|
||||||
|
GoalKey<Silverfish> SILVERFISH_MERGE_WITH_STONE = create("silverfish_merge_with_stone", Silverfish.class);
|
||||||
|
|
||||||
|
GoalKey<Silverfish> SILVERFISH_WAKE_UP_FRIENDS = create("silverfish_wake_up_friends", Silverfish.class);
|
||||||
|
|
||||||
|
GoalKey<SkeletonHorse> SKELETON_TRAP = create("skeleton_trap", SkeletonHorse.class);
|
||||||
|
|
||||||
|
GoalKey<Slime> SLIME_ATTACK = create("slime_attack", Slime.class);
|
||||||
|
|
||||||
|
GoalKey<Slime> SLIME_FLOAT = create("slime_float", Slime.class);
|
||||||
|
|
||||||
|
GoalKey<Slime> SLIME_KEEP_ON_JUMPING = create("slime_keep_on_jumping", Slime.class);
|
||||||
|
|
||||||
|
GoalKey<Slime> SLIME_RANDOM_DIRECTION = create("slime_random_direction", Slime.class);
|
||||||
|
|
||||||
|
GoalKey<Spellcaster> SPELLCASTER_CASTING_SPELL = create("spellcaster_casting_spell", Spellcaster.class);
|
||||||
|
|
||||||
|
GoalKey<Spider> SPIDER = create("spider", Spider.class);
|
||||||
|
|
||||||
|
GoalKey<Spider> SPIDER_ATTACK = create("spider_attack", Spider.class);
|
||||||
|
|
||||||
|
GoalKey<Squid> SQUID_FLEE = create("squid_flee", Squid.class);
|
||||||
|
|
||||||
|
GoalKey<Squid> SQUID_RANDOM_MOVEMENT = create("squid_random_movement", Squid.class);
|
||||||
|
|
||||||
|
GoalKey<Strider> STRIDER_GO_TO_LAVA = create("strider_go_to_lava", Strider.class);
|
||||||
|
|
||||||
|
GoalKey<Tameable> FOLLOW_OWNER = create("follow_owner", Tameable.class);
|
||||||
|
|
||||||
|
GoalKey<Tameable> NON_TAME_RANDOM = create("non_tame_random", Tameable.class);
|
||||||
|
|
||||||
|
GoalKey<Tameable> OWNER_HURT = create("owner_hurt", Tameable.class);
|
||||||
|
|
||||||
|
GoalKey<Tameable> OWNER_HURT_BY = create("owner_hurt_by", Tameable.class);
|
||||||
|
|
||||||
|
GoalKey<Tameable> SIT_WHEN_ORDERED_TO = create("sit_when_ordered_to", Tameable.class);
|
||||||
|
|
||||||
|
GoalKey<Tameable> TAMABLE_ANIMAL_PANIC = create("tamable_animal_panic", Tameable.class);
|
||||||
|
|
||||||
|
GoalKey<Turtle> TURTLE_BREED = create("turtle_breed", Turtle.class);
|
||||||
|
|
||||||
|
GoalKey<Turtle> TURTLE_GO_HOME = create("turtle_go_home", Turtle.class);
|
||||||
|
|
||||||
|
GoalKey<Turtle> TURTLE_GO_TO_WATER = create("turtle_go_to_water", Turtle.class);
|
||||||
|
|
||||||
|
GoalKey<Turtle> TURTLE_LAY_EGG = create("turtle_lay_egg", Turtle.class);
|
||||||
|
|
||||||
|
GoalKey<Turtle> TURTLE_PANIC = create("turtle_panic", Turtle.class);
|
||||||
|
|
||||||
|
GoalKey<Turtle> TURTLE_RANDOM_STROLL = create("turtle_random_stroll", Turtle.class);
|
||||||
|
|
||||||
|
GoalKey<Turtle> TURTLE_TRAVEL = create("turtle_travel", Turtle.class);
|
||||||
|
|
||||||
|
GoalKey<Vex> VEX_CHARGE_ATTACK = create("vex_charge_attack", Vex.class);
|
||||||
|
|
||||||
|
GoalKey<Vex> VEX_COPY_OWNER = create("vex_copy_owner", Vex.class);
|
||||||
|
|
||||||
|
GoalKey<Vex> VEX_RANDOM_MOVE = create("vex_random_move", Vex.class);
|
||||||
|
|
||||||
|
GoalKey<Vindicator> VINDICATOR_JOHNNY_ATTACK = create("vindicator_johnny_attack", Vindicator.class);
|
||||||
|
|
||||||
|
GoalKey<WanderingTrader> WANDER_TO_POSITION = create("wander_to_position", WanderingTrader.class);
|
||||||
|
|
||||||
|
GoalKey<Wither> WITHER_DO_NOTHING = create("wither_do_nothing", Wither.class);
|
||||||
|
|
||||||
|
GoalKey<Wolf> BEG = create("beg", Wolf.class);
|
||||||
|
|
||||||
|
GoalKey<Wolf> WOLF_AVOID_ENTITY = create("wolf_avoid_entity", Wolf.class);
|
||||||
|
|
||||||
|
GoalKey<Zombie> ZOMBIE_ATTACK = create("zombie_attack", Zombie.class);
|
||||||
|
|
||||||
|
GoalKey<Zombie> ZOMBIE_ATTACK_TURTLE_EGG = create("zombie_attack_turtle_egg", Zombie.class);
|
||||||
|
|
||||||
|
private static <T extends Mob> @NotNull GoalKey<T> create(final @NotNull String key,
|
||||||
|
final @NotNull Class<T> type) {
|
||||||
|
return GoalKey.of(type, NamespacedKey.minecraft(key));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,490 @@
|
|||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#BIOME}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class BiomeKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:badlands}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> BADLANDS = create(key("badlands"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:bamboo_jungle}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> BAMBOO_JUNGLE = create(key("bamboo_jungle"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:basalt_deltas}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> BASALT_DELTAS = create(key("basalt_deltas"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:beach}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> BEACH = create(key("beach"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:birch_forest}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> BIRCH_FOREST = create(key("birch_forest"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:cherry_grove}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> CHERRY_GROVE = create(key("cherry_grove"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:cold_ocean}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> COLD_OCEAN = create(key("cold_ocean"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:crimson_forest}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> CRIMSON_FOREST = create(key("crimson_forest"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:dark_forest}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> DARK_FOREST = create(key("dark_forest"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:deep_cold_ocean}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> DEEP_COLD_OCEAN = create(key("deep_cold_ocean"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:deep_dark}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> DEEP_DARK = create(key("deep_dark"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:deep_frozen_ocean}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> DEEP_FROZEN_OCEAN = create(key("deep_frozen_ocean"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:deep_lukewarm_ocean}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> DEEP_LUKEWARM_OCEAN = create(key("deep_lukewarm_ocean"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:deep_ocean}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> DEEP_OCEAN = create(key("deep_ocean"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:desert}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> DESERT = create(key("desert"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:dripstone_caves}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> DRIPSTONE_CAVES = create(key("dripstone_caves"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:end_barrens}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> END_BARRENS = create(key("end_barrens"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:end_highlands}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> END_HIGHLANDS = create(key("end_highlands"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:end_midlands}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> END_MIDLANDS = create(key("end_midlands"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:eroded_badlands}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> ERODED_BADLANDS = create(key("eroded_badlands"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:flower_forest}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> FLOWER_FOREST = create(key("flower_forest"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:forest}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> FOREST = create(key("forest"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:frozen_ocean}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> FROZEN_OCEAN = create(key("frozen_ocean"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:frozen_peaks}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> FROZEN_PEAKS = create(key("frozen_peaks"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:frozen_river}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> FROZEN_RIVER = create(key("frozen_river"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:grove}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> GROVE = create(key("grove"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ice_spikes}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> ICE_SPIKES = create(key("ice_spikes"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:jagged_peaks}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> JAGGED_PEAKS = create(key("jagged_peaks"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:jungle}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> JUNGLE = create(key("jungle"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:lukewarm_ocean}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> LUKEWARM_OCEAN = create(key("lukewarm_ocean"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:lush_caves}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> LUSH_CAVES = create(key("lush_caves"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mangrove_swamp}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> MANGROVE_SWAMP = create(key("mangrove_swamp"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:meadow}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> MEADOW = create(key("meadow"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mushroom_fields}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> MUSHROOM_FIELDS = create(key("mushroom_fields"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:nether_wastes}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> NETHER_WASTES = create(key("nether_wastes"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ocean}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> OCEAN = create(key("ocean"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:old_growth_birch_forest}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> OLD_GROWTH_BIRCH_FOREST = create(key("old_growth_birch_forest"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:old_growth_pine_taiga}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> OLD_GROWTH_PINE_TAIGA = create(key("old_growth_pine_taiga"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:old_growth_spruce_taiga}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> OLD_GROWTH_SPRUCE_TAIGA = create(key("old_growth_spruce_taiga"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:plains}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> PLAINS = create(key("plains"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:river}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> RIVER = create(key("river"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:savanna}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> SAVANNA = create(key("savanna"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:savanna_plateau}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> SAVANNA_PLATEAU = create(key("savanna_plateau"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:small_end_islands}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> SMALL_END_ISLANDS = create(key("small_end_islands"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:snowy_beach}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> SNOWY_BEACH = create(key("snowy_beach"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:snowy_plains}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> SNOWY_PLAINS = create(key("snowy_plains"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:snowy_slopes}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> SNOWY_SLOPES = create(key("snowy_slopes"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:snowy_taiga}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> SNOWY_TAIGA = create(key("snowy_taiga"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:soul_sand_valley}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> SOUL_SAND_VALLEY = create(key("soul_sand_valley"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sparse_jungle}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> SPARSE_JUNGLE = create(key("sparse_jungle"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:stony_peaks}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> STONY_PEAKS = create(key("stony_peaks"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:stony_shore}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> STONY_SHORE = create(key("stony_shore"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sunflower_plains}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> SUNFLOWER_PLAINS = create(key("sunflower_plains"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:swamp}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> SWAMP = create(key("swamp"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:taiga}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> TAIGA = create(key("taiga"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:the_end}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> THE_END = create(key("the_end"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:the_void}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> THE_VOID = create(key("the_void"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:warm_ocean}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> WARM_OCEAN = create(key("warm_ocean"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:warped_forest}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> WARPED_FOREST = create(key("warped_forest"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:windswept_forest}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> WINDSWEPT_FOREST = create(key("windswept_forest"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:windswept_gravelly_hills}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> WINDSWEPT_GRAVELLY_HILLS = create(key("windswept_gravelly_hills"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:windswept_hills}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> WINDSWEPT_HILLS = create(key("windswept_hills"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:windswept_savanna}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> WINDSWEPT_SAVANNA = create(key("windswept_savanna"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wooded_badlands}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Biome> WOODED_BADLANDS = create(key("wooded_badlands"));
|
||||||
|
|
||||||
|
private BiomeKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a key for {@link Biome} in a registry.
|
||||||
|
*
|
||||||
|
* @param key the value's key in the registry
|
||||||
|
* @return a new typed key
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public static @NotNull TypedKey<Biome> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.BIOME, key);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,371 @@
|
|||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.damage.DamageType;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#DAMAGE_TYPE}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class DamageTypeKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:arrow}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> ARROW = create(key("arrow"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:bad_respawn_point}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> BAD_RESPAWN_POINT = create(key("bad_respawn_point"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:cactus}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> CACTUS = create(key("cactus"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:campfire}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> CAMPFIRE = create(key("campfire"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:cramming}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> CRAMMING = create(key("cramming"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:dragon_breath}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> DRAGON_BREATH = create(key("dragon_breath"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:drown}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> DROWN = create(key("drown"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:dry_out}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> DRY_OUT = create(key("dry_out"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:explosion}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> EXPLOSION = create(key("explosion"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fall}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FALL = create(key("fall"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:falling_anvil}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FALLING_ANVIL = create(key("falling_anvil"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:falling_block}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FALLING_BLOCK = create(key("falling_block"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:falling_stalactite}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FALLING_STALACTITE = create(key("falling_stalactite"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fireball}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FIREBALL = create(key("fireball"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fireworks}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FIREWORKS = create(key("fireworks"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fly_into_wall}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FLY_INTO_WALL = create(key("fly_into_wall"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:freeze}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> FREEZE = create(key("freeze"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:generic}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> GENERIC = create(key("generic"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:generic_kill}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> GENERIC_KILL = create(key("generic_kill"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:hot_floor}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> HOT_FLOOR = create(key("hot_floor"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:in_fire}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> IN_FIRE = create(key("in_fire"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:in_wall}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> IN_WALL = create(key("in_wall"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:indirect_magic}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> INDIRECT_MAGIC = create(key("indirect_magic"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:lava}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> LAVA = create(key("lava"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:lightning_bolt}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> LIGHTNING_BOLT = create(key("lightning_bolt"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:magic}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> MAGIC = create(key("magic"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mob_attack}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> MOB_ATTACK = create(key("mob_attack"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mob_attack_no_aggro}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> MOB_ATTACK_NO_AGGRO = create(key("mob_attack_no_aggro"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mob_projectile}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> MOB_PROJECTILE = create(key("mob_projectile"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:on_fire}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> ON_FIRE = create(key("on_fire"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:out_of_world}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> OUT_OF_WORLD = create(key("out_of_world"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:outside_border}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> OUTSIDE_BORDER = create(key("outside_border"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:player_attack}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> PLAYER_ATTACK = create(key("player_attack"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:player_explosion}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> PLAYER_EXPLOSION = create(key("player_explosion"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sonic_boom}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> SONIC_BOOM = create(key("sonic_boom"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:spit}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> SPIT = create(key("spit"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:stalagmite}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> STALAGMITE = create(key("stalagmite"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:starve}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> STARVE = create(key("starve"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sting}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> STING = create(key("sting"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sweet_berry_bush}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> SWEET_BERRY_BUSH = create(key("sweet_berry_bush"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:thorns}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> THORNS = create(key("thorns"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:thrown}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> THROWN = create(key("thrown"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:trident}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> TRIDENT = create(key("trident"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:unattributed_fireball}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> UNATTRIBUTED_FIREBALL = create(key("unattributed_fireball"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wind_charge}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> WIND_CHARGE = create(key("wind_charge"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wither}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> WITHER = create(key("wither"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wither_skull}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<DamageType> WITHER_SKULL = create(key("wither_skull"));
|
||||||
|
|
||||||
|
private DamageTypeKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a key for {@link DamageType} in a registry.
|
||||||
|
*
|
||||||
|
* @param key the value's key in the registry
|
||||||
|
* @return a new typed key
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public static @NotNull TypedKey<DamageType> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.DAMAGE_TYPE, key);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,329 @@
|
|||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#ENCHANTMENT}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class EnchantmentKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:aqua_affinity}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> AQUA_AFFINITY = create(key("aqua_affinity"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:bane_of_arthropods}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> BANE_OF_ARTHROPODS = create(key("bane_of_arthropods"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:binding_curse}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> BINDING_CURSE = create(key("binding_curse"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:blast_protection}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> BLAST_PROTECTION = create(key("blast_protection"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:breach}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> BREACH = create(key("breach"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:channeling}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> CHANNELING = create(key("channeling"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:density}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> DENSITY = create(key("density"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:depth_strider}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> DEPTH_STRIDER = create(key("depth_strider"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:efficiency}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> EFFICIENCY = create(key("efficiency"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:feather_falling}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> FEATHER_FALLING = create(key("feather_falling"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fire_aspect}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> FIRE_ASPECT = create(key("fire_aspect"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fire_protection}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> FIRE_PROTECTION = create(key("fire_protection"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:flame}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> FLAME = create(key("flame"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fortune}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> FORTUNE = create(key("fortune"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:frost_walker}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> FROST_WALKER = create(key("frost_walker"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:impaling}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> IMPALING = create(key("impaling"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:infinity}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> INFINITY = create(key("infinity"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:knockback}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> KNOCKBACK = create(key("knockback"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:looting}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> LOOTING = create(key("looting"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:loyalty}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> LOYALTY = create(key("loyalty"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:luck_of_the_sea}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> LUCK_OF_THE_SEA = create(key("luck_of_the_sea"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:lure}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> LURE = create(key("lure"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mending}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> MENDING = create(key("mending"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:multishot}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> MULTISHOT = create(key("multishot"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:piercing}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> PIERCING = create(key("piercing"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:power}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> POWER = create(key("power"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:projectile_protection}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> PROJECTILE_PROTECTION = create(key("projectile_protection"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:protection}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> PROTECTION = create(key("protection"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:punch}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> PUNCH = create(key("punch"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:quick_charge}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> QUICK_CHARGE = create(key("quick_charge"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:respiration}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> RESPIRATION = create(key("respiration"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:riptide}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> RIPTIDE = create(key("riptide"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sharpness}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> SHARPNESS = create(key("sharpness"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:silk_touch}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> SILK_TOUCH = create(key("silk_touch"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:smite}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> SMITE = create(key("smite"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:soul_speed}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> SOUL_SPEED = create(key("soul_speed"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sweeping_edge}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> SWEEPING_EDGE = create(key("sweeping_edge"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:swift_sneak}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> SWIFT_SNEAK = create(key("swift_sneak"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:thorns}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> THORNS = create(key("thorns"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:unbreaking}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> UNBREAKING = create(key("unbreaking"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:vanishing_curse}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> VANISHING_CURSE = create(key("vanishing_curse"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wind_burst}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Enchantment> WIND_BURST = create(key("wind_burst"));
|
||||||
|
|
||||||
|
private EnchantmentKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull TypedKey<Enchantment> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.ENCHANTMENT, key);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,455 @@
|
|||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.GameEvent;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#GAME_EVENT}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class GameEventKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:block_activate}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> BLOCK_ACTIVATE = create(key("block_activate"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:block_attach}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> BLOCK_ATTACH = create(key("block_attach"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:block_change}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> BLOCK_CHANGE = create(key("block_change"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:block_close}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> BLOCK_CLOSE = create(key("block_close"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:block_deactivate}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> BLOCK_DEACTIVATE = create(key("block_deactivate"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:block_destroy}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> BLOCK_DESTROY = create(key("block_destroy"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:block_detach}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> BLOCK_DETACH = create(key("block_detach"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:block_open}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> BLOCK_OPEN = create(key("block_open"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:block_place}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> BLOCK_PLACE = create(key("block_place"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:container_close}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> CONTAINER_CLOSE = create(key("container_close"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:container_open}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> CONTAINER_OPEN = create(key("container_open"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:drink}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> DRINK = create(key("drink"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:eat}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> EAT = create(key("eat"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:elytra_glide}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> ELYTRA_GLIDE = create(key("elytra_glide"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:entity_action}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> ENTITY_ACTION = create(key("entity_action"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:entity_damage}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> ENTITY_DAMAGE = create(key("entity_damage"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:entity_die}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> ENTITY_DIE = create(key("entity_die"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:entity_dismount}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> ENTITY_DISMOUNT = create(key("entity_dismount"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:entity_interact}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> ENTITY_INTERACT = create(key("entity_interact"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:entity_mount}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> ENTITY_MOUNT = create(key("entity_mount"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:entity_place}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> ENTITY_PLACE = create(key("entity_place"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:equip}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> EQUIP = create(key("equip"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:explode}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> EXPLODE = create(key("explode"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:flap}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> FLAP = create(key("flap"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fluid_pickup}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> FLUID_PICKUP = create(key("fluid_pickup"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fluid_place}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> FLUID_PLACE = create(key("fluid_place"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:hit_ground}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> HIT_GROUND = create(key("hit_ground"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:instrument_play}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> INSTRUMENT_PLAY = create(key("instrument_play"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:item_interact_finish}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> ITEM_INTERACT_FINISH = create(key("item_interact_finish"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:item_interact_start}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> ITEM_INTERACT_START = create(key("item_interact_start"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:jukebox_play}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> JUKEBOX_PLAY = create(key("jukebox_play"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:jukebox_stop_play}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> JUKEBOX_STOP_PLAY = create(key("jukebox_stop_play"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:lightning_strike}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> LIGHTNING_STRIKE = create(key("lightning_strike"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:note_block_play}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> NOTE_BLOCK_PLAY = create(key("note_block_play"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:prime_fuse}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> PRIME_FUSE = create(key("prime_fuse"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:projectile_land}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> PROJECTILE_LAND = create(key("projectile_land"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:projectile_shoot}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> PROJECTILE_SHOOT = create(key("projectile_shoot"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_1}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_1 = create(key("resonate_1"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_2}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_2 = create(key("resonate_2"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_3}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_3 = create(key("resonate_3"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_4}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_4 = create(key("resonate_4"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_5}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_5 = create(key("resonate_5"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_6}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_6 = create(key("resonate_6"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_7}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_7 = create(key("resonate_7"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_8}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_8 = create(key("resonate_8"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_9}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_9 = create(key("resonate_9"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_10}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_10 = create(key("resonate_10"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_11}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_11 = create(key("resonate_11"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_12}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_12 = create(key("resonate_12"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_13}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_13 = create(key("resonate_13"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_14}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_14 = create(key("resonate_14"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resonate_15}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> RESONATE_15 = create(key("resonate_15"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sculk_sensor_tendrils_clicking}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> SCULK_SENSOR_TENDRILS_CLICKING = create(key("sculk_sensor_tendrils_clicking"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:shear}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> SHEAR = create(key("shear"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:shriek}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> SHRIEK = create(key("shriek"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:splash}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> SPLASH = create(key("splash"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:step}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> STEP = create(key("step"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:swim}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> SWIM = create(key("swim"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:teleport}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> TELEPORT = create(key("teleport"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:unequip}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<GameEvent> UNEQUIP = create(key("unequip"));
|
||||||
|
|
||||||
|
private GameEventKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull TypedKey<GameEvent> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.GAME_EVENT, key);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.MusicInstrument;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#INSTRUMENT}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class InstrumentKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:admire_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> ADMIRE_GOAT_HORN = create(key("admire_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:call_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> CALL_GOAT_HORN = create(key("call_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:dream_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> DREAM_GOAT_HORN = create(key("dream_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:feel_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> FEEL_GOAT_HORN = create(key("feel_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ponder_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> PONDER_GOAT_HORN = create(key("ponder_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:seek_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> SEEK_GOAT_HORN = create(key("seek_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sing_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> SING_GOAT_HORN = create(key("sing_goat_horn"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:yearn_goat_horn}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<MusicInstrument> YEARN_GOAT_HORN = create(key("yearn_goat_horn"));
|
||||||
|
|
||||||
|
private InstrumentKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull TypedKey<MusicInstrument> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.INSTRUMENT, key);
|
||||||
|
}
|
||||||
|
}
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -0,0 +1,308 @@
|
|||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#MOB_EFFECT}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class MobEffectKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:absorption}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> ABSORPTION = create(key("absorption"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:bad_omen}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> BAD_OMEN = create(key("bad_omen"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:blindness}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> BLINDNESS = create(key("blindness"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:conduit_power}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> CONDUIT_POWER = create(key("conduit_power"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:darkness}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> DARKNESS = create(key("darkness"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:dolphins_grace}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> DOLPHINS_GRACE = create(key("dolphins_grace"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fire_resistance}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> FIRE_RESISTANCE = create(key("fire_resistance"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:glowing}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> GLOWING = create(key("glowing"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:haste}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> HASTE = create(key("haste"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:health_boost}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> HEALTH_BOOST = create(key("health_boost"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:hero_of_the_village}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> HERO_OF_THE_VILLAGE = create(key("hero_of_the_village"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:hunger}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> HUNGER = create(key("hunger"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:infested}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> INFESTED = create(key("infested"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:instant_damage}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> INSTANT_DAMAGE = create(key("instant_damage"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:instant_health}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> INSTANT_HEALTH = create(key("instant_health"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:invisibility}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> INVISIBILITY = create(key("invisibility"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:jump_boost}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> JUMP_BOOST = create(key("jump_boost"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:levitation}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> LEVITATION = create(key("levitation"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:luck}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> LUCK = create(key("luck"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mining_fatigue}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> MINING_FATIGUE = create(key("mining_fatigue"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:nausea}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> NAUSEA = create(key("nausea"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:night_vision}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> NIGHT_VISION = create(key("night_vision"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:oozing}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> OOZING = create(key("oozing"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:poison}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> POISON = create(key("poison"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:raid_omen}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> RAID_OMEN = create(key("raid_omen"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:regeneration}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> REGENERATION = create(key("regeneration"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:resistance}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> RESISTANCE = create(key("resistance"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:saturation}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> SATURATION = create(key("saturation"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:slow_falling}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> SLOW_FALLING = create(key("slow_falling"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:slowness}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> SLOWNESS = create(key("slowness"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:speed}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> SPEED = create(key("speed"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:strength}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> STRENGTH = create(key("strength"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:trial_omen}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> TRIAL_OMEN = create(key("trial_omen"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:unluck}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> UNLUCK = create(key("unluck"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:water_breathing}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> WATER_BREATHING = create(key("water_breathing"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:weakness}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> WEAKNESS = create(key("weakness"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:weaving}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> WEAVING = create(key("weaving"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wind_charged}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> WIND_CHARGED = create(key("wind_charged"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wither}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<PotionEffectType> WITHER = create(key("wither"));
|
||||||
|
|
||||||
|
private MobEffectKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull TypedKey<PotionEffectType> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.MOB_EFFECT, key);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,280 @@
|
|||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.generator.structure.Structure;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#STRUCTURE}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class StructureKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ancient_city}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> ANCIENT_CITY = create(key("ancient_city"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:bastion_remnant}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> BASTION_REMNANT = create(key("bastion_remnant"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:buried_treasure}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> BURIED_TREASURE = create(key("buried_treasure"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:desert_pyramid}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> DESERT_PYRAMID = create(key("desert_pyramid"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:end_city}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> END_CITY = create(key("end_city"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fortress}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> FORTRESS = create(key("fortress"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:igloo}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> IGLOO = create(key("igloo"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:jungle_pyramid}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> JUNGLE_PYRAMID = create(key("jungle_pyramid"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mansion}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> MANSION = create(key("mansion"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mineshaft}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> MINESHAFT = create(key("mineshaft"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mineshaft_mesa}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> MINESHAFT_MESA = create(key("mineshaft_mesa"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:monument}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> MONUMENT = create(key("monument"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:nether_fossil}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> NETHER_FOSSIL = create(key("nether_fossil"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ocean_ruin_cold}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> OCEAN_RUIN_COLD = create(key("ocean_ruin_cold"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ocean_ruin_warm}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> OCEAN_RUIN_WARM = create(key("ocean_ruin_warm"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:pillager_outpost}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> PILLAGER_OUTPOST = create(key("pillager_outpost"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ruined_portal}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> RUINED_PORTAL = create(key("ruined_portal"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ruined_portal_desert}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> RUINED_PORTAL_DESERT = create(key("ruined_portal_desert"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ruined_portal_jungle}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> RUINED_PORTAL_JUNGLE = create(key("ruined_portal_jungle"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ruined_portal_mountain}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> RUINED_PORTAL_MOUNTAIN = create(key("ruined_portal_mountain"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ruined_portal_nether}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> RUINED_PORTAL_NETHER = create(key("ruined_portal_nether"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ruined_portal_ocean}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> RUINED_PORTAL_OCEAN = create(key("ruined_portal_ocean"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ruined_portal_swamp}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> RUINED_PORTAL_SWAMP = create(key("ruined_portal_swamp"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:shipwreck}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> SHIPWRECK = create(key("shipwreck"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:shipwreck_beached}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> SHIPWRECK_BEACHED = create(key("shipwreck_beached"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:stronghold}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> STRONGHOLD = create(key("stronghold"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:swamp_hut}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> SWAMP_HUT = create(key("swamp_hut"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:trail_ruins}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> TRAIL_RUINS = create(key("trail_ruins"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:trial_chambers}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> TRIAL_CHAMBERS = create(key("trial_chambers"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:village_desert}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> VILLAGE_DESERT = create(key("village_desert"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:village_plains}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> VILLAGE_PLAINS = create(key("village_plains"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:village_savanna}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> VILLAGE_SAVANNA = create(key("village_savanna"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:village_snowy}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> VILLAGE_SNOWY = create(key("village_snowy"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:village_taiga}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Structure> VILLAGE_TAIGA = create(key("village_taiga"));
|
||||||
|
|
||||||
|
private StructureKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a key for {@link Structure} in a registry.
|
||||||
|
*
|
||||||
|
* @param key the value's key in the registry
|
||||||
|
* @return a new typed key
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public static @NotNull TypedKey<Structure> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.STRUCTURE, key);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,147 @@
|
|||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.generator.structure.StructureType;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#STRUCTURE_TYPE}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class StructureTypeKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:buried_treasure}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> BURIED_TREASURE = create(key("buried_treasure"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:desert_pyramid}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> DESERT_PYRAMID = create(key("desert_pyramid"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:end_city}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> END_CITY = create(key("end_city"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:fortress}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> FORTRESS = create(key("fortress"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:igloo}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> IGLOO = create(key("igloo"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:jigsaw}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> JIGSAW = create(key("jigsaw"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:jungle_temple}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> JUNGLE_TEMPLE = create(key("jungle_temple"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:mineshaft}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> MINESHAFT = create(key("mineshaft"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:nether_fossil}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> NETHER_FOSSIL = create(key("nether_fossil"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ocean_monument}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> OCEAN_MONUMENT = create(key("ocean_monument"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ocean_ruin}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> OCEAN_RUIN = create(key("ocean_ruin"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ruined_portal}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> RUINED_PORTAL = create(key("ruined_portal"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:shipwreck}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> SHIPWRECK = create(key("shipwreck"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:stronghold}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> STRONGHOLD = create(key("stronghold"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:swamp_hut}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> SWAMP_HUT = create(key("swamp_hut"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:woodland_mansion}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<StructureType> WOODLAND_MANSION = create(key("woodland_mansion"));
|
||||||
|
|
||||||
|
private StructureTypeKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull TypedKey<StructureType> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.STRUCTURE_TYPE, key);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,112 @@
|
|||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.inventory.meta.trim.TrimMaterial;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#TRIM_MATERIAL}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class TrimMaterialKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:amethyst}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimMaterial> AMETHYST = create(key("amethyst"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:copper}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimMaterial> COPPER = create(key("copper"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:diamond}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimMaterial> DIAMOND = create(key("diamond"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:emerald}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimMaterial> EMERALD = create(key("emerald"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:gold}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimMaterial> GOLD = create(key("gold"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:iron}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimMaterial> IRON = create(key("iron"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:lapis}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimMaterial> LAPIS = create(key("lapis"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:netherite}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimMaterial> NETHERITE = create(key("netherite"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:quartz}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimMaterial> QUARTZ = create(key("quartz"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:redstone}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimMaterial> REDSTONE = create(key("redstone"));
|
||||||
|
|
||||||
|
private TrimMaterialKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a key for {@link TrimMaterial} in a registry.
|
||||||
|
*
|
||||||
|
* @param key the value's key in the registry
|
||||||
|
* @return a new typed key
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public static @NotNull TypedKey<TrimMaterial> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.TRIM_MATERIAL, key);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,168 @@
|
|||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#TRIM_PATTERN}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class TrimPatternKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:bolt}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> BOLT = create(key("bolt"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:coast}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> COAST = create(key("coast"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:dune}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> DUNE = create(key("dune"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:eye}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> EYE = create(key("eye"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:flow}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> FLOW = create(key("flow"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:host}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> HOST = create(key("host"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:raiser}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> RAISER = create(key("raiser"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:rib}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> RIB = create(key("rib"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:sentry}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> SENTRY = create(key("sentry"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:shaper}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> SHAPER = create(key("shaper"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:silence}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> SILENCE = create(key("silence"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:snout}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> SNOUT = create(key("snout"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:spire}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> SPIRE = create(key("spire"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:tide}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> TIDE = create(key("tide"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:vex}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> VEX = create(key("vex"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ward}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> WARD = create(key("ward"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wayfinder}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> WAYFINDER = create(key("wayfinder"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:wild}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<TrimPattern> WILD = create(key("wild"));
|
||||||
|
|
||||||
|
private TrimPatternKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a key for {@link TrimPattern} in a registry.
|
||||||
|
*
|
||||||
|
* @param key the value's key in the registry
|
||||||
|
* @return a new typed key
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public static @NotNull TypedKey<TrimPattern> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.TRIM_PATTERN, key);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,105 @@
|
|||||||
|
package io.papermc.paper.registry.keys;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.entity.Wolf;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#WOLF_VARIANT}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class WolfVariantKeys {
|
||||||
|
/**
|
||||||
|
* {@code minecraft:ashen}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> ASHEN = create(key("ashen"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:black}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> BLACK = create(key("black"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:chestnut}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> CHESTNUT = create(key("chestnut"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:pale}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> PALE = create(key("pale"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:rusty}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> RUSTY = create(key("rusty"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:snowy}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> SNOWY = create(key("snowy"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:spotted}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> SPOTTED = create(key("spotted"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:striped}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> STRIPED = create(key("striped"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code minecraft:woods}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TypedKey<Wolf.Variant> WOODS = create(key("woods"));
|
||||||
|
|
||||||
|
private WolfVariantKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a key for {@link Wolf.Variant} in a registry.
|
||||||
|
*
|
||||||
|
* @param key the value's key in the registry
|
||||||
|
* @return a new typed key
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public static @NotNull TypedKey<Wolf.Variant> create(final @NotNull Key key) {
|
||||||
|
return TypedKey.create(RegistryKey.WOLF_VARIANT, key);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,323 @@
|
|||||||
|
package io.papermc.paper.registry.keys.tags;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.key.Key.key;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.tag.TagKey;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import org.bukkit.MinecraftExperimental;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vanilla keys for {@link RegistryKey#ENCHANTMENT}.
|
||||||
|
*
|
||||||
|
* @apiNote The fields provided here are a direct representation of
|
||||||
|
* what is available from the vanilla game source. They may be
|
||||||
|
* changed (including removals) on any Minecraft version
|
||||||
|
* bump, so cross-version compatibility is not provided on the
|
||||||
|
* same level as it is on most of the other API.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({
|
||||||
|
"unused",
|
||||||
|
"SpellCheckingInspection"
|
||||||
|
})
|
||||||
|
@GeneratedFrom("1.21")
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public final class EnchantmentTagKeys {
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/swamp_special}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_SWAMP_SPECIAL = create(key("trades/swamp_special"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/plains_special}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_PLAINS_SPECIAL = create(key("trades/plains_special"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:on_traded_equipment}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> ON_TRADED_EQUIPMENT = create(key("on_traded_equipment"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/desert_special}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_DESERT_SPECIAL = create(key("trades/desert_special"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:prevents_ice_melting}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> PREVENTS_ICE_MELTING = create(key("prevents_ice_melting"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/taiga_common}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_TAIGA_COMMON = create(key("trades/taiga_common"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:tradeable}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> TRADEABLE = create(key("tradeable"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:curse}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> CURSE = create(key("curse"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:treasure}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> TREASURE = create(key("treasure"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:prevents_infested_spawns}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> PREVENTS_INFESTED_SPAWNS = create(key("prevents_infested_spawns"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/savanna_special}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_SAVANNA_SPECIAL = create(key("trades/savanna_special"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:exclusive_set/riptide}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> EXCLUSIVE_SET_RIPTIDE = create(key("exclusive_set/riptide"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:double_trade_price}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> DOUBLE_TRADE_PRICE = create(key("double_trade_price"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/taiga_special}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_TAIGA_SPECIAL = create(key("trades/taiga_special"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:smelts_loot}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> SMELTS_LOOT = create(key("smelts_loot"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:exclusive_set/boots}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> EXCLUSIVE_SET_BOOTS = create(key("exclusive_set/boots"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/plains_common}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_PLAINS_COMMON = create(key("trades/plains_common"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:on_mob_spawn_equipment}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> ON_MOB_SPAWN_EQUIPMENT = create(key("on_mob_spawn_equipment"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/desert_common}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_DESERT_COMMON = create(key("trades/desert_common"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:exclusive_set/mining}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> EXCLUSIVE_SET_MINING = create(key("exclusive_set/mining"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:tooltip_order}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> TOOLTIP_ORDER = create(key("tooltip_order"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:prevents_decorated_pot_shattering}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> PREVENTS_DECORATED_POT_SHATTERING = create(key("prevents_decorated_pot_shattering"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:exclusive_set/bow}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> EXCLUSIVE_SET_BOW = create(key("exclusive_set/bow"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:on_random_loot}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> ON_RANDOM_LOOT = create(key("on_random_loot"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:exclusive_set/armor}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> EXCLUSIVE_SET_ARMOR = create(key("exclusive_set/armor"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/jungle_common}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_JUNGLE_COMMON = create(key("trades/jungle_common"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:in_enchanting_table}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> IN_ENCHANTING_TABLE = create(key("in_enchanting_table"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/swamp_common}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_SWAMP_COMMON = create(key("trades/swamp_common"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/snow_special}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_SNOW_SPECIAL = create(key("trades/snow_special"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:non_treasure}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> NON_TREASURE = create(key("non_treasure"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/jungle_special}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_JUNGLE_SPECIAL = create(key("trades/jungle_special"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:prevents_bee_spawns_when_mining}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> PREVENTS_BEE_SPAWNS_WHEN_MINING = create(key("prevents_bee_spawns_when_mining"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:exclusive_set/damage}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> EXCLUSIVE_SET_DAMAGE = create(key("exclusive_set/damage"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/savanna_common}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_SAVANNA_COMMON = create(key("trades/savanna_common"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:trades/snow_common}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
@MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE)
|
||||||
|
public static final TagKey<Enchantment> TRADES_SNOW_COMMON = create(key("trades/snow_common"));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code #minecraft:exclusive_set/crossbow}
|
||||||
|
*
|
||||||
|
* @apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
*/
|
||||||
|
public static final TagKey<Enchantment> EXCLUSIVE_SET_CROSSBOW = create(key("exclusive_set/crossbow"));
|
||||||
|
|
||||||
|
private EnchantmentTagKeys() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a tag key for {@link Enchantment} in the registry {@code minecraft:root}.
|
||||||
|
*
|
||||||
|
* @param key the tag key's key
|
||||||
|
* @return a new tag key
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public static @NotNull TagKey<Enchantment> create(final @NotNull Key key) {
|
||||||
|
return TagKey.create(RegistryKey.ENCHANTMENT, key);
|
||||||
|
}
|
||||||
|
}
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -0,0 +1,52 @@
|
|||||||
|
package io.papermc.generator;
|
||||||
|
|
||||||
|
import io.papermc.generator.types.GeneratedKeyType;
|
||||||
|
import io.papermc.generator.types.GeneratedTagKeyType;
|
||||||
|
import io.papermc.generator.types.SourceGenerator;
|
||||||
|
import io.papermc.generator.types.goal.MobGoalGenerator;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import org.bukkit.GameEvent;
|
||||||
|
import org.bukkit.MusicInstrument;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.damage.DamageType;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Wolf;
|
||||||
|
import org.bukkit.generator.structure.Structure;
|
||||||
|
import org.bukkit.generator.structure.StructureType;
|
||||||
|
import org.bukkit.inventory.ItemType;
|
||||||
|
import org.bukkit.inventory.meta.trim.TrimMaterial;
|
||||||
|
import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
public interface Generators {
|
||||||
|
|
||||||
|
SourceGenerator[] API = {
|
||||||
|
simpleKey("GameEventKeys", GameEvent.class, Registries.GAME_EVENT, RegistryKey.GAME_EVENT, false),
|
||||||
|
simpleKey("BiomeKeys", Biome.class, Registries.BIOME, RegistryKey.BIOME, true),
|
||||||
|
simpleKey("TrimMaterialKeys", TrimMaterial.class, Registries.TRIM_MATERIAL, RegistryKey.TRIM_MATERIAL, true),
|
||||||
|
simpleKey("TrimPatternKeys", TrimPattern.class, Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, true),
|
||||||
|
simpleKey("StructureKeys", Structure.class, Registries.STRUCTURE, RegistryKey.STRUCTURE, true),
|
||||||
|
simpleKey("StructureTypeKeys", StructureType.class, Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, false),
|
||||||
|
simpleKey("InstrumentKeys", MusicInstrument.class, Registries.INSTRUMENT, RegistryKey.INSTRUMENT, false),
|
||||||
|
simpleKey("EnchantmentKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, false),
|
||||||
|
simpleKey("MobEffectKeys", PotionEffectType.class, Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, false),
|
||||||
|
simpleKey("DamageTypeKeys", DamageType.class, Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, true),
|
||||||
|
simpleKey("WolfVariantKeys", Wolf.Variant.class, Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, true),
|
||||||
|
simpleKey("ItemTypeKeys", ItemType.class, Registries.ITEM, RegistryKey.ITEM, false),
|
||||||
|
|
||||||
|
simpleTagKey("EnchantmentTagKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT),
|
||||||
|
simpleTagKey("ItemTypeTagKeys", ItemType.class, Registries.ITEM, RegistryKey.ITEM),
|
||||||
|
new MobGoalGenerator("VanillaGoal", "com.destroystokyo.paper.entity.ai")
|
||||||
|
};
|
||||||
|
|
||||||
|
private static <T, A> SourceGenerator simpleKey(final String className, final Class<A> apiType, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey, final boolean publicCreateKeyMethod) {
|
||||||
|
return new GeneratedKeyType<>(className, apiType, "io.papermc.paper.registry.keys", registryKey, apiRegistryKey, publicCreateKeyMethod);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T, A> SourceGenerator simpleTagKey(final String className, final Class<A> apiType, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey) {
|
||||||
|
return new GeneratedTagKeyType<>(className, apiType, "io.papermc.paper.registry.keys.tags", registryKey, apiRegistryKey, true);
|
||||||
|
}
|
||||||
|
}
|
79
paper-api-generator/src/main/java/io/papermc/generator/Main.java
Normale Datei
79
paper-api-generator/src/main/java/io/papermc/generator/Main.java
Normale Datei
@ -0,0 +1,79 @@
|
|||||||
|
package io.papermc.generator;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.MoreExecutors;
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import io.papermc.generator.types.SourceGenerator;
|
||||||
|
import io.papermc.generator.utils.TagCollector;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Map;
|
||||||
|
import net.minecraft.SharedConstants;
|
||||||
|
import net.minecraft.commands.Commands;
|
||||||
|
import net.minecraft.core.LayeredRegistryAccess;
|
||||||
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.resources.RegistryDataLoader;
|
||||||
|
import net.minecraft.server.Bootstrap;
|
||||||
|
import net.minecraft.server.RegistryLayer;
|
||||||
|
import net.minecraft.server.ReloadableServerResources;
|
||||||
|
import net.minecraft.server.WorldLoader;
|
||||||
|
import net.minecraft.server.packs.PackType;
|
||||||
|
import net.minecraft.server.packs.repository.Pack;
|
||||||
|
import net.minecraft.server.packs.repository.PackRepository;
|
||||||
|
import net.minecraft.server.packs.repository.ServerPacksSource;
|
||||||
|
import net.minecraft.server.packs.resources.MultiPackResourceManager;
|
||||||
|
import net.minecraft.tags.TagKey;
|
||||||
|
import net.minecraft.world.flag.FeatureFlags;
|
||||||
|
import org.apache.commons.io.file.PathUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
public final class Main {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
public static final RegistryAccess.Frozen REGISTRY_ACCESS;
|
||||||
|
public static final Map<TagKey<?>, String> EXPERIMENTAL_TAGS;
|
||||||
|
|
||||||
|
static {
|
||||||
|
SharedConstants.tryDetectVersion();
|
||||||
|
Bootstrap.bootStrap();
|
||||||
|
Bootstrap.validate();
|
||||||
|
|
||||||
|
final PackRepository resourceRepository = ServerPacksSource.createVanillaTrustedRepository();
|
||||||
|
resourceRepository.reload();
|
||||||
|
final MultiPackResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, resourceRepository.getAvailablePacks().stream().map(Pack::open).toList());
|
||||||
|
LayeredRegistryAccess<RegistryLayer> layers = RegistryLayer.createRegistryAccess();
|
||||||
|
layers = WorldLoader.loadAndReplaceLayer(resourceManager, layers, RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES);
|
||||||
|
REGISTRY_ACCESS = layers.compositeAccess().freeze();
|
||||||
|
final ReloadableServerResources datapack = ReloadableServerResources.loadResources(resourceManager, layers, FeatureFlags.REGISTRY.allFlags(), Commands.CommandSelection.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join();
|
||||||
|
datapack.updateRegistryTags();
|
||||||
|
|
||||||
|
EXPERIMENTAL_TAGS = TagCollector.grabExperimental(resourceManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Main() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(final String[] args) {
|
||||||
|
LOGGER.info("Running API generators...");
|
||||||
|
generate(Paths.get(args[0]), Generators.API);
|
||||||
|
// LOGGER.info("Running Server generators...");
|
||||||
|
// generate(Paths.get(args[1]), Generators.SERVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void generate(Path output, SourceGenerator[] generators) {
|
||||||
|
try {
|
||||||
|
if (Files.exists(output)) {
|
||||||
|
PathUtils.deleteDirectory(output);
|
||||||
|
}
|
||||||
|
Files.createDirectories(output);
|
||||||
|
|
||||||
|
for (final SourceGenerator generator : generators) {
|
||||||
|
generator.writeToFile(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.info("Files written to {}", output.toAbsolutePath());
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,197 @@
|
|||||||
|
package io.papermc.generator.types;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import com.squareup.javapoet.FieldSpec;
|
||||||
|
import com.squareup.javapoet.JavaFile;
|
||||||
|
import com.squareup.javapoet.MethodSpec;
|
||||||
|
import com.squareup.javapoet.ParameterSpec;
|
||||||
|
import com.squareup.javapoet.ParameterizedTypeName;
|
||||||
|
import com.squareup.javapoet.TypeName;
|
||||||
|
import com.squareup.javapoet.TypeSpec;
|
||||||
|
import io.papermc.generator.Main;
|
||||||
|
import io.papermc.generator.utils.Annotations;
|
||||||
|
import io.papermc.generator.utils.CollectingContext;
|
||||||
|
import io.papermc.generator.utils.Formatting;
|
||||||
|
import io.papermc.generator.utils.Javadocs;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.TypedKey;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.core.RegistrySetBuilder;
|
||||||
|
import net.minecraft.data.registries.VanillaRegistries;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.world.flag.FeatureElement;
|
||||||
|
import net.minecraft.world.flag.FeatureFlags;
|
||||||
|
import org.bukkit.MinecraftExperimental;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||||
|
|
||||||
|
import static com.squareup.javapoet.TypeSpec.classBuilder;
|
||||||
|
import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION;
|
||||||
|
import static io.papermc.generator.utils.Annotations.NOT_NULL;
|
||||||
|
import static io.papermc.generator.utils.Annotations.experimentalAnnotations;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
import static javax.lang.model.element.Modifier.FINAL;
|
||||||
|
import static javax.lang.model.element.Modifier.PRIVATE;
|
||||||
|
import static javax.lang.model.element.Modifier.PUBLIC;
|
||||||
|
import static javax.lang.model.element.Modifier.STATIC;
|
||||||
|
|
||||||
|
@DefaultQualifier(NonNull.class)
|
||||||
|
public class GeneratedKeyType<T, A> extends SimpleGenerator {
|
||||||
|
|
||||||
|
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> VANILLA_REGISTRY_ENTRIES = VanillaRegistries.BUILDER.entries.stream()
|
||||||
|
.collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap));
|
||||||
|
|
||||||
|
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> EXPERIMENTAL_REGISTRY_ENTRIES = Collections.emptyMap(); // Update for Experimental API
|
||||||
|
|
||||||
|
private static final Map<RegistryKey<?>, String> REGISTRY_KEY_FIELD_NAMES;
|
||||||
|
static {
|
||||||
|
final Map<RegistryKey<?>, String> map = new HashMap<>();
|
||||||
|
try {
|
||||||
|
for (final Field field : RegistryKey.class.getFields()) {
|
||||||
|
if (!Modifier.isStatic(field.getModifiers()) || !Modifier.isFinal(field.getModifiers()) || field.getType() != RegistryKey.class) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
map.put((RegistryKey<?>) field.get(null), field.getName());
|
||||||
|
}
|
||||||
|
REGISTRY_KEY_FIELD_NAMES = Map.copyOf(map);
|
||||||
|
} catch (final ReflectiveOperationException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String CREATE_JAVADOC = """
|
||||||
|
Creates a key for {@link $T} in a registry.
|
||||||
|
|
||||||
|
@param key the value's key in the registry
|
||||||
|
@return a new typed key
|
||||||
|
""";
|
||||||
|
|
||||||
|
private final Class<A> apiType;
|
||||||
|
private final ResourceKey<? extends Registry<T>> registryKey;
|
||||||
|
private final RegistryKey<A> apiRegistryKey;
|
||||||
|
private final boolean publicCreateKeyMethod;
|
||||||
|
|
||||||
|
public GeneratedKeyType(final String keysClassName, final Class<A> apiType, final String pkg, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey, final boolean publicCreateKeyMethod) {
|
||||||
|
super(keysClassName, pkg);
|
||||||
|
this.apiType = apiType;
|
||||||
|
this.registryKey = registryKey;
|
||||||
|
this.apiRegistryKey = apiRegistryKey;
|
||||||
|
this.publicCreateKeyMethod = publicCreateKeyMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MethodSpec.Builder createMethod(final TypeName returnType) {
|
||||||
|
final TypeName keyType = TypeName.get(Key.class).annotated(NOT_NULL);
|
||||||
|
|
||||||
|
final ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build();
|
||||||
|
final MethodSpec.Builder create = MethodSpec.methodBuilder("create")
|
||||||
|
.addModifiers(this.publicCreateKeyMethod ? PUBLIC : PRIVATE, STATIC)
|
||||||
|
.addParameter(keyParam)
|
||||||
|
.addCode("return $T.create($T.$L, $N);", TypedKey.class, RegistryKey.class, requireNonNull(REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey), "Missing field for " + this.apiRegistryKey), keyParam)
|
||||||
|
.returns(returnType.annotated(NOT_NULL));
|
||||||
|
if (this.publicCreateKeyMethod) {
|
||||||
|
create.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO remove once not experimental
|
||||||
|
create.addJavadoc(CREATE_JAVADOC, this.apiType);
|
||||||
|
}
|
||||||
|
return create;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TypeSpec.Builder keyHolderType() {
|
||||||
|
return classBuilder(this.className)
|
||||||
|
.addModifiers(PUBLIC, FINAL)
|
||||||
|
.addJavadoc(Javadocs.getVersionDependentClassHeader("{@link $T#$L}"), RegistryKey.class, REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey))
|
||||||
|
.addAnnotations(Annotations.CLASS_HEADER)
|
||||||
|
.addMethod(MethodSpec.constructorBuilder()
|
||||||
|
.addModifiers(PRIVATE)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TypeSpec getTypeSpec() {
|
||||||
|
final TypeName typedKey = ParameterizedTypeName.get(TypedKey.class, this.apiType);
|
||||||
|
|
||||||
|
final TypeSpec.Builder typeBuilder = this.keyHolderType();
|
||||||
|
final MethodSpec.Builder createMethod = this.createMethod(typedKey);
|
||||||
|
|
||||||
|
final Registry<T> registry = Main.REGISTRY_ACCESS.registryOrThrow(this.registryKey);
|
||||||
|
final Set<ResourceKey<T>> experimental = this.collectExperimentalKeys(registry);
|
||||||
|
|
||||||
|
boolean allExperimental = true;
|
||||||
|
for (final Holder.Reference<T> reference : registry.holders().sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath())).toList()) {
|
||||||
|
final ResourceKey<T> key = reference.key();
|
||||||
|
final String keyPath = key.location().getPath();
|
||||||
|
final String fieldName = Formatting.formatKeyAsField(keyPath);
|
||||||
|
final FieldSpec.Builder fieldBuilder = FieldSpec.builder(typedKey, fieldName, PUBLIC, STATIC, FINAL)
|
||||||
|
.initializer("$N(key($S))", createMethod.build(), keyPath)
|
||||||
|
.addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.location().toString());
|
||||||
|
if (experimental.contains(key)) {
|
||||||
|
fieldBuilder.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
|
||||||
|
} else {
|
||||||
|
allExperimental = false;
|
||||||
|
}
|
||||||
|
typeBuilder.addField(fieldBuilder.build());
|
||||||
|
}
|
||||||
|
if (allExperimental) {
|
||||||
|
typeBuilder.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
|
||||||
|
createMethod.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
|
||||||
|
} else {
|
||||||
|
typeBuilder.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO experimental API
|
||||||
|
}
|
||||||
|
return typeBuilder.addMethod(createMethod.build()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<ResourceKey<T>> collectExperimentalKeys(final Registry<T> registry) {
|
||||||
|
if (FeatureElement.FILTERED_REGISTRIES.contains(registry.key())) {
|
||||||
|
return this.collectExperimentalKeysBuiltIn(registry);
|
||||||
|
} else {
|
||||||
|
return this.collectExperimentalKeysDataDriven(registry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<ResourceKey<T>> collectExperimentalKeysBuiltIn(final Registry<T> registry) {
|
||||||
|
final HolderLookup.RegistryLookup<T> filteredLookup = registry.asLookup().filterElements(v -> {
|
||||||
|
return false; // Update for Experimental API
|
||||||
|
});
|
||||||
|
return filteredLookup.listElementIds().collect(Collectors.toUnmodifiableSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private Set<ResourceKey<T>> collectExperimentalKeysDataDriven(final Registry<T> registry) {
|
||||||
|
final RegistrySetBuilder.@Nullable RegistryBootstrap<T> experimentalBootstrap = (RegistrySetBuilder.RegistryBootstrap<T>) EXPERIMENTAL_REGISTRY_ENTRIES.get(this.registryKey);
|
||||||
|
if (experimentalBootstrap == null) {
|
||||||
|
return Collections.emptySet();
|
||||||
|
}
|
||||||
|
final Set<ResourceKey<T>> experimental = Collections.newSetFromMap(new IdentityHashMap<>());
|
||||||
|
final CollectingContext<T> experimentalCollector = new CollectingContext<>(experimental, registry);
|
||||||
|
experimentalBootstrap.run(experimentalCollector);
|
||||||
|
|
||||||
|
final RegistrySetBuilder.@Nullable RegistryBootstrap<T> vanillaBootstrap = (RegistrySetBuilder.RegistryBootstrap<T>) VANILLA_REGISTRY_ENTRIES.get(this.registryKey);
|
||||||
|
if (vanillaBootstrap != null) {
|
||||||
|
final Set<ResourceKey<T>> vanilla = Collections.newSetFromMap(new IdentityHashMap<>());
|
||||||
|
final CollectingContext<T> vanillaCollector = new CollectingContext<>(vanilla, registry);
|
||||||
|
vanillaBootstrap.run(vanillaCollector);
|
||||||
|
return Sets.difference(experimental, vanilla);
|
||||||
|
}
|
||||||
|
return experimental;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JavaFile.Builder file(final JavaFile.Builder builder) {
|
||||||
|
return builder
|
||||||
|
.skipJavaLangImports(true)
|
||||||
|
.addStaticImport(Key.class, "key")
|
||||||
|
.indent(" ");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,149 @@
|
|||||||
|
package io.papermc.generator.types;
|
||||||
|
|
||||||
|
import com.squareup.javapoet.FieldSpec;
|
||||||
|
import com.squareup.javapoet.JavaFile;
|
||||||
|
import com.squareup.javapoet.MethodSpec;
|
||||||
|
import com.squareup.javapoet.ParameterSpec;
|
||||||
|
import com.squareup.javapoet.ParameterizedTypeName;
|
||||||
|
import com.squareup.javapoet.TypeName;
|
||||||
|
import com.squareup.javapoet.TypeSpec;
|
||||||
|
import io.papermc.generator.Main;
|
||||||
|
import io.papermc.generator.utils.Annotations;
|
||||||
|
import io.papermc.generator.utils.Formatting;
|
||||||
|
import io.papermc.generator.utils.Javadocs;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import io.papermc.paper.registry.tag.TagKey;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.core.RegistrySetBuilder;
|
||||||
|
import net.minecraft.data.registries.VanillaRegistries;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import org.bukkit.MinecraftExperimental;
|
||||||
|
|
||||||
|
import static com.squareup.javapoet.TypeSpec.classBuilder;
|
||||||
|
import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION;
|
||||||
|
import static io.papermc.generator.utils.Annotations.NOT_NULL;
|
||||||
|
import static io.papermc.generator.utils.Annotations.experimentalAnnotations;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
import static javax.lang.model.element.Modifier.FINAL;
|
||||||
|
import static javax.lang.model.element.Modifier.PRIVATE;
|
||||||
|
import static javax.lang.model.element.Modifier.PUBLIC;
|
||||||
|
import static javax.lang.model.element.Modifier.STATIC;
|
||||||
|
|
||||||
|
public class GeneratedTagKeyType<T, A> extends SimpleGenerator {
|
||||||
|
|
||||||
|
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> VANILLA_REGISTRY_ENTRIES = VanillaRegistries.BUILDER.entries.stream()
|
||||||
|
.collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap));
|
||||||
|
|
||||||
|
private static final Map<ResourceKey<? extends Registry<?>>, RegistrySetBuilder.RegistryBootstrap<?>> EXPERIMENTAL_REGISTRY_ENTRIES = Collections.emptyMap(); // Update for Experimental API
|
||||||
|
|
||||||
|
private static final Map<RegistryKey<?>, String> REGISTRY_KEY_FIELD_NAMES;
|
||||||
|
static {
|
||||||
|
final Map<RegistryKey<?>, String> map = new HashMap<>();
|
||||||
|
try {
|
||||||
|
for (final Field field : RegistryKey.class.getFields()) {
|
||||||
|
if (!Modifier.isStatic(field.getModifiers()) || !Modifier.isFinal(field.getModifiers()) || field.getType() != RegistryKey.class) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
map.put((RegistryKey<?>) field.get(null), field.getName());
|
||||||
|
}
|
||||||
|
REGISTRY_KEY_FIELD_NAMES = Map.copyOf(map);
|
||||||
|
} catch (final ReflectiveOperationException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String CREATE_JAVADOC = """
|
||||||
|
Creates a tag key for {@link $T} in the registry {@code $L}.
|
||||||
|
|
||||||
|
@param key the tag key's key
|
||||||
|
@return a new tag key
|
||||||
|
""";
|
||||||
|
|
||||||
|
private final Class<A> apiType;
|
||||||
|
private final ResourceKey<? extends Registry<T>> registryKey;
|
||||||
|
private final RegistryKey<A> apiRegistryKey;
|
||||||
|
private final boolean publicCreateKeyMethod;
|
||||||
|
|
||||||
|
public GeneratedTagKeyType(final String keysClassName, final Class<A> apiType, final String pkg, final ResourceKey<? extends Registry<T>> registryKey, final RegistryKey<A> apiRegistryKey, final boolean publicCreateKeyMethod) {
|
||||||
|
super(keysClassName, pkg);
|
||||||
|
this.apiType = apiType;
|
||||||
|
this.registryKey = registryKey;
|
||||||
|
this.apiRegistryKey = apiRegistryKey;
|
||||||
|
this.publicCreateKeyMethod = publicCreateKeyMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MethodSpec.Builder createMethod(final TypeName returnType) {
|
||||||
|
final TypeName keyType = TypeName.get(Key.class).annotated(NOT_NULL);
|
||||||
|
|
||||||
|
final ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build();
|
||||||
|
final MethodSpec.Builder create = MethodSpec.methodBuilder("create")
|
||||||
|
.addModifiers(this.publicCreateKeyMethod ? PUBLIC : PRIVATE, STATIC)
|
||||||
|
.addParameter(keyParam)
|
||||||
|
.addCode("return $T.create($T.$L, $N);", TagKey.class, RegistryKey.class, requireNonNull(REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey), "Missing field for " + this.apiRegistryKey), keyParam)
|
||||||
|
.returns(returnType.annotated(NOT_NULL));
|
||||||
|
if (this.publicCreateKeyMethod) {
|
||||||
|
create.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO remove once not experimental
|
||||||
|
create.addJavadoc(CREATE_JAVADOC, this.apiType, this.registryKey.registry().toString());
|
||||||
|
}
|
||||||
|
return create;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TypeSpec.Builder keyHolderType() {
|
||||||
|
return classBuilder(this.className)
|
||||||
|
.addModifiers(PUBLIC, FINAL)
|
||||||
|
.addJavadoc(Javadocs.getVersionDependentClassHeader("{@link $T#$L}"), RegistryKey.class, REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey))
|
||||||
|
.addAnnotations(Annotations.CLASS_HEADER)
|
||||||
|
.addMethod(MethodSpec.constructorBuilder()
|
||||||
|
.addModifiers(PRIVATE)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TypeSpec getTypeSpec() {
|
||||||
|
final TypeName tagKey = ParameterizedTypeName.get(TagKey.class, this.apiType);
|
||||||
|
|
||||||
|
final TypeSpec.Builder typeBuilder = this.keyHolderType();
|
||||||
|
final MethodSpec.Builder createMethod = this.createMethod(tagKey);
|
||||||
|
|
||||||
|
final Registry<T> registry = Main.REGISTRY_ACCESS.registryOrThrow(this.registryKey);
|
||||||
|
|
||||||
|
final AtomicBoolean allExperimental = new AtomicBoolean(true);
|
||||||
|
registry.getTags().forEach(pair -> {
|
||||||
|
final net.minecraft.tags.TagKey<T> nmsTagKey = pair.getFirst();
|
||||||
|
final String fieldName = Formatting.formatKeyAsField(nmsTagKey.location().getPath());
|
||||||
|
final FieldSpec.Builder fieldBuilder = FieldSpec.builder(tagKey, fieldName, PUBLIC, STATIC, FINAL)
|
||||||
|
.initializer("$N(key($S))", createMethod.build(), nmsTagKey.location().getPath())
|
||||||
|
.addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), "#" + nmsTagKey.location());
|
||||||
|
if (Main.EXPERIMENTAL_TAGS.containsKey(nmsTagKey)) {
|
||||||
|
fieldBuilder.addAnnotations(experimentalAnnotations(MinecraftExperimental.Requires.TRADE_REBALANCE)); // Update for Experimental API
|
||||||
|
} else {
|
||||||
|
allExperimental.set(false);
|
||||||
|
}
|
||||||
|
typeBuilder.addField(fieldBuilder.build());
|
||||||
|
});
|
||||||
|
if (allExperimental.get()) {
|
||||||
|
typeBuilder.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
|
||||||
|
createMethod.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API
|
||||||
|
} else {
|
||||||
|
typeBuilder.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO experimental API
|
||||||
|
}
|
||||||
|
return typeBuilder.addMethod(createMethod.build()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JavaFile.Builder file(final JavaFile.Builder builder) {
|
||||||
|
return builder
|
||||||
|
.skipJavaLangImports(true)
|
||||||
|
.addStaticImport(Key.class, "key")
|
||||||
|
.indent(" ");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package io.papermc.generator.types;
|
||||||
|
|
||||||
|
import com.squareup.javapoet.JavaFile;
|
||||||
|
import com.squareup.javapoet.TypeSpec;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public abstract class SimpleGenerator implements SourceGenerator {
|
||||||
|
|
||||||
|
protected final String className;
|
||||||
|
protected final String packageName;
|
||||||
|
|
||||||
|
protected SimpleGenerator(String className, String packageName) {
|
||||||
|
this.className = className;
|
||||||
|
this.packageName = packageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract TypeSpec getTypeSpec();
|
||||||
|
|
||||||
|
protected abstract JavaFile.Builder file(JavaFile.Builder builder);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToFile(Path parent) throws IOException {
|
||||||
|
|
||||||
|
JavaFile.Builder builder = JavaFile.builder(this.packageName, this.getTypeSpec());
|
||||||
|
this.file(builder)
|
||||||
|
.indent(" ")
|
||||||
|
.skipJavaLangImports(true);
|
||||||
|
|
||||||
|
builder.build().writeTo(parent, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package io.papermc.generator.types;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public interface SourceGenerator {
|
||||||
|
|
||||||
|
void writeToFile(Path parent) throws IOException;
|
||||||
|
}
|
@ -0,0 +1,144 @@
|
|||||||
|
package io.papermc.generator.types.goal;
|
||||||
|
|
||||||
|
import com.destroystokyo.paper.entity.RangedEntity;
|
||||||
|
import com.destroystokyo.paper.entity.ai.GoalKey;
|
||||||
|
import com.squareup.javapoet.ClassName;
|
||||||
|
import com.squareup.javapoet.FieldSpec;
|
||||||
|
import com.squareup.javapoet.JavaFile;
|
||||||
|
import com.squareup.javapoet.MethodSpec;
|
||||||
|
import com.squareup.javapoet.ParameterSpec;
|
||||||
|
import com.squareup.javapoet.ParameterizedTypeName;
|
||||||
|
import com.squareup.javapoet.TypeName;
|
||||||
|
import com.squareup.javapoet.TypeSpec;
|
||||||
|
import com.squareup.javapoet.TypeVariableName;
|
||||||
|
import io.github.classgraph.ClassGraph;
|
||||||
|
import io.github.classgraph.ScanResult;
|
||||||
|
import io.papermc.generator.types.SimpleGenerator;
|
||||||
|
import io.papermc.generator.utils.Annotations;
|
||||||
|
import io.papermc.generator.utils.Formatting;
|
||||||
|
import io.papermc.generator.utils.Javadocs;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.lang.model.element.Modifier;
|
||||||
|
import net.minecraft.world.entity.ai.goal.Goal;
|
||||||
|
import net.minecraft.world.entity.ai.goal.WrappedGoal;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.entity.AbstractHorse;
|
||||||
|
import org.bukkit.entity.Blaze;
|
||||||
|
import org.bukkit.entity.Cat;
|
||||||
|
import org.bukkit.entity.Creature;
|
||||||
|
import org.bukkit.entity.Dolphin;
|
||||||
|
import org.bukkit.entity.Drowned;
|
||||||
|
import org.bukkit.entity.Enderman;
|
||||||
|
import org.bukkit.entity.Evoker;
|
||||||
|
import org.bukkit.entity.Fish;
|
||||||
|
import org.bukkit.entity.Fox;
|
||||||
|
import org.bukkit.entity.Ghast;
|
||||||
|
import org.bukkit.entity.Llama;
|
||||||
|
import org.bukkit.entity.Mob;
|
||||||
|
import org.bukkit.entity.Monster;
|
||||||
|
import org.bukkit.entity.Panda;
|
||||||
|
import org.bukkit.entity.Parrot;
|
||||||
|
import org.bukkit.entity.PigZombie;
|
||||||
|
import org.bukkit.entity.PolarBear;
|
||||||
|
import org.bukkit.entity.Rabbit;
|
||||||
|
import org.bukkit.entity.Raider;
|
||||||
|
import org.bukkit.entity.Ravager;
|
||||||
|
import org.bukkit.entity.Shulker;
|
||||||
|
import org.bukkit.entity.Silverfish;
|
||||||
|
import org.bukkit.entity.SkeletonHorse;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
|
import org.bukkit.entity.Spellcaster;
|
||||||
|
import org.bukkit.entity.Spider;
|
||||||
|
import org.bukkit.entity.Squid;
|
||||||
|
import org.bukkit.entity.Tameable;
|
||||||
|
import org.bukkit.entity.TraderLlama;
|
||||||
|
import org.bukkit.entity.Turtle;
|
||||||
|
import org.bukkit.entity.Vex;
|
||||||
|
import org.bukkit.entity.Vindicator;
|
||||||
|
import org.bukkit.entity.WanderingTrader;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import static javax.lang.model.element.Modifier.FINAL;
|
||||||
|
import static javax.lang.model.element.Modifier.PRIVATE;
|
||||||
|
import static javax.lang.model.element.Modifier.PUBLIC;
|
||||||
|
import static javax.lang.model.element.Modifier.STATIC;
|
||||||
|
|
||||||
|
@DefaultQualifier(NonNull.class)
|
||||||
|
public class MobGoalGenerator extends SimpleGenerator {
|
||||||
|
|
||||||
|
private static final String CLASS_HEADER = Javadocs.getVersionDependentClassHeader("Mob Goals");
|
||||||
|
|
||||||
|
public MobGoalGenerator(final String keysClassName, final String pkg) {
|
||||||
|
super(keysClassName, pkg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TypeSpec getTypeSpec() {
|
||||||
|
TypeVariableName type = TypeVariableName.get("T", Mob.class);
|
||||||
|
TypeSpec.Builder typeBuilder = TypeSpec.interfaceBuilder(this.className)
|
||||||
|
.addSuperinterface(ParameterizedTypeName.get(ClassName.get(com.destroystokyo.paper.entity.ai.Goal.class), type))
|
||||||
|
.addModifiers(PUBLIC)
|
||||||
|
.addTypeVariable(type)
|
||||||
|
.addAnnotations(Annotations.CLASS_HEADER)
|
||||||
|
.addJavadoc(CLASS_HEADER);
|
||||||
|
|
||||||
|
TypeName mobType = ParameterizedTypeName.get(ClassName.get(Class.class), type)
|
||||||
|
.annotated(Annotations.NOT_NULL);
|
||||||
|
TypeName keyType = TypeName.get(String.class)
|
||||||
|
.annotated(Annotations.NOT_NULL);
|
||||||
|
|
||||||
|
ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build();
|
||||||
|
ParameterSpec typeParam = ParameterSpec.builder(mobType, "type", FINAL).build();
|
||||||
|
MethodSpec.Builder createMethod = MethodSpec.methodBuilder("create")
|
||||||
|
.addModifiers(PRIVATE, STATIC)
|
||||||
|
.addParameter(keyParam)
|
||||||
|
.addParameter(typeParam)
|
||||||
|
.addCode("return $T.of($N, $T.minecraft($N));", GoalKey.class, typeParam, NamespacedKey.class, keyParam)
|
||||||
|
.addTypeVariable(type)
|
||||||
|
.returns(ParameterizedTypeName.get(ClassName.get(GoalKey.class), type).annotated(Annotations.NOT_NULL));
|
||||||
|
|
||||||
|
List<Class<Goal>> classes;
|
||||||
|
try (ScanResult scanResult = new ClassGraph().enableAllInfo().whitelistPackages("net.minecraft").scan()) {
|
||||||
|
classes = scanResult.getSubclasses(Goal.class.getName()).loadClasses(Goal.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<GoalKey<Mob>> vanillaNames = classes.stream()
|
||||||
|
.filter(clazz -> !java.lang.reflect.Modifier.isAbstract(clazz.getModifiers()))
|
||||||
|
.filter(clazz -> !WrappedGoal.class.equals(clazz)) // TODO - properly fix
|
||||||
|
.map(goalClass -> MobGoalNames.getKey(goalClass.getName(), goalClass))
|
||||||
|
.filter((key) -> !MobGoalNames.isIgnored(key.getNamespacedKey().getKey()))
|
||||||
|
.sorted(Comparator.<GoalKey<?>, String>comparing(o -> o.getEntityClass().getSimpleName())
|
||||||
|
.thenComparing(vanillaGoalKey -> vanillaGoalKey.getNamespacedKey().getKey())
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
|
||||||
|
for (final GoalKey<?> goalKey : vanillaNames) {
|
||||||
|
TypeName typedKey = ParameterizedTypeName.get(GoalKey.class, goalKey.getEntityClass());
|
||||||
|
NamespacedKey key = goalKey.getNamespacedKey();
|
||||||
|
|
||||||
|
String keyPath = key.getKey();
|
||||||
|
String fieldName = Formatting.formatKeyAsField(keyPath);
|
||||||
|
FieldSpec.Builder fieldBuilder = FieldSpec.builder(typedKey, fieldName, PUBLIC, STATIC, FINAL)
|
||||||
|
.initializer("$N($S, $T.class)", createMethod.build(), keyPath, goalKey.getEntityClass());
|
||||||
|
typeBuilder.addField(fieldBuilder.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeBuilder.addMethod(createMethod.build()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JavaFile.Builder file(JavaFile.Builder builder) {
|
||||||
|
return builder
|
||||||
|
.skipJavaLangImports(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
record DeprecatedEntry(Class<?> entity, String entryName, @Nullable String removalVersion,
|
||||||
|
@Nullable String removedVersion) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,333 @@
|
|||||||
|
package io.papermc.generator.types.goal;
|
||||||
|
|
||||||
|
import com.destroystokyo.paper.entity.RangedEntity;
|
||||||
|
import com.destroystokyo.paper.entity.ai.GoalKey;
|
||||||
|
import com.google.common.collect.BiMap;
|
||||||
|
import com.google.common.collect.HashBiMap;
|
||||||
|
import net.minecraft.world.entity.FlyingMob;
|
||||||
|
import net.minecraft.world.entity.PathfinderMob;
|
||||||
|
import net.minecraft.world.entity.TamableAnimal;
|
||||||
|
import net.minecraft.world.entity.ai.goal.Goal;
|
||||||
|
import net.minecraft.world.entity.ambient.AmbientCreature;
|
||||||
|
import net.minecraft.world.entity.animal.AbstractFish;
|
||||||
|
import net.minecraft.world.entity.animal.AbstractGolem;
|
||||||
|
import net.minecraft.world.entity.animal.AbstractSchoolingFish;
|
||||||
|
import net.minecraft.world.entity.animal.Animal;
|
||||||
|
import net.minecraft.world.entity.animal.Pufferfish;
|
||||||
|
import net.minecraft.world.entity.animal.ShoulderRidingEntity;
|
||||||
|
import net.minecraft.world.entity.animal.SnowGolem;
|
||||||
|
import net.minecraft.world.entity.animal.WaterAnimal;
|
||||||
|
import net.minecraft.world.entity.animal.horse.AbstractChestedHorse;
|
||||||
|
import net.minecraft.world.entity.boss.wither.WitherBoss;
|
||||||
|
import net.minecraft.world.entity.monster.AbstractIllager;
|
||||||
|
import net.minecraft.world.entity.monster.EnderMan;
|
||||||
|
import net.minecraft.world.entity.monster.PatrollingMonster;
|
||||||
|
import net.minecraft.world.entity.monster.RangedAttackMob;
|
||||||
|
import net.minecraft.world.entity.monster.SpellcasterIllager;
|
||||||
|
import net.minecraft.world.entity.monster.ZombifiedPiglin;
|
||||||
|
import net.minecraft.world.entity.monster.piglin.AbstractPiglin;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.entity.AbstractHorse;
|
||||||
|
import org.bukkit.entity.AbstractSkeleton;
|
||||||
|
import org.bukkit.entity.AbstractVillager;
|
||||||
|
import org.bukkit.entity.Ageable;
|
||||||
|
import org.bukkit.entity.Ambient;
|
||||||
|
import org.bukkit.entity.Animals;
|
||||||
|
import org.bukkit.entity.Bat;
|
||||||
|
import org.bukkit.entity.Bee;
|
||||||
|
import org.bukkit.entity.Blaze;
|
||||||
|
import org.bukkit.entity.Cat;
|
||||||
|
import org.bukkit.entity.CaveSpider;
|
||||||
|
import org.bukkit.entity.ChestedHorse;
|
||||||
|
import org.bukkit.entity.Chicken;
|
||||||
|
import org.bukkit.entity.Cod;
|
||||||
|
import org.bukkit.entity.Cow;
|
||||||
|
import org.bukkit.entity.Creature;
|
||||||
|
import org.bukkit.entity.Creeper;
|
||||||
|
import org.bukkit.entity.Dolphin;
|
||||||
|
import org.bukkit.entity.Donkey;
|
||||||
|
import org.bukkit.entity.Drowned;
|
||||||
|
import org.bukkit.entity.ElderGuardian;
|
||||||
|
import org.bukkit.entity.EnderDragon;
|
||||||
|
import org.bukkit.entity.Enderman;
|
||||||
|
import org.bukkit.entity.Endermite;
|
||||||
|
import org.bukkit.entity.Evoker;
|
||||||
|
import org.bukkit.entity.Fish;
|
||||||
|
import org.bukkit.entity.Flying;
|
||||||
|
import org.bukkit.entity.Fox;
|
||||||
|
import org.bukkit.entity.Ghast;
|
||||||
|
import org.bukkit.entity.Giant;
|
||||||
|
import org.bukkit.entity.Golem;
|
||||||
|
import org.bukkit.entity.Guardian;
|
||||||
|
import org.bukkit.entity.Hoglin;
|
||||||
|
import org.bukkit.entity.Horse;
|
||||||
|
import org.bukkit.entity.Husk;
|
||||||
|
import org.bukkit.entity.Illager;
|
||||||
|
import org.bukkit.entity.Illusioner;
|
||||||
|
import org.bukkit.entity.IronGolem;
|
||||||
|
import org.bukkit.entity.Llama;
|
||||||
|
import org.bukkit.entity.MagmaCube;
|
||||||
|
import org.bukkit.entity.Mob;
|
||||||
|
import org.bukkit.entity.Monster;
|
||||||
|
import org.bukkit.entity.Mule;
|
||||||
|
import org.bukkit.entity.MushroomCow;
|
||||||
|
import org.bukkit.entity.Ocelot;
|
||||||
|
import org.bukkit.entity.Panda;
|
||||||
|
import org.bukkit.entity.Parrot;
|
||||||
|
import org.bukkit.entity.Phantom;
|
||||||
|
import org.bukkit.entity.Pig;
|
||||||
|
import org.bukkit.entity.PigZombie;
|
||||||
|
import org.bukkit.entity.Piglin;
|
||||||
|
import org.bukkit.entity.PiglinAbstract;
|
||||||
|
import org.bukkit.entity.PiglinBrute;
|
||||||
|
import org.bukkit.entity.Pillager;
|
||||||
|
import org.bukkit.entity.PolarBear;
|
||||||
|
import org.bukkit.entity.PufferFish;
|
||||||
|
import org.bukkit.entity.Rabbit;
|
||||||
|
import org.bukkit.entity.Raider;
|
||||||
|
import org.bukkit.entity.Ravager;
|
||||||
|
import org.bukkit.entity.Salmon;
|
||||||
|
import org.bukkit.entity.Sheep;
|
||||||
|
import org.bukkit.entity.Shulker;
|
||||||
|
import org.bukkit.entity.Silverfish;
|
||||||
|
import org.bukkit.entity.Skeleton;
|
||||||
|
import org.bukkit.entity.SkeletonHorse;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
|
import org.bukkit.entity.Snowman;
|
||||||
|
import org.bukkit.entity.Spellcaster;
|
||||||
|
import org.bukkit.entity.Spider;
|
||||||
|
import org.bukkit.entity.Squid;
|
||||||
|
import org.bukkit.entity.Stray;
|
||||||
|
import org.bukkit.entity.Strider;
|
||||||
|
import org.bukkit.entity.Tameable;
|
||||||
|
import org.bukkit.entity.TraderLlama;
|
||||||
|
import org.bukkit.entity.TropicalFish;
|
||||||
|
import org.bukkit.entity.Turtle;
|
||||||
|
import org.bukkit.entity.Vex;
|
||||||
|
import org.bukkit.entity.Villager;
|
||||||
|
import org.bukkit.entity.Vindicator;
|
||||||
|
import org.bukkit.entity.WanderingTrader;
|
||||||
|
import org.bukkit.entity.WaterMob;
|
||||||
|
import org.bukkit.entity.Witch;
|
||||||
|
import org.bukkit.entity.Wither;
|
||||||
|
import org.bukkit.entity.WitherSkeleton;
|
||||||
|
import org.bukkit.entity.Wolf;
|
||||||
|
import org.bukkit.entity.Zoglin;
|
||||||
|
import org.bukkit.entity.Zombie;
|
||||||
|
import org.bukkit.entity.ZombieHorse;
|
||||||
|
import org.bukkit.entity.ZombieVillager;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class MobGoalNames {
|
||||||
|
|
||||||
|
private static final Map<Class<? extends Goal>, Class<? extends Mob>> entityClassCache = new HashMap<>();
|
||||||
|
public static final Map<Class<? extends net.minecraft.world.entity.Mob>, Class<? extends Mob>> bukkitMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
//<editor-fold defaultstate="collapsed" desc="bukkitMap Entities">
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.Mob.class, Mob.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.AgeableMob.class, Ageable.class);
|
||||||
|
bukkitMap.put(AmbientCreature.class, Ambient.class);
|
||||||
|
bukkitMap.put(Animal.class, Animals.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.ambient.Bat.class, Bat.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Bee.class, Bee.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Blaze.class, Blaze.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Cat.class, Cat.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.CaveSpider.class, CaveSpider.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Chicken.class, Chicken.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Cod.class, Cod.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Cow.class, Cow.class);
|
||||||
|
bukkitMap.put(PathfinderMob.class, Creature.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Creeper.class, Creeper.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Dolphin.class, Dolphin.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Drowned.class, Drowned.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.boss.enderdragon.EnderDragon.class, EnderDragon.class);
|
||||||
|
bukkitMap.put(EnderMan.class, Enderman.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Endermite.class, Endermite.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Evoker.class, Evoker.class);
|
||||||
|
bukkitMap.put(AbstractFish.class, Fish.class);
|
||||||
|
bukkitMap.put(AbstractSchoolingFish.class, io.papermc.paper.entity.SchoolableFish.class);
|
||||||
|
bukkitMap.put(FlyingMob.class, Flying.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Fox.class, Fox.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Ghast.class, Ghast.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Giant.class, Giant.class);
|
||||||
|
bukkitMap.put(AbstractGolem.class, Golem.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Guardian.class, Guardian.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.ElderGuardian.class, ElderGuardian.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.horse.Horse.class, Horse.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.horse.AbstractHorse.class, AbstractHorse.class);
|
||||||
|
bukkitMap.put(AbstractChestedHorse.class, ChestedHorse.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.horse.Donkey.class, Donkey.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.horse.Mule.class, Mule.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.horse.SkeletonHorse.class, SkeletonHorse.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.horse.ZombieHorse.class, ZombieHorse.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.camel.Camel.class, org.bukkit.entity.Camel.class);
|
||||||
|
bukkitMap.put(AbstractIllager.class, Illager.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Illusioner.class, Illusioner.class);
|
||||||
|
bukkitMap.put(SpellcasterIllager.class, Spellcaster.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.IronGolem.class, IronGolem.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.horse.Llama.class, Llama.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.horse.TraderLlama.class, TraderLlama.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.MagmaCube.class, MagmaCube.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Monster.class, Monster.class);
|
||||||
|
bukkitMap.put(PatrollingMonster.class, Raider.class); // close enough
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.MushroomCow.class, MushroomCow.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Ocelot.class, Ocelot.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Panda.class, Panda.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Parrot.class, Parrot.class);
|
||||||
|
bukkitMap.put(ShoulderRidingEntity.class, Parrot.class); // close enough
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Phantom.class, Phantom.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Pig.class, Pig.class);
|
||||||
|
bukkitMap.put(ZombifiedPiglin.class, PigZombie.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Pillager.class, Pillager.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.PolarBear.class, PolarBear.class);
|
||||||
|
bukkitMap.put(Pufferfish.class, PufferFish.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Rabbit.class, Rabbit.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.raid.Raider.class, Raider.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Ravager.class, Ravager.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Salmon.class, Salmon.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Sheep.class, Sheep.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Shulker.class, Shulker.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Silverfish.class, Silverfish.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Skeleton.class, Skeleton.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.AbstractSkeleton.class, AbstractSkeleton.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Stray.class, Stray.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.WitherSkeleton.class, WitherSkeleton.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Slime.class, Slime.class);
|
||||||
|
bukkitMap.put(SnowGolem.class, Snowman.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Spider.class, Spider.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Squid.class, Squid.class);
|
||||||
|
bukkitMap.put(TamableAnimal.class, Tameable.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.TropicalFish.class, TropicalFish.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Turtle.class, Turtle.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Vex.class, Vex.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.npc.Villager.class, Villager.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.npc.AbstractVillager.class, AbstractVillager.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.npc.WanderingTrader.class, WanderingTrader.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Vindicator.class, Vindicator.class);
|
||||||
|
bukkitMap.put(WaterAnimal.class, WaterMob.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Witch.class, Witch.class);
|
||||||
|
bukkitMap.put(WitherBoss.class, Wither.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.Wolf.class, Wolf.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Zombie.class, Zombie.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Husk.class, Husk.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.ZombieVillager.class, ZombieVillager.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.hoglin.Hoglin.class, Hoglin.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.piglin.Piglin.class, Piglin.class);
|
||||||
|
bukkitMap.put(AbstractPiglin.class, PiglinAbstract.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.piglin.PiglinBrute.class, PiglinBrute.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Strider.class, Strider.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Zoglin.class, Zoglin.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.GlowSquid.class, org.bukkit.entity.GlowSquid.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, org.bukkit.entity.Axolotl.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.goat.Goat.class, org.bukkit.entity.Goat.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.frog.Frog.class, org.bukkit.entity.Frog.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.frog.Tadpole.class, org.bukkit.entity.Tadpole.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.warden.Warden.class, org.bukkit.entity.Warden.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.allay.Allay.class, org.bukkit.entity.Allay.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, org.bukkit.entity.Sniffer.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.breeze.Breeze.class, org.bukkit.entity.Breeze.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, org.bukkit.entity.Armadillo.class);
|
||||||
|
bukkitMap.put(net.minecraft.world.entity.monster.Bogged.class, org.bukkit.entity.Bogged.class);
|
||||||
|
//</editor-fold>
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final BiMap<String, String> deobfuscationMap = HashBiMap.create();
|
||||||
|
static final Set<String> ignored = new HashSet<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
deobfuscationMap.put("abstract_skeleton_1", "abstract_skeleton_melee");
|
||||||
|
|
||||||
|
ignored.add("goal_selector_1");
|
||||||
|
ignored.add("goal_selector_2");
|
||||||
|
ignored.add("selector_1");
|
||||||
|
ignored.add("selector_2");
|
||||||
|
ignored.add("wrapped");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getUsableName(String name) {
|
||||||
|
final String original = name;
|
||||||
|
name = name.substring(name.lastIndexOf(".") + 1);
|
||||||
|
boolean flag = false;
|
||||||
|
// inner classes
|
||||||
|
if (name.contains("$")) {
|
||||||
|
String cut = name.substring(name.indexOf("$") + 1);
|
||||||
|
if (cut.length() <= 2) {
|
||||||
|
name = name.replace("Entity", "");
|
||||||
|
name = name.replace("$", "_");
|
||||||
|
flag = true;
|
||||||
|
} else {
|
||||||
|
// mapped, wooo
|
||||||
|
name = cut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
name = name.replace("PathfinderGoal", "");
|
||||||
|
name = name.replace("TargetGoal", "");
|
||||||
|
name = name.replace("Goal", "");
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (char c : name.toCharArray()) {
|
||||||
|
if (c >= 'A' && c <= 'Z') {
|
||||||
|
sb.append("_");
|
||||||
|
sb.append(Character.toLowerCase(c));
|
||||||
|
} else {
|
||||||
|
sb.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
name = sb.toString();
|
||||||
|
name = name.replaceFirst("_", "");
|
||||||
|
|
||||||
|
if (flag && !deobfuscationMap.containsKey(name.toLowerCase(Locale.ROOT)) && !ignored.contains(name)) {
|
||||||
|
System.out.println("need to map " + original + " (" + name.toLowerCase(Locale.ROOT) + ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
// did we rename this key?
|
||||||
|
return deobfuscationMap.getOrDefault(name, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isIgnored(String name) {
|
||||||
|
return ignored.contains(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static <T extends Mob> GoalKey<T> getKey(String clazzName, Class<? extends Goal> goalClass) {
|
||||||
|
String name = getUsableName(clazzName);
|
||||||
|
if (MobGoalNames.isIgnored(name)) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (GoalKey<T>) GoalKey.of(Mob.class, NamespacedKey.minecraft(name));
|
||||||
|
}
|
||||||
|
return GoalKey.of(getEntity(goalClass), NamespacedKey.minecraft(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends Mob> Class<T> getEntity(Class<? extends Goal> goalClass) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (Class<T>) entityClassCache.computeIfAbsent(goalClass, key -> {
|
||||||
|
for (Constructor<?> ctor : key.getDeclaredConstructors()) {
|
||||||
|
for (int i = 0; i < ctor.getParameterCount(); i++) {
|
||||||
|
Class<?> param = ctor.getParameterTypes()[i];
|
||||||
|
if (net.minecraft.world.entity.Mob.class.isAssignableFrom(param)) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return toBukkitClass((Class<? extends net.minecraft.world.entity.Mob>) param);
|
||||||
|
} else if (RangedAttackMob.class.isAssignableFrom(param)) {
|
||||||
|
return RangedEntity.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("Can't figure out applicable entity for mob goal " + goalClass); // maybe just return EntityInsentient?
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Class<? extends Mob> toBukkitClass(Class<? extends net.minecraft.world.entity.Mob> nmsClass) {
|
||||||
|
Class<? extends Mob> bukkitClass = bukkitMap.get(nmsClass);
|
||||||
|
if (bukkitClass == null) {
|
||||||
|
throw new RuntimeException("Can't figure out applicable bukkit entity for nms entity " + nmsClass); // maybe just return Mob?
|
||||||
|
}
|
||||||
|
return bukkitClass;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
package io.papermc.generator.utils;
|
||||||
|
|
||||||
|
import com.squareup.javapoet.AnnotationSpec;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.papermc.paper.generated.GeneratedFrom;
|
||||||
|
import net.minecraft.SharedConstants;
|
||||||
|
import org.bukkit.MinecraftExperimental;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public final class Annotations {
|
||||||
|
|
||||||
|
public static List<AnnotationSpec> experimentalAnnotations(final MinecraftExperimental.@Nullable Requires requiredFeatureFlag) {
|
||||||
|
final List<AnnotationSpec> annotationSpecs = new ArrayList<>();
|
||||||
|
annotationSpecs.add(AnnotationSpec.builder(ApiStatus.Experimental.class).build());
|
||||||
|
if (requiredFeatureFlag != null) {
|
||||||
|
annotationSpecs.add(AnnotationSpec.builder(MinecraftExperimental.class)
|
||||||
|
.addMember("value", "$T.$L", MinecraftExperimental.Requires.class, requiredFeatureFlag.name())
|
||||||
|
.build());
|
||||||
|
} else {
|
||||||
|
annotationSpecs.add(AnnotationSpec.builder(MinecraftExperimental.class).build());
|
||||||
|
}
|
||||||
|
return annotationSpecs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AnnotationSpec deprecatedVersioned(final @Nullable String version, boolean forRemoval) {
|
||||||
|
AnnotationSpec.Builder annotationSpec = AnnotationSpec.builder(Deprecated.class);
|
||||||
|
if (forRemoval) {
|
||||||
|
annotationSpec.addMember("forRemoval", "$L", forRemoval);
|
||||||
|
}
|
||||||
|
if (version != null) {
|
||||||
|
annotationSpec.addMember("since", "$S", version);
|
||||||
|
}
|
||||||
|
|
||||||
|
return annotationSpec.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AnnotationSpec scheduledRemoval(final @Nullable String version) {
|
||||||
|
return AnnotationSpec.builder(ApiStatus.ScheduledForRemoval.class)
|
||||||
|
.addMember("inVersion", "$S", version)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public static final AnnotationSpec EXPERIMENTAL_API_ANNOTATION = AnnotationSpec.builder(ApiStatus.Experimental.class).build();
|
||||||
|
public static final AnnotationSpec NOT_NULL = AnnotationSpec.builder(NotNull.class).build();
|
||||||
|
private static final AnnotationSpec SUPPRESS_WARNINGS = AnnotationSpec.builder(SuppressWarnings.class)
|
||||||
|
.addMember("value", "$S", "unused")
|
||||||
|
.addMember("value", "$S", "SpellCheckingInspection")
|
||||||
|
.build();
|
||||||
|
private static final AnnotationSpec GENERATED_FROM = AnnotationSpec.builder(GeneratedFrom.class)
|
||||||
|
.addMember("value", "$S", SharedConstants.getCurrentVersion().getName())
|
||||||
|
.build();
|
||||||
|
public static final Iterable<AnnotationSpec> CLASS_HEADER = List.of(
|
||||||
|
SUPPRESS_WARNINGS,
|
||||||
|
GENERATED_FROM
|
||||||
|
);
|
||||||
|
|
||||||
|
private Annotations() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package io.papermc.generator.utils;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Lifecycle;
|
||||||
|
import io.papermc.generator.Main;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.HolderGetter;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.data.worldgen.BootstrapContext;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||||
|
|
||||||
|
@DefaultQualifier(NonNull.class)
|
||||||
|
public record CollectingContext<T>(Set<ResourceKey<T>> registered,
|
||||||
|
Registry<T> registry) implements BootstrapContext<T> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Holder.Reference<T> register(final ResourceKey<T> resourceKey, final @NonNull T t, final Lifecycle lifecycle) {
|
||||||
|
this.registered.add(resourceKey);
|
||||||
|
return Holder.Reference.createStandAlone(this.registry.holderOwner(), resourceKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <S> HolderGetter<S> lookup(final ResourceKey<? extends Registry<? extends S>> resourceKey) {
|
||||||
|
return Main.REGISTRY_ACCESS.registryOrThrow(resourceKey).asLookup();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package io.papermc.generator.utils;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.apache.commons.lang3.math.NumberUtils;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public final class Formatting {
|
||||||
|
|
||||||
|
private static final Pattern ILLEGAL_FIELD_CHARACTERS = Pattern.compile("[.-/]");
|
||||||
|
|
||||||
|
public static String formatKeyAsField(String path) {
|
||||||
|
return ILLEGAL_FIELD_CHARACTERS.matcher(path.toUpperCase(Locale.ROOT)).replaceAll("_");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<String> formatTagKey(String tagDir, String resourcePath) {
|
||||||
|
int tagsIndex = resourcePath.indexOf(tagDir);
|
||||||
|
int dotIndex = resourcePath.lastIndexOf('.');
|
||||||
|
if (tagsIndex == -1 || dotIndex == -1) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return Optional.of(resourcePath.substring(tagsIndex + tagDir.length() + 1, dotIndex)); // namespace/tags/registry_key/[tag_key].json
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Comparator<String> ALPHABETIC_KEY_ORDER = alphabeticKeyOrder(path -> path);
|
||||||
|
|
||||||
|
public static <T> Comparator<T> alphabeticKeyOrder(Function<T, String> mapper) {
|
||||||
|
return (o1, o2) -> {
|
||||||
|
String path1 = mapper.apply(o1);
|
||||||
|
String path2 = mapper.apply(o2);
|
||||||
|
|
||||||
|
OptionalInt trailingInt1 = tryParseTrailingInt(path1);
|
||||||
|
OptionalInt trailingInt2 = tryParseTrailingInt(path2);
|
||||||
|
|
||||||
|
if (trailingInt1.isPresent() && trailingInt2.isPresent()) {
|
||||||
|
return Integer.compare(trailingInt1.getAsInt(), trailingInt2.getAsInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
return path1.compareTo(path2);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OptionalInt tryParseTrailingInt(String path) {
|
||||||
|
int delimiterIndex = path.lastIndexOf('_');
|
||||||
|
if (delimiterIndex != -1) {
|
||||||
|
String score = path.substring(delimiterIndex + 1);
|
||||||
|
if (NumberUtils.isDigits(score)) {
|
||||||
|
return OptionalInt.of(Integer.parseInt(score));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return OptionalInt.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Formatting() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package io.papermc.generator.utils;
|
||||||
|
|
||||||
|
public final class Javadocs {
|
||||||
|
|
||||||
|
public static String getVersionDependentClassHeader(String headerIdentifier) {
|
||||||
|
return """
|
||||||
|
Vanilla keys for %s.
|
||||||
|
|
||||||
|
@apiNote The fields provided here are a direct representation of
|
||||||
|
what is available from the vanilla game source. They may be
|
||||||
|
changed (including removals) on any Minecraft version
|
||||||
|
bump, so cross-version compatibility is not provided on the
|
||||||
|
same level as it is on most of the other API.
|
||||||
|
""".formatted(headerIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getVersionDependentField(String headerIdentifier) {
|
||||||
|
return """
|
||||||
|
%s
|
||||||
|
|
||||||
|
@apiNote This field is version-dependant and may be removed in future Minecraft versions
|
||||||
|
""".formatted(headerIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Javadocs() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package io.papermc.generator.utils;
|
||||||
|
|
||||||
|
import com.google.common.collect.HashMultimap;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import io.papermc.generator.Main;
|
||||||
|
import io.papermc.generator.utils.Formatting;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.core.RegistryAccess;
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.server.packs.PackResources;
|
||||||
|
import net.minecraft.server.packs.PackType;
|
||||||
|
import net.minecraft.server.packs.repository.BuiltInPackSource;
|
||||||
|
import net.minecraft.server.packs.resources.MultiPackResourceManager;
|
||||||
|
import net.minecraft.tags.TagKey;
|
||||||
|
import net.minecraft.tags.TagManager;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
// collect all the tags by grabbing the json from the data-packs
|
||||||
|
// another (probably) way is to hook into the data generator like the typed keys generator
|
||||||
|
public final class TagCollector {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
|
public static Map<TagKey<?>, String> grabExperimental(final MultiPackResourceManager resourceManager) {
|
||||||
|
Map<TagKey<?>, String> result = new IdentityHashMap<>();
|
||||||
|
|
||||||
|
// collect all vanilla tags
|
||||||
|
Multimap<ResourceKey<? extends Registry<?>>, String> vanillaTags = HashMultimap.create();
|
||||||
|
PackResources vanillaPack = resourceManager.listPacks()
|
||||||
|
.filter(packResources -> packResources.packId().equals(BuiltInPackSource.VANILLA_ID))
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow();
|
||||||
|
collectFromPack(vanillaPack, (entry, path) -> vanillaTags.put(entry.key(), path));
|
||||||
|
|
||||||
|
// then distinct with other data-pack tags to know for sure newly created tags and so experimental one
|
||||||
|
resourceManager.listPacks().forEach(pack -> {
|
||||||
|
String packId = pack.packId();
|
||||||
|
if (packId.equals(BuiltInPackSource.VANILLA_ID)) return;
|
||||||
|
|
||||||
|
collectFromPack(pack, (entry, path) -> {
|
||||||
|
if (vanillaTags.get(entry.key()).contains(path)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.put(entry.value().getTagNames()
|
||||||
|
.filter(tagKey -> tagKey.location().getPath().equals(path))
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow(), packId);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return Collections.unmodifiableMap(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void collectFromPack(PackResources pack, BiConsumer<RegistryAccess.RegistryEntry<?>, String> output) {
|
||||||
|
Set<String> namespaces = pack.getNamespaces(PackType.SERVER_DATA);
|
||||||
|
|
||||||
|
for (String namespace : namespaces) {
|
||||||
|
Main.REGISTRY_ACCESS.registries().forEach(entry -> {
|
||||||
|
// this is probably expensive but can't find another way around and data-pack loader has similar logic
|
||||||
|
// the issue is that registry key can have parent/key (and custom folder too) but tag key can also have parent/key so parsing become a mess
|
||||||
|
// without having at least one of the two values
|
||||||
|
String tagDir = Registries.tagsDirPath(entry.key());
|
||||||
|
pack.listResources(PackType.SERVER_DATA, namespace, tagDir, (id, supplier) -> {
|
||||||
|
Formatting.formatTagKey(tagDir, id.getPath()).ifPresentOrElse(path -> output.accept(entry, path), () -> {
|
||||||
|
LOGGER.warn("Unable to parse the path: {}/{}/{}.json in the data-pack {} into a tag key", namespace, tagDir, id.getPath(), pack.packId());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TagCollector() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package io.papermc.generator;
|
||||||
|
|
||||||
|
import io.github.classgraph.ClassGraph;
|
||||||
|
import io.github.classgraph.ScanResult;
|
||||||
|
import io.papermc.generator.types.goal.MobGoalNames;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.Mob;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
|
public class MobGoalConverterTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBukkitMap() {
|
||||||
|
final List<Class<Mob>> classes;
|
||||||
|
try (ScanResult scanResult = new ClassGraph().enableAllInfo().whitelistPackages(Entity.class.getPackageName()).scan()) {
|
||||||
|
classes = scanResult.getSubclasses(Mob.class.getName()).loadClasses(Mob.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertFalse(classes.isEmpty(), "There are supposed to be more than 0 mob classes!");
|
||||||
|
|
||||||
|
List<String> missingClasses = new ArrayList<>();
|
||||||
|
for (Class<Mob> nmsClass : classes) {
|
||||||
|
if (!MobGoalNames.bukkitMap.containsKey(nmsClass)) {
|
||||||
|
missingClasses.add(nmsClass.getCanonicalName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!missingClasses.isEmpty()) {
|
||||||
|
fail("Missing some entity classes in the bukkit map: " + String.join(", ", missingClasses));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
paper-api-generator/wideners.at
Normale Datei
7
paper-api-generator/wideners.at
Normale Datei
@ -0,0 +1,7 @@
|
|||||||
|
public net/minecraft/server/WorldLoader loadAndReplaceLayer(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/core/LayeredRegistryAccess;Lnet/minecraft/server/RegistryLayer;Ljava/util/List;)Lnet/minecraft/core/LayeredRegistryAccess;
|
||||||
|
|
||||||
|
# for auto-marking experimental stuff
|
||||||
|
public net/minecraft/core/RegistrySetBuilder entries
|
||||||
|
public net/minecraft/core/RegistrySetBuilder$RegistryStub
|
||||||
|
public net/minecraft/data/registries/UpdateOneTwentyOneRegistries BUILDER
|
||||||
|
public net/minecraft/data/registries/VanillaRegistries BUILDER
|
@ -8,7 +8,7 @@ apply if there are changes made to it from upstream - thus notifying us
|
|||||||
that changes were made.
|
that changes were made.
|
||||||
|
|
||||||
diff --git a/.gitignore b/.gitignore
|
diff --git a/.gitignore b/.gitignore
|
||||||
index 11038da2e071699d6561a331565db0c8d7850d0e..317acfec5894101294a55abff61819431e6a5e65 100644
|
index 5dd700a956e915c00b25d91dea8d6f285ddab72b..97e78e27ee0eea2c8b24886eeb19164d552323fe 100644
|
||||||
--- a/.gitignore
|
--- a/.gitignore
|
||||||
+++ b/.gitignore
|
+++ b/.gitignore
|
||||||
@@ -1,3 +1,5 @@
|
@@ -1,3 +1,5 @@
|
||||||
@ -17,7 +17,7 @@ index 11038da2e071699d6561a331565db0c8d7850d0e..317acfec5894101294a55abff6181943
|
|||||||
# Eclipse stuff
|
# Eclipse stuff
|
||||||
/.classpath
|
/.classpath
|
||||||
/.project
|
/.project
|
||||||
@@ -31,3 +33,7 @@
|
@@ -32,3 +34,7 @@
|
||||||
*.ipr
|
*.ipr
|
||||||
*.iws
|
*.iws
|
||||||
.idea/
|
.idea/
|
||||||
@ -27,10 +27,10 @@ index 11038da2e071699d6561a331565db0c8d7850d0e..317acfec5894101294a55abff6181943
|
|||||||
+/.factorypath
|
+/.factorypath
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..c2e5d8006420aab5a60e5aaa188223aeb0396483
|
index 0000000000000000000000000000000000000000..6271e2bad0ed937c2c46a8c8fdf186c46b0b620e
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/build.gradle.kts
|
+++ b/build.gradle.kts
|
||||||
@@ -0,0 +1,86 @@
|
@@ -0,0 +1,91 @@
|
||||||
+plugins {
|
+plugins {
|
||||||
+ `java-library`
|
+ `java-library`
|
||||||
+ `maven-publish`
|
+ `maven-publish`
|
||||||
@ -41,29 +41,30 @@ index 0000000000000000000000000000000000000000..c2e5d8006420aab5a60e5aaa188223ae
|
|||||||
+ withJavadocJar()
|
+ withJavadocJar()
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+val annotationsVersion = "24.0.1"
|
+val annotationsVersion = "24.1.0"
|
||||||
+val bungeeCordChatVersion = "1.20-R0.1"
|
+val bungeeCordChatVersion = "1.20-R0.2"
|
||||||
+
|
+
|
||||||
+dependencies {
|
+dependencies {
|
||||||
+ // api dependencies are listed transitively to API consumers
|
+ // api dependencies are listed transitively to API consumers
|
||||||
+ api("com.google.guava:guava:31.1-jre")
|
+ api("com.google.guava:guava:32.1.2-jre")
|
||||||
+ api("com.google.code.gson:gson:2.10")
|
+ api("com.google.code.gson:gson:2.10.1")
|
||||||
+ api("net.md-5:bungeecord-chat:$bungeeCordChatVersion")
|
+ api("net.md-5:bungeecord-chat:$bungeeCordChatVersion")
|
||||||
+ api("org.yaml:snakeyaml:2.0")
|
+ api("org.yaml:snakeyaml:2.2")
|
||||||
+ api("org.joml:joml:1.10.5")
|
+ api("org.joml:joml:1.10.5")
|
||||||
+
|
+
|
||||||
+ compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")
|
+ compileOnly("org.apache.maven:maven-resolver-provider:3.9.6")
|
||||||
+ compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
|
+ compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18")
|
||||||
+ compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3")
|
+ compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18")
|
||||||
+
|
+
|
||||||
+ val annotations = "org.jetbrains:annotations-java5:$annotationsVersion"
|
+ val annotations = "org.jetbrains:annotations-java5:$annotationsVersion"
|
||||||
+ compileOnly(annotations)
|
+ compileOnly(annotations)
|
||||||
+ testCompileOnly(annotations)
|
+ testCompileOnly(annotations)
|
||||||
+
|
+
|
||||||
+ testImplementation("org.apache.commons:commons-lang3:3.12.0")
|
+ testImplementation("org.apache.commons:commons-lang3:3.12.0")
|
||||||
+ testImplementation("junit:junit:4.13.2")
|
+ testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
|
||||||
+ testImplementation("org.hamcrest:hamcrest-library:1.3")
|
+ testImplementation("org.hamcrest:hamcrest:2.2")
|
||||||
+ testImplementation("org.ow2.asm:asm-tree:9.5")
|
+ testImplementation("org.mockito:mockito-core:5.11.0")
|
||||||
|
+ testImplementation("org.ow2.asm:asm-tree:9.7")
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+configure<PublishingExtension> {
|
+configure<PublishingExtension> {
|
||||||
@ -99,8 +100,8 @@ index 0000000000000000000000000000000000000000..c2e5d8006420aab5a60e5aaa188223ae
|
|||||||
+ options.use()
|
+ options.use()
|
||||||
+ options.isDocFilesSubDirs = true
|
+ options.isDocFilesSubDirs = true
|
||||||
+ options.links(
|
+ options.links(
|
||||||
+ "https://guava.dev/releases/31.1-jre/api/docs/",
|
+ "https://guava.dev/releases/32.1.2-jre/api/docs/",
|
||||||
+ "https://javadoc.io/doc/org.yaml/snakeyaml/2.0/",
|
+ "https://javadoc.io/doc/org.yaml/snakeyaml/2.2/",
|
||||||
+ "https://javadoc.io/doc/org.jetbrains/annotations-java5/$annotationsVersion/",
|
+ "https://javadoc.io/doc/org.jetbrains/annotations-java5/$annotationsVersion/",
|
||||||
+ "https://javadoc.io/doc/net.md-5/bungeecord-chat/$bungeeCordChatVersion/",
|
+ "https://javadoc.io/doc/net.md-5/bungeecord-chat/$bungeeCordChatVersion/",
|
||||||
+ )
|
+ )
|
||||||
@ -117,12 +118,16 @@ index 0000000000000000000000000000000000000000..c2e5d8006420aab5a60e5aaa188223ae
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
|
+
|
||||||
|
+tasks.test {
|
||||||
|
+ useJUnitPlatform()
|
||||||
|
+}
|
||||||
diff --git a/pom.xml b/pom.xml
|
diff --git a/pom.xml b/pom.xml
|
||||||
deleted file mode 100644
|
deleted file mode 100644
|
||||||
index 068987ca1171857fc9996d645e775448a09f0feb..0000000000000000000000000000000000000000
|
index 86628114c1d111f6d256186ca739ba8a44b3412a..0000000000000000000000000000000000000000
|
||||||
--- a/pom.xml
|
--- a/pom.xml
|
||||||
+++ /dev/null
|
+++ /dev/null
|
||||||
@@ -1,270 +0,0 @@
|
@@ -1,267 +0,0 @@
|
||||||
-
|
-
|
||||||
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
@ -130,7 +135,7 @@ index 068987ca1171857fc9996d645e775448a09f0feb..00000000000000000000000000000000
|
|||||||
-
|
-
|
||||||
- <groupId>org.spigotmc</groupId>
|
- <groupId>org.spigotmc</groupId>
|
||||||
- <artifactId>spigot-api</artifactId>
|
- <artifactId>spigot-api</artifactId>
|
||||||
- <version>1.20.1-R0.1-SNAPSHOT</version>
|
- <version>1.21-R0.1-SNAPSHOT</version>
|
||||||
- <packaging>jar</packaging>
|
- <packaging>jar</packaging>
|
||||||
-
|
-
|
||||||
- <name>Spigot-API</name>
|
- <name>Spigot-API</name>
|
||||||
@ -139,8 +144,7 @@ index 068987ca1171857fc9996d645e775448a09f0feb..00000000000000000000000000000000
|
|||||||
-
|
-
|
||||||
- <properties>
|
- <properties>
|
||||||
- <skipTests>true</skipTests>
|
- <skipTests>true</skipTests>
|
||||||
- <maven.compiler.source>1.8</maven.compiler.source>
|
- <maven.compiler.release>17</maven.compiler.release>
|
||||||
- <maven.compiler.target>1.8</maven.compiler.target>
|
|
||||||
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
- </properties>
|
- </properties>
|
||||||
-
|
-
|
||||||
@ -160,14 +164,14 @@ index 068987ca1171857fc9996d645e775448a09f0feb..00000000000000000000000000000000
|
|||||||
- <dependency>
|
- <dependency>
|
||||||
- <groupId>com.google.guava</groupId>
|
- <groupId>com.google.guava</groupId>
|
||||||
- <artifactId>guava</artifactId>
|
- <artifactId>guava</artifactId>
|
||||||
- <version>31.1-jre</version>
|
- <version>32.1.2-jre</version>
|
||||||
- <scope>compile</scope>
|
- <scope>compile</scope>
|
||||||
- </dependency>
|
- </dependency>
|
||||||
- <!-- bundled with Minecraft, should be kept in sync -->
|
- <!-- bundled with Minecraft, should be kept in sync -->
|
||||||
- <dependency>
|
- <dependency>
|
||||||
- <groupId>com.google.code.gson</groupId>
|
- <groupId>com.google.code.gson</groupId>
|
||||||
- <artifactId>gson</artifactId>
|
- <artifactId>gson</artifactId>
|
||||||
- <version>2.10</version>
|
- <version>2.10.1</version>
|
||||||
- <scope>compile</scope>
|
- <scope>compile</scope>
|
||||||
- </dependency>
|
- </dependency>
|
||||||
- <!-- bundled with Minecraft, should be kept in sync -->
|
- <!-- bundled with Minecraft, should be kept in sync -->
|
||||||
@ -180,59 +184,65 @@ index 068987ca1171857fc9996d645e775448a09f0feb..00000000000000000000000000000000
|
|||||||
- <dependency>
|
- <dependency>
|
||||||
- <groupId>net.md-5</groupId>
|
- <groupId>net.md-5</groupId>
|
||||||
- <artifactId>bungeecord-chat</artifactId>
|
- <artifactId>bungeecord-chat</artifactId>
|
||||||
- <version>1.20-R0.1</version>
|
- <version>1.20-R0.2</version>
|
||||||
- <type>jar</type>
|
- <type>jar</type>
|
||||||
- <scope>compile</scope>
|
- <scope>compile</scope>
|
||||||
- </dependency>
|
- </dependency>
|
||||||
- <dependency>
|
- <dependency>
|
||||||
- <groupId>org.yaml</groupId>
|
- <groupId>org.yaml</groupId>
|
||||||
- <artifactId>snakeyaml</artifactId>
|
- <artifactId>snakeyaml</artifactId>
|
||||||
- <version>2.0</version>
|
- <version>2.2</version>
|
||||||
- <scope>compile</scope>
|
- <scope>compile</scope>
|
||||||
- </dependency>
|
- </dependency>
|
||||||
- <!-- not part of the API proper -->
|
- <!-- not part of the API proper -->
|
||||||
- <dependency>
|
- <dependency>
|
||||||
- <groupId>org.apache.maven</groupId>
|
- <groupId>org.apache.maven</groupId>
|
||||||
- <artifactId>maven-resolver-provider</artifactId>
|
- <artifactId>maven-resolver-provider</artifactId>
|
||||||
- <version>3.8.5</version>
|
- <version>3.9.6</version>
|
||||||
- <scope>provided</scope>
|
- <scope>provided</scope>
|
||||||
- </dependency>
|
- </dependency>
|
||||||
- <dependency>
|
- <dependency>
|
||||||
- <groupId>org.apache.maven.resolver</groupId>
|
- <groupId>org.apache.maven.resolver</groupId>
|
||||||
- <artifactId>maven-resolver-connector-basic</artifactId>
|
- <artifactId>maven-resolver-connector-basic</artifactId>
|
||||||
- <version>1.7.3</version>
|
- <version>1.9.18</version>
|
||||||
- <scope>provided</scope>
|
- <scope>provided</scope>
|
||||||
- </dependency>
|
- </dependency>
|
||||||
- <dependency>
|
- <dependency>
|
||||||
- <groupId>org.apache.maven.resolver</groupId>
|
- <groupId>org.apache.maven.resolver</groupId>
|
||||||
- <artifactId>maven-resolver-transport-http</artifactId>
|
- <artifactId>maven-resolver-transport-http</artifactId>
|
||||||
- <version>1.7.3</version>
|
- <version>1.9.18</version>
|
||||||
- <scope>provided</scope>
|
- <scope>provided</scope>
|
||||||
- </dependency>
|
- </dependency>
|
||||||
- <!-- annotations -->
|
- <!-- annotations -->
|
||||||
- <dependency>
|
- <dependency>
|
||||||
- <groupId>org.jetbrains</groupId>
|
- <groupId>org.jetbrains</groupId>
|
||||||
- <artifactId>annotations-java5</artifactId>
|
- <artifactId>annotations-java5</artifactId>
|
||||||
- <version>24.0.1</version>
|
- <version>24.1.0</version>
|
||||||
- <scope>provided</scope>
|
- <scope>provided</scope>
|
||||||
- </dependency>
|
- </dependency>
|
||||||
- <!-- testing -->
|
- <!-- testing -->
|
||||||
- <dependency>
|
- <dependency>
|
||||||
- <groupId>junit</groupId>
|
- <groupId>org.junit.jupiter</groupId>
|
||||||
- <artifactId>junit</artifactId>
|
- <artifactId>junit-jupiter</artifactId>
|
||||||
- <version>4.13.2</version>
|
- <version>5.10.2</version>
|
||||||
- <scope>test</scope>
|
- <scope>test</scope>
|
||||||
- </dependency>
|
- </dependency>
|
||||||
- <dependency>
|
- <dependency>
|
||||||
- <groupId>org.hamcrest</groupId>
|
- <groupId>org.hamcrest</groupId>
|
||||||
- <artifactId>hamcrest-library</artifactId>
|
- <artifactId>hamcrest</artifactId>
|
||||||
- <version>1.3</version>
|
- <version>2.2</version>
|
||||||
|
- <scope>test</scope>
|
||||||
|
- </dependency>
|
||||||
|
- <dependency>
|
||||||
|
- <groupId>org.mockito</groupId>
|
||||||
|
- <artifactId>mockito-core</artifactId>
|
||||||
|
- <version>5.11.0</version>
|
||||||
- <scope>test</scope>
|
- <scope>test</scope>
|
||||||
- </dependency>
|
- </dependency>
|
||||||
- <dependency>
|
- <dependency>
|
||||||
- <groupId>org.ow2.asm</groupId>
|
- <groupId>org.ow2.asm</groupId>
|
||||||
- <artifactId>asm-tree</artifactId>
|
- <artifactId>asm-tree</artifactId>
|
||||||
- <version>9.5</version>
|
- <version>9.7</version>
|
||||||
- <scope>test</scope>
|
- <scope>test</scope>
|
||||||
- </dependency>
|
- </dependency>
|
||||||
- </dependencies>
|
- </dependencies>
|
||||||
@ -255,25 +265,16 @@ index 068987ca1171857fc9996d645e775448a09f0feb..00000000000000000000000000000000
|
|||||||
- <plugin>
|
- <plugin>
|
||||||
- <groupId>org.apache.maven.plugins</groupId>
|
- <groupId>org.apache.maven.plugins</groupId>
|
||||||
- <artifactId>maven-compiler-plugin</artifactId>
|
- <artifactId>maven-compiler-plugin</artifactId>
|
||||||
- <version>3.11.0</version>
|
- <version>3.13.0</version>
|
||||||
- <configuration>
|
- <configuration>
|
||||||
- <!-- we use the Eclipse compiler as it doesn't need a JDK -->
|
|
||||||
- <compilerId>eclipse</compilerId>
|
|
||||||
- <!-- default changed with version 3.11.0 -->
|
- <!-- default changed with version 3.11.0 -->
|
||||||
- <showWarnings>false</showWarnings>
|
- <showWarnings>false</showWarnings>
|
||||||
- </configuration>
|
- </configuration>
|
||||||
- <dependencies>
|
|
||||||
- <dependency>
|
|
||||||
- <groupId>org.codehaus.plexus</groupId>
|
|
||||||
- <artifactId>plexus-compiler-eclipse</artifactId>
|
|
||||||
- <version>2.13.0</version>
|
|
||||||
- </dependency>
|
|
||||||
- </dependencies>
|
|
||||||
- </plugin>
|
- </plugin>
|
||||||
- <plugin>
|
- <plugin>
|
||||||
- <groupId>org.apache.maven.plugins</groupId>
|
- <groupId>org.apache.maven.plugins</groupId>
|
||||||
- <artifactId>maven-jar-plugin</artifactId>
|
- <artifactId>maven-jar-plugin</artifactId>
|
||||||
- <version>3.3.0</version>
|
- <version>3.4.1</version>
|
||||||
- <configuration>
|
- <configuration>
|
||||||
- <archive>
|
- <archive>
|
||||||
- <manifest>
|
- <manifest>
|
||||||
@ -288,7 +289,7 @@ index 068987ca1171857fc9996d645e775448a09f0feb..00000000000000000000000000000000
|
|||||||
- <plugin>
|
- <plugin>
|
||||||
- <groupId>org.apache.maven.plugins</groupId>
|
- <groupId>org.apache.maven.plugins</groupId>
|
||||||
- <artifactId>maven-shade-plugin</artifactId>
|
- <artifactId>maven-shade-plugin</artifactId>
|
||||||
- <version>3.5.0</version>
|
- <version>3.5.3</version>
|
||||||
- <executions>
|
- <executions>
|
||||||
- <execution>
|
- <execution>
|
||||||
- <phase>package</phase>
|
- <phase>package</phase>
|
||||||
@ -315,13 +316,10 @@ index 068987ca1171857fc9996d645e775448a09f0feb..00000000000000000000000000000000
|
|||||||
- <plugin>
|
- <plugin>
|
||||||
- <groupId>org.apache.maven.plugins</groupId>
|
- <groupId>org.apache.maven.plugins</groupId>
|
||||||
- <artifactId>maven-javadoc-plugin</artifactId>
|
- <artifactId>maven-javadoc-plugin</artifactId>
|
||||||
- <version>3.5.0</version>
|
- <version>3.6.3</version>
|
||||||
- <configuration>
|
- <configuration>
|
||||||
- <links>
|
- <links>
|
||||||
- <link>https://guava.dev/releases/31.1-jre/api/docs/</link>
|
- <link>https://guava.dev/releases/32.1.2-jre/api/docs/</link>
|
||||||
- <link>https://javadoc.io/doc/org.yaml/snakeyaml/2.0/</link>
|
|
||||||
- <link>https://javadoc.io/doc/org.jetbrains/annotations-java5/24.0.1/</link>
|
|
||||||
- <link>https://javadoc.io/doc/net.md-5/bungeecord-chat/1.20-R0.1/</link>
|
|
||||||
- </links>
|
- </links>
|
||||||
- <tags>
|
- <tags>
|
||||||
- <tag>
|
- <tag>
|
||||||
@ -332,6 +330,11 @@ index 068987ca1171857fc9996d645e775448a09f0feb..00000000000000000000000000000000
|
|||||||
- </tags>
|
- </tags>
|
||||||
- </configuration>
|
- </configuration>
|
||||||
- </plugin>
|
- </plugin>
|
||||||
|
- <plugin>
|
||||||
|
- <groupId>org.apache.maven.plugins</groupId>
|
||||||
|
- <artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
- <version>3.2.5</version>
|
||||||
|
- </plugin>
|
||||||
- </plugins>
|
- </plugins>
|
||||||
- </build>
|
- </build>
|
||||||
-
|
-
|
||||||
@ -346,7 +349,7 @@ index 068987ca1171857fc9996d645e775448a09f0feb..00000000000000000000000000000000
|
|||||||
- <plugin>
|
- <plugin>
|
||||||
- <groupId>org.apache.maven.plugins</groupId>
|
- <groupId>org.apache.maven.plugins</groupId>
|
||||||
- <artifactId>maven-checkstyle-plugin</artifactId>
|
- <artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
- <version>3.3.0</version>
|
- <version>3.3.1</version>
|
||||||
- <executions>
|
- <executions>
|
||||||
- <execution>
|
- <execution>
|
||||||
- <phase>process-classes</phase>
|
- <phase>process-classes</phase>
|
||||||
@ -357,7 +360,6 @@ index 068987ca1171857fc9996d645e775448a09f0feb..00000000000000000000000000000000
|
|||||||
- </executions>
|
- </executions>
|
||||||
- <configuration>
|
- <configuration>
|
||||||
- <configLocation>checkstyle.xml</configLocation>
|
- <configLocation>checkstyle.xml</configLocation>
|
||||||
- <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
|
|
||||||
- <includeTestSourceDirectory>true</includeTestSourceDirectory>
|
- <includeTestSourceDirectory>true</includeTestSourceDirectory>
|
||||||
- </configuration>
|
- </configuration>
|
||||||
- <dependencies>
|
- <dependencies>
|
||||||
|
@ -5,12 +5,12 @@ Subject: [PATCH] Build system changes
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
index c2e5d8006420aab5a60e5aaa188223aeb0396483..ffd1c792b0e0fe1ed3da85cf933202c5193734ce 100644
|
index 6271e2bad0ed937c2c46a8c8fdf186c46b0b620e..a918fd14c95e714e935758d60bccd72755e00b11 100644
|
||||||
--- a/build.gradle.kts
|
--- a/build.gradle.kts
|
||||||
+++ b/build.gradle.kts
|
+++ b/build.gradle.kts
|
||||||
@@ -18,15 +18,27 @@ dependencies {
|
@@ -18,15 +18,26 @@ dependencies {
|
||||||
api("net.md-5:bungeecord-chat:$bungeeCordChatVersion")
|
api("net.md-5:bungeecord-chat:$bungeeCordChatVersion")
|
||||||
api("org.yaml:snakeyaml:2.0")
|
api("org.yaml:snakeyaml:2.2")
|
||||||
api("org.joml:joml:1.10.5")
|
api("org.joml:joml:1.10.5")
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ api("com.googlecode.json-simple:json-simple:1.1.1") {
|
+ api("com.googlecode.json-simple:json-simple:1.1.1") {
|
||||||
@ -18,10 +18,9 @@ index c2e5d8006420aab5a60e5aaa188223aeb0396483..ffd1c792b0e0fe1ed3da85cf933202c5
|
|||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
|
||||||
compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")
|
compileOnly("org.apache.maven:maven-resolver-provider:3.9.6")
|
||||||
compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
|
compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18")
|
||||||
compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3")
|
compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18")
|
||||||
+ compileOnly("com.google.code.findbugs:jsr305:1.3.9") // Paper
|
|
||||||
|
|
||||||
- val annotations = "org.jetbrains:annotations-java5:$annotationsVersion"
|
- val annotations = "org.jetbrains:annotations-java5:$annotationsVersion"
|
||||||
+ val annotations = "org.jetbrains:annotations:$annotationsVersion" // Paper - we don't want Java 5 annotations...
|
+ val annotations = "org.jetbrains:annotations:$annotationsVersion" // Paper - we don't want Java 5 annotations...
|
||||||
@ -29,26 +28,31 @@ index c2e5d8006420aab5a60e5aaa188223aeb0396483..ffd1c792b0e0fe1ed3da85cf933202c5
|
|||||||
testCompileOnly(annotations)
|
testCompileOnly(annotations)
|
||||||
|
|
||||||
+ // Paper start - add checker
|
+ // Paper start - add checker
|
||||||
+ val checkerQual = "org.checkerframework:checker-qual:3.21.0"
|
+ val checkerQual = "org.checkerframework:checker-qual:3.33.0"
|
||||||
+ compileOnlyApi(checkerQual)
|
+ compileOnlyApi(checkerQual)
|
||||||
+ testCompileOnly(checkerQual)
|
+ testCompileOnly(checkerQual)
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
testImplementation("org.apache.commons:commons-lang3:3.12.0")
|
testImplementation("org.apache.commons:commons-lang3:3.12.0")
|
||||||
testImplementation("junit:junit:4.13.2")
|
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
|
||||||
testImplementation("org.hamcrest:hamcrest-library:1.3")
|
testImplementation("org.hamcrest:hamcrest:2.2")
|
||||||
@@ -68,7 +80,7 @@ tasks.withType<Javadoc> {
|
@@ -69,8 +80,12 @@ tasks.withType<Javadoc> {
|
||||||
options.links(
|
options.links(
|
||||||
"https://guava.dev/releases/31.1-jre/api/docs/",
|
"https://guava.dev/releases/32.1.2-jre/api/docs/",
|
||||||
"https://javadoc.io/doc/org.yaml/snakeyaml/2.0/",
|
"https://javadoc.io/doc/org.yaml/snakeyaml/2.2/",
|
||||||
- "https://javadoc.io/doc/org.jetbrains/annotations-java5/$annotationsVersion/",
|
- "https://javadoc.io/doc/org.jetbrains/annotations-java5/$annotationsVersion/",
|
||||||
+ "https://javadoc.io/doc/org.jetbrains/annotations/$annotationsVersion/", // Paper - we don't want Java 5 annotations
|
+ "https://javadoc.io/doc/org.jetbrains/annotations/$annotationsVersion/", // Paper - we don't want Java 5 annotations
|
||||||
"https://javadoc.io/doc/net.md-5/bungeecord-chat/$bungeeCordChatVersion/",
|
"https://javadoc.io/doc/net.md-5/bungeecord-chat/$bungeeCordChatVersion/",
|
||||||
|
+ // Paper start - add missing javadoc links
|
||||||
|
+ "https://javadoc.io/doc/org.joml/joml/1.10.5/index.html",
|
||||||
|
+ "https://www.javadoc.io/doc/com.google.code.gson/gson/2.10.1",
|
||||||
|
+ // Paper end
|
||||||
)
|
)
|
||||||
options.tags("apiNote:a:API Note:")
|
options.tags("apiNote:a:API Note:")
|
||||||
@@ -84,3 +96,14 @@ tasks.withType<Javadoc> {
|
|
||||||
}
|
@@ -89,3 +104,14 @@ tasks.withType<Javadoc> {
|
||||||
}
|
tasks.test {
|
||||||
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+// Paper start
|
+// Paper start
|
||||||
|
@ -3,7 +3,6 @@ From: Shane Freeder <theboyetronic@gmail.com>
|
|||||||
Date: Sun, 17 Mar 2019 23:04:30 +0000
|
Date: Sun, 17 Mar 2019 23:04:30 +0000
|
||||||
Subject: [PATCH] Test changes
|
Subject: [PATCH] Test changes
|
||||||
|
|
||||||
- convert to mockito for mocking of types
|
|
||||||
- Allow use of TYPE_USE annotations
|
- Allow use of TYPE_USE annotations
|
||||||
- Ignore package-private methods for nullability annotations
|
- Ignore package-private methods for nullability annotations
|
||||||
- Add excludes for classes which don't pass
|
- Add excludes for classes which don't pass
|
||||||
@ -13,46 +12,22 @@ Co-authored-by: Riley Park <rileysebastianpark@gmail.com>
|
|||||||
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
index ffd1c792b0e0fe1ed3da85cf933202c5193734ce..b38a9f4d628fa639e5d2b7dcd5a63f0bf6b8330b 100644
|
index a918fd14c95e714e935758d60bccd72755e00b11..768024b2b4584fd7dd86f068c0e79c89ffc5faa1 100644
|
||||||
--- a/build.gradle.kts
|
--- a/build.gradle.kts
|
||||||
+++ b/build.gradle.kts
|
+++ b/build.gradle.kts
|
||||||
@@ -38,6 +38,7 @@ dependencies {
|
@@ -105,6 +105,12 @@ tasks.test {
|
||||||
compileOnlyApi(checkerQual)
|
useJUnitPlatform()
|
||||||
testCompileOnly(checkerQual)
|
}
|
||||||
// Paper end
|
|
||||||
+ testImplementation("org.mockito:mockito-core:4.9.0") // Paper - add mockito
|
|
||||||
|
|
||||||
testImplementation("org.apache.commons:commons-lang3:3.12.0")
|
+// Paper start - compile tests with -parameters for better junit parameterized test names
|
||||||
testImplementation("junit:junit:4.13.2")
|
+tasks.compileTestJava {
|
||||||
diff --git a/src/test/java/io/papermc/paper/testing/EmptyRegistry.java b/src/test/java/io/papermc/paper/testing/EmptyRegistry.java
|
+ options.compilerArgs.add("-parameters")
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..ba9ddce87a9f385e729a5c2cf7c5eec120e388a7
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/test/java/io/papermc/paper/testing/EmptyRegistry.java
|
|
||||||
@@ -0,0 +1,23 @@
|
|
||||||
+package io.papermc.paper.testing;
|
|
||||||
+
|
|
||||||
+import java.util.Collections;
|
|
||||||
+import java.util.Iterator;
|
|
||||||
+import org.bukkit.Keyed;
|
|
||||||
+import org.bukkit.NamespacedKey;
|
|
||||||
+import org.bukkit.Registry;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+import org.jetbrains.annotations.Nullable;
|
|
||||||
+
|
|
||||||
+public record EmptyRegistry() implements Registry<Keyed> {
|
|
||||||
+
|
|
||||||
+ @NotNull
|
|
||||||
+ @Override
|
|
||||||
+ public Iterator<Keyed> iterator() {
|
|
||||||
+ return Collections.emptyIterator();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public @Nullable Keyed get(@NotNull final NamespacedKey key) {
|
|
||||||
+ return null;
|
|
||||||
+ }
|
|
||||||
+}
|
+}
|
||||||
|
+// Paper end
|
||||||
|
+
|
||||||
|
// Paper start
|
||||||
|
val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) {
|
||||||
|
badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;")
|
||||||
diff --git a/src/test/java/io/papermc/paper/testing/EmptyTag.java b/src/test/java/io/papermc/paper/testing/EmptyTag.java
|
diff --git a/src/test/java/io/papermc/paper/testing/EmptyTag.java b/src/test/java/io/papermc/paper/testing/EmptyTag.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..77154095cfb8b259bdb318e8ff40cb6f559ebc18
|
index 0000000000000000000000000000000000000000..77154095cfb8b259bdb318e8ff40cb6f559ebc18
|
||||||
@ -90,62 +65,8 @@ index 0000000000000000000000000000000000000000..77154095cfb8b259bdb318e8ff40cb6f
|
|||||||
+ return Collections.emptySet();
|
+ return Collections.emptySet();
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/test/java/io/papermc/paper/testing/TestServer.java b/src/test/java/io/papermc/paper/testing/TestServer.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..756acf231b1b076b08046d86992ba7ce7f62a94f
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/test/java/io/papermc/paper/testing/TestServer.java
|
|
||||||
@@ -0,0 +1,48 @@
|
|
||||||
+package io.papermc.paper.testing;
|
|
||||||
+
|
|
||||||
+import java.util.logging.Logger;
|
|
||||||
+import org.bukkit.Bukkit;
|
|
||||||
+import org.bukkit.NamespacedKey;
|
|
||||||
+import org.bukkit.Server;
|
|
||||||
+import org.bukkit.command.SimpleCommandMap;
|
|
||||||
+import org.bukkit.plugin.PluginManager;
|
|
||||||
+import org.bukkit.plugin.SimplePluginManager;
|
|
||||||
+
|
|
||||||
+import static org.mockito.ArgumentMatchers.anyString;
|
|
||||||
+import static org.mockito.Mockito.any;
|
|
||||||
+import static org.mockito.Mockito.mock;
|
|
||||||
+import static org.mockito.Mockito.when;
|
|
||||||
+
|
|
||||||
+public final class TestServer {
|
|
||||||
+
|
|
||||||
+ @SuppressWarnings("removal")
|
|
||||||
+ public static void setup() {
|
|
||||||
+ //noinspection ConstantValue
|
|
||||||
+ if (Bukkit.getServer() != null) {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ final Server dummyServer = mock(Server.class);
|
|
||||||
+
|
|
||||||
+ final Logger logger = Logger.getLogger(TestServer.class.getCanonicalName());
|
|
||||||
+ when(dummyServer.getLogger()).thenReturn(logger);
|
|
||||||
+ when(dummyServer.getName()).thenReturn(TestServer.class.getSimpleName());
|
|
||||||
+ when(dummyServer.getVersion()).thenReturn("Version_" + TestServer.class.getPackage().getImplementationVersion());
|
|
||||||
+ when(dummyServer.getBukkitVersion()).thenReturn("BukkitVersion_" + TestServer.class.getPackage().getImplementationVersion());
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ final Thread currentThread = Thread.currentThread();
|
|
||||||
+ when(dummyServer.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread));
|
|
||||||
+
|
|
||||||
+ when(dummyServer.getTag(anyString(), any(NamespacedKey.class), any())).thenAnswer(ignored -> new EmptyTag());
|
|
||||||
+
|
|
||||||
+ final PluginManager pluginManager = new SimplePluginManager(dummyServer, new SimpleCommandMap(dummyServer));
|
|
||||||
+ when(dummyServer.getPluginManager()).thenReturn(pluginManager);
|
|
||||||
+
|
|
||||||
+ when(dummyServer.getRegistry(any())).thenAnswer(ignored -> new EmptyRegistry());
|
|
||||||
+ when(dummyServer.getScoreboardCriteria(anyString())).thenReturn(null);
|
|
||||||
+
|
|
||||||
+ Bukkit.setServer(dummyServer);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
|
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
|
||||||
index 4ac3dd977e75cd8464163351d306e037ee32cb48..c26ea217927ba77611e6ae93f8df50a83bceb3dd 100644
|
index 64e7aef6220097edefdff3b98a771b988365930d..d9091ba1e5a55e03adca98305233cce9d6888609 100644
|
||||||
--- a/src/test/java/org/bukkit/AnnotationTest.java
|
--- a/src/test/java/org/bukkit/AnnotationTest.java
|
||||||
+++ b/src/test/java/org/bukkit/AnnotationTest.java
|
+++ b/src/test/java/org/bukkit/AnnotationTest.java
|
||||||
@@ -29,7 +29,13 @@ public class AnnotationTest {
|
@@ -29,7 +29,13 @@ public class AnnotationTest {
|
||||||
@ -182,7 +103,7 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..c26ea217927ba77611e6ae93f8df50a8
|
|||||||
};
|
};
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -67,14 +83,40 @@ public class AnnotationTest {
|
@@ -67,14 +83,48 @@ public class AnnotationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mustBeAnnotated(Type.getReturnType(method.desc)) && !isWellAnnotated(method.invisibleAnnotations)) {
|
if (mustBeAnnotated(Type.getReturnType(method.desc)) && !isWellAnnotated(method.invisibleAnnotations)) {
|
||||||
@ -219,11 +140,19 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..c26ea217927ba77611e6ae93f8df50a8
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+ if (method.visibleTypeAnnotations != null) {
|
||||||
|
+ for (final org.objectweb.asm.tree.TypeAnnotationNode invisibleTypeAnnotation : method.visibleTypeAnnotations) {
|
||||||
|
+ final org.objectweb.asm.TypeReference ref = new org.objectweb.asm.TypeReference(invisibleTypeAnnotation.typeRef);
|
||||||
|
+ if (ref.getSort() == org.objectweb.asm.TypeReference.METHOD_FORMAL_PARAMETER && ref.getTypeParameterIndex() == i && java.util.Arrays.asList(ACCEPTED_ANNOTATIONS).contains(invisibleTypeAnnotation.desc)) {
|
||||||
|
+ continue dancing;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
+ // Paper end - Allow use of TYPE_USE annotations
|
+ // Paper end - Allow use of TYPE_USE annotations
|
||||||
ParameterNode paramNode = parameters == null ? null : parameters.get(i);
|
ParameterNode paramNode = parameters == null ? null : parameters.get(i);
|
||||||
String paramName = paramNode == null ? null : paramNode.name;
|
String paramName = paramNode == null ? null : paramNode.name;
|
||||||
|
|
||||||
@@ -91,13 +133,18 @@ public class AnnotationTest {
|
@@ -91,13 +141,18 @@ public class AnnotationTest {
|
||||||
|
|
||||||
Collections.sort(errors);
|
Collections.sort(errors);
|
||||||
|
|
||||||
@ -241,12 +170,12 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..c26ea217927ba77611e6ae93f8df50a8
|
|||||||
+ builder.append("\t").append(message).append("\n");
|
+ builder.append("\t").append(message).append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
- Assert.fail("There " + errors.size() + " are missing annotation(s)");
|
- fail("There " + errors.size() + " are missing annotation(s)");
|
||||||
+ Assert.fail(builder.toString());
|
+ fail(builder.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void collectClasses(@NotNull File from, @NotNull Map<String, ClassNode> to) throws IOException {
|
private static void collectClasses(@NotNull File from, @NotNull Map<String, ClassNode> to) throws IOException {
|
||||||
@@ -140,6 +187,11 @@ public class AnnotationTest {
|
@@ -140,6 +195,11 @@ public class AnnotationTest {
|
||||||
// Exceptions are excluded
|
// Exceptions are excluded
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -258,7 +187,7 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..c26ea217927ba77611e6ae93f8df50a8
|
|||||||
|
|
||||||
for (String excludedClass : EXCLUDED_CLASSES) {
|
for (String excludedClass : EXCLUDED_CLASSES) {
|
||||||
if (excludedClass.equals(clazz.name)) {
|
if (excludedClass.equals(clazz.name)) {
|
||||||
@@ -152,7 +204,7 @@ public class AnnotationTest {
|
@@ -152,7 +212,7 @@ public class AnnotationTest {
|
||||||
|
|
||||||
private static boolean isMethodIncluded(@NotNull ClassNode clazz, @NotNull MethodNode method, @NotNull Map<String, ClassNode> allClasses) {
|
private static boolean isMethodIncluded(@NotNull ClassNode clazz, @NotNull MethodNode method, @NotNull Map<String, ClassNode> allClasses) {
|
||||||
// Exclude private, synthetic and deprecated methods
|
// Exclude private, synthetic and deprecated methods
|
||||||
@ -267,7 +196,7 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..c26ea217927ba77611e6ae93f8df50a8
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,11 +222,30 @@ public class AnnotationTest {
|
@@ -170,11 +230,30 @@ public class AnnotationTest {
|
||||||
if ("<init>".equals(method.name) && isAnonymous(clazz)) {
|
if ("<init>".equals(method.name) && isAnonymous(clazz)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -300,243 +229,30 @@ index 4ac3dd977e75cd8464163351d306e037ee32cb48..c26ea217927ba77611e6ae93f8df50a8
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
diff --git a/src/test/java/org/bukkit/BukkitMirrorTest.java b/src/test/java/org/bukkit/BukkitMirrorTest.java
|
diff --git a/src/test/java/org/bukkit/BukkitMirrorTest.java b/src/test/java/org/bukkit/BukkitMirrorTest.java
|
||||||
index 2dfada66067d79b84cd490eadbe0178e8cd8c260..06d66512c91c680130132b79e34fbf32245ff9ee 100644
|
index 89ca06ebecdaadd5dfc7bc74473ca15ad36f6eff..5974ceea58940e1799f3589eac0e39b925a42c3b 100644
|
||||||
--- a/src/test/java/org/bukkit/BukkitMirrorTest.java
|
--- a/src/test/java/org/bukkit/BukkitMirrorTest.java
|
||||||
+++ b/src/test/java/org/bukkit/BukkitMirrorTest.java
|
+++ b/src/test/java/org/bukkit/BukkitMirrorTest.java
|
||||||
@@ -20,6 +20,7 @@ public class BukkitMirrorTest {
|
@@ -9,6 +9,7 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
||||||
@Parameters(name = "{index}: {1}")
|
+@org.junit.jupiter.api.Disabled // Paper
|
||||||
public static List<Object[]> data() {
|
public class BukkitMirrorTest {
|
||||||
+ if (true) return List.of(); // Paper
|
|
||||||
return Lists.transform(Arrays.asList(Server.class.getDeclaredMethods()), new Function<Method, Object[]>() {
|
|
||||||
@Override
|
|
||||||
public Object[] apply(Method input) {
|
|
||||||
diff --git a/src/test/java/org/bukkit/TestServer.java b/src/test/java/org/bukkit/TestServer.java
|
|
||||||
deleted file mode 100644
|
|
||||||
index 701a17c10f31cd345238a3c568264178ce372faa..0000000000000000000000000000000000000000
|
|
||||||
--- a/src/test/java/org/bukkit/TestServer.java
|
|
||||||
+++ /dev/null
|
|
||||||
@@ -1,139 +0,0 @@
|
|
||||||
-package org.bukkit;
|
|
||||||
-
|
|
||||||
-import com.google.common.collect.ImmutableMap;
|
|
||||||
-import java.lang.reflect.InvocationHandler;
|
|
||||||
-import java.lang.reflect.Method;
|
|
||||||
-import java.lang.reflect.Proxy;
|
|
||||||
-import java.util.Iterator;
|
|
||||||
-import java.util.Map;
|
|
||||||
-import java.util.logging.Logger;
|
|
||||||
-import org.bukkit.command.SimpleCommandMap;
|
|
||||||
-import org.bukkit.plugin.PluginManager;
|
|
||||||
-import org.bukkit.plugin.SimplePluginManager;
|
|
||||||
-import org.jetbrains.annotations.NotNull;
|
|
||||||
-import org.jetbrains.annotations.Nullable;
|
|
||||||
-
|
|
||||||
-public final class TestServer implements InvocationHandler {
|
|
||||||
- private static interface MethodHandler {
|
|
||||||
- Object handle(TestServer server, Object[] args);
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- private static final Map<Method, MethodHandler> methods;
|
|
||||||
-
|
|
||||||
- static {
|
|
||||||
- try {
|
|
||||||
- ImmutableMap.Builder<Method, MethodHandler> methodMap = ImmutableMap.builder();
|
|
||||||
- methodMap.put(
|
|
||||||
- Server.class.getMethod("isPrimaryThread"),
|
|
||||||
- new MethodHandler() {
|
|
||||||
- @Override
|
|
||||||
- public Object handle(TestServer server, Object[] args) {
|
|
||||||
- return Thread.currentThread().equals(server.creatingThread);
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- );
|
|
||||||
- methodMap.put(
|
|
||||||
- Server.class.getMethod("getPluginManager"),
|
|
||||||
- new MethodHandler() {
|
|
||||||
- @Override
|
|
||||||
- public Object handle(TestServer server, Object[] args) {
|
|
||||||
- return server.pluginManager;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- );
|
|
||||||
- methodMap.put(
|
|
||||||
- Server.class.getMethod("getLogger"),
|
|
||||||
- new MethodHandler() {
|
|
||||||
- final Logger logger = Logger.getLogger(TestServer.class.getCanonicalName());
|
|
||||||
- @Override
|
|
||||||
- public Object handle(TestServer server, Object[] args) {
|
|
||||||
- return logger;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- );
|
|
||||||
- methodMap.put(
|
|
||||||
- Server.class.getMethod("getName"),
|
|
||||||
- new MethodHandler() {
|
|
||||||
- @Override
|
|
||||||
- public Object handle(TestServer server, Object[] args) {
|
|
||||||
- return TestServer.class.getSimpleName();
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- );
|
|
||||||
- methodMap.put(
|
|
||||||
- Server.class.getMethod("getVersion"),
|
|
||||||
- new MethodHandler() {
|
|
||||||
- @Override
|
|
||||||
- public Object handle(TestServer server, Object[] args) {
|
|
||||||
- return "Version_" + TestServer.class.getPackage().getImplementationVersion();
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- );
|
|
||||||
- methodMap.put(
|
|
||||||
- Server.class.getMethod("getBukkitVersion"),
|
|
||||||
- new MethodHandler() {
|
|
||||||
- @Override
|
|
||||||
- public Object handle(TestServer server, Object[] args) {
|
|
||||||
- return "BukkitVersion_" + TestServer.class.getPackage().getImplementationVersion();
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- );
|
|
||||||
- methodMap.put(
|
|
||||||
- Server.class.getMethod("getRegistry", Class.class),
|
|
||||||
- new MethodHandler() {
|
|
||||||
- @Override
|
|
||||||
- public Object handle(TestServer server, Object[] args) {
|
|
||||||
- return new Registry() {
|
|
||||||
- @NotNull
|
|
||||||
- @Override
|
|
||||||
- public Iterator iterator() {
|
|
||||||
- return null;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- @Nullable
|
|
||||||
- @Override
|
|
||||||
- public Keyed get(@NotNull NamespacedKey key) {
|
|
||||||
- return null;
|
|
||||||
- }
|
|
||||||
- };
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- );
|
|
||||||
- methodMap.put(
|
|
||||||
- Server.class.getMethod("getScoreboardCriteria", String.class),
|
|
||||||
- new MethodHandler() {
|
|
||||||
- @Override
|
|
||||||
- public Object handle(TestServer server, Object[] args) {
|
|
||||||
- // Does not need to return anything. Exists solely to test CriteriaTest which has static init fields
|
|
||||||
- return null;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- );
|
|
||||||
- methods = methodMap.build();
|
|
||||||
-
|
|
||||||
- TestServer server = new TestServer();
|
|
||||||
- Server instance = Proxy.getProxyClass(Server.class.getClassLoader(), Server.class).asSubclass(Server.class).getConstructor(InvocationHandler.class).newInstance(server);
|
|
||||||
- Bukkit.setServer(instance);
|
|
||||||
- server.pluginManager = new SimplePluginManager(instance, new SimpleCommandMap(instance));
|
|
||||||
- } catch (Throwable t) {
|
|
||||||
- throw new Error(t);
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- private Thread creatingThread = Thread.currentThread();
|
|
||||||
- private PluginManager pluginManager;
|
|
||||||
- private TestServer() {};
|
|
||||||
-
|
|
||||||
- public static Server getInstance() {
|
|
||||||
- return Bukkit.getServer();
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- @Override
|
|
||||||
- public Object invoke(Object proxy, Method method, Object[] args) {
|
|
||||||
- MethodHandler handler = methods.get(method);
|
|
||||||
- if (handler != null) {
|
|
||||||
- return handler.handle(this, args);
|
|
||||||
- }
|
|
||||||
- throw new UnsupportedOperationException(String.valueOf(method));
|
|
||||||
- }
|
|
||||||
-}
|
|
||||||
diff --git a/src/test/java/org/bukkit/TestWorld.java b/src/test/java/org/bukkit/TestWorld.java
|
|
||||||
index ab34f1199921d415fa2ca6e281a8125c9e6d7173..f64d024f5bbf9482aaddb56597b23b04c66f21bf 100644
|
|
||||||
--- a/src/test/java/org/bukkit/TestWorld.java
|
|
||||||
+++ b/src/test/java/org/bukkit/TestWorld.java
|
|
||||||
@@ -18,7 +18,7 @@ public final class TestWorld implements InvocationHandler {
|
|
||||||
|
|
||||||
static {
|
public static Stream<Arguments> data() {
|
||||||
try {
|
diff --git a/src/test/java/org/bukkit/support/TestServer.java b/src/test/java/org/bukkit/support/TestServer.java
|
||||||
- TestServer.getInstance();
|
index 5709d52ed4ac4ce8dd8b0569281279f7305c5fb9..a47ee3ce660ec4467b5ed6a4b41fb2d19179a189 100644
|
||||||
+ io.papermc.paper.testing.TestServer.setup(); // Paper
|
--- a/src/test/java/org/bukkit/support/TestServer.java
|
||||||
|
+++ b/src/test/java/org/bukkit/support/TestServer.java
|
||||||
|
@@ -72,6 +72,11 @@ public final class TestServer {
|
||||||
|
UnsafeValues unsafeValues = mock(withSettings().stubOnly());
|
||||||
|
when(instance.getUnsafe()).thenReturn(unsafeValues);
|
||||||
|
|
||||||
ImmutableMap.Builder<Method, MethodHandler> methodMap = ImmutableMap.builder();
|
+ // Paper start - testing changes
|
||||||
methodMap.put(
|
+ when(instance.getTag(anyString(), any(NamespacedKey.class), any())).thenAnswer(ignored -> new io.papermc.paper.testing.EmptyTag());
|
||||||
diff --git a/src/test/java/org/bukkit/event/SyntheticEventTest.java b/src/test/java/org/bukkit/event/SyntheticEventTest.java
|
+ when(instance.getScoreboardCriteria(anyString())).thenReturn(null);
|
||||||
index d402cb59f508205ebe9ee450594826b04cecb90b..09886568ae6167141b463b6262565fa212af3385 100644
|
+ // Paper end - testing changes
|
||||||
--- a/src/test/java/org/bukkit/event/SyntheticEventTest.java
|
+
|
||||||
+++ b/src/test/java/org/bukkit/event/SyntheticEventTest.java
|
Bukkit.setServer(instance);
|
||||||
@@ -1,6 +1,5 @@
|
|
||||||
package org.bukkit.event;
|
|
||||||
|
|
||||||
-import org.bukkit.TestServer;
|
|
||||||
import org.bukkit.plugin.PluginLoader;
|
|
||||||
import org.bukkit.plugin.SimplePluginManager;
|
|
||||||
import org.bukkit.plugin.TestPlugin;
|
|
||||||
@@ -12,14 +11,15 @@ public class SyntheticEventTest {
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
- final JavaPluginLoader loader = new JavaPluginLoader(TestServer.getInstance());
|
|
||||||
+ io.papermc.paper.testing.TestServer.setup(); // Paper
|
|
||||||
+ final JavaPluginLoader loader = new JavaPluginLoader(org.bukkit.Bukkit.getServer()); // Paper
|
|
||||||
TestPlugin plugin = new TestPlugin(getClass().getName()) {
|
|
||||||
@Override
|
|
||||||
public PluginLoader getPluginLoader() {
|
|
||||||
return loader;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
- SimplePluginManager pluginManager = new SimplePluginManager(TestServer.getInstance(), null);
|
|
||||||
+ SimplePluginManager pluginManager = new SimplePluginManager(org.bukkit.Bukkit.getServer(), null); // Paper
|
|
||||||
|
|
||||||
TestEvent event = new TestEvent(false);
|
|
||||||
Impl impl = new Impl();
|
|
||||||
diff --git a/src/test/java/org/bukkit/plugin/PluginManagerTest.java b/src/test/java/org/bukkit/plugin/PluginManagerTest.java
|
|
||||||
index f188cd4f3b07027c30d41f1162db77a506b7b6bb..c46ed2acb82db814d660459b705dd49e6d44240f 100644
|
|
||||||
--- a/src/test/java/org/bukkit/plugin/PluginManagerTest.java
|
|
||||||
+++ b/src/test/java/org/bukkit/plugin/PluginManagerTest.java
|
|
||||||
@@ -2,7 +2,6 @@ package org.bukkit.plugin;
|
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.*;
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
-import org.bukkit.TestServer;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.TestEvent;
|
|
||||||
import org.bukkit.permissions.Permission;
|
|
||||||
@@ -14,7 +13,7 @@ public class PluginManagerTest {
|
|
||||||
volatile Object value = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- private static final PluginManager pm = TestServer.getInstance().getPluginManager();
|
|
||||||
+ private static final PluginManager pm = org.bukkit.Bukkit.getServer().getPluginManager(); // Paper
|
|
||||||
|
|
||||||
private final MutableObject store = new MutableObject();
|
|
||||||
|
|
||||||
diff --git a/src/test/java/org/bukkit/scoreboard/CriteriaTest.java b/src/test/java/org/bukkit/scoreboard/CriteriaTest.java
|
|
||||||
index eb94b6f4d58cd9f66b07791c57af7e359992e28c..a93f28e2f987a36e2c7e4f7d31506b750bdb222b 100644
|
|
||||||
--- a/src/test/java/org/bukkit/scoreboard/CriteriaTest.java
|
|
||||||
+++ b/src/test/java/org/bukkit/scoreboard/CriteriaTest.java
|
|
||||||
@@ -2,7 +2,6 @@ package org.bukkit.scoreboard;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Statistic;
|
|
||||||
-import org.bukkit.TestServer;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
@@ -11,7 +10,7 @@ public class CriteriaTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStatistic() {
|
|
||||||
- TestServer.getInstance();
|
|
||||||
+ io.papermc.paper.testing.TestServer.setup(); // Paper
|
|
||||||
|
|
||||||
Assert.assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.AVIATE_ONE_CM, Material.STONE)); // Generic statistic with block
|
|
||||||
Assert.assertThrows(IllegalArgumentException.class, () -> Criteria.statistic(Statistic.AVIATE_ONE_CM, EntityType.CREEPER)); // Generic statistic with entity type
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Aikar <aikar@aikar.co>
|
|
||||||
Date: Fri, 1 Apr 2016 00:02:47 -0400
|
|
||||||
Subject: [PATCH] Add FastUtil to Bukkit
|
|
||||||
|
|
||||||
Doesn't expose to plugins, just allows Paper-API to use it for optimization
|
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
|
||||||
index b38a9f4d628fa639e5d2b7dcd5a63f0bf6b8330b..19720f73cb8454d6ddd8d75e7d08556d61436505 100644
|
|
||||||
--- a/build.gradle.kts
|
|
||||||
+++ b/build.gradle.kts
|
|
||||||
@@ -22,6 +22,7 @@ dependencies {
|
|
||||||
api("com.googlecode.json-simple:json-simple:1.1.1") {
|
|
||||||
isTransitive = false // includes junit
|
|
||||||
}
|
|
||||||
+ api("it.unimi.dsi:fastutil:8.5.6")
|
|
||||||
// Paper end
|
|
||||||
|
|
||||||
compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")
|
|
343
patches/api/0004-Code-Generation.patch
Normale Datei
343
patches/api/0004-Code-Generation.patch
Normale Datei
@ -0,0 +1,343 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||||
|
Date: Fri, 26 May 2023 18:14:44 -0700
|
||||||
|
Subject: [PATCH] Code Generation
|
||||||
|
|
||||||
|
Currently includes generated key holder classes for types
|
||||||
|
used in the Registry Modification API
|
||||||
|
|
||||||
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
|
index 768024b2b4584fd7dd86f068c0e79c89ffc5faa1..f11a22ab01e97e51619c96f2d8a78a99297efc59 100644
|
||||||
|
--- a/build.gradle.kts
|
||||||
|
+++ b/build.gradle.kts
|
||||||
|
@@ -1,6 +1,7 @@
|
||||||
|
plugins {
|
||||||
|
`java-library`
|
||||||
|
`maven-publish`
|
||||||
|
+ idea // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
@@ -45,6 +46,22 @@ dependencies {
|
||||||
|
testImplementation("org.ow2.asm:asm-tree:9.7")
|
||||||
|
}
|
||||||
|
|
||||||
|
+// Paper start
|
||||||
|
+val generatedApiPath: java.nio.file.Path = rootProject.projectDir.toPath().resolve("paper-api-generator/generated")
|
||||||
|
+idea {
|
||||||
|
+ module {
|
||||||
|
+ generatedSourceDirs.add(generatedApiPath.toFile())
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+sourceSets {
|
||||||
|
+ main {
|
||||||
|
+ java {
|
||||||
|
+ srcDir(generatedApiPath)
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+// Paper end
|
||||||
|
+
|
||||||
|
configure<PublishingExtension> {
|
||||||
|
publications.create<MavenPublication>("maven") {
|
||||||
|
from(components["java"])
|
||||||
|
@@ -121,3 +138,14 @@ tasks.check {
|
||||||
|
dependsOn(scanJar)
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
|
+// Paper start
|
||||||
|
+val scanJarForOldGeneratedCode = tasks.register("scanJarForOldGeneratedCode", io.papermc.paperweight.tasks.ScanJarForOldGeneratedCode::class) {
|
||||||
|
+ mcVersion.set(providers.gradleProperty("mcVersion"))
|
||||||
|
+ annotation.set("Lio/papermc/paper/generated/GeneratedFrom;")
|
||||||
|
+ jarToScan.set(tasks.jar.flatMap { it.archiveFile })
|
||||||
|
+ classpath.from(configurations.compileClasspath)
|
||||||
|
+}
|
||||||
|
+tasks.check {
|
||||||
|
+ dependsOn(scanJarForOldGeneratedCode)
|
||||||
|
+}
|
||||||
|
+// Paper end
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/generated/GeneratedFrom.java b/src/main/java/io/papermc/paper/generated/GeneratedFrom.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..2512dba27edfdccbc4430815b6cba048e3d93484
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/generated/GeneratedFrom.java
|
||||||
|
@@ -0,0 +1,21 @@
|
||||||
|
+package io.papermc.paper.generated;
|
||||||
|
+
|
||||||
|
+import java.lang.annotation.Documented;
|
||||||
|
+import java.lang.annotation.ElementType;
|
||||||
|
+import java.lang.annotation.Retention;
|
||||||
|
+import java.lang.annotation.RetentionPolicy;
|
||||||
|
+import java.lang.annotation.Target;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Used to mark classes which are generated from
|
||||||
|
+ * a specific version of minecraft.
|
||||||
|
+ */
|
||||||
|
+@ApiStatus.Internal
|
||||||
|
+@Documented
|
||||||
|
+@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
+@Target(ElementType.TYPE)
|
||||||
|
+public @interface GeneratedFrom {
|
||||||
|
+
|
||||||
|
+ String value();
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKey.java b/src/main/java/io/papermc/paper/registry/RegistryKey.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..76daccf4ea502e1747a6f9176dc16fd20c561286
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/RegistryKey.java
|
||||||
|
@@ -0,0 +1,147 @@
|
||||||
|
+package io.papermc.paper.registry;
|
||||||
|
+
|
||||||
|
+import net.kyori.adventure.key.Keyed;
|
||||||
|
+import org.bukkit.Art;
|
||||||
|
+import org.bukkit.Fluid;
|
||||||
|
+import org.bukkit.GameEvent;
|
||||||
|
+import org.bukkit.JukeboxSong;
|
||||||
|
+import org.bukkit.MusicInstrument;
|
||||||
|
+import org.bukkit.Particle;
|
||||||
|
+import org.bukkit.Sound;
|
||||||
|
+import org.bukkit.attribute.Attribute;
|
||||||
|
+import org.bukkit.block.Biome;
|
||||||
|
+import org.bukkit.block.BlockType;
|
||||||
|
+import org.bukkit.block.banner.PatternType;
|
||||||
|
+import org.bukkit.damage.DamageType;
|
||||||
|
+import org.bukkit.enchantments.Enchantment;
|
||||||
|
+import org.bukkit.entity.Cat;
|
||||||
|
+import org.bukkit.entity.EntityType;
|
||||||
|
+import org.bukkit.entity.Frog;
|
||||||
|
+import org.bukkit.entity.Villager;
|
||||||
|
+import org.bukkit.entity.Wolf;
|
||||||
|
+import org.bukkit.entity.memory.MemoryKey;
|
||||||
|
+import org.bukkit.generator.structure.Structure;
|
||||||
|
+import org.bukkit.generator.structure.StructureType;
|
||||||
|
+import org.bukkit.inventory.ItemType;
|
||||||
|
+import org.bukkit.inventory.meta.trim.TrimMaterial;
|
||||||
|
+import org.bukkit.inventory.meta.trim.TrimPattern;
|
||||||
|
+import org.bukkit.map.MapCursor;
|
||||||
|
+import org.bukkit.potion.PotionEffectType;
|
||||||
|
+import org.bukkit.potion.PotionType;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
|
+
|
||||||
|
+import static io.papermc.paper.registry.RegistryKeyImpl.create;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Identifier for a specific registry. For use with
|
||||||
|
+ * {@link TypedKey} and the registry modification API.
|
||||||
|
+ * <p>
|
||||||
|
+ * There are 2 types of registries, identified as "built-in"
|
||||||
|
+ * or "data-driven". The former are not changeable by datapacks (which
|
||||||
|
+ * doesn't necessarily mean they aren't changeable in the API) and
|
||||||
|
+ * are loaded first. "Data-driven" registries are all created by
|
||||||
|
+ * reading in data from the vanilla and other datapacks.
|
||||||
|
+ *
|
||||||
|
+ * @param <T> the value type
|
||||||
|
+ */
|
||||||
|
+@SuppressWarnings("unused")
|
||||||
|
+public sealed interface RegistryKey<T> extends Keyed permits RegistryKeyImpl {
|
||||||
|
+
|
||||||
|
+ /* ******************* *
|
||||||
|
+ * Built-in Registries *
|
||||||
|
+ * ******************* */
|
||||||
|
+ /**
|
||||||
|
+ * Built-in registry for game events
|
||||||
|
+ * @see io.papermc.paper.registry.keys.GameEventKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<GameEvent> GAME_EVENT = create("game_event");
|
||||||
|
+ /**
|
||||||
|
+ * Built-in registry for structure types.
|
||||||
|
+ * @see io.papermc.paper.registry.keys.StructureTypeKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<StructureType> STRUCTURE_TYPE = create("worldgen/structure_type");
|
||||||
|
+ /**
|
||||||
|
+ * Built-in registry for instruments.
|
||||||
|
+ * @see io.papermc.paper.registry.keys.InstrumentKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<MusicInstrument> INSTRUMENT = create("instrument");
|
||||||
|
+ /**
|
||||||
|
+ * Built-in registry for potion effect types (mob effects).
|
||||||
|
+ * @see io.papermc.paper.registry.keys.MobEffectKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<PotionEffectType> MOB_EFFECT = create("mob_effect");
|
||||||
|
+ /**
|
||||||
|
+ * @apiNote DO NOT USE
|
||||||
|
+ */
|
||||||
|
+ @ApiStatus.Internal
|
||||||
|
+ RegistryKey<BlockType> BLOCK = create("block");
|
||||||
|
+ /**
|
||||||
|
+ * @apiNote DO NOT USE
|
||||||
|
+ */
|
||||||
|
+ @ApiStatus.Internal
|
||||||
|
+ RegistryKey<ItemType> ITEM = create("item");
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ /* ********************** *
|
||||||
|
+ * Data-driven Registries *
|
||||||
|
+ * ********************** */
|
||||||
|
+ /**
|
||||||
|
+ * Data-driven registry for biomes.
|
||||||
|
+ * @see io.papermc.paper.registry.keys.BiomeKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<Biome> BIOME = create("worldgen/biome");
|
||||||
|
+ /**
|
||||||
|
+ * Data-driven registry for structures.
|
||||||
|
+ * @see io.papermc.paper.registry.keys.StructureKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<Structure> STRUCTURE = create("worldgen/structure");
|
||||||
|
+ /**
|
||||||
|
+ * Data-driven registry for trim materials.
|
||||||
|
+ * @see io.papermc.paper.registry.keys.TrimMaterialKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<TrimMaterial> TRIM_MATERIAL = create("trim_material");
|
||||||
|
+ /**
|
||||||
|
+ * Data-driven registry for trim patterns.
|
||||||
|
+ * @see io.papermc.paper.registry.keys.TrimPatternKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<TrimPattern> TRIM_PATTERN = create("trim_pattern");
|
||||||
|
+ /**
|
||||||
|
+ * Data-driven registry for damage types.
|
||||||
|
+ * @see io.papermc.paper.registry.keys.DamageTypeKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<DamageType> DAMAGE_TYPE = create("damage_type");
|
||||||
|
+ /**
|
||||||
|
+ * Data-driven registry for wolf variants.
|
||||||
|
+ * @see io.papermc.paper.registry.keys.WolfVariantKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<Wolf.Variant> WOLF_VARIANT = create("wolf_variant");
|
||||||
|
+ /**
|
||||||
|
+ * Data-driven registry for enchantments.
|
||||||
|
+ * @see io.papermc.paper.registry.keys.EnchantmentKeys
|
||||||
|
+ */
|
||||||
|
+ RegistryKey<Enchantment> ENCHANTMENT = create("enchantment");
|
||||||
|
+ /**
|
||||||
|
+ * Data-driven registry for jukebox songs.
|
||||||
|
+ */
|
||||||
|
+ @ApiStatus.Experimental
|
||||||
|
+ RegistryKey<JukeboxSong> JUKEBOX_SONG = create("jukebox_song");
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ /* ******************* *
|
||||||
|
+ * API-only Registries *
|
||||||
|
+ * ******************* */
|
||||||
|
+ RegistryKey<Art> PAINTING_VARIANT = create("painting_variant");
|
||||||
|
+ RegistryKey<Attribute> ATTRIBUTE = create("attribute");
|
||||||
|
+ RegistryKey<PatternType> BANNER_PATTERN = create("banner_pattern");
|
||||||
|
+ RegistryKey<Cat.Type> CAT_VARIANT = create("cat_variant");
|
||||||
|
+ RegistryKey<EntityType> ENTITY_TYPE = create("entity_type");
|
||||||
|
+ RegistryKey<Particle> PARTICLE_TYPE = create("particle_type");
|
||||||
|
+ RegistryKey<PotionType> POTION = create("potion");
|
||||||
|
+ RegistryKey<Sound> SOUND_EVENT = create("sound_event");
|
||||||
|
+ RegistryKey<Villager.Profession> VILLAGER_PROFESSION = create("villager_profession");
|
||||||
|
+ RegistryKey<Villager.Type> VILLAGER_TYPE = create("villager_type");
|
||||||
|
+ RegistryKey<MemoryKey<?>> MEMORY_MODULE_TYPE = create("memory_module_type");
|
||||||
|
+ RegistryKey<Fluid> FLUID = create("fluid");
|
||||||
|
+ RegistryKey<Frog.Variant> FROG_VARIANT = create("frog_variant");
|
||||||
|
+ RegistryKey<MapCursor.Type> MAP_DECORATION_TYPE = create("map_decoration_type");
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..791813220b2504214b1adecc69093cd600fb0f8c
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/RegistryKeyImpl.java
|
||||||
|
@@ -0,0 +1,24 @@
|
||||||
|
+package io.papermc.paper.registry;
|
||||||
|
+
|
||||||
|
+import com.google.common.collect.Sets;
|
||||||
|
+import java.util.Set;
|
||||||
|
+import net.kyori.adventure.key.Key;
|
||||||
|
+import org.intellij.lang.annotations.Subst;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+record RegistryKeyImpl<T>(@NotNull Key key) implements RegistryKey<T> {
|
||||||
|
+
|
||||||
|
+ static final Set<RegistryKey<?>> REGISTRY_KEYS = Sets.newIdentityHashSet();
|
||||||
|
+
|
||||||
|
+ static <T> RegistryKey<T> create(@Subst("some_key") final String key) {
|
||||||
|
+ final RegistryKey<T> registryKey = createInternal(key);
|
||||||
|
+ REGISTRY_KEYS.add(registryKey);
|
||||||
|
+ return registryKey;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // creates the key without adding to the internal set of keys
|
||||||
|
+ static <T> RegistryKey<T> createInternal(@Subst("some_key") final String key) {
|
||||||
|
+ return new RegistryKeyImpl<>(Key.key(Key.MINECRAFT_NAMESPACE, key));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/TypedKey.java b/src/main/java/io/papermc/paper/registry/TypedKey.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..6f5a062ba7ee7173468ecea3c1855a233bf3855e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/TypedKey.java
|
||||||
|
@@ -0,0 +1,44 @@
|
||||||
|
+package io.papermc.paper.registry;
|
||||||
|
+
|
||||||
|
+import net.kyori.adventure.key.Key;
|
||||||
|
+import net.kyori.adventure.key.Keyed;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Represents a key for a value in a specific registry.
|
||||||
|
+ *
|
||||||
|
+ * @param <T> the value type for the registry
|
||||||
|
+ */
|
||||||
|
+@ApiStatus.Experimental
|
||||||
|
+public sealed interface TypedKey<T> extends Keyed permits TypedKeyImpl {
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the key for the value in the registry.
|
||||||
|
+ *
|
||||||
|
+ * @return the value's key
|
||||||
|
+ */
|
||||||
|
+ @Override
|
||||||
|
+ @NotNull Key key();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the registry key for the value this key
|
||||||
|
+ * represents.
|
||||||
|
+ *
|
||||||
|
+ * @return the registry key
|
||||||
|
+ */
|
||||||
|
+ @NotNull RegistryKey<T> registryKey();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Create a typed key from a key and a registry key.
|
||||||
|
+ *
|
||||||
|
+ * @param registryKey the registry this key is for
|
||||||
|
+ * @param key the key for the value in the registry
|
||||||
|
+ * @param <T> value type
|
||||||
|
+ * @return a new key for the value key and registry key
|
||||||
|
+ */
|
||||||
|
+ @ApiStatus.Experimental
|
||||||
|
+ static <T> @NotNull TypedKey<T> create(final @NotNull RegistryKey<T> registryKey, final @NotNull Key key) {
|
||||||
|
+ return new TypedKeyImpl<>(key, registryKey);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..1a97b3359c4ece5c29131da7c3f208aaa8fab66e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/registry/TypedKeyImpl.java
|
||||||
|
@@ -0,0 +1,8 @@
|
||||||
|
+package io.papermc.paper.registry;
|
||||||
|
+
|
||||||
|
+import net.kyori.adventure.key.Key;
|
||||||
|
+import net.kyori.adventure.key.Keyed;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+record TypedKeyImpl<T>(@NotNull Key key, @NotNull RegistryKey<T> registryKey) implements TypedKey<T> {
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/org/bukkit/MinecraftExperimental.java b/src/main/java/org/bukkit/MinecraftExperimental.java
|
||||||
|
index a86b87e4c3332202e40e484c3f9c6562b419c70f..305532968f9f7dd497c77259ed147ea2f081bc74 100644
|
||||||
|
--- a/src/main/java/org/bukkit/MinecraftExperimental.java
|
||||||
|
+++ b/src/main/java/org/bukkit/MinecraftExperimental.java
|
||||||
|
@@ -47,5 +47,6 @@ public @interface MinecraftExperimental {
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public enum Requires {
|
||||||
|
|
||||||
|
+ BUNDLE, TRADE_REBALANCE // Paper
|
||||||
|
}
|
||||||
|
}
|
19
patches/api/0005-Add-FastUtil-to-Bukkit.patch
Normale Datei
19
patches/api/0005-Add-FastUtil-to-Bukkit.patch
Normale Datei
@ -0,0 +1,19 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aikar <aikar@aikar.co>
|
||||||
|
Date: Fri, 1 Apr 2016 00:02:47 -0400
|
||||||
|
Subject: [PATCH] Add FastUtil to Bukkit
|
||||||
|
|
||||||
|
Doesn't expose to plugins, just allows Paper-API to use it for optimization
|
||||||
|
|
||||||
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
|
index f11a22ab01e97e51619c96f2d8a78a99297efc59..2f266350a787a4cfdfda1b0e760bfb7604cac43c 100644
|
||||||
|
--- a/build.gradle.kts
|
||||||
|
+++ b/build.gradle.kts
|
||||||
|
@@ -23,6 +23,7 @@ dependencies {
|
||||||
|
api("com.googlecode.json-simple:json-simple:1.1.1") {
|
||||||
|
isTransitive = false // includes junit
|
||||||
|
}
|
||||||
|
+ api("it.unimi.dsi:fastutil:8.5.6")
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
compileOnly("org.apache.maven:maven-resolver-provider:3.9.6")
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
5492
patches/api/0006-Adventure.patch
Normale Datei
5492
patches/api/0006-Adventure.patch
Normale Datei
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -1,370 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Techcable <Techcable@outlook.com>
|
|
||||||
Date: Thu, 3 Mar 2016 13:20:33 -0700
|
|
||||||
Subject: [PATCH] Use ASM for event executors.
|
|
||||||
|
|
||||||
Uses method handles for private or static methods.
|
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
|
||||||
index cbab63d2f3b045f6193f5a3422ae4b5509d3003b..ba6f0a70ba2442dbe60ed6cc92e4fb91a48d9f3b 100644
|
|
||||||
--- a/build.gradle.kts
|
|
||||||
+++ b/build.gradle.kts
|
|
||||||
@@ -42,6 +42,9 @@ dependencies {
|
|
||||||
apiAndDocs("net.kyori:adventure-text-serializer-legacy")
|
|
||||||
apiAndDocs("net.kyori:adventure-text-serializer-plain")
|
|
||||||
apiAndDocs("net.kyori:adventure-text-logger-slf4j")
|
|
||||||
+
|
|
||||||
+ implementation("org.ow2.asm:asm:9.4")
|
|
||||||
+ implementation("org.ow2.asm:asm-commons:9.4")
|
|
||||||
// Paper end
|
|
||||||
|
|
||||||
compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java b/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..5b28e9b1daba7834af67dbc193dd656bedd9a994
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java
|
|
||||||
@@ -0,0 +1,42 @@
|
|
||||||
+package com.destroystokyo.paper.event.executor;
|
|
||||||
+
|
|
||||||
+import java.lang.invoke.MethodHandle;
|
|
||||||
+import java.lang.invoke.MethodHandles;
|
|
||||||
+import java.lang.reflect.Method;
|
|
||||||
+
|
|
||||||
+import com.destroystokyo.paper.util.SneakyThrow;
|
|
||||||
+import org.bukkit.event.Event;
|
|
||||||
+import org.bukkit.event.EventException;
|
|
||||||
+import org.bukkit.event.Listener;
|
|
||||||
+import org.bukkit.plugin.EventExecutor;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+
|
|
||||||
+public class MethodHandleEventExecutor implements EventExecutor {
|
|
||||||
+ private final Class<? extends Event> eventClass;
|
|
||||||
+ private final MethodHandle handle;
|
|
||||||
+
|
|
||||||
+ public MethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull MethodHandle handle) {
|
|
||||||
+ this.eventClass = eventClass;
|
|
||||||
+ this.handle = handle;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public MethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull Method m) {
|
|
||||||
+ this.eventClass = eventClass;
|
|
||||||
+ try {
|
|
||||||
+ m.setAccessible(true);
|
|
||||||
+ this.handle = MethodHandles.lookup().unreflect(m);
|
|
||||||
+ } catch (IllegalAccessException e) {
|
|
||||||
+ throw new AssertionError("Unable to set accessible", e);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException {
|
|
||||||
+ if (!eventClass.isInstance(event)) return;
|
|
||||||
+ try {
|
|
||||||
+ handle.invoke(listener, event);
|
|
||||||
+ } catch (Throwable t) {
|
|
||||||
+ SneakyThrow.sneaky(t);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java b/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..c83672427324bd068ed52916f700b68446a226f6
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java
|
|
||||||
@@ -0,0 +1,43 @@
|
|
||||||
+package com.destroystokyo.paper.event.executor;
|
|
||||||
+
|
|
||||||
+import java.lang.invoke.MethodHandle;
|
|
||||||
+import java.lang.invoke.MethodHandles;
|
|
||||||
+import java.lang.reflect.Method;
|
|
||||||
+import java.lang.reflect.Modifier;
|
|
||||||
+
|
|
||||||
+import com.destroystokyo.paper.util.SneakyThrow;
|
|
||||||
+import com.google.common.base.Preconditions;
|
|
||||||
+
|
|
||||||
+import org.bukkit.Bukkit;
|
|
||||||
+import org.bukkit.event.Event;
|
|
||||||
+import org.bukkit.event.EventException;
|
|
||||||
+import org.bukkit.event.Listener;
|
|
||||||
+import org.bukkit.plugin.EventExecutor;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+
|
|
||||||
+public class StaticMethodHandleEventExecutor implements EventExecutor {
|
|
||||||
+ private final Class<? extends Event> eventClass;
|
|
||||||
+ private final MethodHandle handle;
|
|
||||||
+
|
|
||||||
+ public StaticMethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull Method m) {
|
|
||||||
+ Preconditions.checkArgument(Modifier.isStatic(m.getModifiers()), "Not a static method: %s", m);
|
|
||||||
+ Preconditions.checkArgument(eventClass != null, "eventClass is null");
|
|
||||||
+ this.eventClass = eventClass;
|
|
||||||
+ try {
|
|
||||||
+ m.setAccessible(true);
|
|
||||||
+ this.handle = MethodHandles.lookup().unreflect(m);
|
|
||||||
+ } catch (IllegalAccessException e) {
|
|
||||||
+ throw new AssertionError("Unable to set accessible", e);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException {
|
|
||||||
+ if (!eventClass.isInstance(event)) return;
|
|
||||||
+ try {
|
|
||||||
+ handle.invoke(event);
|
|
||||||
+ } catch (Throwable throwable) {
|
|
||||||
+ SneakyThrow.sneaky(throwable);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/asm/ASMEventExecutorGenerator.java b/src/main/java/com/destroystokyo/paper/event/executor/asm/ASMEventExecutorGenerator.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..084c31af1a7ba32bb4c3dc8f16f67fd09ce0b6a4
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/event/executor/asm/ASMEventExecutorGenerator.java
|
|
||||||
@@ -0,0 +1,54 @@
|
|
||||||
+package com.destroystokyo.paper.event.executor.asm;
|
|
||||||
+
|
|
||||||
+import java.lang.reflect.Method;
|
|
||||||
+import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
+
|
|
||||||
+import org.bukkit.plugin.EventExecutor;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+import org.objectweb.asm.ClassWriter;
|
|
||||||
+import org.objectweb.asm.Type;
|
|
||||||
+import org.objectweb.asm.commons.GeneratorAdapter;
|
|
||||||
+
|
|
||||||
+import static org.objectweb.asm.Opcodes.*;
|
|
||||||
+
|
|
||||||
+public class ASMEventExecutorGenerator {
|
|
||||||
+
|
|
||||||
+ private static final String EXECUTE_DESCRIPTOR = "(Lorg/bukkit/event/Listener;Lorg/bukkit/event/Event;)V";
|
|
||||||
+
|
|
||||||
+ @NotNull
|
|
||||||
+ public static byte[] generateEventExecutor(@NotNull Method m, @NotNull String name) {
|
|
||||||
+ ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
|
||||||
+ writer.visit(V1_8, ACC_PUBLIC, name.replace('.', '/'), null, Type.getInternalName(Object.class), new String[] {Type.getInternalName(EventExecutor.class)});
|
|
||||||
+ // Generate constructor
|
|
||||||
+ GeneratorAdapter methodGenerator = new GeneratorAdapter(writer.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null), ACC_PUBLIC, "<init>", "()V");
|
|
||||||
+ methodGenerator.loadThis();
|
|
||||||
+ methodGenerator.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(Object.class), "<init>", "()V", false); // Invoke the super class (Object) constructor
|
|
||||||
+ methodGenerator.returnValue();
|
|
||||||
+ methodGenerator.endMethod();
|
|
||||||
+ // Generate the execute method
|
|
||||||
+ methodGenerator = new GeneratorAdapter(writer.visitMethod(ACC_PUBLIC, "execute", EXECUTE_DESCRIPTOR, null, null), ACC_PUBLIC, "execute", EXECUTE_DESCRIPTOR);
|
|
||||||
+ methodGenerator.loadArg(0);
|
|
||||||
+ methodGenerator.checkCast(Type.getType(m.getDeclaringClass()));
|
|
||||||
+ methodGenerator.loadArg(1);
|
|
||||||
+ methodGenerator.checkCast(Type.getType(m.getParameterTypes()[0]));
|
|
||||||
+ methodGenerator.visitMethodInsn(m.getDeclaringClass().isInterface() ? INVOKEINTERFACE : INVOKEVIRTUAL, Type.getInternalName(m.getDeclaringClass()), m.getName(), Type.getMethodDescriptor(m), m.getDeclaringClass().isInterface());
|
|
||||||
+ // The only purpose of this switch statement is to generate the correct pop instruction, should the event handler method return something other than void.
|
|
||||||
+ // Non-void event handlers will be unsupported in a future release.
|
|
||||||
+ switch (Type.getType(m.getReturnType()).getSize()) {
|
|
||||||
+ // case 0 is omitted because the only type that has size 0 is void - no pop instruction needed.
|
|
||||||
+ case 1 -> methodGenerator.pop(); // handles reference types and most primitives
|
|
||||||
+ case 2 -> methodGenerator.pop2(); // handles long and double
|
|
||||||
+ }
|
|
||||||
+ methodGenerator.returnValue();
|
|
||||||
+ methodGenerator.endMethod();
|
|
||||||
+ writer.visitEnd();
|
|
||||||
+ return writer.toByteArray();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static AtomicInteger NEXT_ID = new AtomicInteger(1);
|
|
||||||
+ @NotNull
|
|
||||||
+ public static String generateName() {
|
|
||||||
+ int id = NEXT_ID.getAndIncrement();
|
|
||||||
+ return "com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor" + id;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/asm/ClassDefiner.java b/src/main/java/com/destroystokyo/paper/event/executor/asm/ClassDefiner.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..f79685b48bb581277a6891927988b6f7a4389dc4
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/event/executor/asm/ClassDefiner.java
|
|
||||||
@@ -0,0 +1,34 @@
|
|
||||||
+package com.destroystokyo.paper.event.executor.asm;
|
|
||||||
+
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+
|
|
||||||
+public interface ClassDefiner {
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Returns if the defined classes can bypass access checks
|
|
||||||
+ *
|
|
||||||
+ * @return if classes bypass access checks
|
|
||||||
+ */
|
|
||||||
+ public default boolean isBypassAccessChecks() {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Define a class
|
|
||||||
+ *
|
|
||||||
+ * @param parentLoader the parent classloader
|
|
||||||
+ * @param name the name of the class
|
|
||||||
+ * @param data the class data to load
|
|
||||||
+ * @return the defined class
|
|
||||||
+ * @throws ClassFormatError if the class data is invalid
|
|
||||||
+ * @throws NullPointerException if any of the arguments are null
|
|
||||||
+ */
|
|
||||||
+ @NotNull
|
|
||||||
+ public Class<?> defineClass(@NotNull ClassLoader parentLoader, @NotNull String name, @NotNull byte[] data);
|
|
||||||
+
|
|
||||||
+ @NotNull
|
|
||||||
+ public static ClassDefiner getInstance() {
|
|
||||||
+ return SafeClassDefiner.INSTANCE;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/asm/SafeClassDefiner.java b/src/main/java/com/destroystokyo/paper/event/executor/asm/SafeClassDefiner.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..ac99477e9f2c08041aeff31abc1d1edee58d0a67
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/event/executor/asm/SafeClassDefiner.java
|
|
||||||
@@ -0,0 +1,66 @@
|
|
||||||
+package com.destroystokyo.paper.event.executor.asm;
|
|
||||||
+
|
|
||||||
+import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
+import java.util.concurrent.ConcurrentMap;
|
|
||||||
+
|
|
||||||
+import com.google.common.base.Preconditions;
|
|
||||||
+
|
|
||||||
+import com.google.common.collect.MapMaker;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+import org.objectweb.asm.Type;
|
|
||||||
+
|
|
||||||
+public class SafeClassDefiner implements ClassDefiner {
|
|
||||||
+ /* default */ static final SafeClassDefiner INSTANCE = new SafeClassDefiner();
|
|
||||||
+
|
|
||||||
+ private SafeClassDefiner() {}
|
|
||||||
+
|
|
||||||
+ private final ConcurrentMap<ClassLoader, GeneratedClassLoader> loaders = new MapMaker().weakKeys().makeMap();
|
|
||||||
+
|
|
||||||
+ @NotNull
|
|
||||||
+ @Override
|
|
||||||
+ public Class<?> defineClass(@NotNull ClassLoader parentLoader, @NotNull String name, @NotNull byte[] data) {
|
|
||||||
+ GeneratedClassLoader loader = loaders.computeIfAbsent(parentLoader, GeneratedClassLoader::new);
|
|
||||||
+ synchronized (loader.getClassLoadingLock(name)) {
|
|
||||||
+ Preconditions.checkState(!loader.hasClass(name), "%s already defined", name);
|
|
||||||
+ Class<?> c = loader.define(name, data);
|
|
||||||
+ assert c.getName().equals(name);
|
|
||||||
+ return c;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static class GeneratedClassLoader extends ClassLoader {
|
|
||||||
+ static {
|
|
||||||
+ ClassLoader.registerAsParallelCapable();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ protected GeneratedClassLoader(@NotNull ClassLoader parent) {
|
|
||||||
+ super(parent);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private Class<?> define(@NotNull String name, byte[] data) {
|
|
||||||
+ synchronized (getClassLoadingLock(name)) {
|
|
||||||
+ assert !hasClass(name);
|
|
||||||
+ Class<?> c = defineClass(name, data, 0, data.length);
|
|
||||||
+ resolveClass(c);
|
|
||||||
+ return c;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ @NotNull
|
|
||||||
+ public Object getClassLoadingLock(@NotNull String name) {
|
|
||||||
+ return super.getClassLoadingLock(name);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public boolean hasClass(@NotNull String name) {
|
|
||||||
+ synchronized (getClassLoadingLock(name)) {
|
|
||||||
+ try {
|
|
||||||
+ Class.forName(name);
|
|
||||||
+ return true;
|
|
||||||
+ } catch (ClassNotFoundException e) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/org/bukkit/plugin/EventExecutor.java b/src/main/java/org/bukkit/plugin/EventExecutor.java
|
|
||||||
index a850f0780de05463fc0d3f9e15ff7f19d88b2aed..9026e108ccd3a88aee1267ee275137befa646455 100644
|
|
||||||
--- a/src/main/java/org/bukkit/plugin/EventExecutor.java
|
|
||||||
+++ b/src/main/java/org/bukkit/plugin/EventExecutor.java
|
|
||||||
@@ -5,9 +5,75 @@ import org.bukkit.event.EventException;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
+// Paper start
|
|
||||||
+import java.lang.reflect.Method;
|
|
||||||
+import java.lang.reflect.Modifier;
|
|
||||||
+import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
+import java.util.concurrent.ConcurrentMap;
|
|
||||||
+import java.util.function.Function;
|
|
||||||
+
|
|
||||||
+import com.destroystokyo.paper.event.executor.MethodHandleEventExecutor;
|
|
||||||
+import com.destroystokyo.paper.event.executor.StaticMethodHandleEventExecutor;
|
|
||||||
+import com.destroystokyo.paper.event.executor.asm.ASMEventExecutorGenerator;
|
|
||||||
+import com.destroystokyo.paper.event.executor.asm.ClassDefiner;
|
|
||||||
+import com.google.common.base.Preconditions;
|
|
||||||
+// Paper end
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Interface which defines the class for event call backs to plugins
|
|
||||||
*/
|
|
||||||
public interface EventExecutor {
|
|
||||||
public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException;
|
|
||||||
+
|
|
||||||
+ // Paper start
|
|
||||||
+ ConcurrentMap<Method, Class<? extends EventExecutor>> eventExecutorMap = new ConcurrentHashMap<Method, Class<? extends EventExecutor>>() {
|
|
||||||
+ @NotNull
|
|
||||||
+ @Override
|
|
||||||
+ public Class<? extends EventExecutor> computeIfAbsent(@NotNull Method key, @NotNull Function<? super Method, ? extends Class<? extends EventExecutor>> mappingFunction) {
|
|
||||||
+ Class<? extends EventExecutor> executorClass = get(key);
|
|
||||||
+ if (executorClass != null)
|
|
||||||
+ return executorClass;
|
|
||||||
+
|
|
||||||
+ //noinspection SynchronizationOnLocalVariableOrMethodParameter
|
|
||||||
+ synchronized (key) {
|
|
||||||
+ executorClass = get(key);
|
|
||||||
+ if (executorClass != null)
|
|
||||||
+ return executorClass;
|
|
||||||
+
|
|
||||||
+ return super.computeIfAbsent(key, mappingFunction);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ @NotNull
|
|
||||||
+ public static EventExecutor create(@NotNull Method m, @NotNull Class<? extends Event> eventClass) {
|
|
||||||
+ Preconditions.checkNotNull(m, "Null method");
|
|
||||||
+ Preconditions.checkArgument(m.getParameterCount() != 0, "Incorrect number of arguments %s", m.getParameterCount());
|
|
||||||
+ Preconditions.checkArgument(m.getParameterTypes()[0] == eventClass, "First parameter %s doesn't match event class %s", m.getParameterTypes()[0], eventClass);
|
|
||||||
+ ClassDefiner definer = ClassDefiner.getInstance();
|
|
||||||
+ if (Modifier.isStatic(m.getModifiers())) {
|
|
||||||
+ return new StaticMethodHandleEventExecutor(eventClass, m);
|
|
||||||
+ } else if (definer.isBypassAccessChecks() || Modifier.isPublic(m.getDeclaringClass().getModifiers()) && Modifier.isPublic(m.getModifiers())) {
|
|
||||||
+ // get the existing generated EventExecutor class for the Method or generate one
|
|
||||||
+ Class<? extends EventExecutor> executorClass = eventExecutorMap.computeIfAbsent(m, (__) -> {
|
|
||||||
+ String name = ASMEventExecutorGenerator.generateName();
|
|
||||||
+ byte[] classData = ASMEventExecutorGenerator.generateEventExecutor(m, name);
|
|
||||||
+ return definer.defineClass(m.getDeclaringClass().getClassLoader(), name, classData).asSubclass(EventExecutor.class);
|
|
||||||
+ });
|
|
||||||
+
|
|
||||||
+ try {
|
|
||||||
+ EventExecutor asmExecutor = executorClass.newInstance();
|
|
||||||
+ // Define a wrapper to conform to bukkit stupidity (passing in events that don't match and wrapper exception)
|
|
||||||
+ return (listener, event) -> {
|
|
||||||
+ if (!eventClass.isInstance(event)) return;
|
|
||||||
+ asmExecutor.execute(listener, event);
|
|
||||||
+ };
|
|
||||||
+ } catch (InstantiationException | IllegalAccessException e) {
|
|
||||||
+ throw new AssertionError("Unable to initialize generated event executor", e);
|
|
||||||
+ }
|
|
||||||
+ } else {
|
|
||||||
+ return new MethodHandleEventExecutor(eventClass, m);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
367
patches/api/0008-Use-ASM-for-event-executors.patch
Normale Datei
367
patches/api/0008-Use-ASM-for-event-executors.patch
Normale Datei
@ -0,0 +1,367 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Techcable <Techcable@outlook.com>
|
||||||
|
Date: Thu, 3 Mar 2016 13:20:33 -0700
|
||||||
|
Subject: [PATCH] Use ASM for event executors.
|
||||||
|
|
||||||
|
Uses method handles for private or static methods.
|
||||||
|
|
||||||
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
|
index af3514113abdf3f42c41f1e7ff0f930cc1a417f5..ed0b67ac322aa22b191cd35502ae5b4f20af19f8 100644
|
||||||
|
--- a/build.gradle.kts
|
||||||
|
+++ b/build.gradle.kts
|
||||||
|
@@ -47,6 +47,9 @@ dependencies {
|
||||||
|
apiAndDocs("net.kyori:adventure-text-serializer-legacy")
|
||||||
|
apiAndDocs("net.kyori:adventure-text-serializer-plain")
|
||||||
|
apiAndDocs("net.kyori:adventure-text-logger-slf4j")
|
||||||
|
+
|
||||||
|
+ implementation("org.ow2.asm:asm:9.7")
|
||||||
|
+ implementation("org.ow2.asm:asm-commons:9.7")
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
compileOnly("org.apache.maven:maven-resolver-provider:3.9.6")
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java b/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..5b28e9b1daba7834af67dbc193dd656bedd9a994
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/event/executor/MethodHandleEventExecutor.java
|
||||||
|
@@ -0,0 +1,42 @@
|
||||||
|
+package com.destroystokyo.paper.event.executor;
|
||||||
|
+
|
||||||
|
+import java.lang.invoke.MethodHandle;
|
||||||
|
+import java.lang.invoke.MethodHandles;
|
||||||
|
+import java.lang.reflect.Method;
|
||||||
|
+
|
||||||
|
+import com.destroystokyo.paper.util.SneakyThrow;
|
||||||
|
+import org.bukkit.event.Event;
|
||||||
|
+import org.bukkit.event.EventException;
|
||||||
|
+import org.bukkit.event.Listener;
|
||||||
|
+import org.bukkit.plugin.EventExecutor;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+public class MethodHandleEventExecutor implements EventExecutor {
|
||||||
|
+ private final Class<? extends Event> eventClass;
|
||||||
|
+ private final MethodHandle handle;
|
||||||
|
+
|
||||||
|
+ public MethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull MethodHandle handle) {
|
||||||
|
+ this.eventClass = eventClass;
|
||||||
|
+ this.handle = handle;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public MethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull Method m) {
|
||||||
|
+ this.eventClass = eventClass;
|
||||||
|
+ try {
|
||||||
|
+ m.setAccessible(true);
|
||||||
|
+ this.handle = MethodHandles.lookup().unreflect(m);
|
||||||
|
+ } catch (IllegalAccessException e) {
|
||||||
|
+ throw new AssertionError("Unable to set accessible", e);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException {
|
||||||
|
+ if (!eventClass.isInstance(event)) return;
|
||||||
|
+ try {
|
||||||
|
+ handle.invoke(listener, event);
|
||||||
|
+ } catch (Throwable t) {
|
||||||
|
+ SneakyThrow.sneaky(t);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java b/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..827f2b27f70a7ec0bc11d039305c3e58c02a4ef4
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/event/executor/StaticMethodHandleEventExecutor.java
|
||||||
|
@@ -0,0 +1,42 @@
|
||||||
|
+package com.destroystokyo.paper.event.executor;
|
||||||
|
+
|
||||||
|
+import java.lang.invoke.MethodHandle;
|
||||||
|
+import java.lang.invoke.MethodHandles;
|
||||||
|
+import java.lang.reflect.Method;
|
||||||
|
+import java.lang.reflect.Modifier;
|
||||||
|
+
|
||||||
|
+import com.destroystokyo.paper.util.SneakyThrow;
|
||||||
|
+import com.google.common.base.Preconditions;
|
||||||
|
+
|
||||||
|
+import org.bukkit.event.Event;
|
||||||
|
+import org.bukkit.event.EventException;
|
||||||
|
+import org.bukkit.event.Listener;
|
||||||
|
+import org.bukkit.plugin.EventExecutor;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+public class StaticMethodHandleEventExecutor implements EventExecutor {
|
||||||
|
+ private final Class<? extends Event> eventClass;
|
||||||
|
+ private final MethodHandle handle;
|
||||||
|
+
|
||||||
|
+ public StaticMethodHandleEventExecutor(@NotNull Class<? extends Event> eventClass, @NotNull Method m) {
|
||||||
|
+ Preconditions.checkArgument(Modifier.isStatic(m.getModifiers()), "Not a static method: %s", m);
|
||||||
|
+ Preconditions.checkArgument(eventClass != null, "eventClass is null");
|
||||||
|
+ this.eventClass = eventClass;
|
||||||
|
+ try {
|
||||||
|
+ m.setAccessible(true);
|
||||||
|
+ this.handle = MethodHandles.lookup().unreflect(m);
|
||||||
|
+ } catch (IllegalAccessException e) {
|
||||||
|
+ throw new AssertionError("Unable to set accessible", e);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException {
|
||||||
|
+ if (!eventClass.isInstance(event)) return;
|
||||||
|
+ try {
|
||||||
|
+ handle.invoke(event);
|
||||||
|
+ } catch (Throwable throwable) {
|
||||||
|
+ SneakyThrow.sneaky(throwable);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/asm/ASMEventExecutorGenerator.java b/src/main/java/com/destroystokyo/paper/event/executor/asm/ASMEventExecutorGenerator.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..084c31af1a7ba32bb4c3dc8f16f67fd09ce0b6a4
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/event/executor/asm/ASMEventExecutorGenerator.java
|
||||||
|
@@ -0,0 +1,54 @@
|
||||||
|
+package com.destroystokyo.paper.event.executor.asm;
|
||||||
|
+
|
||||||
|
+import java.lang.reflect.Method;
|
||||||
|
+import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
+
|
||||||
|
+import org.bukkit.plugin.EventExecutor;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+import org.objectweb.asm.ClassWriter;
|
||||||
|
+import org.objectweb.asm.Type;
|
||||||
|
+import org.objectweb.asm.commons.GeneratorAdapter;
|
||||||
|
+
|
||||||
|
+import static org.objectweb.asm.Opcodes.*;
|
||||||
|
+
|
||||||
|
+public class ASMEventExecutorGenerator {
|
||||||
|
+
|
||||||
|
+ private static final String EXECUTE_DESCRIPTOR = "(Lorg/bukkit/event/Listener;Lorg/bukkit/event/Event;)V";
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ public static byte[] generateEventExecutor(@NotNull Method m, @NotNull String name) {
|
||||||
|
+ ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||||
|
+ writer.visit(V1_8, ACC_PUBLIC, name.replace('.', '/'), null, Type.getInternalName(Object.class), new String[] {Type.getInternalName(EventExecutor.class)});
|
||||||
|
+ // Generate constructor
|
||||||
|
+ GeneratorAdapter methodGenerator = new GeneratorAdapter(writer.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null), ACC_PUBLIC, "<init>", "()V");
|
||||||
|
+ methodGenerator.loadThis();
|
||||||
|
+ methodGenerator.visitMethodInsn(INVOKESPECIAL, Type.getInternalName(Object.class), "<init>", "()V", false); // Invoke the super class (Object) constructor
|
||||||
|
+ methodGenerator.returnValue();
|
||||||
|
+ methodGenerator.endMethod();
|
||||||
|
+ // Generate the execute method
|
||||||
|
+ methodGenerator = new GeneratorAdapter(writer.visitMethod(ACC_PUBLIC, "execute", EXECUTE_DESCRIPTOR, null, null), ACC_PUBLIC, "execute", EXECUTE_DESCRIPTOR);
|
||||||
|
+ methodGenerator.loadArg(0);
|
||||||
|
+ methodGenerator.checkCast(Type.getType(m.getDeclaringClass()));
|
||||||
|
+ methodGenerator.loadArg(1);
|
||||||
|
+ methodGenerator.checkCast(Type.getType(m.getParameterTypes()[0]));
|
||||||
|
+ methodGenerator.visitMethodInsn(m.getDeclaringClass().isInterface() ? INVOKEINTERFACE : INVOKEVIRTUAL, Type.getInternalName(m.getDeclaringClass()), m.getName(), Type.getMethodDescriptor(m), m.getDeclaringClass().isInterface());
|
||||||
|
+ // The only purpose of this switch statement is to generate the correct pop instruction, should the event handler method return something other than void.
|
||||||
|
+ // Non-void event handlers will be unsupported in a future release.
|
||||||
|
+ switch (Type.getType(m.getReturnType()).getSize()) {
|
||||||
|
+ // case 0 is omitted because the only type that has size 0 is void - no pop instruction needed.
|
||||||
|
+ case 1 -> methodGenerator.pop(); // handles reference types and most primitives
|
||||||
|
+ case 2 -> methodGenerator.pop2(); // handles long and double
|
||||||
|
+ }
|
||||||
|
+ methodGenerator.returnValue();
|
||||||
|
+ methodGenerator.endMethod();
|
||||||
|
+ writer.visitEnd();
|
||||||
|
+ return writer.toByteArray();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static AtomicInteger NEXT_ID = new AtomicInteger(1);
|
||||||
|
+ @NotNull
|
||||||
|
+ public static String generateName() {
|
||||||
|
+ int id = NEXT_ID.getAndIncrement();
|
||||||
|
+ return "com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor" + id;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/asm/ClassDefiner.java b/src/main/java/com/destroystokyo/paper/event/executor/asm/ClassDefiner.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..f79685b48bb581277a6891927988b6f7a4389dc4
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/event/executor/asm/ClassDefiner.java
|
||||||
|
@@ -0,0 +1,34 @@
|
||||||
|
+package com.destroystokyo.paper.event.executor.asm;
|
||||||
|
+
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+public interface ClassDefiner {
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Returns if the defined classes can bypass access checks
|
||||||
|
+ *
|
||||||
|
+ * @return if classes bypass access checks
|
||||||
|
+ */
|
||||||
|
+ public default boolean isBypassAccessChecks() {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Define a class
|
||||||
|
+ *
|
||||||
|
+ * @param parentLoader the parent classloader
|
||||||
|
+ * @param name the name of the class
|
||||||
|
+ * @param data the class data to load
|
||||||
|
+ * @return the defined class
|
||||||
|
+ * @throws ClassFormatError if the class data is invalid
|
||||||
|
+ * @throws NullPointerException if any of the arguments are null
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public Class<?> defineClass(@NotNull ClassLoader parentLoader, @NotNull String name, @NotNull byte[] data);
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ public static ClassDefiner getInstance() {
|
||||||
|
+ return SafeClassDefiner.INSTANCE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/event/executor/asm/SafeClassDefiner.java b/src/main/java/com/destroystokyo/paper/event/executor/asm/SafeClassDefiner.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..abcc966d8ee01d73c1d1480237ab46fa0ab55fdc
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/event/executor/asm/SafeClassDefiner.java
|
||||||
|
@@ -0,0 +1,64 @@
|
||||||
|
+package com.destroystokyo.paper.event.executor.asm;
|
||||||
|
+
|
||||||
|
+import java.util.concurrent.ConcurrentMap;
|
||||||
|
+
|
||||||
|
+import com.google.common.base.Preconditions;
|
||||||
|
+
|
||||||
|
+import com.google.common.collect.MapMaker;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+public class SafeClassDefiner implements ClassDefiner {
|
||||||
|
+ /* default */ static final SafeClassDefiner INSTANCE = new SafeClassDefiner();
|
||||||
|
+
|
||||||
|
+ private SafeClassDefiner() {}
|
||||||
|
+
|
||||||
|
+ private final ConcurrentMap<ClassLoader, GeneratedClassLoader> loaders = new MapMaker().weakKeys().makeMap();
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ @Override
|
||||||
|
+ public Class<?> defineClass(@NotNull ClassLoader parentLoader, @NotNull String name, @NotNull byte[] data) {
|
||||||
|
+ GeneratedClassLoader loader = loaders.computeIfAbsent(parentLoader, GeneratedClassLoader::new);
|
||||||
|
+ synchronized (loader.getClassLoadingLock(name)) {
|
||||||
|
+ Preconditions.checkState(!loader.hasClass(name), "%s already defined", name);
|
||||||
|
+ Class<?> c = loader.define(name, data);
|
||||||
|
+ assert c.getName().equals(name);
|
||||||
|
+ return c;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static class GeneratedClassLoader extends ClassLoader {
|
||||||
|
+ static {
|
||||||
|
+ ClassLoader.registerAsParallelCapable();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected GeneratedClassLoader(@NotNull ClassLoader parent) {
|
||||||
|
+ super(parent);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private Class<?> define(@NotNull String name, byte[] data) {
|
||||||
|
+ synchronized (getClassLoadingLock(name)) {
|
||||||
|
+ assert !hasClass(name);
|
||||||
|
+ Class<?> c = defineClass(name, data, 0, data.length);
|
||||||
|
+ resolveClass(c);
|
||||||
|
+ return c;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ @NotNull
|
||||||
|
+ public Object getClassLoadingLock(@NotNull String name) {
|
||||||
|
+ return super.getClassLoadingLock(name);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean hasClass(@NotNull String name) {
|
||||||
|
+ synchronized (getClassLoadingLock(name)) {
|
||||||
|
+ try {
|
||||||
|
+ Class.forName(name);
|
||||||
|
+ return true;
|
||||||
|
+ } catch (ClassNotFoundException e) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/org/bukkit/plugin/EventExecutor.java b/src/main/java/org/bukkit/plugin/EventExecutor.java
|
||||||
|
index a850f0780de05463fc0d3f9e15ff7f19d88b2aed..9026e108ccd3a88aee1267ee275137befa646455 100644
|
||||||
|
--- a/src/main/java/org/bukkit/plugin/EventExecutor.java
|
||||||
|
+++ b/src/main/java/org/bukkit/plugin/EventExecutor.java
|
||||||
|
@@ -5,9 +5,75 @@ import org.bukkit.event.EventException;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
+// Paper start
|
||||||
|
+import java.lang.reflect.Method;
|
||||||
|
+import java.lang.reflect.Modifier;
|
||||||
|
+import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
+import java.util.concurrent.ConcurrentMap;
|
||||||
|
+import java.util.function.Function;
|
||||||
|
+
|
||||||
|
+import com.destroystokyo.paper.event.executor.MethodHandleEventExecutor;
|
||||||
|
+import com.destroystokyo.paper.event.executor.StaticMethodHandleEventExecutor;
|
||||||
|
+import com.destroystokyo.paper.event.executor.asm.ASMEventExecutorGenerator;
|
||||||
|
+import com.destroystokyo.paper.event.executor.asm.ClassDefiner;
|
||||||
|
+import com.google.common.base.Preconditions;
|
||||||
|
+// Paper end
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Interface which defines the class for event call backs to plugins
|
||||||
|
*/
|
||||||
|
public interface EventExecutor {
|
||||||
|
public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException;
|
||||||
|
+
|
||||||
|
+ // Paper start
|
||||||
|
+ ConcurrentMap<Method, Class<? extends EventExecutor>> eventExecutorMap = new ConcurrentHashMap<Method, Class<? extends EventExecutor>>() {
|
||||||
|
+ @NotNull
|
||||||
|
+ @Override
|
||||||
|
+ public Class<? extends EventExecutor> computeIfAbsent(@NotNull Method key, @NotNull Function<? super Method, ? extends Class<? extends EventExecutor>> mappingFunction) {
|
||||||
|
+ Class<? extends EventExecutor> executorClass = get(key);
|
||||||
|
+ if (executorClass != null)
|
||||||
|
+ return executorClass;
|
||||||
|
+
|
||||||
|
+ //noinspection SynchronizationOnLocalVariableOrMethodParameter
|
||||||
|
+ synchronized (key) {
|
||||||
|
+ executorClass = get(key);
|
||||||
|
+ if (executorClass != null)
|
||||||
|
+ return executorClass;
|
||||||
|
+
|
||||||
|
+ return super.computeIfAbsent(key, mappingFunction);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ };
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ public static EventExecutor create(@NotNull Method m, @NotNull Class<? extends Event> eventClass) {
|
||||||
|
+ Preconditions.checkNotNull(m, "Null method");
|
||||||
|
+ Preconditions.checkArgument(m.getParameterCount() != 0, "Incorrect number of arguments %s", m.getParameterCount());
|
||||||
|
+ Preconditions.checkArgument(m.getParameterTypes()[0] == eventClass, "First parameter %s doesn't match event class %s", m.getParameterTypes()[0], eventClass);
|
||||||
|
+ ClassDefiner definer = ClassDefiner.getInstance();
|
||||||
|
+ if (Modifier.isStatic(m.getModifiers())) {
|
||||||
|
+ return new StaticMethodHandleEventExecutor(eventClass, m);
|
||||||
|
+ } else if (definer.isBypassAccessChecks() || Modifier.isPublic(m.getDeclaringClass().getModifiers()) && Modifier.isPublic(m.getModifiers())) {
|
||||||
|
+ // get the existing generated EventExecutor class for the Method or generate one
|
||||||
|
+ Class<? extends EventExecutor> executorClass = eventExecutorMap.computeIfAbsent(m, (__) -> {
|
||||||
|
+ String name = ASMEventExecutorGenerator.generateName();
|
||||||
|
+ byte[] classData = ASMEventExecutorGenerator.generateEventExecutor(m, name);
|
||||||
|
+ return definer.defineClass(m.getDeclaringClass().getClassLoader(), name, classData).asSubclass(EventExecutor.class);
|
||||||
|
+ });
|
||||||
|
+
|
||||||
|
+ try {
|
||||||
|
+ EventExecutor asmExecutor = executorClass.newInstance();
|
||||||
|
+ // Define a wrapper to conform to bukkit stupidity (passing in events that don't match and wrapper exception)
|
||||||
|
+ return (listener, event) -> {
|
||||||
|
+ if (!eventClass.isInstance(event)) return;
|
||||||
|
+ asmExecutor.execute(listener, event);
|
||||||
|
+ };
|
||||||
|
+ } catch (InstantiationException | IllegalAccessException e) {
|
||||||
|
+ throw new AssertionError("Unable to initialize generated event executor", e);
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ return new MethodHandleEventExecutor(eventClass, m);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
@ -1,422 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
||||||
Date: Sun, 20 Mar 2022 10:42:28 -0700
|
|
||||||
Subject: [PATCH] Add Position
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/math/BlockPosition.java b/src/main/java/io/papermc/paper/math/BlockPosition.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..f0fdabce4af640da2a406412e67020761ded3ac1
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/io/papermc/paper/math/BlockPosition.java
|
|
||||||
@@ -0,0 +1,98 @@
|
|
||||||
+package io.papermc.paper.math;
|
|
||||||
+
|
|
||||||
+import org.bukkit.Axis;
|
|
||||||
+import org.bukkit.block.BlockFace;
|
|
||||||
+import org.jetbrains.annotations.ApiStatus;
|
|
||||||
+import org.jetbrains.annotations.Contract;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * A position represented with integers.
|
|
||||||
+ * <p>
|
|
||||||
+ * <b>May see breaking changes until Experimental annotation is removed.</b>
|
|
||||||
+ * @see FinePosition
|
|
||||||
+ */
|
|
||||||
+@ApiStatus.Experimental
|
|
||||||
+public interface BlockPosition extends Position {
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default double x() {
|
|
||||||
+ return this.blockX();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default double y() {
|
|
||||||
+ return this.blockY();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default double z() {
|
|
||||||
+ return this.blockZ();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default boolean isBlock() {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default boolean isFine() {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default @NotNull BlockPosition toBlock() {
|
|
||||||
+ return this;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default @NotNull BlockPosition offset(int x, int y, int z) {
|
|
||||||
+ return x == 0 && y == 0 && z == 0 ? this : new BlockPositionImpl(this.blockX() + x, this.blockY() + y, this.blockZ() + z);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default @NotNull FinePosition offset(double x, double y, double z) {
|
|
||||||
+ return new FinePositionImpl(this.blockX() + x, this.blockY() + y, this.blockZ() + z);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Returns a block position offset by 1 in the direction specified.
|
|
||||||
+ *
|
|
||||||
+ * @param blockFace the block face to offset towards
|
|
||||||
+ * @return the offset block position
|
|
||||||
+ */
|
|
||||||
+ @Contract(value = "_ -> new", pure = true)
|
|
||||||
+ default @NotNull BlockPosition offset(@NotNull BlockFace blockFace) {
|
|
||||||
+ return this.offset(blockFace, 1);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Returns a block position offset in the direction specified
|
|
||||||
+ * multiplied by the amount.
|
|
||||||
+ *
|
|
||||||
+ * @param blockFace the block face to offset towards
|
|
||||||
+ * @param amount the number of times to move in that direction
|
|
||||||
+ * @return the offset block position
|
|
||||||
+ */
|
|
||||||
+ @Contract(pure = true)
|
|
||||||
+ default @NotNull BlockPosition offset(@NotNull BlockFace blockFace, int amount) {
|
|
||||||
+ return amount == 0 ? this : new BlockPositionImpl(this.blockX() + (blockFace.getModX() * amount), this.blockY() + (blockFace.getModY() * amount), this.blockZ() + (blockFace.getModZ() * amount));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Returns a block position offset by the amount along
|
|
||||||
+ * the specified axis.
|
|
||||||
+ *
|
|
||||||
+ * @param axis the axis to offset along
|
|
||||||
+ * @param amount the amount to offset along that axis
|
|
||||||
+ * @return the offset block position
|
|
||||||
+ */
|
|
||||||
+ @Contract(pure = true)
|
|
||||||
+ default @NotNull BlockPosition offset(@NotNull Axis axis, int amount) {
|
|
||||||
+ return amount == 0 ? this : switch (axis) {
|
|
||||||
+ case X -> new BlockPositionImpl(this.blockX() + amount, this.blockY(), this.blockZ());
|
|
||||||
+ case Y -> new BlockPositionImpl(this.blockX(), this.blockY() + amount, this.blockZ());
|
|
||||||
+ case Z -> new BlockPositionImpl(this.blockX(), this.blockY(), this.blockZ() + amount);
|
|
||||||
+ };
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/math/BlockPositionImpl.java b/src/main/java/io/papermc/paper/math/BlockPositionImpl.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..eb5a3f26c7ba56c6715827f52c0013a860ec7d9a
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/io/papermc/paper/math/BlockPositionImpl.java
|
|
||||||
@@ -0,0 +1,4 @@
|
|
||||||
+package io.papermc.paper.math;
|
|
||||||
+
|
|
||||||
+record BlockPositionImpl(int blockX, int blockY, int blockZ) implements BlockPosition {
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/math/FinePosition.java b/src/main/java/io/papermc/paper/math/FinePosition.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..d8df70d731573cf2446044925f218876d62fd7cf
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/io/papermc/paper/math/FinePosition.java
|
|
||||||
@@ -0,0 +1,56 @@
|
|
||||||
+package io.papermc.paper.math;
|
|
||||||
+
|
|
||||||
+import org.bukkit.util.NumberConversions;
|
|
||||||
+import org.bukkit.util.Vector;
|
|
||||||
+import org.jetbrains.annotations.ApiStatus;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * A position represented with doubles.
|
|
||||||
+ * <p>
|
|
||||||
+ * <b>May see breaking changes until Experimental annotation is removed.</b>
|
|
||||||
+ * @see BlockPosition
|
|
||||||
+ */
|
|
||||||
+@ApiStatus.Experimental
|
|
||||||
+public interface FinePosition extends Position {
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default int blockX() {
|
|
||||||
+ return NumberConversions.floor(this.x());
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default int blockY() {
|
|
||||||
+ return NumberConversions.floor(this.y());
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default int blockZ() {
|
|
||||||
+ return NumberConversions.floor(this.z());
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default boolean isBlock() {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default boolean isFine() {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default @NotNull BlockPosition toBlock() {
|
|
||||||
+ return new BlockPositionImpl(this.blockX(), this.blockY(), this.blockZ());
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default @NotNull FinePosition offset(int x, int y, int z) {
|
|
||||||
+ return this.offset((double) x, y, z);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ default @NotNull FinePosition offset(double x, double y, double z) {
|
|
||||||
+ return x == 0.0 && y == 0.0 && z == 0.0 ? this : new FinePositionImpl(this.x() + x, this.y() + y, this.z() + z);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/math/FinePositionImpl.java b/src/main/java/io/papermc/paper/math/FinePositionImpl.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..93476aaf8d21efb5a30b6d2cc2eeda8100fb72d0
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/io/papermc/paper/math/FinePositionImpl.java
|
|
||||||
@@ -0,0 +1,4 @@
|
|
||||||
+package io.papermc.paper.math;
|
|
||||||
+
|
|
||||||
+record FinePositionImpl(double x, double y, double z) implements FinePosition {
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/math/Position.java b/src/main/java/io/papermc/paper/math/Position.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..300da713dcc303b340efad70efe57facf5422964
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/io/papermc/paper/math/Position.java
|
|
||||||
@@ -0,0 +1,184 @@
|
|
||||||
+package io.papermc.paper.math;
|
|
||||||
+
|
|
||||||
+import org.bukkit.Location;
|
|
||||||
+import org.bukkit.World;
|
|
||||||
+import org.bukkit.util.Vector;
|
|
||||||
+import org.jetbrains.annotations.ApiStatus;
|
|
||||||
+import org.jetbrains.annotations.Contract;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * Common interface for {@link FinePosition} and {@link BlockPosition}.
|
|
||||||
+ * <p>
|
|
||||||
+ * <b>May see breaking changes until Experimental annotation is removed.</b>
|
|
||||||
+ */
|
|
||||||
+@ApiStatus.Experimental
|
|
||||||
+public interface Position {
|
|
||||||
+
|
|
||||||
+ FinePosition FINE_ZERO = new FinePositionImpl(0, 0, 0);
|
|
||||||
+ BlockPosition BLOCK_ZERO = new BlockPositionImpl(0, 0, 0);
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the block x value for this position
|
|
||||||
+ *
|
|
||||||
+ * @return the block x value
|
|
||||||
+ */
|
|
||||||
+ int blockX();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the block x value for this position
|
|
||||||
+ *
|
|
||||||
+ * @return the block x value
|
|
||||||
+ */
|
|
||||||
+ int blockY();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the block x value for this position
|
|
||||||
+ *
|
|
||||||
+ * @return the block x value
|
|
||||||
+ */
|
|
||||||
+ int blockZ();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the x value for this position
|
|
||||||
+ *
|
|
||||||
+ * @return the x value
|
|
||||||
+ */
|
|
||||||
+ double x();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the y value for this position
|
|
||||||
+ *
|
|
||||||
+ * @return the y value
|
|
||||||
+ */
|
|
||||||
+ double y();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the z value for this position
|
|
||||||
+ *
|
|
||||||
+ * @return the z value
|
|
||||||
+ */
|
|
||||||
+ double z();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Checks of this position represents a {@link BlockPosition}
|
|
||||||
+ *
|
|
||||||
+ * @return true if block
|
|
||||||
+ */
|
|
||||||
+ boolean isBlock();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Checks if this position represents a {@link FinePosition}
|
|
||||||
+ *
|
|
||||||
+ * @return true if fine
|
|
||||||
+ */
|
|
||||||
+ boolean isFine();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Returns a position offset by the specified amounts.
|
|
||||||
+ *
|
|
||||||
+ * @param x x value to offset
|
|
||||||
+ * @param y y value to offset
|
|
||||||
+ * @param z z value to offset
|
|
||||||
+ * @return the offset position
|
|
||||||
+ */
|
|
||||||
+ @NotNull Position offset(int x, int y, int z);
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Returns a position offset by the specified amounts.
|
|
||||||
+ *
|
|
||||||
+ * @param x x value to offset
|
|
||||||
+ * @param y y value to offset
|
|
||||||
+ * @param z z value to offset
|
|
||||||
+ * @return the offset position
|
|
||||||
+ */
|
|
||||||
+ @NotNull FinePosition offset(double x, double y, double z);
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Returns a new position at the center of the block position this represents
|
|
||||||
+ *
|
|
||||||
+ * @return a new center position
|
|
||||||
+ */
|
|
||||||
+ @Contract(value = "-> new", pure = true)
|
|
||||||
+ default @NotNull FinePosition toCenter() {
|
|
||||||
+ return new FinePositionImpl(this.blockX() + 0.5, this.blockY() + 0.5, this.blockZ() + 0.5);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Returns the block position of this position
|
|
||||||
+ * or itself if it already is a block position
|
|
||||||
+ *
|
|
||||||
+ * @return the block position
|
|
||||||
+ */
|
|
||||||
+ @Contract(pure = true)
|
|
||||||
+ @NotNull BlockPosition toBlock();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Converts this position to a vector
|
|
||||||
+ *
|
|
||||||
+ * @return a new vector
|
|
||||||
+ */
|
|
||||||
+ @Contract(value = "-> new", pure = true)
|
|
||||||
+ default @NotNull Vector toVector() {
|
|
||||||
+ return new Vector(this.x(), this.y(), this.z());
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Creates a new location object at this position with the specified world
|
|
||||||
+ *
|
|
||||||
+ * @param world the world for the location object
|
|
||||||
+ * @return a new location
|
|
||||||
+ */
|
|
||||||
+ @Contract(value = "_ -> new", pure = true)
|
|
||||||
+ default @NotNull Location toLocation(@NotNull World world) {
|
|
||||||
+ return new Location(world, this.x(), this.y(), this.z());
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Creates a position at the coordinates
|
|
||||||
+ *
|
|
||||||
+ * @param x x coord
|
|
||||||
+ * @param y y coord
|
|
||||||
+ * @param z z coord
|
|
||||||
+ * @return a position with those coords
|
|
||||||
+ */
|
|
||||||
+ @Contract(value = "_, _, _ -> new", pure = true)
|
|
||||||
+ static @NotNull BlockPosition block(int x, int y, int z) {
|
|
||||||
+ return new BlockPositionImpl(x, y, z);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Creates a position from the location.
|
|
||||||
+ *
|
|
||||||
+ * @param location the location to copy the position of
|
|
||||||
+ * @return a new position at that location
|
|
||||||
+ */
|
|
||||||
+ @Contract(value = "_ -> new", pure = true)
|
|
||||||
+ static @NotNull BlockPosition block(@NotNull Location location) {
|
|
||||||
+ return new BlockPositionImpl(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Creates a position at the coordinates
|
|
||||||
+ *
|
|
||||||
+ * @param x x coord
|
|
||||||
+ * @param y y coord
|
|
||||||
+ * @param z z coord
|
|
||||||
+ * @return a position with those coords
|
|
||||||
+ */
|
|
||||||
+ @Contract(value = "_, _, _ -> new", pure = true)
|
|
||||||
+ static @NotNull FinePosition fine(double x, double y, double z) {
|
|
||||||
+ return new FinePositionImpl(x, y, z);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Creates a position from the location.
|
|
||||||
+ *
|
|
||||||
+ * @param location the location to copy the position of
|
|
||||||
+ * @return a new position at that location
|
|
||||||
+ */
|
|
||||||
+ @Contract(value = "_ -> new", pure = true)
|
|
||||||
+ static @NotNull FinePosition fine(@NotNull Location location) {
|
|
||||||
+ return new FinePositionImpl(location.getX(), location.getY(), location.getZ());
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
|
|
||||||
index 7c4db051472fb6a6c6d24092dc6f75487356690a..3b99f359f556e6f2c341d55fa69b7462e69b6546 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Location.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Location.java
|
|
||||||
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.Nullable;
|
|
||||||
* magnitude than 360 are valid, but may be normalized to any other equivalent
|
|
||||||
* representation by the implementation.
|
|
||||||
*/
|
|
||||||
-public class Location implements Cloneable, ConfigurationSerializable {
|
|
||||||
+public class Location implements Cloneable, ConfigurationSerializable, io.papermc.paper.math.FinePosition { // Paper
|
|
||||||
private Reference<World> world;
|
|
||||||
private double x;
|
|
||||||
private double y;
|
|
||||||
@@ -706,4 +706,26 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
|
||||||
}
|
|
||||||
return pitch;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ // Paper - add Position
|
|
||||||
+ @Override
|
|
||||||
+ public double x() {
|
|
||||||
+ return this.getX();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public double y() {
|
|
||||||
+ return this.getY();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public double z() {
|
|
||||||
+ return this.getZ();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public @NotNull Location toLocation(@NotNull World world) {
|
|
||||||
+ return new Location(world, this.x(), this.y(), this.z(), this.getYaw(), this.getPitch());
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
2572
patches/api/0009-Paper-Plugins.patch
Normale Datei
2572
patches/api/0009-Paper-Plugins.patch
Normale Datei
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
434
patches/api/0010-Add-Position.patch
Normale Datei
434
patches/api/0010-Add-Position.patch
Normale Datei
@ -0,0 +1,434 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||||
|
Date: Sun, 20 Mar 2022 10:42:28 -0700
|
||||||
|
Subject: [PATCH] Add Position
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/math/BlockPosition.java b/src/main/java/io/papermc/paper/math/BlockPosition.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..f0fdabce4af640da2a406412e67020761ded3ac1
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/math/BlockPosition.java
|
||||||
|
@@ -0,0 +1,98 @@
|
||||||
|
+package io.papermc.paper.math;
|
||||||
|
+
|
||||||
|
+import org.bukkit.Axis;
|
||||||
|
+import org.bukkit.block.BlockFace;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
|
+import org.jetbrains.annotations.Contract;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * A position represented with integers.
|
||||||
|
+ * <p>
|
||||||
|
+ * <b>May see breaking changes until Experimental annotation is removed.</b>
|
||||||
|
+ * @see FinePosition
|
||||||
|
+ */
|
||||||
|
+@ApiStatus.Experimental
|
||||||
|
+public interface BlockPosition extends Position {
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default double x() {
|
||||||
|
+ return this.blockX();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default double y() {
|
||||||
|
+ return this.blockY();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default double z() {
|
||||||
|
+ return this.blockZ();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default boolean isBlock() {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default boolean isFine() {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default @NotNull BlockPosition toBlock() {
|
||||||
|
+ return this;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default @NotNull BlockPosition offset(int x, int y, int z) {
|
||||||
|
+ return x == 0 && y == 0 && z == 0 ? this : new BlockPositionImpl(this.blockX() + x, this.blockY() + y, this.blockZ() + z);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default @NotNull FinePosition offset(double x, double y, double z) {
|
||||||
|
+ return new FinePositionImpl(this.blockX() + x, this.blockY() + y, this.blockZ() + z);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Returns a block position offset by 1 in the direction specified.
|
||||||
|
+ *
|
||||||
|
+ * @param blockFace the block face to offset towards
|
||||||
|
+ * @return the offset block position
|
||||||
|
+ */
|
||||||
|
+ @Contract(value = "_ -> new", pure = true)
|
||||||
|
+ default @NotNull BlockPosition offset(@NotNull BlockFace blockFace) {
|
||||||
|
+ return this.offset(blockFace, 1);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Returns a block position offset in the direction specified
|
||||||
|
+ * multiplied by the amount.
|
||||||
|
+ *
|
||||||
|
+ * @param blockFace the block face to offset towards
|
||||||
|
+ * @param amount the number of times to move in that direction
|
||||||
|
+ * @return the offset block position
|
||||||
|
+ */
|
||||||
|
+ @Contract(pure = true)
|
||||||
|
+ default @NotNull BlockPosition offset(@NotNull BlockFace blockFace, int amount) {
|
||||||
|
+ return amount == 0 ? this : new BlockPositionImpl(this.blockX() + (blockFace.getModX() * amount), this.blockY() + (blockFace.getModY() * amount), this.blockZ() + (blockFace.getModZ() * amount));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Returns a block position offset by the amount along
|
||||||
|
+ * the specified axis.
|
||||||
|
+ *
|
||||||
|
+ * @param axis the axis to offset along
|
||||||
|
+ * @param amount the amount to offset along that axis
|
||||||
|
+ * @return the offset block position
|
||||||
|
+ */
|
||||||
|
+ @Contract(pure = true)
|
||||||
|
+ default @NotNull BlockPosition offset(@NotNull Axis axis, int amount) {
|
||||||
|
+ return amount == 0 ? this : switch (axis) {
|
||||||
|
+ case X -> new BlockPositionImpl(this.blockX() + amount, this.blockY(), this.blockZ());
|
||||||
|
+ case Y -> new BlockPositionImpl(this.blockX(), this.blockY() + amount, this.blockZ());
|
||||||
|
+ case Z -> new BlockPositionImpl(this.blockX(), this.blockY(), this.blockZ() + amount);
|
||||||
|
+ };
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/math/BlockPositionImpl.java b/src/main/java/io/papermc/paper/math/BlockPositionImpl.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..eb5a3f26c7ba56c6715827f52c0013a860ec7d9a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/math/BlockPositionImpl.java
|
||||||
|
@@ -0,0 +1,4 @@
|
||||||
|
+package io.papermc.paper.math;
|
||||||
|
+
|
||||||
|
+record BlockPositionImpl(int blockX, int blockY, int blockZ) implements BlockPosition {
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/math/FinePosition.java b/src/main/java/io/papermc/paper/math/FinePosition.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..d8df70d731573cf2446044925f218876d62fd7cf
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/math/FinePosition.java
|
||||||
|
@@ -0,0 +1,56 @@
|
||||||
|
+package io.papermc.paper.math;
|
||||||
|
+
|
||||||
|
+import org.bukkit.util.NumberConversions;
|
||||||
|
+import org.bukkit.util.Vector;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * A position represented with doubles.
|
||||||
|
+ * <p>
|
||||||
|
+ * <b>May see breaking changes until Experimental annotation is removed.</b>
|
||||||
|
+ * @see BlockPosition
|
||||||
|
+ */
|
||||||
|
+@ApiStatus.Experimental
|
||||||
|
+public interface FinePosition extends Position {
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default int blockX() {
|
||||||
|
+ return NumberConversions.floor(this.x());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default int blockY() {
|
||||||
|
+ return NumberConversions.floor(this.y());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default int blockZ() {
|
||||||
|
+ return NumberConversions.floor(this.z());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default boolean isBlock() {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default boolean isFine() {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default @NotNull BlockPosition toBlock() {
|
||||||
|
+ return new BlockPositionImpl(this.blockX(), this.blockY(), this.blockZ());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default @NotNull FinePosition offset(int x, int y, int z) {
|
||||||
|
+ return this.offset((double) x, y, z);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ default @NotNull FinePosition offset(double x, double y, double z) {
|
||||||
|
+ return x == 0.0 && y == 0.0 && z == 0.0 ? this : new FinePositionImpl(this.x() + x, this.y() + y, this.z() + z);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/math/FinePositionImpl.java b/src/main/java/io/papermc/paper/math/FinePositionImpl.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..93476aaf8d21efb5a30b6d2cc2eeda8100fb72d0
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/math/FinePositionImpl.java
|
||||||
|
@@ -0,0 +1,4 @@
|
||||||
|
+package io.papermc.paper.math;
|
||||||
|
+
|
||||||
|
+record FinePositionImpl(double x, double y, double z) implements FinePosition {
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/math/Position.java b/src/main/java/io/papermc/paper/math/Position.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..26bc5a0fa67855af87c8fd4cd8229b4d9f242740
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/math/Position.java
|
||||||
|
@@ -0,0 +1,191 @@
|
||||||
|
+package io.papermc.paper.math;
|
||||||
|
+
|
||||||
|
+import org.bukkit.Location;
|
||||||
|
+import org.bukkit.World;
|
||||||
|
+import org.bukkit.util.Vector;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
|
+import org.jetbrains.annotations.Contract;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Common interface for {@link FinePosition} and {@link BlockPosition}.
|
||||||
|
+ * <p>
|
||||||
|
+ * <b>May see breaking changes until Experimental annotation is removed.</b>
|
||||||
|
+ */
|
||||||
|
+@ApiStatus.Experimental
|
||||||
|
+public interface Position {
|
||||||
|
+
|
||||||
|
+ FinePosition FINE_ZERO = new FinePositionImpl(0, 0, 0);
|
||||||
|
+ BlockPosition BLOCK_ZERO = new BlockPositionImpl(0, 0, 0);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the block x value for this position
|
||||||
|
+ *
|
||||||
|
+ * @return the block x value
|
||||||
|
+ */
|
||||||
|
+ int blockX();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the block x value for this position
|
||||||
|
+ *
|
||||||
|
+ * @return the block x value
|
||||||
|
+ */
|
||||||
|
+ int blockY();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the block x value for this position
|
||||||
|
+ *
|
||||||
|
+ * @return the block x value
|
||||||
|
+ */
|
||||||
|
+ int blockZ();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the x value for this position
|
||||||
|
+ *
|
||||||
|
+ * @return the x value
|
||||||
|
+ */
|
||||||
|
+ double x();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the y value for this position
|
||||||
|
+ *
|
||||||
|
+ * @return the y value
|
||||||
|
+ */
|
||||||
|
+ double y();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the z value for this position
|
||||||
|
+ *
|
||||||
|
+ * @return the z value
|
||||||
|
+ */
|
||||||
|
+ double z();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Checks of this position represents a {@link BlockPosition}
|
||||||
|
+ *
|
||||||
|
+ * @return true if block
|
||||||
|
+ */
|
||||||
|
+ boolean isBlock();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Checks if this position represents a {@link FinePosition}
|
||||||
|
+ *
|
||||||
|
+ * @return true if fine
|
||||||
|
+ */
|
||||||
|
+ boolean isFine();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Checks if each component of this position is finite.
|
||||||
|
+ */
|
||||||
|
+ default boolean isFinite() {
|
||||||
|
+ return Double.isFinite(this.x()) && Double.isFinite(this.y()) && Double.isFinite(this.z());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Returns a position offset by the specified amounts.
|
||||||
|
+ *
|
||||||
|
+ * @param x x value to offset
|
||||||
|
+ * @param y y value to offset
|
||||||
|
+ * @param z z value to offset
|
||||||
|
+ * @return the offset position
|
||||||
|
+ */
|
||||||
|
+ @NotNull Position offset(int x, int y, int z);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Returns a position offset by the specified amounts.
|
||||||
|
+ *
|
||||||
|
+ * @param x x value to offset
|
||||||
|
+ * @param y y value to offset
|
||||||
|
+ * @param z z value to offset
|
||||||
|
+ * @return the offset position
|
||||||
|
+ */
|
||||||
|
+ @NotNull FinePosition offset(double x, double y, double z);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Returns a new position at the center of the block position this represents
|
||||||
|
+ *
|
||||||
|
+ * @return a new center position
|
||||||
|
+ */
|
||||||
|
+ @Contract(value = "-> new", pure = true)
|
||||||
|
+ default @NotNull FinePosition toCenter() {
|
||||||
|
+ return new FinePositionImpl(this.blockX() + 0.5, this.blockY() + 0.5, this.blockZ() + 0.5);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Returns the block position of this position
|
||||||
|
+ * or itself if it already is a block position
|
||||||
|
+ *
|
||||||
|
+ * @return the block position
|
||||||
|
+ */
|
||||||
|
+ @Contract(pure = true)
|
||||||
|
+ @NotNull BlockPosition toBlock();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Converts this position to a vector
|
||||||
|
+ *
|
||||||
|
+ * @return a new vector
|
||||||
|
+ */
|
||||||
|
+ @Contract(value = "-> new", pure = true)
|
||||||
|
+ default @NotNull Vector toVector() {
|
||||||
|
+ return new Vector(this.x(), this.y(), this.z());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Creates a new location object at this position with the specified world
|
||||||
|
+ *
|
||||||
|
+ * @param world the world for the location object
|
||||||
|
+ * @return a new location
|
||||||
|
+ */
|
||||||
|
+ @Contract(value = "_ -> new", pure = true)
|
||||||
|
+ default @NotNull Location toLocation(@NotNull World world) {
|
||||||
|
+ return new Location(world, this.x(), this.y(), this.z());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Creates a position at the coordinates
|
||||||
|
+ *
|
||||||
|
+ * @param x x coord
|
||||||
|
+ * @param y y coord
|
||||||
|
+ * @param z z coord
|
||||||
|
+ * @return a position with those coords
|
||||||
|
+ */
|
||||||
|
+ @Contract(value = "_, _, _ -> new", pure = true)
|
||||||
|
+ static @NotNull BlockPosition block(int x, int y, int z) {
|
||||||
|
+ return new BlockPositionImpl(x, y, z);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Creates a position from the location.
|
||||||
|
+ *
|
||||||
|
+ * @param location the location to copy the position of
|
||||||
|
+ * @return a new position at that location
|
||||||
|
+ */
|
||||||
|
+ @Contract(value = "_ -> new", pure = true)
|
||||||
|
+ static @NotNull BlockPosition block(@NotNull Location location) {
|
||||||
|
+ return new BlockPositionImpl(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Creates a position at the coordinates
|
||||||
|
+ *
|
||||||
|
+ * @param x x coord
|
||||||
|
+ * @param y y coord
|
||||||
|
+ * @param z z coord
|
||||||
|
+ * @return a position with those coords
|
||||||
|
+ */
|
||||||
|
+ @Contract(value = "_, _, _ -> new", pure = true)
|
||||||
|
+ static @NotNull FinePosition fine(double x, double y, double z) {
|
||||||
|
+ return new FinePositionImpl(x, y, z);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Creates a position from the location.
|
||||||
|
+ *
|
||||||
|
+ * @param location the location to copy the position of
|
||||||
|
+ * @return a new position at that location
|
||||||
|
+ */
|
||||||
|
+ @Contract(value = "_ -> new", pure = true)
|
||||||
|
+ static @NotNull FinePosition fine(@NotNull Location location) {
|
||||||
|
+ return new FinePositionImpl(location.getX(), location.getY(), location.getZ());
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
|
||||||
|
index 7c4db051472fb6a6c6d24092dc6f75487356690a..85c342fc50f2fe0ce9a1b3980df9e088c3dea92d 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Location.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Location.java
|
||||||
|
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
* magnitude than 360 are valid, but may be normalized to any other equivalent
|
||||||
|
* representation by the implementation.
|
||||||
|
*/
|
||||||
|
-public class Location implements Cloneable, ConfigurationSerializable {
|
||||||
|
+public class Location implements Cloneable, ConfigurationSerializable, io.papermc.paper.math.FinePosition { // Paper
|
||||||
|
private Reference<World> world;
|
||||||
|
private double x;
|
||||||
|
private double y;
|
||||||
|
@@ -706,4 +706,31 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
||||||
|
}
|
||||||
|
return pitch;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // Paper - add Position
|
||||||
|
+ @Override
|
||||||
|
+ public double x() {
|
||||||
|
+ return this.getX();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public double y() {
|
||||||
|
+ return this.getY();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public double z() {
|
||||||
|
+ return this.getZ();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isFinite() {
|
||||||
|
+ return io.papermc.paper.math.FinePosition.super.isFinite() && Float.isFinite(this.getYaw()) && Float.isFinite(this.getPitch());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull Location toLocation(@NotNull World world) {
|
||||||
|
+ return new Location(world, this.x(), this.y(), this.z(), this.getYaw(), this.getPitch());
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -1,96 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
|
||||||
Date: Tue, 18 May 2021 14:42:26 -0700
|
|
||||||
Subject: [PATCH] Add command line option to load extra plugin jars not in the
|
|
||||||
plugins folder
|
|
||||||
|
|
||||||
ex: java -jar paperclip.jar nogui -add-plugin=/path/to/plugin.jar -add-plugin=/path/to/another/plugin_jar.jar
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
index 45f9ac35874c67c24718f6891b95df1ff4f0b93f..7717f5346aa784df4a0f6e43a5a74a66f279bc8a 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
@@ -78,6 +78,20 @@ public final class Bukkit {
|
|
||||||
return server;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ /**
|
|
||||||
+ * Returns the de facto plugins directory, generally used for storing plugin jars to be loaded,
|
|
||||||
+ * as well as their {@link org.bukkit.plugin.Plugin#getDataFolder() data folders}.
|
|
||||||
+ *
|
|
||||||
+ * <p>Plugins should use {@link org.bukkit.plugin.Plugin#getDataFolder()} rather than traversing this
|
|
||||||
+ * directory manually when determining the location in which to store their data and configuration files.</p>
|
|
||||||
+ *
|
|
||||||
+ * @return plugins directory
|
|
||||||
+ */
|
|
||||||
+ @NotNull
|
|
||||||
+ public static File getPluginsFolder() {
|
|
||||||
+ return server.getPluginsFolder();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Attempts to set the {@link Server} singleton.
|
|
||||||
* <p>
|
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
|
||||||
index 087da3cd2cafd8255ed70e5e632b270a33e37eaf..0f990d33ab07249e4cf2d2269920b4cbeed27d39 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
|
||||||
@@ -63,6 +63,18 @@ import org.jetbrains.annotations.Nullable;
|
|
||||||
*/
|
|
||||||
public interface Server extends PluginMessageRecipient, net.kyori.adventure.audience.ForwardingAudience { // Paper
|
|
||||||
|
|
||||||
+ /**
|
|
||||||
+ * Returns the de facto plugins directory, generally used for storing plugin jars to be loaded,
|
|
||||||
+ * as well as their {@link org.bukkit.plugin.Plugin#getDataFolder() data folders}.
|
|
||||||
+ *
|
|
||||||
+ * <p>Plugins should use {@link org.bukkit.plugin.Plugin#getDataFolder()} rather than traversing this
|
|
||||||
+ * directory manually when determining the location in which to store their data and configuration files.</p>
|
|
||||||
+ *
|
|
||||||
+ * @return plugins directory
|
|
||||||
+ */
|
|
||||||
+ @NotNull
|
|
||||||
+ File getPluginsFolder();
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Used for all administrative messages, such as an operator using a
|
|
||||||
* command.
|
|
||||||
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
|
||||||
index 63389474a2b3f0e283b42e7004aa6a94904a3d17..974ff7116b294473ec450757e8a9341540f43dcd 100644
|
|
||||||
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
|
||||||
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
|
||||||
@@ -116,9 +116,22 @@ public final class SimplePluginManager implements PluginManager {
|
|
||||||
@Override
|
|
||||||
@NotNull
|
|
||||||
public Plugin[] loadPlugins(@NotNull File directory) {
|
|
||||||
+ // Paper start - extra jars
|
|
||||||
+ return this.loadPlugins(directory, java.util.Collections.emptyList());
|
|
||||||
+ }
|
|
||||||
+ @NotNull
|
|
||||||
+ public Plugin[] loadPlugins(final @NotNull File directory, final @NotNull List<File> extraPluginJars) {
|
|
||||||
+ // Paper end
|
|
||||||
if (true) {
|
|
||||||
List<Plugin> pluginList = new ArrayList<>();
|
|
||||||
java.util.Collections.addAll(pluginList, this.paperPluginManager.loadPlugins(directory));
|
|
||||||
+ for (File file : extraPluginJars) {
|
|
||||||
+ try {
|
|
||||||
+ pluginList.add(this.paperPluginManager.loadPlugin(file));
|
|
||||||
+ } catch (Exception e) {
|
|
||||||
+ this.server.getLogger().log(Level.SEVERE, "Plugin loading error!", e);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
return pluginList.toArray(new Plugin[0]);
|
|
||||||
}
|
|
||||||
Preconditions.checkArgument(directory != null, "Directory cannot be null");
|
|
||||||
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
|
||||||
index de6b6188587fd254ab96cbc1f95fda2056d9cbe2..eaefbb00e9993d54906cc8cf35cf753c0d6c7707 100644
|
|
||||||
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
|
||||||
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
|
||||||
@@ -93,7 +93,7 @@ public final class JavaPluginLoader implements PluginLoader {
|
|
||||||
throw new InvalidPluginException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
- final File parentFile = file.getParentFile();
|
|
||||||
+ final File parentFile = this.server.getPluginsFolder(); // Paper
|
|
||||||
final File dataFolder = new File(parentFile, description.getName());
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
final File oldDataFolder = new File(parentFile, description.getRawName());
|
|
3830
patches/api/0011-Timings-v2.patch
Normale Datei
3830
patches/api/0011-Timings-v2.patch
Normale Datei
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -0,0 +1,96 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||||
|
Date: Tue, 18 May 2021 14:42:26 -0700
|
||||||
|
Subject: [PATCH] Add command line option to load extra plugin jars not in the
|
||||||
|
plugins folder
|
||||||
|
|
||||||
|
ex: java -jar paperclip.jar nogui -add-plugin=/path/to/plugin.jar -add-plugin=/path/to/another/plugin_jar.jar
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
index 6ecab28705afc0e3652677b516d8a5398e8b2666..db51751d2dc1ac419e8fac32466ad3a7727fa2fe 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
@@ -83,6 +83,20 @@ public final class Bukkit {
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /**
|
||||||
|
+ * Returns the de facto plugins directory, generally used for storing plugin jars to be loaded,
|
||||||
|
+ * as well as their {@link org.bukkit.plugin.Plugin#getDataFolder() data folders}.
|
||||||
|
+ *
|
||||||
|
+ * <p>Plugins should use {@link org.bukkit.plugin.Plugin#getDataFolder()} rather than traversing this
|
||||||
|
+ * directory manually when determining the location in which to store their data and configuration files.</p>
|
||||||
|
+ *
|
||||||
|
+ * @return plugins directory
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public static File getPluginsFolder() {
|
||||||
|
+ return server.getPluginsFolder();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Attempts to set the {@link Server} singleton.
|
||||||
|
* <p>
|
||||||
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
|
index f4b2ad91c7a46af5fc16f31369d155e4e3ab3aae..638e98416fdf7ac065abe058d625b1c924be5abb 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
|
@@ -68,6 +68,18 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
*/
|
||||||
|
public interface Server extends PluginMessageRecipient, net.kyori.adventure.audience.ForwardingAudience { // Paper
|
||||||
|
|
||||||
|
+ /**
|
||||||
|
+ * Returns the de facto plugins directory, generally used for storing plugin jars to be loaded,
|
||||||
|
+ * as well as their {@link org.bukkit.plugin.Plugin#getDataFolder() data folders}.
|
||||||
|
+ *
|
||||||
|
+ * <p>Plugins should use {@link org.bukkit.plugin.Plugin#getDataFolder()} rather than traversing this
|
||||||
|
+ * directory manually when determining the location in which to store their data and configuration files.</p>
|
||||||
|
+ *
|
||||||
|
+ * @return plugins directory
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ File getPluginsFolder();
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Used for all administrative messages, such as an operator using a
|
||||||
|
* command.
|
||||||
|
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||||
|
index 6018574cd15b802833613beefa88da15dc2730cb..e7b1895d3918487d711afcbe41d76863d85c0a62 100644
|
||||||
|
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||||
|
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||||
|
@@ -117,9 +117,22 @@ public final class SimplePluginManager implements PluginManager {
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public Plugin[] loadPlugins(@NotNull File directory) {
|
||||||
|
+ // Paper start - extra jars
|
||||||
|
+ return this.loadPlugins(directory, java.util.Collections.emptyList());
|
||||||
|
+ }
|
||||||
|
+ @NotNull
|
||||||
|
+ public Plugin[] loadPlugins(final @NotNull File directory, final @NotNull List<File> extraPluginJars) {
|
||||||
|
+ // Paper end
|
||||||
|
if (true) {
|
||||||
|
List<Plugin> pluginList = new ArrayList<>();
|
||||||
|
java.util.Collections.addAll(pluginList, this.paperPluginManager.loadPlugins(directory));
|
||||||
|
+ for (File file : extraPluginJars) {
|
||||||
|
+ try {
|
||||||
|
+ pluginList.add(this.paperPluginManager.loadPlugin(file));
|
||||||
|
+ } catch (Exception e) {
|
||||||
|
+ this.server.getLogger().log(Level.SEVERE, "Plugin loading error!", e);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
return pluginList.toArray(new Plugin[0]);
|
||||||
|
}
|
||||||
|
Preconditions.checkArgument(directory != null, "Directory cannot be null");
|
||||||
|
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||||
|
index de6b6188587fd254ab96cbc1f95fda2056d9cbe2..eaefbb00e9993d54906cc8cf35cf753c0d6c7707 100644
|
||||||
|
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||||
|
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||||
|
@@ -93,7 +93,7 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||||
|
throw new InvalidPluginException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
- final File parentFile = file.getParentFile();
|
||||||
|
+ final File parentFile = this.server.getPluginsFolder(); // Paper
|
||||||
|
final File dataFolder = new File(parentFile, description.getName());
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
final File oldDataFolder = new File(parentFile, description.getRawName());
|
@ -1,33 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jedediah Smith <jedediah@silencegreys.com>
|
|
||||||
Date: Mon, 29 Feb 2016 17:22:34 -0600
|
|
||||||
Subject: [PATCH] Player affects spawning API
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
|
||||||
index 1a54682f584479a5a548f6f1f2ffd5da5dc11c88..6b1a198f930a5a995e0cb6c279b455e1639a5039 100644
|
|
||||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
|
||||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
|
||||||
@@ -2196,6 +2196,22 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
|
||||||
@Deprecated // Paper
|
|
||||||
public String getLocale();
|
|
||||||
|
|
||||||
+ // Paper start
|
|
||||||
+ /**
|
|
||||||
+ * Get whether the player can affect mob spawning
|
|
||||||
+ *
|
|
||||||
+ * @return if the player can affect mob spawning
|
|
||||||
+ */
|
|
||||||
+ public boolean getAffectsSpawning();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Set whether the player can affect mob spawning
|
|
||||||
+ *
|
|
||||||
+ * @param affects Whether the player can affect mob spawning
|
|
||||||
+ */
|
|
||||||
+ public void setAffectsSpawning(boolean affects);
|
|
||||||
+ // Paper end
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Update the list of commands sent to the client.
|
|
||||||
* <br>
|
|
@ -1,49 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Aikar <aikar@aikar.co>
|
|
||||||
Date: Mon, 29 Feb 2016 17:24:57 -0600
|
|
||||||
Subject: [PATCH] Add getTPS method
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
index 7717f5346aa784df4a0f6e43a5a74a66f279bc8a..fba3e617a8847a3e9282e6a1a389132b2ad5511c 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
@@ -1964,6 +1964,17 @@ public final class Bukkit {
|
|
||||||
return server.getEntity(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Paper start
|
|
||||||
+ /**
|
|
||||||
+ * Gets the current server TPS
|
|
||||||
+ * @return current server TPS (1m, 5m, 15m in Paper-Server)
|
|
||||||
+ */
|
|
||||||
+ @NotNull
|
|
||||||
+ public static double[] getTPS() {
|
|
||||||
+ return server.getTPS();
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Get the advancement specified by this key.
|
|
||||||
*
|
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
|
||||||
index 0f990d33ab07249e4cf2d2269920b4cbeed27d39..c8cf66e64a3163c2bdf781f3ce52059546969b9b 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
|
||||||
@@ -1672,6 +1672,16 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
|
||||||
@Nullable
|
|
||||||
Entity getEntity(@NotNull UUID uuid);
|
|
||||||
|
|
||||||
+ // Paper start
|
|
||||||
+ /**
|
|
||||||
+ * Gets the current server TPS
|
|
||||||
+ *
|
|
||||||
+ * @return current server TPS (1m, 5m, 15m in Paper-Server)
|
|
||||||
+ */
|
|
||||||
+ @NotNull
|
|
||||||
+ public double[] getTPS();
|
|
||||||
+ // Paper end
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Get the advancement specified by this key.
|
|
||||||
*
|
|
33
patches/api/0013-Player-affects-spawning-API.patch
Normale Datei
33
patches/api/0013-Player-affects-spawning-API.patch
Normale Datei
@ -0,0 +1,33 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
||||||
|
Date: Mon, 29 Feb 2016 17:22:34 -0600
|
||||||
|
Subject: [PATCH] Player affects spawning API
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||||
|
index 3594b0eb4068c83c93efe948a8ef4ba217edce17..1ba2f706a62ee6962451305b1895654453b485cd 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||||
|
@@ -2583,6 +2583,22 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||||
|
@Deprecated // Paper
|
||||||
|
public String getLocale();
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ /**
|
||||||
|
+ * Get whether the player can affect mob spawning
|
||||||
|
+ *
|
||||||
|
+ * @return if the player can affect mob spawning
|
||||||
|
+ */
|
||||||
|
+ public boolean getAffectsSpawning();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Set whether the player can affect mob spawning
|
||||||
|
+ *
|
||||||
|
+ * @param affects Whether the player can affect mob spawning
|
||||||
|
+ */
|
||||||
|
+ public void setAffectsSpawning(boolean affects);
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Update the list of commands sent to the client.
|
||||||
|
* <br>
|
49
patches/api/0014-Add-getTPS-method.patch
Normale Datei
49
patches/api/0014-Add-getTPS-method.patch
Normale Datei
@ -0,0 +1,49 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aikar <aikar@aikar.co>
|
||||||
|
Date: Mon, 29 Feb 2016 17:24:57 -0600
|
||||||
|
Subject: [PATCH] Add getTPS method
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
index d978c72cdbc10792f852a4ba372518073893d02b..5780003631beae773231afe3afc6b834bfe1f84d 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
@@ -2108,6 +2108,17 @@ public final class Bukkit {
|
||||||
|
return server.getEntity(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ /**
|
||||||
|
+ * Gets the current server TPS
|
||||||
|
+ * @return current server TPS (1m, 5m, 15m in Paper-Server)
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public static double[] getTPS() {
|
||||||
|
+ return server.getTPS();
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Get the advancement specified by this key.
|
||||||
|
*
|
||||||
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
|
index 8949b8e29ae7f412481291630a5cb7b5b8809842..ba28d9f3213ca4b5f15178dc637bff37a8896edc 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
|
@@ -1797,6 +1797,16 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
|
@Nullable
|
||||||
|
Entity getEntity(@NotNull UUID uuid);
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ /**
|
||||||
|
+ * Gets the current server TPS
|
||||||
|
+ *
|
||||||
|
+ * @return current server TPS (1m, 5m, 15m in Paper-Server)
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public double[] getTPS();
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Get the advancement specified by this key.
|
||||||
|
*
|
@ -1,200 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Zach Brown <zach@zachbr.io>
|
|
||||||
Date: Mon, 27 May 2019 01:10:06 -0500
|
|
||||||
Subject: [PATCH] Version Command 2.0
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..a736d7bcdc5861a01b66ba36158db1c716339346
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java
|
|
||||||
@@ -0,0 +1,45 @@
|
|
||||||
+package com.destroystokyo.paper.util;
|
|
||||||
+
|
|
||||||
+import net.kyori.adventure.text.Component;
|
|
||||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
+import org.bukkit.Bukkit;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+
|
|
||||||
+public interface VersionFetcher {
|
|
||||||
+ /**
|
|
||||||
+ * Amount of time to cache results for in milliseconds
|
|
||||||
+ * <p>
|
|
||||||
+ * Negative values will never cache.
|
|
||||||
+ *
|
|
||||||
+ * @return cache time
|
|
||||||
+ */
|
|
||||||
+ long getCacheTime();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the version message to cache and show to command senders.
|
|
||||||
+ *
|
|
||||||
+ * <p>NOTE: This is run in a new thread separate from that of the command processing thread</p>
|
|
||||||
+ *
|
|
||||||
+ * @param serverVersion the current version of the server (will match {@link Bukkit#getVersion()})
|
|
||||||
+ * @return the message to show when requesting a version
|
|
||||||
+ */
|
|
||||||
+ @NotNull
|
|
||||||
+ Component getVersionMessage(@NotNull String serverVersion);
|
|
||||||
+
|
|
||||||
+ class DummyVersionFetcher implements VersionFetcher {
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public long getCacheTime() {
|
|
||||||
+ return -1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @NotNull
|
|
||||||
+ @Override
|
|
||||||
+ public Component getVersionMessage(@NotNull String serverVersion) {
|
|
||||||
+ Bukkit.getLogger().warning("Version provider has not been set, cannot check for updates!");
|
|
||||||
+ Bukkit.getLogger().info("Override the default implementation of org.bukkit.UnsafeValues#getVersionFetcher()");
|
|
||||||
+ new Throwable().printStackTrace();
|
|
||||||
+ return Component.text("Unable to check for updates. No version provider set.", NamedTextColor.RED);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
|
||||||
index f68ef89f37057cf677a767026ab395f7a839a2f9..a6aa33b9574d0278e10927007a62290e1d102e73 100644
|
|
||||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
|
||||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
|
||||||
@@ -119,5 +119,12 @@ public interface UnsafeValues {
|
|
||||||
* @return name
|
|
||||||
*/
|
|
||||||
String getTimingsServerName();
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Called once by the version command on first use, then cached.
|
|
||||||
+ */
|
|
||||||
+ default com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
|
|
||||||
+ return new com.destroystokyo.paper.util.VersionFetcher.DummyVersionFetcher();
|
|
||||||
+ }
|
|
||||||
// Paper end
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
||||||
index 04b4fb6859df0221f8f9f92c5a7ac2dda1073355..b437cf212a63aa96a9492db8d01d5d37061aee23 100644
|
|
||||||
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
||||||
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
|
||||||
@@ -24,8 +24,25 @@ import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
|
||||||
import org.bukkit.util.StringUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
+// Paper start - version command 2.0
|
|
||||||
+import com.destroystokyo.paper.util.VersionFetcher;
|
|
||||||
+import net.kyori.adventure.text.Component;
|
|
||||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
+import net.kyori.adventure.text.event.ClickEvent;
|
|
||||||
+import net.kyori.adventure.text.format.TextDecoration;
|
|
||||||
+import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
|
||||||
+// Paper end - version command 2.0
|
|
||||||
|
|
||||||
public class VersionCommand extends BukkitCommand {
|
|
||||||
+ private VersionFetcher versionFetcher; // Paper - version command 2.0
|
|
||||||
+ private VersionFetcher getVersionFetcher() { // lazy load because unsafe isn't available at command registration
|
|
||||||
+ if (versionFetcher == null) {
|
|
||||||
+ versionFetcher = Bukkit.getUnsafe().getVersionFetcher();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return versionFetcher;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
public VersionCommand(@NotNull String name) {
|
|
||||||
super(name);
|
|
||||||
|
|
||||||
@@ -40,7 +57,7 @@ public class VersionCommand extends BukkitCommand {
|
|
||||||
if (!testPermission(sender)) return true;
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
- sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")");
|
|
||||||
+ //sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")"); // Paper - moved to setVersionMessage
|
|
||||||
sendVersion(sender);
|
|
||||||
} else {
|
|
||||||
StringBuilder name = new StringBuilder();
|
|
||||||
@@ -79,8 +96,17 @@ public class VersionCommand extends BukkitCommand {
|
|
||||||
|
|
||||||
private void describeToSender(@NotNull Plugin plugin, @NotNull CommandSender sender) {
|
|
||||||
PluginDescriptionFile desc = plugin.getDescription();
|
|
||||||
- sender.sendMessage(ChatColor.GREEN + desc.getName() + ChatColor.WHITE + " version " + ChatColor.GREEN + desc.getVersion());
|
|
||||||
-
|
|
||||||
+ // Paper start - version command 2.0
|
|
||||||
+ sender.sendMessage(
|
|
||||||
+ Component.text()
|
|
||||||
+ .append(Component.text(desc.getName(), NamedTextColor.GREEN))
|
|
||||||
+ .append(Component.text(" version "))
|
|
||||||
+ .append(Component.text(desc.getVersion(), NamedTextColor.GREEN)
|
|
||||||
+ .hoverEvent(Component.text("Click to copy to clipboard", NamedTextColor.WHITE))
|
|
||||||
+ .clickEvent(ClickEvent.copyToClipboard(desc.getVersion()))
|
|
||||||
+ )
|
|
||||||
+ );
|
|
||||||
+ // Paper end - version command 2.0
|
|
||||||
if (desc.getDescription() != null) {
|
|
||||||
sender.sendMessage(desc.getDescription());
|
|
||||||
}
|
|
||||||
@@ -146,14 +172,14 @@ public class VersionCommand extends BukkitCommand {
|
|
||||||
|
|
||||||
private final ReentrantLock versionLock = new ReentrantLock();
|
|
||||||
private boolean hasVersion = false;
|
|
||||||
- private String versionMessage = null;
|
|
||||||
+ private Component versionMessage = null; // Paper
|
|
||||||
private final Set<CommandSender> versionWaiters = new HashSet<CommandSender>();
|
|
||||||
private boolean versionTaskStarted = false;
|
|
||||||
private long lastCheck = 0;
|
|
||||||
|
|
||||||
private void sendVersion(@NotNull CommandSender sender) {
|
|
||||||
if (hasVersion) {
|
|
||||||
- if (System.currentTimeMillis() - lastCheck > 21600000) {
|
|
||||||
+ if (System.currentTimeMillis() - lastCheck > getVersionFetcher().getCacheTime()) { // Paper - use version supplier
|
|
||||||
lastCheck = System.currentTimeMillis();
|
|
||||||
hasVersion = false;
|
|
||||||
} else {
|
|
||||||
@@ -168,7 +194,7 @@ public class VersionCommand extends BukkitCommand {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
versionWaiters.add(sender);
|
|
||||||
- sender.sendMessage("Checking version, please wait...");
|
|
||||||
+ sender.sendMessage(Component.text("Checking version, please wait...", NamedTextColor.WHITE, TextDecoration.ITALIC)); // Paper
|
|
||||||
if (!versionTaskStarted) {
|
|
||||||
versionTaskStarted = true;
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
@@ -186,6 +212,13 @@ public class VersionCommand extends BukkitCommand {
|
|
||||||
|
|
||||||
private void obtainVersion() {
|
|
||||||
String version = Bukkit.getVersion();
|
|
||||||
+ // Paper start
|
|
||||||
+ if (version.startsWith("null")) { // running from ide?
|
|
||||||
+ setVersionMessage(Component.text("Unknown version, custom build?", NamedTextColor.YELLOW));
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ setVersionMessage(getVersionFetcher().getVersionMessage(version));
|
|
||||||
+ /*
|
|
||||||
if (version == null) version = "Custom";
|
|
||||||
String[] parts = version.substring(0, version.indexOf(' ')).split("-");
|
|
||||||
if (parts.length == 4) {
|
|
||||||
@@ -215,11 +248,24 @@ public class VersionCommand extends BukkitCommand {
|
|
||||||
} else {
|
|
||||||
setVersionMessage("Unknown version, custom build?");
|
|
||||||
}
|
|
||||||
+ */
|
|
||||||
+ // Paper end
|
|
||||||
}
|
|
||||||
|
|
||||||
- private void setVersionMessage(@NotNull String msg) {
|
|
||||||
+ // Paper start
|
|
||||||
+ private void setVersionMessage(final @NotNull Component msg) {
|
|
||||||
lastCheck = System.currentTimeMillis();
|
|
||||||
- versionMessage = msg;
|
|
||||||
+ final Component message = Component.textOfChildren(
|
|
||||||
+ Component.text("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")", NamedTextColor.WHITE),
|
|
||||||
+ Component.newline(),
|
|
||||||
+ msg
|
|
||||||
+ );
|
|
||||||
+ this.versionMessage = Component.text()
|
|
||||||
+ .append(message)
|
|
||||||
+ .hoverEvent(Component.text("Click to copy to clipboard", NamedTextColor.WHITE))
|
|
||||||
+ .clickEvent(ClickEvent.copyToClipboard(PlainTextComponentSerializer.plainText().serialize(message)))
|
|
||||||
+ .build();
|
|
||||||
+ // Paper end
|
|
||||||
versionLock.lock();
|
|
||||||
try {
|
|
||||||
hasVersion = true;
|
|
@ -1,66 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Byteflux <byte@byteflux.net>
|
|
||||||
Date: Mon, 29 Feb 2016 17:50:31 -0600
|
|
||||||
Subject: [PATCH] Entity Origin API
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
|
||||||
index 598abaa82c634178043a29f6caa6ac5221659d06..70a32f89c16439c575d8928332cfed64d1d6ab7e 100644
|
|
||||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
|
||||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
|
||||||
@@ -725,5 +725,15 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
|
||||||
default net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity> asHoverEvent(final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowEntity> op) {
|
|
||||||
return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.customName())));
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the location where this entity originates from.
|
|
||||||
+ * <p>
|
|
||||||
+ * This value can be null if the entity hasn't yet been added to the world.
|
|
||||||
+ *
|
|
||||||
+ * @return Location where entity originates or null if not yet added
|
|
||||||
+ */
|
|
||||||
+ @Nullable
|
|
||||||
+ Location getOrigin();
|
|
||||||
// Paper end
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java
|
|
||||||
index d96fd494b523491fcf1ac54d164351fd487f65d6..ae1ce2ee2deb82f3f4144ec54b3ba119b437c5e9 100644
|
|
||||||
--- a/src/main/java/org/bukkit/entity/FallingBlock.java
|
|
||||||
+++ b/src/main/java/org/bukkit/entity/FallingBlock.java
|
|
||||||
@@ -126,4 +126,15 @@ public interface FallingBlock extends Entity {
|
|
||||||
* @param damage the max damage to set. Must be >= 0
|
|
||||||
*/
|
|
||||||
void setMaxDamage(int damage);
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the source block location of the FallingBlock
|
|
||||||
+ *
|
|
||||||
+ * @return the source block location the FallingBlock was spawned from
|
|
||||||
+ * @deprecated replaced by {@link Entity#getOrigin()}
|
|
||||||
+ */
|
|
||||||
+ @Deprecated
|
|
||||||
+ default org.bukkit.Location getSourceLoc() {
|
|
||||||
+ return this.getOrigin();
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/bukkit/entity/TNTPrimed.java b/src/main/java/org/bukkit/entity/TNTPrimed.java
|
|
||||||
index a23cfdf66877f0a61eae700de084c76e6ee7b431..0813bd913c8fdb2001963ce3e82c07c2af105418 100644
|
|
||||||
--- a/src/main/java/org/bukkit/entity/TNTPrimed.java
|
|
||||||
+++ b/src/main/java/org/bukkit/entity/TNTPrimed.java
|
|
||||||
@@ -53,4 +53,15 @@ public interface TNTPrimed extends Explosive {
|
|
||||||
* @param source the source of this primed TNT
|
|
||||||
*/
|
|
||||||
public void setSource(@Nullable Entity source);
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the source block location of the TNTPrimed
|
|
||||||
+ *
|
|
||||||
+ * @return the source block location the TNTPrimed was spawned from
|
|
||||||
+ * @deprecated replaced by {@link Entity#getOrigin()}
|
|
||||||
+ */
|
|
||||||
+ @Deprecated
|
|
||||||
+ default org.bukkit.Location getSourceLoc() {
|
|
||||||
+ return this.getOrigin();
|
|
||||||
+ }
|
|
||||||
}
|
|
528
patches/api/0015-Expose-server-build-information.patch
Normale Datei
528
patches/api/0015-Expose-server-build-information.patch
Normale Datei
@ -0,0 +1,528 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Zach Brown <zach@zachbr.io>
|
||||||
|
Date: Mon, 27 May 2019 01:10:06 -0500
|
||||||
|
Subject: [PATCH] Expose server build information
|
||||||
|
|
||||||
|
Co-authored-by: Professor Bloodstone <git@bloodstone.dev>
|
||||||
|
Co-authored-by: Mark Vainomaa <mikroskeem@mikroskeem.eu>
|
||||||
|
Co-authored-by: masmc05 <masmc05@gmail.com>
|
||||||
|
Co-authored-by: Riley Park <rileysebastianpark@gmail.com>
|
||||||
|
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..a736d7bcdc5861a01b66ba36158db1c716339346
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java
|
||||||
|
@@ -0,0 +1,45 @@
|
||||||
|
+package com.destroystokyo.paper.util;
|
||||||
|
+
|
||||||
|
+import net.kyori.adventure.text.Component;
|
||||||
|
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+public interface VersionFetcher {
|
||||||
|
+ /**
|
||||||
|
+ * Amount of time to cache results for in milliseconds
|
||||||
|
+ * <p>
|
||||||
|
+ * Negative values will never cache.
|
||||||
|
+ *
|
||||||
|
+ * @return cache time
|
||||||
|
+ */
|
||||||
|
+ long getCacheTime();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the version message to cache and show to command senders.
|
||||||
|
+ *
|
||||||
|
+ * <p>NOTE: This is run in a new thread separate from that of the command processing thread</p>
|
||||||
|
+ *
|
||||||
|
+ * @param serverVersion the current version of the server (will match {@link Bukkit#getVersion()})
|
||||||
|
+ * @return the message to show when requesting a version
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ Component getVersionMessage(@NotNull String serverVersion);
|
||||||
|
+
|
||||||
|
+ class DummyVersionFetcher implements VersionFetcher {
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public long getCacheTime() {
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ @Override
|
||||||
|
+ public Component getVersionMessage(@NotNull String serverVersion) {
|
||||||
|
+ Bukkit.getLogger().warning("Version provider has not been set, cannot check for updates!");
|
||||||
|
+ Bukkit.getLogger().info("Override the default implementation of org.bukkit.UnsafeValues#getVersionFetcher()");
|
||||||
|
+ new Throwable().printStackTrace();
|
||||||
|
+ return Component.text("Unable to check for updates. No version provider set.", NamedTextColor.RED);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfo.java b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..9df9d09aa477d4cd3c496ba0933c816df1ef0964
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||||
|
@@ -0,0 +1,121 @@
|
||||||
|
+package io.papermc.paper;
|
||||||
|
+
|
||||||
|
+import java.time.Instant;
|
||||||
|
+import java.util.Optional;
|
||||||
|
+import java.util.OptionalInt;
|
||||||
|
+import net.kyori.adventure.key.Key;
|
||||||
|
+import net.kyori.adventure.util.Services;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Information about the current server build.
|
||||||
|
+ */
|
||||||
|
+@ApiStatus.NonExtendable
|
||||||
|
+public interface ServerBuildInfo {
|
||||||
|
+ /**
|
||||||
|
+ * The brand id for Paper.
|
||||||
|
+ */
|
||||||
|
+ Key BRAND_PAPER_ID = Key.key("papermc", "paper");
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the {@code ServerBuildInfo}.
|
||||||
|
+ *
|
||||||
|
+ * @return the {@code ServerBuildInfo}
|
||||||
|
+ */
|
||||||
|
+ static @NotNull ServerBuildInfo buildInfo() {
|
||||||
|
+ //<editor-fold defaultstate="collapsed" desc="Holder">
|
||||||
|
+ final class Holder {
|
||||||
|
+ static final Optional<ServerBuildInfo> INSTANCE = Services.service(ServerBuildInfo.class);
|
||||||
|
+ }
|
||||||
|
+ //</editor-fold>
|
||||||
|
+ return Holder.INSTANCE.orElseThrow();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the brand id of the server.
|
||||||
|
+ *
|
||||||
|
+ * @return the brand id of the server (e.g. "papermc:paper")
|
||||||
|
+ */
|
||||||
|
+ @NotNull Key brandId();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Checks if the current server supports the specified brand.
|
||||||
|
+ *
|
||||||
|
+ * @param brandId the brand to check (e.g. "papermc:folia")
|
||||||
|
+ * @return {@code true} if the server supports the specified brand
|
||||||
|
+ */
|
||||||
|
+ @ApiStatus.Experimental
|
||||||
|
+ boolean isBrandCompatible(final @NotNull Key brandId);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the brand name of the server.
|
||||||
|
+ *
|
||||||
|
+ * @return the brand name of the server (e.g. "Paper")
|
||||||
|
+ */
|
||||||
|
+ @NotNull String brandName();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the Minecraft version id.
|
||||||
|
+ *
|
||||||
|
+ * @return the Minecraft version id (e.g. "1.20.4", "1.20.2-pre2", "23w31a")
|
||||||
|
+ */
|
||||||
|
+ @NotNull String minecraftVersionId();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the Minecraft version name.
|
||||||
|
+ *
|
||||||
|
+ * @return the Minecraft version name (e.g. "1.20.4", "1.20.2 Pre-release 2", "23w31a")
|
||||||
|
+ */
|
||||||
|
+ @NotNull String minecraftVersionName();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the build number.
|
||||||
|
+ *
|
||||||
|
+ * @return the build number
|
||||||
|
+ */
|
||||||
|
+ @NotNull OptionalInt buildNumber();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the build time.
|
||||||
|
+ *
|
||||||
|
+ * @return the build time
|
||||||
|
+ */
|
||||||
|
+ @NotNull Instant buildTime();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the git commit branch.
|
||||||
|
+ *
|
||||||
|
+ * @return the git commit branch
|
||||||
|
+ */
|
||||||
|
+ @NotNull Optional<String> gitBranch();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the git commit hash.
|
||||||
|
+ *
|
||||||
|
+ * @return the git commit hash
|
||||||
|
+ */
|
||||||
|
+ @NotNull Optional<String> gitCommit();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Creates a string representation of the server build information.
|
||||||
|
+ *
|
||||||
|
+ * @param representation the type of representation
|
||||||
|
+ * @return a string
|
||||||
|
+ */
|
||||||
|
+ @NotNull String asString(final @NotNull StringRepresentation representation);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * String representation types.
|
||||||
|
+ */
|
||||||
|
+ enum StringRepresentation {
|
||||||
|
+ /**
|
||||||
|
+ * A simple version string, in format {@code <minecraftVersionId>-<buildNumber>-<gitCommit>}.
|
||||||
|
+ */
|
||||||
|
+ VERSION_SIMPLE,
|
||||||
|
+ /**
|
||||||
|
+ * A simple version string, in format {@code <minecraftVersionId>-<buildNumber>-<gitBranch>@<gitCommit> (<buildTime>)}.
|
||||||
|
+ */
|
||||||
|
+ VERSION_FULL,
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/util/JarManifests.java b/src/main/java/io/papermc/paper/util/JarManifests.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..909617079db61b675cc7b60b44ef96b306076343
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/util/JarManifests.java
|
||||||
|
@@ -0,0 +1,37 @@
|
||||||
|
+package io.papermc.paper.util;
|
||||||
|
+
|
||||||
|
+import java.io.IOException;
|
||||||
|
+import java.io.InputStream;
|
||||||
|
+import java.net.URL;
|
||||||
|
+import java.util.Collections;
|
||||||
|
+import java.util.Map;
|
||||||
|
+import java.util.WeakHashMap;
|
||||||
|
+import java.util.jar.Manifest;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+import org.jetbrains.annotations.Nullable;
|
||||||
|
+
|
||||||
|
+@ApiStatus.Internal
|
||||||
|
+public final class JarManifests {
|
||||||
|
+ private JarManifests() {
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static final Map<ClassLoader, Manifest> MANIFESTS = Collections.synchronizedMap(new WeakHashMap<>());
|
||||||
|
+
|
||||||
|
+ public static @Nullable Manifest manifest(final @NotNull Class<?> clazz) {
|
||||||
|
+ return MANIFESTS.computeIfAbsent(clazz.getClassLoader(), classLoader -> {
|
||||||
|
+ final String classLocation = "/" + clazz.getName().replace(".", "/") + ".class";
|
||||||
|
+ final URL resource = clazz.getResource(classLocation);
|
||||||
|
+ if (resource == null) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ final String classFilePath = resource.toString().replace("\\", "/");
|
||||||
|
+ final String archivePath = classFilePath.substring(0, classFilePath.length() - classLocation.length());
|
||||||
|
+ try (final InputStream stream = new URL(archivePath + "/META-INF/MANIFEST.MF").openStream()) {
|
||||||
|
+ return new Manifest(stream);
|
||||||
|
+ } catch (final IOException ex) {
|
||||||
|
+ return null;
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
index 5780003631beae773231afe3afc6b834bfe1f84d..a005d5f8879262c763d8c4fbd09b9a99810d5e8c 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
@@ -110,13 +110,26 @@ public final class Bukkit {
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.server = server;
|
||||||
|
- server.getLogger().info("This server is running " + getName() + " version " + getVersion() + " (Implementing API version " + getBukkitVersion() + ")");
|
||||||
|
+ // Paper start - add git information
|
||||||
|
+ server.getLogger().info(getVersionMessage());
|
||||||
|
+ }
|
||||||
|
+ /**
|
||||||
|
+ * Gets message describing the version server is running.
|
||||||
|
+ *
|
||||||
|
+ * @return message describing the version server is running
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public static String getVersionMessage() {
|
||||||
|
+ final io.papermc.paper.ServerBuildInfo version = io.papermc.paper.ServerBuildInfo.buildInfo();
|
||||||
|
+ return "This server is running " + getName() + " version " + version.asString(io.papermc.paper.ServerBuildInfo.StringRepresentation.VERSION_FULL) + " (Implementing API version " + getBukkitVersion() + ")";
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of this server implementation.
|
||||||
|
*
|
||||||
|
* @return name of this server implementation
|
||||||
|
+ * @see io.papermc.paper.ServerBuildInfo#brandName()
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static String getName() {
|
||||||
|
@@ -127,6 +140,7 @@ public final class Bukkit {
|
||||||
|
* Gets the version string of this server implementation.
|
||||||
|
*
|
||||||
|
* @return version of this server implementation
|
||||||
|
+ * @see io.papermc.paper.ServerBuildInfo
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static String getVersion() {
|
||||||
|
@@ -143,6 +157,20 @@ public final class Bukkit {
|
||||||
|
return server.getBukkitVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start - expose game version
|
||||||
|
+ /**
|
||||||
|
+ * Gets the version of game this server implements
|
||||||
|
+ *
|
||||||
|
+ * @return version of game
|
||||||
|
+ * @see io.papermc.paper.ServerBuildInfo#minecraftVersionId()
|
||||||
|
+ * @see io.papermc.paper.ServerBuildInfo#minecraftVersionName()
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public static String getMinecraftVersion() {
|
||||||
|
+ return server.getMinecraftVersion();
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Gets a view of all currently logged in players. This {@linkplain
|
||||||
|
* Collections#unmodifiableCollection(Collection) view} is a reused
|
||||||
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
|
index ba28d9f3213ca4b5f15178dc637bff37a8896edc..8a07f21eeb04fb54032ce377a1478f60303e1824 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
|
@@ -120,6 +120,16 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
|
@NotNull
|
||||||
|
public String getBukkitVersion();
|
||||||
|
|
||||||
|
+ // Paper start - expose game version
|
||||||
|
+ /**
|
||||||
|
+ * Gets the version of game this server implements
|
||||||
|
+ *
|
||||||
|
+ * @return version of game
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ String getMinecraftVersion();
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Gets a view of all currently logged in players. This {@linkplain
|
||||||
|
* Collections#unmodifiableCollection(Collection) view} is a reused
|
||||||
|
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
|
index 12ef99f1c91b92a133611c5f5aeaaeebd02ce232..6e67fdb091a006d2d13bc2d93db4d55348af4c8f 100644
|
||||||
|
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
|
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||||
|
@@ -163,5 +163,12 @@ public interface UnsafeValues {
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
|
String getTimingsServerName();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Called once by the version command on first use, then cached.
|
||||||
|
+ */
|
||||||
|
+ default com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
|
||||||
|
+ return new com.destroystokyo.paper.util.VersionFetcher.DummyVersionFetcher();
|
||||||
|
+ }
|
||||||
|
// Paper end
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||||
|
index 263208d3cba36cb80c9ee4e3022ef702ea113df2..e64bb57f74e6d6f78927be228825b3e0bdf41f48 100644
|
||||||
|
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||||
|
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||||
|
@@ -25,8 +25,25 @@ import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
+// Paper start - version command 2.0
|
||||||
|
+import com.destroystokyo.paper.util.VersionFetcher;
|
||||||
|
+import net.kyori.adventure.text.Component;
|
||||||
|
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
+import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
+import net.kyori.adventure.text.format.TextDecoration;
|
||||||
|
+import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
|
+// Paper end - version command 2.0
|
||||||
|
|
||||||
|
public class VersionCommand extends BukkitCommand {
|
||||||
|
+ private VersionFetcher versionFetcher; // Paper - version command 2.0
|
||||||
|
+ private VersionFetcher getVersionFetcher() { // lazy load because unsafe isn't available at command registration
|
||||||
|
+ if (versionFetcher == null) {
|
||||||
|
+ versionFetcher = Bukkit.getUnsafe().getVersionFetcher();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return versionFetcher;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
public VersionCommand(@NotNull String name) {
|
||||||
|
super(name);
|
||||||
|
|
||||||
|
@@ -41,7 +58,7 @@ public class VersionCommand extends BukkitCommand {
|
||||||
|
if (!testPermission(sender)) return true;
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
- sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")");
|
||||||
|
+ //sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")"); // Paper - moved to setVersionMessage
|
||||||
|
sendVersion(sender);
|
||||||
|
} else {
|
||||||
|
StringBuilder name = new StringBuilder();
|
||||||
|
@@ -80,8 +97,17 @@ public class VersionCommand extends BukkitCommand {
|
||||||
|
|
||||||
|
private void describeToSender(@NotNull Plugin plugin, @NotNull CommandSender sender) {
|
||||||
|
PluginDescriptionFile desc = plugin.getDescription();
|
||||||
|
- sender.sendMessage(ChatColor.GREEN + desc.getName() + ChatColor.WHITE + " version " + ChatColor.GREEN + desc.getVersion());
|
||||||
|
-
|
||||||
|
+ // Paper start - version command 2.0
|
||||||
|
+ sender.sendMessage(
|
||||||
|
+ Component.text()
|
||||||
|
+ .append(Component.text(desc.getName(), NamedTextColor.GREEN))
|
||||||
|
+ .append(Component.text(" version "))
|
||||||
|
+ .append(Component.text(desc.getVersion(), NamedTextColor.GREEN)
|
||||||
|
+ .hoverEvent(Component.text("Click to copy to clipboard", NamedTextColor.WHITE))
|
||||||
|
+ .clickEvent(ClickEvent.copyToClipboard(desc.getVersion()))
|
||||||
|
+ )
|
||||||
|
+ );
|
||||||
|
+ // Paper end - version command 2.0
|
||||||
|
if (desc.getDescription() != null) {
|
||||||
|
sender.sendMessage(desc.getDescription());
|
||||||
|
}
|
||||||
|
@@ -147,14 +173,14 @@ public class VersionCommand extends BukkitCommand {
|
||||||
|
|
||||||
|
private final ReentrantLock versionLock = new ReentrantLock();
|
||||||
|
private boolean hasVersion = false;
|
||||||
|
- private String versionMessage = null;
|
||||||
|
+ private Component versionMessage = null; // Paper
|
||||||
|
private final Set<CommandSender> versionWaiters = new HashSet<CommandSender>();
|
||||||
|
private boolean versionTaskStarted = false;
|
||||||
|
private long lastCheck = 0;
|
||||||
|
|
||||||
|
private void sendVersion(@NotNull CommandSender sender) {
|
||||||
|
if (hasVersion) {
|
||||||
|
- if (System.currentTimeMillis() - lastCheck > 21600000) {
|
||||||
|
+ if (System.currentTimeMillis() - lastCheck > getVersionFetcher().getCacheTime()) { // Paper - use version supplier
|
||||||
|
lastCheck = System.currentTimeMillis();
|
||||||
|
hasVersion = false;
|
||||||
|
} else {
|
||||||
|
@@ -169,7 +195,7 @@ public class VersionCommand extends BukkitCommand {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
versionWaiters.add(sender);
|
||||||
|
- sender.sendMessage("Checking version, please wait...");
|
||||||
|
+ sender.sendMessage(Component.text("Checking version, please wait...", NamedTextColor.WHITE, TextDecoration.ITALIC)); // Paper
|
||||||
|
if (!versionTaskStarted) {
|
||||||
|
versionTaskStarted = true;
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@@ -187,6 +213,13 @@ public class VersionCommand extends BukkitCommand {
|
||||||
|
|
||||||
|
private void obtainVersion() {
|
||||||
|
String version = Bukkit.getVersion();
|
||||||
|
+ // Paper start
|
||||||
|
+ if (version.startsWith("null")) { // running from ide?
|
||||||
|
+ setVersionMessage(Component.text("Unknown version, custom build?", NamedTextColor.YELLOW));
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ setVersionMessage(getVersionFetcher().getVersionMessage(version));
|
||||||
|
+ /*
|
||||||
|
if (version == null) version = "Custom";
|
||||||
|
String[] parts = version.substring(0, version.indexOf(' ')).split("-");
|
||||||
|
if (parts.length == 4) {
|
||||||
|
@@ -216,11 +249,24 @@ public class VersionCommand extends BukkitCommand {
|
||||||
|
} else {
|
||||||
|
setVersionMessage("Unknown version, custom build?");
|
||||||
|
}
|
||||||
|
+ */
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
|
||||||
|
- private void setVersionMessage(@NotNull String msg) {
|
||||||
|
+ // Paper start
|
||||||
|
+ private void setVersionMessage(final @NotNull Component msg) {
|
||||||
|
lastCheck = System.currentTimeMillis();
|
||||||
|
- versionMessage = msg;
|
||||||
|
+ final Component message = Component.textOfChildren(
|
||||||
|
+ Component.text(Bukkit.getVersionMessage(), NamedTextColor.WHITE),
|
||||||
|
+ Component.newline(),
|
||||||
|
+ msg
|
||||||
|
+ );
|
||||||
|
+ this.versionMessage = Component.text()
|
||||||
|
+ .append(message)
|
||||||
|
+ .hoverEvent(Component.text("Click to copy to clipboard", NamedTextColor.WHITE))
|
||||||
|
+ .clickEvent(ClickEvent.copyToClipboard(PlainTextComponentSerializer.plainText().serialize(message)))
|
||||||
|
+ .build();
|
||||||
|
+ // Paper end
|
||||||
|
versionLock.lock();
|
||||||
|
try {
|
||||||
|
hasVersion = true;
|
||||||
|
diff --git a/src/test/java/io/papermc/paper/TestServerBuildInfo.java b/src/test/java/io/papermc/paper/TestServerBuildInfo.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..17be27a869c1047a7a9440fb8f3717260d4abbd0
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/test/java/io/papermc/paper/TestServerBuildInfo.java
|
||||||
|
@@ -0,0 +1,59 @@
|
||||||
|
+package io.papermc.paper;
|
||||||
|
+
|
||||||
|
+import java.time.Instant;
|
||||||
|
+import java.util.Optional;
|
||||||
|
+import java.util.OptionalInt;
|
||||||
|
+import net.kyori.adventure.key.Key;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+public class TestServerBuildInfo implements ServerBuildInfo {
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull Key brandId() {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isBrandCompatible(final @NotNull Key brandId) {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull String brandName() {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull String minecraftVersionId() {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull String minecraftVersionName() {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull OptionalInt buildNumber() {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull Instant buildTime() {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull Optional<String> gitBranch() {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull Optional<String> gitCommit() {
|
||||||
|
+ throw new UnsupportedOperationException();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public @NotNull String asString(final @NotNull StringRepresentation representation) {
|
||||||
|
+ return "";
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/test/resources/META-INF/services/io.papermc.paper.ServerBuildInfo b/src/test/resources/META-INF/services/io.papermc.paper.ServerBuildInfo
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..64e2f8559b9c5a52e0a3229d3d12f65e9af145b3
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/test/resources/META-INF/services/io.papermc.paper.ServerBuildInfo
|
||||||
|
@@ -0,0 +1 @@
|
||||||
|
+io.papermc.paper.TestServerBuildInfo
|
@ -1,63 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Isaac Moore <rmsy@me.com>
|
|
||||||
Date: Mon, 29 Feb 2016 18:02:25 -0600
|
|
||||||
Subject: [PATCH] Add PlayerLocaleChangeEvent
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..bb7baa91fd4ba763fd8ce216bc9043c5e2c4b7b7
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java
|
|
||||||
@@ -0,0 +1,51 @@
|
|
||||||
+package com.destroystokyo.paper.event.player;
|
|
||||||
+
|
|
||||||
+import org.bukkit.entity.Player;
|
|
||||||
+import org.bukkit.event.HandlerList;
|
|
||||||
+import org.bukkit.event.player.PlayerEvent;
|
|
||||||
+import org.jetbrains.annotations.ApiStatus;
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * Called when the locale of the player is changed.
|
|
||||||
+ *
|
|
||||||
+ * @deprecated Replaced by {@link org.bukkit.event.player.PlayerLocaleChangeEvent} upstream
|
|
||||||
+ */
|
|
||||||
+@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21")
|
|
||||||
+public class PlayerLocaleChangeEvent extends PlayerEvent {
|
|
||||||
+ private static final HandlerList handlers = new HandlerList();
|
|
||||||
+ private final String oldLocale;
|
|
||||||
+ private final String newLocale;
|
|
||||||
+
|
|
||||||
+ public PlayerLocaleChangeEvent(final Player player, final String oldLocale, final String newLocale) {
|
|
||||||
+ super(player);
|
|
||||||
+ this.oldLocale = oldLocale;
|
|
||||||
+ this.newLocale = newLocale;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the locale the player switched from.
|
|
||||||
+ *
|
|
||||||
+ * @return player's old locale
|
|
||||||
+ */
|
|
||||||
+ public String getOldLocale() {
|
|
||||||
+ return oldLocale;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the locale the player is changed to.
|
|
||||||
+ *
|
|
||||||
+ * @return player's new locale
|
|
||||||
+ */
|
|
||||||
+ public String getNewLocale() {
|
|
||||||
+ return newLocale;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public HandlerList getHandlers() {
|
|
||||||
+ return handlers;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static HandlerList getHandlerList() {
|
|
||||||
+ return handlers;
|
|
||||||
+ }
|
|
||||||
+}
|
|
66
patches/api/0016-Entity-Origin-API.patch
Normale Datei
66
patches/api/0016-Entity-Origin-API.patch
Normale Datei
@ -0,0 +1,66 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Byteflux <byte@byteflux.net>
|
||||||
|
Date: Mon, 29 Feb 2016 17:50:31 -0600
|
||||||
|
Subject: [PATCH] Entity Origin API
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||||
|
index c78fb359bd28b8dc1ba242642ec612e856525993..4e1fb0974d061d5bb64899cac576318d2e6f8bf6 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||||
|
@@ -791,5 +791,15 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
||||||
|
default net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity> asHoverEvent(final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowEntity> op) {
|
||||||
|
return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.customName())));
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the location where this entity originates from.
|
||||||
|
+ * <p>
|
||||||
|
+ * This value can be null if the entity hasn't yet been added to the world.
|
||||||
|
+ *
|
||||||
|
+ * @return Location where entity originates or null if not yet added
|
||||||
|
+ */
|
||||||
|
+ @Nullable
|
||||||
|
+ Location getOrigin();
|
||||||
|
// Paper end
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||||
|
index d96fd494b523491fcf1ac54d164351fd487f65d6..ae1ce2ee2deb82f3f4144ec54b3ba119b437c5e9 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||||
|
@@ -126,4 +126,15 @@ public interface FallingBlock extends Entity {
|
||||||
|
* @param damage the max damage to set. Must be >= 0
|
||||||
|
*/
|
||||||
|
void setMaxDamage(int damage);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the source block location of the FallingBlock
|
||||||
|
+ *
|
||||||
|
+ * @return the source block location the FallingBlock was spawned from
|
||||||
|
+ * @deprecated replaced by {@link Entity#getOrigin()}
|
||||||
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
|
+ default org.bukkit.Location getSourceLoc() {
|
||||||
|
+ return this.getOrigin();
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/TNTPrimed.java b/src/main/java/org/bukkit/entity/TNTPrimed.java
|
||||||
|
index a23cfdf66877f0a61eae700de084c76e6ee7b431..0813bd913c8fdb2001963ce3e82c07c2af105418 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/TNTPrimed.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/TNTPrimed.java
|
||||||
|
@@ -53,4 +53,15 @@ public interface TNTPrimed extends Explosive {
|
||||||
|
* @param source the source of this primed TNT
|
||||||
|
*/
|
||||||
|
public void setSource(@Nullable Entity source);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the source block location of the TNTPrimed
|
||||||
|
+ *
|
||||||
|
+ * @return the source block location the TNTPrimed was spawned from
|
||||||
|
+ * @deprecated replaced by {@link Entity#getOrigin()}
|
||||||
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
|
+ default org.bukkit.Location getSourceLoc() {
|
||||||
|
+ return this.getOrigin();
|
||||||
|
+ }
|
||||||
|
}
|
@ -8,12 +8,12 @@ Add per player no-tick, tick, and send view distances.
|
|||||||
Also add send/no-tick view distance to World.
|
Also add send/no-tick view distance to World.
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||||
index 5357291ff0f2f20bd87ab9f6e57f6a4f6ff65226..887aa6217583d224d66f6d238ac269c23725d459 100644
|
index 9732929b666b0a5e1a2a41c8e8794cc4f2535e41..0a3a66e04f8785874f10a76603bff46469543688 100644
|
||||||
--- a/src/main/java/org/bukkit/World.java
|
--- a/src/main/java/org/bukkit/World.java
|
||||||
+++ b/src/main/java/org/bukkit/World.java
|
+++ b/src/main/java/org/bukkit/World.java
|
||||||
@@ -2662,6 +2662,62 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
@@ -2968,6 +2968,66 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
||||||
int getSimulationDistance();
|
@NotNull
|
||||||
// Spigot end
|
public Set<FeatureFlag> getFeatureFlags();
|
||||||
|
|
||||||
+ // Paper start - view distance api
|
+ // Paper start - view distance api
|
||||||
+ /**
|
+ /**
|
||||||
@ -38,7 +38,9 @@ index 5357291ff0f2f20bd87ab9f6e57f6a4f6ff65226..887aa6217583d224d66f6d238ac269c2
|
|||||||
+ * @deprecated Use {@link #getViewDistance()}
|
+ * @deprecated Use {@link #getViewDistance()}
|
||||||
+ */
|
+ */
|
||||||
+ @Deprecated
|
+ @Deprecated
|
||||||
+ int getNoTickViewDistance();
|
+ default int getNoTickViewDistance() {
|
||||||
|
+ return this.getViewDistance();
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Sets the no-tick view distance for this world.
|
+ * Sets the no-tick view distance for this world.
|
||||||
@ -50,7 +52,9 @@ index 5357291ff0f2f20bd87ab9f6e57f6a4f6ff65226..887aa6217583d224d66f6d238ac269c2
|
|||||||
+ * @deprecated Use {@link #setViewDistance(int)}
|
+ * @deprecated Use {@link #setViewDistance(int)}
|
||||||
+ */
|
+ */
|
||||||
+ @Deprecated
|
+ @Deprecated
|
||||||
+ void setNoTickViewDistance(int viewDistance);
|
+ default void setNoTickViewDistance(int viewDistance) {
|
||||||
|
+ this.setViewDistance(viewDistance);
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Gets the sending view distance for this world.
|
+ * Gets the sending view distance for this world.
|
||||||
@ -71,14 +75,14 @@ index 5357291ff0f2f20bd87ab9f6e57f6a4f6ff65226..887aa6217583d224d66f6d238ac269c2
|
|||||||
+ void setSendViewDistance(int viewDistance);
|
+ void setSendViewDistance(int viewDistance);
|
||||||
+ // Paper end - view distance api
|
+ // Paper end - view distance api
|
||||||
+
|
+
|
||||||
// Spigot start
|
/**
|
||||||
public class Spigot {
|
* Gets all generated structures that intersect the chunk at the given
|
||||||
|
* coordinates. <br>
|
||||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||||
index 6b1a198f930a5a995e0cb6c279b455e1639a5039..f8e45f70fe23cf73c8677b5d24cefcd3aae5e24e 100644
|
index 1ba2f706a62ee6962451305b1895654453b485cd..7d530bd0e4d833da760d1cf82aba966b7fb480b1 100644
|
||||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||||
@@ -2210,6 +2210,78 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
@@ -2597,6 +2597,82 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||||
* @param affects Whether the player can affect mob spawning
|
* @param affects Whether the player can affect mob spawning
|
||||||
*/
|
*/
|
||||||
public void setAffectsSpawning(boolean affects);
|
public void setAffectsSpawning(boolean affects);
|
||||||
@ -123,7 +127,9 @@ index 6b1a198f930a5a995e0cb6c279b455e1639a5039..f8e45f70fe23cf73c8677b5d24cefcd3
|
|||||||
+ * @deprecated Use {@link #getViewDistance()}
|
+ * @deprecated Use {@link #getViewDistance()}
|
||||||
+ */
|
+ */
|
||||||
+ @Deprecated
|
+ @Deprecated
|
||||||
+ public int getNoTickViewDistance();
|
+ default int getNoTickViewDistance() {
|
||||||
|
+ return this.getViewDistance();
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Sets the no-ticking view distance for this player.
|
+ * Sets the no-ticking view distance for this player.
|
||||||
@ -135,7 +141,9 @@ index 6b1a198f930a5a995e0cb6c279b455e1639a5039..f8e45f70fe23cf73c8677b5d24cefcd3
|
|||||||
+ * @deprecated Use {@link #setViewDistance(int)}
|
+ * @deprecated Use {@link #setViewDistance(int)}
|
||||||
+ */
|
+ */
|
||||||
+ @Deprecated
|
+ @Deprecated
|
||||||
+ public void setNoTickViewDistance(int viewDistance);
|
+ default void setNoTickViewDistance(int viewDistance) {
|
||||||
|
+ this.setViewDistance(viewDistance);
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Gets the sending view distance for this player.
|
+ * Gets the sending view distance for this player.
|
||||||
|
@ -6,10 +6,10 @@ Subject: [PATCH] Add BeaconEffectEvent
|
|||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java
|
diff --git a/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..978813b94a5eae0afccbd3b38b463091a46b56ac
|
index 0000000000000000000000000000000000000000..7270c1feece2dc15a4a0503c4bca93a1288f8f13
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java
|
+++ b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java
|
||||||
@@ -0,0 +1,86 @@
|
@@ -0,0 +1,91 @@
|
||||||
+package com.destroystokyo.paper.event.block;
|
+package com.destroystokyo.paper.event.block;
|
||||||
+
|
+
|
||||||
+import org.bukkit.block.Block;
|
+import org.bukkit.block.Block;
|
||||||
@ -18,18 +18,23 @@ index 0000000000000000000000000000000000000000..978813b94a5eae0afccbd3b38b463091
|
|||||||
+import org.bukkit.event.HandlerList;
|
+import org.bukkit.event.HandlerList;
|
||||||
+import org.bukkit.event.block.BlockEvent;
|
+import org.bukkit.event.block.BlockEvent;
|
||||||
+import org.bukkit.potion.PotionEffect;
|
+import org.bukkit.potion.PotionEffect;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
+import org.jetbrains.annotations.NotNull;
|
+import org.jetbrains.annotations.NotNull;
|
||||||
+
|
+
|
||||||
+/**
|
+/**
|
||||||
+ * Called when a beacon effect is being applied to a player.
|
+ * Called when a beacon effect is being applied to a player.
|
||||||
+ */
|
+ */
|
||||||
+public class BeaconEffectEvent extends BlockEvent implements Cancellable {
|
+public class BeaconEffectEvent extends BlockEvent implements Cancellable {
|
||||||
+ private static final HandlerList handlers = new HandlerList();
|
|
||||||
+ private boolean cancelled;
|
|
||||||
+ private PotionEffect effect;
|
|
||||||
+ private Player player;
|
|
||||||
+ private boolean primary;
|
|
||||||
+
|
+
|
||||||
|
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
+
|
||||||
|
+ private final Player player;
|
||||||
|
+ private final boolean primary;
|
||||||
|
+ private PotionEffect effect;
|
||||||
|
+
|
||||||
|
+ private boolean cancelled;
|
||||||
|
+
|
||||||
|
+ @ApiStatus.Internal
|
||||||
+ public BeaconEffectEvent(@NotNull Block block, @NotNull PotionEffect effect, @NotNull Player player, boolean primary) {
|
+ public BeaconEffectEvent(@NotNull Block block, @NotNull PotionEffect effect, @NotNull Player player, boolean primary) {
|
||||||
+ super(block);
|
+ super(block);
|
||||||
+ this.effect = effect;
|
+ this.effect = effect;
|
||||||
@ -37,16 +42,6 @@ index 0000000000000000000000000000000000000000..978813b94a5eae0afccbd3b38b463091
|
|||||||
+ this.primary = primary;
|
+ this.primary = primary;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
|
||||||
+ public boolean isCancelled() {
|
|
||||||
+ return cancelled;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public void setCancelled(boolean cancelled) {
|
|
||||||
+ this.cancelled = cancelled;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
+ /**
|
||||||
+ * Gets the potion effect being applied.
|
+ * Gets the potion effect being applied.
|
||||||
+ *
|
+ *
|
||||||
@ -54,7 +49,7 @@ index 0000000000000000000000000000000000000000..978813b94a5eae0afccbd3b38b463091
|
|||||||
+ */
|
+ */
|
||||||
+ @NotNull
|
+ @NotNull
|
||||||
+ public PotionEffect getEffect() {
|
+ public PotionEffect getEffect() {
|
||||||
+ return effect;
|
+ return this.effect;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
@ -73,26 +68,36 @@ index 0000000000000000000000000000000000000000..978813b94a5eae0afccbd3b38b463091
|
|||||||
+ */
|
+ */
|
||||||
+ @NotNull
|
+ @NotNull
|
||||||
+ public Player getPlayer() {
|
+ public Player getPlayer() {
|
||||||
+ return player;
|
+ return this.player;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /**
|
+ /**
|
||||||
+ * Gets whether the effect is a primary beacon effect.
|
+ * Gets whether the effect is a primary beacon effect.
|
||||||
+ *
|
+ *
|
||||||
+ * @return true if this event represents a primary effect
|
+ * @return {@code true} if this event represents a primary effect
|
||||||
+ */
|
+ */
|
||||||
+ public boolean isPrimary() {
|
+ public boolean isPrimary() {
|
||||||
+ return primary;
|
+ return this.primary;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isCancelled() {
|
||||||
|
+ return this.cancelled;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void setCancelled(boolean cancel) {
|
||||||
|
+ this.cancelled = cancel;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @NotNull
|
+ @NotNull
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public HandlerList getHandlers() {
|
+ public HandlerList getHandlers() {
|
||||||
+ return handlers;
|
+ return HANDLER_LIST;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @NotNull
|
+ @NotNull
|
||||||
+ public static HandlerList getHandlerList() {
|
+ public static HandlerList getHandlerList() {
|
||||||
+ return handlers;
|
+ return HANDLER_LIST;
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Steve Anton <anxuiz.nx@gmail.com>
|
|
||||||
Date: Mon, 29 Feb 2016 18:13:58 -0600
|
|
||||||
Subject: [PATCH] Add PlayerInitialSpawnEvent
|
|
||||||
|
|
||||||
For modifying a player's initial spawn location as they join the server
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..febd384b43560d7d55c96bda5b0701a27fc9e18e
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java
|
|
||||||
@@ -0,0 +1,18 @@
|
|
||||||
+package com.destroystokyo.paper.event.player;
|
|
||||||
+
|
|
||||||
+import org.bukkit.Location;
|
|
||||||
+import org.bukkit.entity.Player;
|
|
||||||
+import org.jetbrains.annotations.ApiStatus;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+import org.spigotmc.event.player.PlayerSpawnLocationEvent;
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * @deprecated Use {@link PlayerSpawnLocationEvent}, Duplicate API
|
|
||||||
+ */
|
|
||||||
+@Deprecated(forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.21")
|
|
||||||
+public class PlayerInitialSpawnEvent extends PlayerSpawnLocationEvent {
|
|
||||||
+
|
|
||||||
+ public PlayerInitialSpawnEvent(@NotNull Player who, @NotNull Location spawnLocation) {
|
|
||||||
+ super(who, spawnLocation);
|
|
||||||
+ }
|
|
||||||
+}
|
|
50
patches/api/0019-Expose-server-CommandMap.patch
Normale Datei
50
patches/api/0019-Expose-server-CommandMap.patch
Normale Datei
@ -0,0 +1,50 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: kashike <kashike@vq.lc>
|
||||||
|
Date: Mon, 29 Feb 2016 19:48:59 -0600
|
||||||
|
Subject: [PATCH] Expose server CommandMap
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
index a005d5f8879262c763d8c4fbd09b9a99810d5e8c..26f3ac9c15ff554becfe8ea53a48f67b2de60ed6 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
@@ -2337,6 +2337,19 @@ public final class Bukkit {
|
||||||
|
return server.getUnsafe();
|
||||||
|
}
|
||||||
|
|
||||||
|
+
|
||||||
|
+ // Paper start
|
||||||
|
+ /**
|
||||||
|
+ * Gets the active {@link org.bukkit.command.CommandMap}
|
||||||
|
+ *
|
||||||
|
+ * @return the active command map
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public static org.bukkit.command.CommandMap getCommandMap() {
|
||||||
|
+ return server.getCommandMap();
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
@NotNull
|
||||||
|
public static Server.Spigot spigot() {
|
||||||
|
return server.spigot();
|
||||||
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
|
index 8a07f21eeb04fb54032ce377a1478f60303e1824..d78481bf17818415524f14417caf86d5684b2235 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
|
@@ -1817,6 +1817,15 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
|
public double[] getTPS();
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ /**
|
||||||
|
+ * Gets the active {@link org.bukkit.command.CommandMap}
|
||||||
|
+ *
|
||||||
|
+ * @return the active command map
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ org.bukkit.command.CommandMap getCommandMap();
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Get the advancement specified by this key.
|
||||||
|
*
|
@ -1,50 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: kashike <kashike@vq.lc>
|
|
||||||
Date: Mon, 29 Feb 2016 19:48:59 -0600
|
|
||||||
Subject: [PATCH] Expose server CommandMap
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
index fba3e617a8847a3e9282e6a1a389132b2ad5511c..acb34296923fb27cfc28c130cf0b5405cfe340f6 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
@@ -2165,6 +2165,19 @@ public final class Bukkit {
|
|
||||||
return server.getUnsafe();
|
|
||||||
}
|
|
||||||
|
|
||||||
+
|
|
||||||
+ // Paper start
|
|
||||||
+ /**
|
|
||||||
+ * Gets the active {@link org.bukkit.command.CommandMap}
|
|
||||||
+ *
|
|
||||||
+ * @return the active command map
|
|
||||||
+ */
|
|
||||||
+ @NotNull
|
|
||||||
+ public static org.bukkit.command.CommandMap getCommandMap() {
|
|
||||||
+ return server.getCommandMap();
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
+
|
|
||||||
@NotNull
|
|
||||||
public static Server.Spigot spigot() {
|
|
||||||
return server.spigot();
|
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
|
||||||
index c8cf66e64a3163c2bdf781f3ce52059546969b9b..5b3c34b01038849b1463870ccf657b11db82cd09 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
|
||||||
@@ -1682,6 +1682,15 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
|
||||||
public double[] getTPS();
|
|
||||||
// Paper end
|
|
||||||
|
|
||||||
+ // Paper start
|
|
||||||
+ /**
|
|
||||||
+ * Gets the active {@link org.bukkit.command.CommandMap}
|
|
||||||
+ *
|
|
||||||
+ * @return the active command map
|
|
||||||
+ */
|
|
||||||
+ @NotNull
|
|
||||||
+ org.bukkit.command.CommandMap getCommandMap();
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Get the advancement specified by this key.
|
|
||||||
*
|
|
@ -0,0 +1,124 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||||
|
Date: Mon, 29 Feb 2016 19:54:32 -0600
|
||||||
|
Subject: [PATCH] Graduate bungeecord chat API from spigot subclasses
|
||||||
|
|
||||||
|
Change Javadoc to be accurate
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
index fe074fe9553f61bdd72b64830532a78415348781..4c5327da1468cb1f9af00a99e7e79f578c47ee2a 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
@@ -472,6 +472,30 @@ public final class Bukkit {
|
||||||
|
return server.broadcastMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ /**
|
||||||
|
+ * Sends the component to all online players.
|
||||||
|
+ *
|
||||||
|
+ * @param component the component to send
|
||||||
|
+ * @deprecated use {@code sendMessage} methods on {@link #getServer()} that accept {@link net.kyori.adventure.text.Component}
|
||||||
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
|
+ public static void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent component) {
|
||||||
|
+ server.broadcast(component);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Sends an array of components as a single message to all online players.
|
||||||
|
+ *
|
||||||
|
+ * @param components the components to send
|
||||||
|
+ * @deprecated use {@code sendMessage} methods on {@link #getServer()} that accept {@link net.kyori.adventure.text.Component}
|
||||||
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
|
+ public static void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
|
||||||
|
+ server.broadcast(components);
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Gets the name of the update folder. The update folder is used to safely
|
||||||
|
* update plugins at the right moment on a plugin load.
|
||||||
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
|
index 9545da2adacaf0bd719c2baef929588cd1042d25..19b75704ed9eee0c929df417e1e5d0ea3718e2f8 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
|
@@ -383,6 +383,30 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
|
@Deprecated // Paper
|
||||||
|
public int broadcastMessage(@NotNull String message);
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ /**
|
||||||
|
+ * Sends the component to all online players.
|
||||||
|
+ *
|
||||||
|
+ * @param component the component to send
|
||||||
|
+ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component}
|
||||||
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
|
+ public default void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent component) {
|
||||||
|
+ spigot().broadcast(component);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Sends an array of components as a single message to all online players.
|
||||||
|
+ *
|
||||||
|
+ * @param components the components to send
|
||||||
|
+ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component}
|
||||||
|
+ */
|
||||||
|
+ @Deprecated
|
||||||
|
+ public default void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
|
||||||
|
+ spigot().broadcast(components);
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Gets the name of the update folder. The update folder is used to safely
|
||||||
|
* update plugins at the right moment on a plugin load.
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||||
|
index 7d530bd0e4d833da760d1cf82aba966b7fb480b1..f9bacbfa223826b3b54525648080fda306a1ec36 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||||
|
@@ -1214,6 +1214,42 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||||
|
*/
|
||||||
|
public void sendMap(@NotNull MapView map);
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ /**
|
||||||
|
+ * Sends the component to the player
|
||||||
|
+ *
|
||||||
|
+ * @param component the components to send
|
||||||
|
+ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component}
|
||||||
|
+ */
|
||||||
|
+ @Override
|
||||||
|
+ @Deprecated
|
||||||
|
+ public default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent component) {
|
||||||
|
+ spigot().sendMessage(component);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Sends an array of components as a single message to the player
|
||||||
|
+ *
|
||||||
|
+ * @param components the components to send
|
||||||
|
+ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component}
|
||||||
|
+ */
|
||||||
|
+ @Override
|
||||||
|
+ @Deprecated
|
||||||
|
+ public default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
|
||||||
|
+ spigot().sendMessage(components);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Sends an array of components as a single message to the specified screen position of this player
|
||||||
|
+ *
|
||||||
|
+ * @param position the screen position
|
||||||
|
+ * @param components the components to send
|
||||||
|
+ */
|
||||||
|
+ public default void sendMessage(net.md_5.bungee.api.ChatMessageType position, net.md_5.bungee.api.chat.BaseComponent... components) {
|
||||||
|
+ spigot().sendMessage(position, components);
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Send a hurt animation. This fakes incoming damage towards the player from
|
||||||
|
* the given yaw relative to the player's direction.
|
583
patches/api/0021-Add-exception-reporting-event.patch
Normale Datei
583
patches/api/0021-Add-exception-reporting-event.patch
Normale Datei
@ -0,0 +1,583 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||||
|
Date: Mon, 29 Feb 2016 20:24:35 -0600
|
||||||
|
Subject: [PATCH] Add exception reporting event
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java b/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..9377ee1c2368ce058397037952d17bc010f66957
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/event/server/ServerExceptionEvent.java
|
||||||
|
@@ -0,0 +1,45 @@
|
||||||
|
+package com.destroystokyo.paper.event.server;
|
||||||
|
+
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
+import org.bukkit.event.Event;
|
||||||
|
+import org.bukkit.event.HandlerList;
|
||||||
|
+import com.destroystokyo.paper.exception.ServerException;
|
||||||
|
+import org.jetbrains.annotations.ApiStatus;
|
||||||
|
+import org.jetbrains.annotations.NotNull;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Called whenever an exception is thrown in a recoverable section of the server.
|
||||||
|
+ */
|
||||||
|
+public class ServerExceptionEvent extends Event {
|
||||||
|
+
|
||||||
|
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
+
|
||||||
|
+ @NotNull private final ServerException exception;
|
||||||
|
+
|
||||||
|
+ @ApiStatus.Internal
|
||||||
|
+ public ServerExceptionEvent(@NotNull ServerException exception) {
|
||||||
|
+ super(!Bukkit.isPrimaryThread());
|
||||||
|
+ this.exception = exception;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the wrapped exception that was thrown.
|
||||||
|
+ *
|
||||||
|
+ * @return Exception thrown
|
||||||
|
+ */
|
||||||
|
+ @NotNull
|
||||||
|
+ public ServerException getException() {
|
||||||
|
+ return this.exception;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ @Override
|
||||||
|
+ public HandlerList getHandlers() {
|
||||||
|
+ return HANDLER_LIST;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @NotNull
|
||||||
|
+ public static HandlerList getHandlerList() {
|
||||||
|
+ return HANDLER_LIST;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerCommandException.java b/src/main/java/com/destroystokyo/paper/exception/ServerCommandException.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..6fb39af0479a818f7f1465bcdfe505ab4ff7da1a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/exception/ServerCommandException.java
|
||||||
|
@@ -0,0 +1,64 @@
|
||||||
|
+package com.destroystokyo.paper.exception;
|
||||||
|
+
|
||||||
|
+import org.bukkit.command.Command;
|
||||||
|
+import org.bukkit.command.CommandSender;
|
||||||
|
+
|
||||||
|
+import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Thrown when a command throws an exception
|
||||||
|
+ */
|
||||||
|
+public class ServerCommandException extends ServerException {
|
||||||
|
+
|
||||||
|
+ private final Command command;
|
||||||
|
+ private final CommandSender commandSender;
|
||||||
|
+ private final String[] arguments;
|
||||||
|
+
|
||||||
|
+ public ServerCommandException(String message, Throwable cause, Command command, CommandSender commandSender, String[] arguments) {
|
||||||
|
+ super(message, cause);
|
||||||
|
+ this.commandSender = checkNotNull(commandSender, "commandSender");
|
||||||
|
+ this.arguments = checkNotNull(arguments, "arguments");
|
||||||
|
+ this.command = checkNotNull(command, "command");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ServerCommandException(Throwable cause, Command command, CommandSender commandSender, String[] arguments) {
|
||||||
|
+ super(cause);
|
||||||
|
+ this.commandSender = checkNotNull(commandSender, "commandSender");
|
||||||
|
+ this.arguments = checkNotNull(arguments, "arguments");
|
||||||
|
+ this.command = checkNotNull(command, "command");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected ServerCommandException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Command command, CommandSender commandSender, String[] arguments) {
|
||||||
|
+ super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
+ this.commandSender = checkNotNull(commandSender, "commandSender");
|
||||||
|
+ this.arguments = checkNotNull(arguments, "arguments");
|
||||||
|
+ this.command = checkNotNull(command, "command");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the command which threw the exception
|
||||||
|
+ *
|
||||||
|
+ * @return exception throwing command
|
||||||
|
+ */
|
||||||
|
+ public Command getCommand() {
|
||||||
|
+ return command;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the command sender which executed the command request
|
||||||
|
+ *
|
||||||
|
+ * @return command sender of exception thrown command request
|
||||||
|
+ */
|
||||||
|
+ public CommandSender getCommandSender() {
|
||||||
|
+ return commandSender;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the arguments which threw the exception for the command
|
||||||
|
+ *
|
||||||
|
+ * @return arguments of exception thrown command request
|
||||||
|
+ */
|
||||||
|
+ public String[] getArguments() {
|
||||||
|
+ return arguments;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerEventException.java b/src/main/java/com/destroystokyo/paper/exception/ServerEventException.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..410b24139535cd5d8439ad581c43c61b5757fbf6
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/exception/ServerEventException.java
|
||||||
|
@@ -0,0 +1,52 @@
|
||||||
|
+package com.destroystokyo.paper.exception;
|
||||||
|
+
|
||||||
|
+import org.bukkit.event.Event;
|
||||||
|
+import org.bukkit.event.Listener;
|
||||||
|
+import org.bukkit.plugin.Plugin;
|
||||||
|
+
|
||||||
|
+import static com.google.common.base.Preconditions.*;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Exception thrown when a server event listener throws an exception
|
||||||
|
+ */
|
||||||
|
+public class ServerEventException extends ServerPluginException {
|
||||||
|
+
|
||||||
|
+ private final Listener listener;
|
||||||
|
+ private final Event event;
|
||||||
|
+
|
||||||
|
+ public ServerEventException(String message, Throwable cause, Plugin responsiblePlugin, Listener listener, Event event) {
|
||||||
|
+ super(message, cause, responsiblePlugin);
|
||||||
|
+ this.listener = checkNotNull(listener, "listener");
|
||||||
|
+ this.event = checkNotNull(event, "event");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ServerEventException(Throwable cause, Plugin responsiblePlugin, Listener listener, Event event) {
|
||||||
|
+ super(cause, responsiblePlugin);
|
||||||
|
+ this.listener = checkNotNull(listener, "listener");
|
||||||
|
+ this.event = checkNotNull(event, "event");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected ServerEventException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Plugin responsiblePlugin, Listener listener, Event event) {
|
||||||
|
+ super(message, cause, enableSuppression, writableStackTrace, responsiblePlugin);
|
||||||
|
+ this.listener = checkNotNull(listener, "listener");
|
||||||
|
+ this.event = checkNotNull(event, "event");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the listener which threw the exception
|
||||||
|
+ *
|
||||||
|
+ * @return event listener
|
||||||
|
+ */
|
||||||
|
+ public Listener getListener() {
|
||||||
|
+ return listener;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the event which caused the exception
|
||||||
|
+ *
|
||||||
|
+ * @return event
|
||||||
|
+ */
|
||||||
|
+ public Event getEvent() {
|
||||||
|
+ return event;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerException.java b/src/main/java/com/destroystokyo/paper/exception/ServerException.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..c06ea3942447d4824b83ff839cb449fb818dede1
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/exception/ServerException.java
|
||||||
|
@@ -0,0 +1,23 @@
|
||||||
|
+package com.destroystokyo.paper.exception;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Wrapper exception for all exceptions that are thrown by the server.
|
||||||
|
+ */
|
||||||
|
+public class ServerException extends Exception {
|
||||||
|
+
|
||||||
|
+ public ServerException(String message) {
|
||||||
|
+ super(message);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ServerException(String message, Throwable cause) {
|
||||||
|
+ super(message, cause);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ServerException(Throwable cause) {
|
||||||
|
+ super(cause);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected ServerException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
+ super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerInternalException.java b/src/main/java/com/destroystokyo/paper/exception/ServerInternalException.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..2c3effca7c9d6c904cbe248d312b74e2cd360acf
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/exception/ServerInternalException.java
|
||||||
|
@@ -0,0 +1,36 @@
|
||||||
|
+package com.destroystokyo.paper.exception;
|
||||||
|
+
|
||||||
|
+import java.util.logging.Level;
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
+import com.destroystokyo.paper.event.server.ServerExceptionEvent;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Thrown when the internal server throws a recoverable exception.
|
||||||
|
+ */
|
||||||
|
+public class ServerInternalException extends ServerException {
|
||||||
|
+
|
||||||
|
+ public ServerInternalException(String message) {
|
||||||
|
+ super(message);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ServerInternalException(String message, Throwable cause) {
|
||||||
|
+ super(message, cause);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ServerInternalException(Throwable cause) {
|
||||||
|
+ super(cause);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected ServerInternalException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
+ super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void reportInternalException(Throwable cause) {
|
||||||
|
+ try {
|
||||||
|
+ Bukkit.getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(cause)));
|
||||||
|
+ ;
|
||||||
|
+ } catch (Throwable t) {
|
||||||
|
+ Bukkit.getLogger().log(Level.WARNING, "Exception posting ServerExceptionEvent", t); // Don't want to rethrow!
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerPluginEnableDisableException.java b/src/main/java/com/destroystokyo/paper/exception/ServerPluginEnableDisableException.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..f016ba3b1b62e554a9bacbb9635f2dbe441b3c4e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/exception/ServerPluginEnableDisableException.java
|
||||||
|
@@ -0,0 +1,20 @@
|
||||||
|
+package com.destroystokyo.paper.exception;
|
||||||
|
+
|
||||||
|
+import org.bukkit.plugin.Plugin;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Thrown whenever there is an exception with any enabling or disabling of plugins.
|
||||||
|
+ */
|
||||||
|
+public class ServerPluginEnableDisableException extends ServerPluginException {
|
||||||
|
+ public ServerPluginEnableDisableException(String message, Throwable cause, Plugin responsiblePlugin) {
|
||||||
|
+ super(message, cause, responsiblePlugin);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ServerPluginEnableDisableException(Throwable cause, Plugin responsiblePlugin) {
|
||||||
|
+ super(cause, responsiblePlugin);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected ServerPluginEnableDisableException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Plugin responsiblePlugin) {
|
||||||
|
+ super(message, cause, enableSuppression, writableStackTrace, responsiblePlugin);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerPluginException.java b/src/main/java/com/destroystokyo/paper/exception/ServerPluginException.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..be3f92e3c6bcefe8b78da701b75121275001882e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/exception/ServerPluginException.java
|
||||||
|
@@ -0,0 +1,36 @@
|
||||||
|
+package com.destroystokyo.paper.exception;
|
||||||
|
+
|
||||||
|
+import org.bukkit.plugin.Plugin;
|
||||||
|
+
|
||||||
|
+import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Wrapper exception for all cases to which a plugin can be immediately blamed for
|
||||||
|
+ */
|
||||||
|
+public class ServerPluginException extends ServerException {
|
||||||
|
+ public ServerPluginException(String message, Throwable cause, Plugin responsiblePlugin) {
|
||||||
|
+ super(message, cause);
|
||||||
|
+ this.responsiblePlugin = checkNotNull(responsiblePlugin, "responsiblePlugin");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ServerPluginException(Throwable cause, Plugin responsiblePlugin) {
|
||||||
|
+ super(cause);
|
||||||
|
+ this.responsiblePlugin = checkNotNull(responsiblePlugin, "responsiblePlugin");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected ServerPluginException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Plugin responsiblePlugin) {
|
||||||
|
+ super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
+ this.responsiblePlugin = checkNotNull(responsiblePlugin, "responsiblePlugin");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private final Plugin responsiblePlugin;
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the plugin which is directly responsible for the exception being thrown
|
||||||
|
+ *
|
||||||
|
+ * @return plugin which is responsible for the exception throw
|
||||||
|
+ */
|
||||||
|
+ public Plugin getResponsiblePlugin() {
|
||||||
|
+ return responsiblePlugin;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerPluginMessageException.java b/src/main/java/com/destroystokyo/paper/exception/ServerPluginMessageException.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..2faef4cb358ec65e32a6aba6426f0dd7ddf90d2a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/exception/ServerPluginMessageException.java
|
||||||
|
@@ -0,0 +1,64 @@
|
||||||
|
+package com.destroystokyo.paper.exception;
|
||||||
|
+
|
||||||
|
+import org.bukkit.entity.Player;
|
||||||
|
+import org.bukkit.plugin.Plugin;
|
||||||
|
+
|
||||||
|
+import static com.google.common.base.Preconditions.*;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Thrown when an incoming plugin message channel throws an exception
|
||||||
|
+ */
|
||||||
|
+public class ServerPluginMessageException extends ServerPluginException {
|
||||||
|
+
|
||||||
|
+ private final Player player;
|
||||||
|
+ private final String channel;
|
||||||
|
+ private final byte[] data;
|
||||||
|
+
|
||||||
|
+ public ServerPluginMessageException(String message, Throwable cause, Plugin responsiblePlugin, Player player, String channel, byte[] data) {
|
||||||
|
+ super(message, cause, responsiblePlugin);
|
||||||
|
+ this.player = checkNotNull(player, "player");
|
||||||
|
+ this.channel = checkNotNull(channel, "channel");
|
||||||
|
+ this.data = checkNotNull(data, "data");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ServerPluginMessageException(Throwable cause, Plugin responsiblePlugin, Player player, String channel, byte[] data) {
|
||||||
|
+ super(cause, responsiblePlugin);
|
||||||
|
+ this.player = checkNotNull(player, "player");
|
||||||
|
+ this.channel = checkNotNull(channel, "channel");
|
||||||
|
+ this.data = checkNotNull(data, "data");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected ServerPluginMessageException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Plugin responsiblePlugin, Player player, String channel, byte[] data) {
|
||||||
|
+ super(message, cause, enableSuppression, writableStackTrace, responsiblePlugin);
|
||||||
|
+ this.player = checkNotNull(player, "player");
|
||||||
|
+ this.channel = checkNotNull(channel, "channel");
|
||||||
|
+ this.data = checkNotNull(data, "data");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the channel to which the error occurred from receiving data from
|
||||||
|
+ *
|
||||||
|
+ * @return exception channel
|
||||||
|
+ */
|
||||||
|
+ public String getChannel() {
|
||||||
|
+ return channel;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the data to which the error occurred from
|
||||||
|
+ *
|
||||||
|
+ * @return exception data
|
||||||
|
+ */
|
||||||
|
+ public byte[] getData() {
|
||||||
|
+ return data;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the player which the plugin message causing the exception originated from
|
||||||
|
+ *
|
||||||
|
+ * @return exception player
|
||||||
|
+ */
|
||||||
|
+ public Player getPlayer() {
|
||||||
|
+ return player;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerSchedulerException.java b/src/main/java/com/destroystokyo/paper/exception/ServerSchedulerException.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..2d0b2d4a9b3e5bdeec0e4ea7ab69858d86aa3715
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/exception/ServerSchedulerException.java
|
||||||
|
@@ -0,0 +1,37 @@
|
||||||
|
+package com.destroystokyo.paper.exception;
|
||||||
|
+
|
||||||
|
+import org.bukkit.scheduler.BukkitTask;
|
||||||
|
+
|
||||||
|
+import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Thrown when a plugin's scheduler fails with an exception
|
||||||
|
+ */
|
||||||
|
+public class ServerSchedulerException extends ServerPluginException {
|
||||||
|
+
|
||||||
|
+ private final BukkitTask task;
|
||||||
|
+
|
||||||
|
+ public ServerSchedulerException(String message, Throwable cause, BukkitTask task) {
|
||||||
|
+ super(message, cause, task.getOwner());
|
||||||
|
+ this.task = checkNotNull(task, "task");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ServerSchedulerException(Throwable cause, BukkitTask task) {
|
||||||
|
+ super(cause, task.getOwner());
|
||||||
|
+ this.task = checkNotNull(task, "task");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected ServerSchedulerException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, BukkitTask task) {
|
||||||
|
+ super(message, cause, enableSuppression, writableStackTrace, task.getOwner());
|
||||||
|
+ this.task = checkNotNull(task, "task");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the task which threw the exception
|
||||||
|
+ *
|
||||||
|
+ * @return exception throwing task
|
||||||
|
+ */
|
||||||
|
+ public BukkitTask getTask() {
|
||||||
|
+ return task;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/exception/ServerTabCompleteException.java b/src/main/java/com/destroystokyo/paper/exception/ServerTabCompleteException.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..5582999fe94c7a3dac655044ccc6d078cd9521a1
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/exception/ServerTabCompleteException.java
|
||||||
|
@@ -0,0 +1,22 @@
|
||||||
|
+package com.destroystokyo.paper.exception;
|
||||||
|
+
|
||||||
|
+import org.bukkit.command.Command;
|
||||||
|
+import org.bukkit.command.CommandSender;
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * Called when a tab-complete request throws an exception
|
||||||
|
+ */
|
||||||
|
+public class ServerTabCompleteException extends ServerCommandException {
|
||||||
|
+
|
||||||
|
+ public ServerTabCompleteException(String message, Throwable cause, Command command, CommandSender commandSender, String[] arguments) {
|
||||||
|
+ super(message, cause, command, commandSender, arguments);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ServerTabCompleteException(Throwable cause, Command command, CommandSender commandSender, String[] arguments) {
|
||||||
|
+ super(cause, command, commandSender, arguments);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected ServerTabCompleteException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Command command, CommandSender commandSender, String[] arguments) {
|
||||||
|
+ super(message, cause, enableSuppression, writableStackTrace, command, commandSender, arguments);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||||
|
index 36fc2c35395c72f8b81a2a2f3265fd205384ce26..c7fa1d235cea78bda4656ed66b8d42b119cc50fb 100644
|
||||||
|
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||||
|
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||||
|
@@ -156,11 +156,14 @@ public class SimpleCommandMap implements CommandMap {
|
||||||
|
target.execute(sender, sentCommandLabel, Arrays.copyOfRange(args, 1, args.length));
|
||||||
|
} // target.timings.stopTiming(); // Spigot // Paper
|
||||||
|
} catch (CommandException ex) {
|
||||||
|
+ server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args))); // Paper
|
||||||
|
//target.timings.stopTiming(); // Spigot // Paper
|
||||||
|
throw ex;
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
//target.timings.stopTiming(); // Spigot // Paper
|
||||||
|
- throw new CommandException("Unhandled exception executing '" + commandLine + "' in " + target, ex);
|
||||||
|
+ String msg = "Unhandled exception executing '" + commandLine + "' in " + target;
|
||||||
|
+ server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args))); // Paper
|
||||||
|
+ throw new CommandException(msg, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return true as command was handled
|
||||||
|
@@ -239,7 +242,9 @@ public class SimpleCommandMap implements CommandMap {
|
||||||
|
} catch (CommandException ex) {
|
||||||
|
throw ex;
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
- throw new CommandException("Unhandled exception executing tab-completer for '" + cmdLine + "' in " + target, ex);
|
||||||
|
+ String msg = "Unhandled exception executing tab-completer for '" + cmdLine + "' in " + target;
|
||||||
|
+ server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerTabCompleteException(msg, ex, target, sender, args))); // Paper
|
||||||
|
+ throw new CommandException(msg, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||||
|
index e7b1895d3918487d711afcbe41d76863d85c0a62..003bece642b682985625db93cad93026352bfc66 100644
|
||||||
|
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||||
|
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||||
|
@@ -528,7 +528,8 @@ public final class SimplePluginManager implements PluginManager {
|
||||||
|
try {
|
||||||
|
plugin.getPluginLoader().enablePlugin(plugin);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
- server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
||||||
|
+ handlePluginException("Error occurred (in the plugin loader) while enabling "
|
||||||
|
+ + plugin.getDescription().getFullName() + " (Is it up to date?)", ex, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
HandlerList.bakeAll();
|
||||||
|
@@ -551,32 +552,37 @@ public final class SimplePluginManager implements PluginManager {
|
||||||
|
try {
|
||||||
|
plugin.getPluginLoader().disablePlugin(plugin);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
- server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
||||||
|
+ handlePluginException("Error occurred (in the plugin loader) while disabling "
|
||||||
|
+ + plugin.getDescription().getFullName() + " (Is it up to date?)", ex, plugin); // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
server.getScheduler().cancelTasks(plugin);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
- server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while cancelling tasks for " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
||||||
|
+ handlePluginException("Error occurred (in the plugin loader) while cancelling tasks for "
|
||||||
|
+ + plugin.getDescription().getFullName() + " (Is it up to date?)", ex, plugin); // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
server.getServicesManager().unregisterAll(plugin);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
- server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while unregistering services for " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
||||||
|
+ handlePluginException("Error occurred (in the plugin loader) while unregistering services for "
|
||||||
|
+ + plugin.getDescription().getFullName() + " (Is it up to date?)", ex, plugin); // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
HandlerList.unregisterAll(plugin);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
- server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while unregistering events for " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
||||||
|
+ handlePluginException("Error occurred (in the plugin loader) while unregistering events for "
|
||||||
|
+ + plugin.getDescription().getFullName() + " (Is it up to date?)", ex, plugin); // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
server.getMessenger().unregisterIncomingPluginChannel(plugin);
|
||||||
|
server.getMessenger().unregisterOutgoingPluginChannel(plugin);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
- server.getLogger().log(Level.SEVERE, "Error occurred (in the plugin loader) while unregistering plugin channels for " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
||||||
|
+ handlePluginException("Error occurred (in the plugin loader) while unregistering plugin channels for "
|
||||||
|
+ + plugin.getDescription().getFullName() + " (Is it up to date?)", ex, plugin); // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
@@ -589,6 +595,13 @@ public final class SimplePluginManager implements PluginManager {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ private void handlePluginException(String msg, Throwable ex, Plugin plugin) {
|
||||||
|
+ server.getLogger().log(Level.SEVERE, msg, ex);
|
||||||
|
+ callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerPluginEnableDisableException(msg, ex, plugin)));
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
public void clearPlugins() {
|
||||||
|
if (true) {this.paperPluginManager.clearPlugins(); return;} // Paper
|
||||||
|
@@ -654,7 +667,13 @@ public final class SimplePluginManager implements PluginManager {
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
- server.getLogger().log(Level.SEVERE, "Could not pass event " + event.getEventName() + " to " + registration.getPlugin().getDescription().getFullName(), ex);
|
||||||
|
+ // Paper start - error reporting
|
||||||
|
+ String msg = "Could not pass event " + event.getEventName() + " to " + registration.getPlugin().getDescription().getFullName();
|
||||||
|
+ server.getLogger().log(Level.SEVERE, msg, ex);
|
||||||
|
+ if (!(event instanceof com.destroystokyo.paper.event.server.ServerExceptionEvent)) { // We don't want to cause an endless event loop
|
||||||
|
+ callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerEventException(msg, ex, registration.getPlugin(), registration.getListener(), event)));
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,124 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
|
||||||
Date: Mon, 29 Feb 2016 19:54:32 -0600
|
|
||||||
Subject: [PATCH] Graduate bungeecord chat API from spigot subclasses
|
|
||||||
|
|
||||||
Change Javadoc to be accurate
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
index b53e94d79862d66165bbcd2a79b82770398a7f3e..9417030074fccdd9113bf75eb8f17f74b9a9118b 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
@@ -410,6 +410,30 @@ public final class Bukkit {
|
|
||||||
return server.broadcastMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Paper start
|
|
||||||
+ /**
|
|
||||||
+ * Sends the component to all online players.
|
|
||||||
+ *
|
|
||||||
+ * @param component the component to send
|
|
||||||
+ * @deprecated use {@code sendMessage} methods on {@link #getServer()} that accept {@link net.kyori.adventure.text.Component}
|
|
||||||
+ */
|
|
||||||
+ @Deprecated
|
|
||||||
+ public static void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent component) {
|
|
||||||
+ server.broadcast(component);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Sends an array of components as a single message to all online players.
|
|
||||||
+ *
|
|
||||||
+ * @param components the components to send
|
|
||||||
+ * @deprecated use {@code sendMessage} methods on {@link #getServer()} that accept {@link net.kyori.adventure.text.Component}
|
|
||||||
+ */
|
|
||||||
+ @Deprecated
|
|
||||||
+ public static void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
|
|
||||||
+ server.broadcast(components);
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Gets the name of the update folder. The update folder is used to safely
|
|
||||||
* update plugins at the right moment on a plugin load.
|
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
|
||||||
index 124e88e512d24b6ff7ace3cf7d5a6adf4c2bb40d..ccc825a2ea43bb84a5a08dff00c4d8ec27e4e95a 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
|
||||||
@@ -345,6 +345,30 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
|
||||||
@Deprecated // Paper
|
|
||||||
public int broadcastMessage(@NotNull String message);
|
|
||||||
|
|
||||||
+ // Paper start
|
|
||||||
+ /**
|
|
||||||
+ * Sends the component to all online players.
|
|
||||||
+ *
|
|
||||||
+ * @param component the component to send
|
|
||||||
+ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component}
|
|
||||||
+ */
|
|
||||||
+ @Deprecated
|
|
||||||
+ public default void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent component) {
|
|
||||||
+ spigot().broadcast(component);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Sends an array of components as a single message to all online players.
|
|
||||||
+ *
|
|
||||||
+ * @param components the components to send
|
|
||||||
+ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component}
|
|
||||||
+ */
|
|
||||||
+ @Deprecated
|
|
||||||
+ public default void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
|
|
||||||
+ spigot().broadcast(components);
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Gets the name of the update folder. The update folder is used to safely
|
|
||||||
* update plugins at the right moment on a plugin load.
|
|
||||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
|
||||||
index f8e45f70fe23cf73c8677b5d24cefcd3aae5e24e..f52e7d4e5b8399d04d77384f8fe5315086acd776 100644
|
|
||||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
|
||||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
|
||||||
@@ -1041,6 +1041,42 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
|
||||||
*/
|
|
||||||
public void sendMap(@NotNull MapView map);
|
|
||||||
|
|
||||||
+ // Paper start
|
|
||||||
+ /**
|
|
||||||
+ * Sends the component to the player
|
|
||||||
+ *
|
|
||||||
+ * @param component the components to send
|
|
||||||
+ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component}
|
|
||||||
+ */
|
|
||||||
+ @Override
|
|
||||||
+ @Deprecated
|
|
||||||
+ public default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent component) {
|
|
||||||
+ spigot().sendMessage(component);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Sends an array of components as a single message to the player
|
|
||||||
+ *
|
|
||||||
+ * @param components the components to send
|
|
||||||
+ * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component}
|
|
||||||
+ */
|
|
||||||
+ @Override
|
|
||||||
+ @Deprecated
|
|
||||||
+ public default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) {
|
|
||||||
+ spigot().sendMessage(components);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Sends an array of components as a single message to the specified screen position of this player
|
|
||||||
+ *
|
|
||||||
+ * @param position the screen position
|
|
||||||
+ * @param components the components to send
|
|
||||||
+ */
|
|
||||||
+ public default void sendMessage(net.md_5.bungee.api.ChatMessageType position, net.md_5.bungee.api.chat.BaseComponent... components) {
|
|
||||||
+ spigot().sendMessage(position, components);
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Send a hurt animation. This fakes incoming damage towards the player from
|
|
||||||
* the given yaw relative to the player's direction.
|
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren